[dev.link] cmd/link: convert Asmb2 path to loader APIs for Elf/AMD64

This patch converts the linker's Asmb2 phase to use loader APIs
for AMD64 (other architectures to be converted in a subsequent
patch).

Change-Id: I5a9aa9b03769cabc1a22b982f48fd113213d7bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/233338
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2020-05-07 10:06:28 -04:00
parent 88a12a99b4
commit 25e9417b98
11 changed files with 1004 additions and 160 deletions

View file

@ -2112,12 +2112,6 @@ func (d *dwctxt2) dwarfaddshstrings(ctxt *Link, shstrtab loader.Sym) {
panic("not yet implemented")
}
// Add section symbols for DWARF debug info. This is called before
// dwarfaddelfheaders.
func (d *dwctxt2) dwarfaddelfsectionsyms(ctxt *Link) {
panic("not yet implemented")
}
// dwarfcompress compresses the DWARF sections. Relocations are applied
// on the fly. After this, dwarfp will contain a different (new) set of
// symbols, and sections may have been replaced.
@ -2152,3 +2146,19 @@ func saveDwsectCUSize(sname string, pkgname string, size uint64) {
func addDwsectCUSize(sname string, pkgname string, size uint64) {
dwsectCUSize[sname+"."+pkgname] += size
}
func dwarfaddelfsectionsyms(ctxt *Link) {
if *FlagW { // disable dwarf
return
}
if ctxt.LinkMode != LinkExternal {
return
}
ldr := ctxt.loader
for _, si := range dwarfp2 {
s := si.secSym()
sect := ldr.SymSect(si.secSym())
putelfsectionsym(ctxt, ctxt.Out, s, sect.Elfsect.(*ElfShdr).shnum)
}
}