2015-09-10 11:32:49 -04:00
|
|
|
// Inferno utils/5l/asm.c
|
2016-08-28 17:04:46 -07:00
|
|
|
// https://bitbucket.org/inferno-os/inferno-os/src/default/utils/5l/asm.c
|
2015-09-10 11:32:49 -04:00
|
|
|
//
|
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
|
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Portions Copyright © 1997-1999 Vita Nuova Limited
|
|
|
|
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
|
|
|
|
|
// Portions Copyright © 2004,2006 Bruce Ellis
|
|
|
|
|
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
|
2016-04-10 14:32:26 -07:00
|
|
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
2015-09-10 11:32:49 -04:00
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
package mips64
|
|
|
|
|
|
|
|
|
|
import (
|
2017-04-18 12:53:25 -07:00
|
|
|
"cmd/internal/objabi"
|
2016-04-06 12:01:40 -07:00
|
|
|
"cmd/internal/sys"
|
2015-09-10 11:32:49 -04:00
|
|
|
"cmd/link/internal/ld"
|
2017-10-04 17:54:04 -04:00
|
|
|
"cmd/link/internal/sym"
|
2017-10-06 16:01:02 -04:00
|
|
|
"debug/elf"
|
2015-09-10 11:32:49 -04:00
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
)
|
|
|
|
|
|
2016-08-21 13:52:23 -04:00
|
|
|
func gentext(ctxt *ld.Link) {}
|
2015-09-10 11:32:49 -04:00
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
|
2015-09-10 11:32:49 -04:00
|
|
|
log.Fatalf("adddynrel not implemented")
|
2016-09-05 23:49:53 -04:00
|
|
|
return false
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
func elfreloc1(ctxt *ld.Link, r *sym.Reloc, sectoff int64) bool {
|
2016-04-27 22:18:09 -04:00
|
|
|
// mips64 ELF relocation (endian neutral)
|
|
|
|
|
// offset uint64
|
|
|
|
|
// sym uint32
|
|
|
|
|
// ssym uint8
|
|
|
|
|
// type3 uint8
|
|
|
|
|
// type2 uint8
|
|
|
|
|
// type uint8
|
|
|
|
|
// addend int64
|
|
|
|
|
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Write64(uint64(sectoff))
|
2016-04-27 22:18:09 -04:00
|
|
|
|
|
|
|
|
elfsym := r.Xsym.ElfsymForReloc()
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Write32(uint32(elfsym))
|
|
|
|
|
ctxt.Out.Write8(0)
|
|
|
|
|
ctxt.Out.Write8(0)
|
|
|
|
|
ctxt.Out.Write8(0)
|
2016-04-27 22:18:09 -04:00
|
|
|
switch r.Type {
|
|
|
|
|
default:
|
2017-08-27 22:00:00 +09:00
|
|
|
return false
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDR:
|
2016-04-27 22:18:09 -04:00
|
|
|
switch r.Siz {
|
|
|
|
|
case 4:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_32))
|
2016-04-27 22:18:09 -04:00
|
|
|
case 8:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_64))
|
2016-04-27 22:18:09 -04:00
|
|
|
default:
|
2017-08-27 22:00:00 +09:00
|
|
|
return false
|
2016-04-27 22:18:09 -04:00
|
|
|
}
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPS:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_LO16))
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPSU:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_HI16))
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPSTLS:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_TLS_TPREL_LO16))
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_CALLMIPS,
|
|
|
|
|
objabi.R_JMPMIPS:
|
2017-10-06 16:01:02 -04:00
|
|
|
ctxt.Out.Write8(uint8(elf.R_MIPS_26))
|
2016-04-27 22:18:09 -04:00
|
|
|
}
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Write64(uint64(r.Xadd))
|
2016-04-27 22:18:09 -04:00
|
|
|
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2016-08-21 13:52:23 -04:00
|
|
|
func elfsetupplt(ctxt *ld.Link) {
|
2015-09-10 11:32:49 -04:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
func machoreloc1(arch *sys.Arch, out *ld.OutBuf, s *sym.Symbol, r *sym.Reloc, sectoff int64) bool {
|
2017-08-27 22:00:00 +09:00
|
|
|
return false
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
|
2017-10-05 10:20:17 -04:00
|
|
|
if ctxt.LinkMode == ld.LinkExternal {
|
2016-04-27 22:18:09 -04:00
|
|
|
switch r.Type {
|
|
|
|
|
default:
|
2017-08-27 22:00:00 +09:00
|
|
|
return false
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPS,
|
|
|
|
|
objabi.R_ADDRMIPSU:
|
2017-08-27 22:00:00 +09:00
|
|
|
r.Done = false
|
2016-04-27 22:18:09 -04:00
|
|
|
|
|
|
|
|
// set up addend for eventual relocation via outer symbol.
|
|
|
|
|
rs := r.Sym
|
|
|
|
|
r.Xadd = r.Add
|
|
|
|
|
for rs.Outer != nil {
|
2016-09-17 09:39:33 -04:00
|
|
|
r.Xadd += ld.Symaddr(rs) - ld.Symaddr(rs.Outer)
|
2016-04-27 22:18:09 -04:00
|
|
|
rs = rs.Outer
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
if rs.Type != sym.SHOSTOBJ && rs.Type != sym.SDYNIMPORT && rs.Sect == nil {
|
2016-09-17 09:39:33 -04:00
|
|
|
ld.Errorf(s, "missing section for %s", rs.Name)
|
2016-04-27 22:18:09 -04:00
|
|
|
}
|
|
|
|
|
r.Xsym = rs
|
|
|
|
|
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPSTLS,
|
|
|
|
|
objabi.R_CALLMIPS,
|
|
|
|
|
objabi.R_JMPMIPS:
|
2017-08-27 22:00:00 +09:00
|
|
|
r.Done = false
|
2016-04-27 22:18:09 -04:00
|
|
|
r.Xsym = r.Sym
|
|
|
|
|
r.Xadd = r.Add
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2016-04-27 22:18:09 -04:00
|
|
|
}
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch r.Type {
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_CONST:
|
2015-09-10 11:32:49 -04:00
|
|
|
*val = r.Add
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_GOTOFF:
|
cmd/link: use ctxt.{Lookup,ROLookup} in favour of function versions of same
Done with two eg templates:
package p
import (
"cmd/link/internal/ld"
)
func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ld.Linklookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ctxt.Syms.Lookup(name, v)
}
package p
import (
"cmd/link/internal/ld"
)
func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ld.Linkrlookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ctxt.Syms.ROLookup(name, v)
}
Change-Id: I00647dbf62294557bd24c29ad1f108fc786335f1
Reviewed-on: https://go-review.googlesource.com/29343
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-20 15:06:08 +12:00
|
|
|
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPS,
|
|
|
|
|
objabi.R_ADDRMIPSU:
|
2016-09-17 09:39:33 -04:00
|
|
|
t := ld.Symaddr(r.Sym) + r.Add
|
2017-09-30 21:10:49 +00:00
|
|
|
o1 := ctxt.Arch.ByteOrder.Uint32(s.P[r.Off:])
|
2017-04-18 12:53:25 -07:00
|
|
|
if r.Type == objabi.R_ADDRMIPS {
|
2016-04-27 22:18:02 -04:00
|
|
|
*val = int64(o1&0xffff0000 | uint32(t)&0xffff)
|
2015-09-10 11:32:49 -04:00
|
|
|
} else {
|
2016-04-27 22:18:02 -04:00
|
|
|
*val = int64(o1&0xffff0000 | uint32((t+1<<15)>>16)&0xffff)
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_ADDRMIPSTLS:
|
2016-04-27 22:18:14 -04:00
|
|
|
// thread pointer is at 0x7000 offset from the start of TLS data area
|
2016-09-17 09:39:33 -04:00
|
|
|
t := ld.Symaddr(r.Sym) + r.Add - 0x7000
|
2016-04-27 22:18:14 -04:00
|
|
|
if t < -32768 || t >= 32678 {
|
2016-09-17 09:39:33 -04:00
|
|
|
ld.Errorf(s, "TLS offset out of range %d", t)
|
2016-04-27 22:18:14 -04:00
|
|
|
}
|
2017-09-30 21:10:49 +00:00
|
|
|
o1 := ctxt.Arch.ByteOrder.Uint32(s.P[r.Off:])
|
2016-04-27 22:18:14 -04:00
|
|
|
*val = int64(o1&0xffff0000 | uint32(t)&0xffff)
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.R_CALLMIPS,
|
|
|
|
|
objabi.R_JMPMIPS:
|
2015-09-10 11:32:49 -04:00
|
|
|
// Low 26 bits = (S + A) >> 2
|
2016-09-17 09:39:33 -04:00
|
|
|
t := ld.Symaddr(r.Sym) + r.Add
|
2017-09-30 21:10:49 +00:00
|
|
|
o1 := ctxt.Arch.ByteOrder.Uint32(s.P[r.Off:])
|
2015-09-10 11:32:49 -04:00
|
|
|
*val = int64(o1&0xfc000000 | uint32(t>>2)&^0xfc000000)
|
2017-08-27 22:00:00 +09:00
|
|
|
return true
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-08-27 22:00:00 +09:00
|
|
|
return false
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-04 17:54:04 -04:00
|
|
|
func archrelocvariant(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, t int64) int64 {
|
2015-09-10 11:32:49 -04:00
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 22:40:38 -04:00
|
|
|
func asmb(ctxt *ld.Link) {
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f asmb\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-07 13:43:38 -04:00
|
|
|
if ctxt.IsELF {
|
2016-09-20 15:57:53 +12:00
|
|
|
ld.Asmbelfsetup()
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-04-18 21:52:06 +12:00
|
|
|
sect := ld.Segtext.Sections[0]
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(sect.Vaddr - ld.Segtext.Vaddr + ld.Segtext.Fileoff))
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Codeblk(ctxt, int64(sect.Vaddr), int64(sect.Length))
|
2017-04-18 21:52:06 +12:00
|
|
|
for _, sect = range ld.Segtext.Sections[1:] {
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(sect.Vaddr - ld.Segtext.Vaddr + ld.Segtext.Fileoff))
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Datblk(ctxt, int64(sect.Vaddr), int64(sect.Length))
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ld.Segrodata.Filelen > 0 {
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f rodatblk\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(ld.Segrodata.Fileoff))
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2016-09-05 23:29:16 -04:00
|
|
|
if ld.Segrelrodata.Filelen > 0 {
|
|
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f rodatblk\n", ld.Cputime())
|
2016-09-05 23:29:16 -04:00
|
|
|
}
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(ld.Segrelrodata.Fileoff))
|
2016-09-05 23:29:16 -04:00
|
|
|
ld.Datblk(ctxt, int64(ld.Segrelrodata.Vaddr), int64(ld.Segrelrodata.Filelen))
|
|
|
|
|
}
|
2015-09-10 11:32:49 -04:00
|
|
|
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f datblk\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(ld.Segdata.Fileoff))
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Datblk(ctxt, int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
|
2015-09-10 11:32:49 -04:00
|
|
|
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(ld.Segdwarf.Fileoff))
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
|
2016-03-14 09:23:04 -07:00
|
|
|
|
2015-09-10 11:32:49 -04:00
|
|
|
/* output symbol table */
|
|
|
|
|
ld.Symsize = 0
|
|
|
|
|
|
|
|
|
|
ld.Lcsize = 0
|
|
|
|
|
symo := uint32(0)
|
2016-08-22 18:53:01 -04:00
|
|
|
if !*ld.FlagS {
|
2015-09-10 11:32:49 -04:00
|
|
|
// TODO: rationalize
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f sym\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2017-10-07 13:49:44 -04:00
|
|
|
switch ctxt.HeadType {
|
2015-09-10 11:32:49 -04:00
|
|
|
default:
|
2017-10-07 13:43:38 -04:00
|
|
|
if ctxt.IsELF {
|
2016-03-14 09:23:04 -07:00
|
|
|
symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
|
2016-08-21 18:34:24 -04:00
|
|
|
symo = uint32(ld.Rnd(int64(symo), int64(*ld.FlagRound)))
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.Hplan9:
|
2015-09-10 11:32:49 -04:00
|
|
|
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen)
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(int64(symo))
|
2017-10-07 13:49:44 -04:00
|
|
|
switch ctxt.HeadType {
|
2015-09-10 11:32:49 -04:00
|
|
|
default:
|
2017-10-07 13:43:38 -04:00
|
|
|
if ctxt.IsELF {
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f elfsym\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Asmelfsym(ctxt)
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Flush()
|
|
|
|
|
ctxt.Out.Write(ld.Elfstrdat)
|
2015-09-10 11:32:49 -04:00
|
|
|
|
2017-10-05 10:20:17 -04:00
|
|
|
if ctxt.LinkMode == ld.LinkExternal {
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Elfemitreloc(ctxt)
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.Hplan9:
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Asmplan9sym(ctxt)
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Flush()
|
2015-09-10 11:32:49 -04:00
|
|
|
|
cmd/link: use ctxt.{Lookup,ROLookup} in favour of function versions of same
Done with two eg templates:
package p
import (
"cmd/link/internal/ld"
)
func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ld.Linklookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ctxt.Syms.Lookup(name, v)
}
package p
import (
"cmd/link/internal/ld"
)
func before(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ld.Linkrlookup(ctxt, name, v)
}
func after(ctxt *ld.Link, name string, v int) *ld.Symbol {
return ctxt.Syms.ROLookup(name, v)
}
Change-Id: I00647dbf62294557bd24c29ad1f108fc786335f1
Reviewed-on: https://go-review.googlesource.com/29343
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-20 15:06:08 +12:00
|
|
|
sym := ctxt.Syms.Lookup("pclntab", 0)
|
2015-09-10 11:32:49 -04:00
|
|
|
if sym != nil {
|
|
|
|
|
ld.Lcsize = int32(len(sym.P))
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Write(sym.P)
|
|
|
|
|
ctxt.Out.Flush()
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-21 18:25:28 -04:00
|
|
|
if ctxt.Debugvlog != 0 {
|
2017-04-18 12:53:25 -07:00
|
|
|
ctxt.Logf("%5.2f header\n", ld.Cputime())
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.SeekSet(0)
|
2017-10-07 13:49:44 -04:00
|
|
|
switch ctxt.HeadType {
|
2015-09-10 11:32:49 -04:00
|
|
|
default:
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.Hplan9: /* plan 9 */
|
2015-09-10 11:32:49 -04:00
|
|
|
magic := uint32(4*18*18 + 7)
|
2017-09-30 21:10:49 +00:00
|
|
|
if ctxt.Arch == sys.ArchMIPS64LE {
|
2015-09-10 11:32:49 -04:00
|
|
|
magic = uint32(4*26*26 + 7)
|
|
|
|
|
}
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Write32(magic) /* magic */
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Segtext.Filelen)) /* sizes */
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Segdata.Filelen))
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Segdata.Length - ld.Segdata.Filelen))
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Symsize)) /* nsyms */
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Entryvalue(ctxt))) /* va of entry */
|
|
|
|
|
ctxt.Out.Write32(0)
|
|
|
|
|
ctxt.Out.Write32(uint32(ld.Lcsize))
|
2015-09-10 11:32:49 -04:00
|
|
|
|
2017-04-18 12:53:25 -07:00
|
|
|
case objabi.Hlinux,
|
|
|
|
|
objabi.Hfreebsd,
|
|
|
|
|
objabi.Hnetbsd,
|
|
|
|
|
objabi.Hopenbsd,
|
|
|
|
|
objabi.Hnacl:
|
2016-08-19 22:40:38 -04:00
|
|
|
ld.Asmbelf(ctxt, int64(symo))
|
2015-09-10 11:32:49 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-01 02:37:20 +00:00
|
|
|
ctxt.Out.Flush()
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagC {
|
2015-09-10 11:32:49 -04:00
|
|
|
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
|
|
|
|
|
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
|
|
|
|
|
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
|
|
|
|
|
fmt.Printf("symsize=%d\n", ld.Symsize)
|
|
|
|
|
fmt.Printf("lcsize=%d\n", ld.Lcsize)
|
|
|
|
|
fmt.Printf("total=%d\n", ld.Segtext.Filelen+ld.Segdata.Length+uint64(ld.Symsize)+uint64(ld.Lcsize))
|
|
|
|
|
}
|
|
|
|
|
}
|