1
0
mirror of https://github.com/golang/go synced 2024-11-19 03:44:40 -07:00

cmd/link: generate DWARF info using symbols

This updates dwarf.go to generate debug information as symbols
instead of directly writing to the output file. This should make
it easier to move generation of some of the debug info into the compiler.

Change-Id: Id2358988bfb689865ab4d68f82716f0676336df4
Reviewed-on: https://go-review.googlesource.com/20679
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ryan Brown 2016-03-14 09:23:04 -07:00 committed by David Crawshaw
parent 0382a30dd6
commit a037c73ccf
13 changed files with 729 additions and 1064 deletions

View File

@ -423,6 +423,8 @@ const (
SCONST SCONST
SDYNIMPORT SDYNIMPORT
SHOSTOBJ SHOSTOBJ
SDWARFSECT
SDWARFINFO
SSUB = 1 << 8 SSUB = 1 << 8
SMASK = SSUB - 1 SMASK = SSUB - 1
SHIDDEN = 1 << 9 SHIDDEN = 1 << 9
@ -495,6 +497,8 @@ const (
// of a JMP instruction, by encoding the address into the instruction. // of a JMP instruction, by encoding the address into the instruction.
// The stack nosplit check ignores this since it is not a function call. // The stack nosplit check ignores this since it is not a function call.
R_JMPMIPS R_JMPMIPS
// R_DWARFREF resolves to the offset of the symbol from its section.
R_DWARFREF
// Platform dependent relocations. Architectures with fixed width instructions // Platform dependent relocations. Architectures with fixed width instructions
// have the inherent issue that a 32-bit (or 64-bit!) displacement cannot be // have the inherent issue that a 32-bit (or 64-bit!) displacement cannot be

View File

@ -650,19 +650,11 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
machlink := int64(0) machlink := int64(0)
if ld.HEADTYPE == obj.Hdarwin { if ld.HEADTYPE == obj.Hdarwin {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
dwarfoff := ld.Rnd(int64(uint64(ld.HEADR)+ld.Segtext.Length), int64(ld.INITRND)) + ld.Rnd(int64(ld.Segdata.Filelen), int64(ld.INITRND))
ld.Cseek(dwarfoff)
ld.Segdwarf.Fileoff = uint64(ld.Cpos())
ld.Dwarfemitdebugsections()
ld.Segdwarf.Filelen = uint64(ld.Cpos()) - ld.Segdwarf.Fileoff
machlink = ld.Domacholink() machlink = ld.Domacholink()
} }
@ -715,11 +707,11 @@ func asmb() {
obj.Hdragonfly, obj.Hdragonfly,
obj.Hsolaris, obj.Hsolaris,
obj.Hnacl: obj.Hnacl:
symo = int64(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = ld.Rnd(symo, int64(ld.INITRND)) symo = ld.Rnd(symo, int64(ld.INITRND))
case obj.Hwindows: case obj.Hwindows:
symo = int64(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = int64(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = ld.Rnd(symo, ld.PEFILEALIGN) symo = ld.Rnd(symo, ld.PEFILEALIGN)
} }
@ -736,8 +728,6 @@ func asmb() {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }
@ -762,8 +752,6 @@ func asmb() {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
ld.Dwarfemitdebugsections()
case obj.Hdarwin: case obj.Hdarwin:
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Machoemitreloc() ld.Machoemitreloc()

View File

@ -597,19 +597,11 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
machlink := uint32(0) machlink := uint32(0)
if ld.HEADTYPE == obj.Hdarwin { if ld.HEADTYPE == obj.Hdarwin {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
dwarfoff := uint32(ld.Rnd(int64(uint64(ld.HEADR)+ld.Segtext.Length), int64(ld.INITRND)) + ld.Rnd(int64(ld.Segdata.Filelen), int64(ld.INITRND)))
ld.Cseek(int64(dwarfoff))
ld.Segdwarf.Fileoff = uint64(ld.Cpos())
ld.Dwarfemitdebugsections()
ld.Segdwarf.Filelen = uint64(ld.Cpos()) - ld.Segdwarf.Fileoff
machlink = uint32(ld.Domacholink()) machlink = uint32(ld.Domacholink())
} }
@ -627,7 +619,7 @@ func asmb() {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
} }
@ -649,11 +641,6 @@ func asmb() {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }

View File

@ -435,19 +435,11 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
machlink := uint32(0) machlink := uint32(0)
if ld.HEADTYPE == obj.Hdarwin { if ld.HEADTYPE == obj.Hdarwin {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
dwarfoff := uint32(ld.Rnd(int64(uint64(ld.HEADR)+ld.Segtext.Length), int64(ld.INITRND)) + ld.Rnd(int64(ld.Segdata.Filelen), int64(ld.INITRND)))
ld.Cseek(int64(dwarfoff))
ld.Segdwarf.Fileoff = uint64(ld.Cpos())
ld.Dwarfemitdebugsections()
ld.Segdwarf.Filelen = uint64(ld.Cpos()) - ld.Segdwarf.Fileoff
machlink = uint32(ld.Domacholink()) machlink = uint32(ld.Domacholink())
} }
@ -465,7 +457,7 @@ func asmb() {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
} }
@ -487,11 +479,6 @@ func asmb() {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }

View File

@ -84,6 +84,20 @@ func setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
return off + wid return off + wid
} }
func Addbytes(ctxt *Link, s *LSym, bytes []byte) int64 {
if s.Type == 0 {
s.Type = obj.SDATA
}
s.Attr |= AttrReachable
s.Size += int64(len(bytes))
if int64(int(s.Size)) != s.Size {
log.Fatalf("Addbytes size %d too long", s.Size)
}
s.P = append(s.P, bytes...)
return s.Size
}
func adduintxx(ctxt *Link, s *LSym, v uint64, wid int) int64 { func adduintxx(ctxt *Link, s *LSym, v uint64, wid int) int64 {
off := s.Size off := s.Size
setuintxx(ctxt, s, off, v, int64(wid)) setuintxx(ctxt, s, off, v, int64(wid))
@ -489,6 +503,25 @@ func relocsym(s *LSym) {
errorexit() errorexit()
} }
case obj.R_DWARFREF:
if r.Sym.Sect == nil {
Diag("missing DWARF section: %s from %s", r.Sym.Name, s.Name)
}
if Linkmode == LinkExternal {
r.Done = 0
r.Type = obj.R_ADDR
r.Xsym = Linkrlookup(Ctxt, r.Sym.Sect.Name, 0)
r.Xadd = r.Add + Symaddr(r.Sym) - int64(r.Sym.Sect.Vaddr)
o = r.Xadd
rs = r.Xsym
if Iself && Thearch.Thechar == '6' {
o = 0
}
break
}
o = Symaddr(r.Sym) + r.Add - int64(r.Sym.Sect.Vaddr)
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call. // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL: case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL:
if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != obj.SCONST && (r.Sym.Sect != Ctxt.Cursym.Sect || r.Type == obj.R_GOTPCREL) { if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != obj.SCONST && (r.Sym.Sect != Ctxt.Cursym.Sect || r.Type == obj.R_GOTPCREL) {
@ -614,6 +647,9 @@ func reloc() {
for s := datap; s != nil; s = s.Next { for s := datap; s != nil; s = s.Next {
relocsym(s) relocsym(s)
} }
for s := dwarfp; s != nil; s = s.Next {
relocsym(s)
}
} }
func dynrelocsym(s *LSym) { func dynrelocsym(s *LSym) {
@ -893,6 +929,14 @@ func Datblk(addr int64, size int64) {
fmt.Fprintf(&Bso, "\t%.8x|\n", uint(eaddr)) fmt.Fprintf(&Bso, "\t%.8x|\n", uint(eaddr))
} }
func Dwarfblk(addr int64, size int64) {
if Debug['a'] != 0 {
fmt.Fprintf(&Bso, "dwarfblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos())
}
blk(dwarfp, addr, size)
}
var zeros [512]byte var zeros [512]byte
// strnput writes the first n bytes of s. // strnput writes the first n bytes of s.
@ -1691,6 +1735,40 @@ func dodata() {
Diag("read-only data segment too large") Diag("read-only data segment too large")
} }
dwarfgeneratedebugsyms()
for s = dwarfp; s != nil && s.Type == obj.SDWARFSECT; s = s.Next {
sect = addsection(&Segdwarf, s.Name, 04)
sect.Align = 1
datsize = Rnd(datsize, int64(sect.Align))
sect.Vaddr = uint64(datsize)
s.Sect = sect
s.Type = obj.SRODATA
s.Value = int64(uint64(datsize) - sect.Vaddr)
growdatsize(&datsize, s)
sect.Length = uint64(datsize) - sect.Vaddr
}
if s != nil {
sect = addsection(&Segdwarf, ".debug_info", 04)
sect.Align = 1
datsize = Rnd(datsize, int64(sect.Align))
sect.Vaddr = uint64(datsize)
for ; s != nil && s.Type == obj.SDWARFINFO; s = s.Next {
s.Sect = sect
s.Type = obj.SRODATA
s.Value = int64(uint64(datsize) - sect.Vaddr)
s.Attr |= AttrLocal
growdatsize(&datsize, s)
}
sect.Length = uint64(datsize) - sect.Vaddr
}
// The compiler uses 4-byte relocation offsets, so the entire segment must fit in 32 bits.
if datsize != int64(uint32(datsize)) {
Diag("dwarf segment too large")
}
/* number the sections */ /* number the sections */
n := int32(1) n := int32(1)
@ -1706,6 +1784,10 @@ func dodata() {
sect.Extnum = int16(n) sect.Extnum = int16(n)
n++ n++
} }
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
sect.Extnum = int16(n)
n++
}
} }
// Add buildid to beginning of text segment, on non-ELF systems. // Add buildid to beginning of text segment, on non-ELF systems.
@ -1857,6 +1939,29 @@ func address() {
Segdata.Filelen = bss.Vaddr - Segdata.Vaddr Segdata.Filelen = bss.Vaddr - Segdata.Vaddr
va = uint64(Rnd(int64(va), int64(INITRND)))
Segdwarf.Rwx = 06
Segdwarf.Vaddr = va
Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(INITRND)))
Segdwarf.Filelen = 0
if HEADTYPE == obj.Hwindows {
Segdwarf.Fileoff = Segdata.Fileoff + uint64(Rnd(int64(Segdata.Filelen), int64(PEFILEALIGN)))
}
for s := Segdwarf.Sect; s != nil; s = s.Next {
vlen = int64(s.Length)
if s.Next != nil {
vlen = int64(s.Next.Vaddr - s.Vaddr)
}
s.Vaddr = va
va += uint64(vlen)
if HEADTYPE == obj.Hwindows {
va = uint64(Rnd(int64(va), PEFILEALIGN))
}
Segdwarf.Length = va - Segdwarf.Vaddr
}
Segdwarf.Filelen = va - Segdwarf.Vaddr
text := Segtext.Sect text := Segtext.Sect
var rodata *Section var rodata *Section
if Segrodata.Sect != nil { if Segrodata.Sect != nil {
@ -1884,6 +1989,15 @@ func address() {
sub.Value += sym.Value sub.Value += sym.Value
} }
} }
for sym := dwarfp; sym != nil; sym = sym.Next {
Ctxt.Cursym = sym
if sym.Sect != nil {
sym.Value += int64(sym.Sect.Vaddr)
}
for sub = sym.Sub; sub != nil; sub = sub.Sub {
sub.Value += sym.Value
}
}
if Buildmode == BuildmodeShared { if Buildmode == BuildmodeShared {
s := Linklookup(Ctxt, "go.link.abihashbytes", 0) s := Linklookup(Ctxt, "go.link.abihashbytes", 0)

File diff suppressed because it is too large Load Diff

View File

@ -1622,6 +1622,9 @@ func elfshbits(sect *Section) *ElfShdr {
sh.flags |= SHF_TLS sh.flags |= SHF_TLS
sh.type_ = SHT_NOBITS sh.type_ = SHT_NOBITS
} }
if strings.HasPrefix(sect.Name, ".debug") {
sh.flags = 0
}
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
sh.addr = sect.Vaddr sh.addr = sect.Vaddr
@ -1739,6 +1742,9 @@ func Elfemitreloc() {
for sect := Segdata.Sect; sect != nil; sect = sect.Next { for sect := Segdata.Sect; sect != nil; sect = sect.Next {
elfrelocsect(sect, datap) elfrelocsect(sect, datap)
} }
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
elfrelocsect(sect, dwarfp)
}
} }
func addgonote(sectionName string, tag uint32, desc []byte) { func addgonote(sectionName string, tag uint32, desc []byte) {
@ -2067,6 +2073,9 @@ func Asmbelfsetup() {
for sect := Segdata.Sect; sect != nil; sect = sect.Next { for sect := Segdata.Sect; sect != nil; sect = sect.Next {
elfshalloc(sect) elfshalloc(sect)
} }
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
elfshalloc(sect)
}
} }
func Asmbelf(symo int64) { func Asmbelf(symo int64) {
@ -2432,6 +2441,9 @@ elfobj:
for sect := Segdata.Sect; sect != nil; sect = sect.Next { for sect := Segdata.Sect; sect != nil; sect = sect.Next {
elfshbits(sect) elfshbits(sect)
} }
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
elfshbits(sect)
}
if Linkmode == LinkExternal { if Linkmode == LinkExternal {
for sect := Segtext.Sect; sect != nil; sect = sect.Next { for sect := Segtext.Sect; sect != nil; sect = sect.Next {
@ -2443,7 +2455,14 @@ elfobj:
for sect := Segdata.Sect; sect != nil; sect = sect.Next { for sect := Segdata.Sect; sect != nil; sect = sect.Next {
elfshreloc(sect) elfshreloc(sect)
} }
for s := dwarfp; s != nil; s = s.Next {
if len(s.R) > 0 || s.Type == obj.SDWARFINFO {
elfshreloc(s.Sect)
}
if s.Type == obj.SDWARFINFO {
break
}
}
// add a .note.GNU-stack section to mark the stack as non-executable // add a .note.GNU-stack section to mark the stack as non-executable
sh := elfshname(".note.GNU-stack") sh := elfshname(".note.GNU-stack")
@ -2467,8 +2486,6 @@ elfobj:
sh.off = uint64(symo) + uint64(Symsize) sh.off = uint64(symo) + uint64(Symsize)
sh.size = uint64(len(Elfstrdat)) sh.size = uint64(len(Elfstrdat))
sh.addralign = 1 sh.addralign = 1
dwarfaddelfheaders()
} }
/* Main header */ /* Main header */

View File

@ -356,7 +356,7 @@ func machoshbits(mseg *MachoSeg, sect *Section, segname string) {
buf := "__" + strings.Replace(sect.Name[1:], ".", "_", -1) buf := "__" + strings.Replace(sect.Name[1:], ".", "_", -1)
var msect *MachoSect var msect *MachoSect
if sect.Rwx&1 == 0 && (Thearch.Thechar == '7' || // arm64 if sect.Rwx&1 == 0 && segname != "__DWARF" && (Thearch.Thechar == '7' || // arm64
(Thearch.Thechar == '6' && (Buildmode == BuildmodeCShared || Buildmode == BuildmodeCArchive))) { // amd64 (Thearch.Thechar == '6' && (Buildmode == BuildmodeCShared || Buildmode == BuildmodeCArchive))) { // amd64
// Darwin external linker on arm64 and on amd64 in c-shared/c-archive buildmode // Darwin external linker on arm64 and on amd64 in c-shared/c-archive buildmode
// complains about absolute relocs in __TEXT, so if the section is not // complains about absolute relocs in __TEXT, so if the section is not
@ -411,6 +411,10 @@ func machoshbits(mseg *MachoSeg, sect *Section, segname string) {
msect.name = "__mod_init_func" msect.name = "__mod_init_func"
msect.flag = 9 // S_MOD_INIT_FUNC_POINTERS msect.flag = 9 // S_MOD_INIT_FUNC_POINTERS
} }
if segname == "__DWARF" {
msect.flag |= 0x02000000
}
} }
func Asmbmacho() { func Asmbmacho() {
@ -492,6 +496,20 @@ func Asmbmacho() {
machoshbits(ms, sect, "__DATA") machoshbits(ms, sect, "__DATA")
} }
/* dwarf */
if Debug['w'] == 0 {
if Linkmode != LinkExternal {
ms = newMachoSeg("__DWARF", 20)
ms.vaddr = Segdwarf.Vaddr
ms.vsize = 0
ms.fileoffset = Segdwarf.Fileoff
ms.filesize = Segdwarf.Filelen
}
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
machoshbits(ms, sect, "__DWARF")
}
}
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
switch Thearch.Thechar { switch Thearch.Thechar {
default: default:
@ -586,11 +604,6 @@ func Asmbmacho() {
ml.data[1] = 10<<16 | 7<<8 | 0<<0 // SDK 10.7.0 ml.data[1] = 10<<16 | 7<<8 | 0<<0 // SDK 10.7.0
} }
// TODO: dwarf headers go in ms too
if Debug['s'] == 0 {
dwarfaddmachoheaders(ms)
}
a := machowrite() a := machowrite()
if int32(a) > HEADR { if int32(a) > HEADR {
Exitf("HEADR too small: %d > %d", a, HEADR) Exitf("HEADR too small: %d > %d", a, HEADR)
@ -876,5 +889,7 @@ func Machoemitreloc() {
for sect := Segdata.Sect; sect != nil; sect = sect.Next { for sect := Segdata.Sect; sect != nil; sect = sect.Next {
machorelocsect(sect, datap) machorelocsect(sect, datap)
} }
dwarfemitreloc() for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
machorelocsect(sect, dwarfp)
}
} }

View File

@ -195,18 +195,6 @@ func putelfsectionsym(s *LSym, shndx int) {
numelfsym++ numelfsym++
} }
func putelfsymshndx(sympos int64, shndx int) {
here := Cpos()
if elf64 {
Cseek(sympos + 6)
} else {
Cseek(sympos + 14)
}
Thearch.Wput(uint16(shndx))
Cseek(here)
}
func Asmelfsym() { func Asmelfsym() {
// the first symbol entry is reserved // the first symbol entry is reserved
putelfsyment(0, 0, 0, STB_LOCAL<<4|STT_NOTYPE, 0, 0) putelfsyment(0, 0, 0, STB_LOCAL<<4|STT_NOTYPE, 0, 0)

View File

@ -147,6 +147,9 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
/* output symbol table */ /* output symbol table */
ld.Symsize = 0 ld.Symsize = 0
@ -161,7 +164,7 @@ func asmb() {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
} }
@ -180,11 +183,6 @@ func asmb() {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }

View File

@ -868,6 +868,9 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
/* output symbol table */ /* output symbol table */
ld.Symsize = 0 ld.Symsize = 0
@ -882,7 +885,7 @@ func asmb() {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
} }
@ -901,11 +904,6 @@ func asmb() {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }

View File

@ -539,6 +539,9 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
/* output symbol table */ /* output symbol table */
ld.Symsize = 0 ld.Symsize = 0
@ -552,7 +555,7 @@ func asmb() {
fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(&ld.Bso, "%5.2f sym\n", obj.Cputime())
} }
ld.Bso.Flush() ld.Bso.Flush()
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
ld.Cseek(int64(symo)) ld.Cseek(int64(symo))
@ -566,7 +569,6 @@ func asmb() {
if ld.Debug['v'] != 0 { if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()

View File

@ -643,19 +643,11 @@ func asmb() {
ld.Cseek(int64(ld.Segdata.Fileoff)) ld.Cseek(int64(ld.Segdata.Fileoff))
ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen)) ld.Datblk(int64(ld.Segdata.Vaddr), int64(ld.Segdata.Filelen))
ld.Cseek(int64(ld.Segdwarf.Fileoff))
ld.Dwarfblk(int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))
machlink := uint32(0) machlink := uint32(0)
if ld.HEADTYPE == obj.Hdarwin { if ld.HEADTYPE == obj.Hdarwin {
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
dwarfoff := uint32(ld.Rnd(int64(uint64(ld.HEADR)+ld.Segtext.Length), int64(ld.INITRND)) + ld.Rnd(int64(ld.Segdata.Filelen), int64(ld.INITRND)))
ld.Cseek(int64(dwarfoff))
ld.Segdwarf.Fileoff = uint64(ld.Cpos())
ld.Dwarfemitdebugsections()
ld.Segdwarf.Filelen = uint64(ld.Cpos()) - ld.Segdwarf.Fileoff
machlink = uint32(ld.Domacholink()) machlink = uint32(ld.Domacholink())
} }
@ -672,7 +664,7 @@ func asmb() {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
} }
@ -683,7 +675,7 @@ func asmb() {
symo = uint32(ld.Segdwarf.Fileoff + uint64(ld.Rnd(int64(ld.Segdwarf.Filelen), int64(ld.INITRND))) + uint64(machlink)) symo = uint32(ld.Segdwarf.Fileoff + uint64(ld.Rnd(int64(ld.Segdwarf.Filelen), int64(ld.INITRND))) + uint64(machlink))
case obj.Hwindows: case obj.Hwindows:
symo = uint32(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), ld.PEFILEALIGN)) symo = uint32(ld.Rnd(int64(symo), ld.PEFILEALIGN))
} }
@ -698,11 +690,6 @@ func asmb() {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
}
ld.Dwarfemitdebugsections()
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {
ld.Elfemitreloc() ld.Elfemitreloc()
} }
@ -726,7 +713,6 @@ func asmb() {
if ld.Debug['v'] != 0 { if ld.Debug['v'] != 0 {
fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(&ld.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
ld.Dwarfemitdebugsections()
case obj.Hdarwin: case obj.Hdarwin:
if ld.Linkmode == ld.LinkExternal { if ld.Linkmode == ld.LinkExternal {