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

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