1
0
mirror of https://github.com/golang/go synced 2024-11-24 07:40:17 -07:00

cmd/link: keep go.buildid alive on AIX external linking

As we use relative addressing for text symbols in functab, it is
important that the offsets we computed stay unchanged by the
external linker, i.e. all symbols in Textp should not be removed
by the external linker. Most of them are actually referenced (our
deadcode pass ensures that), except go.buildid which is generated
late and not used by the program. Keep it alive.

Should fix AIX builder.

Change-Id: Ibc4a8951be997b9d8d870d75c54754977d9b8333
Reviewed-on: https://go-review.googlesource.com/c/go/+/354369
Trust: Cherry Mui <cherryyz@google.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Cherry Mui 2021-10-06 12:39:41 -04:00
parent 316057142c
commit 415f0a3375

View File

@ -676,7 +676,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
if ctxt.IsAIX() && ctxt.IsExternal() {
// Add R_XCOFFREF relocation to prevent ld's garbage collection of
// runtime.rodata, runtime.erodata and runtime.epclntab.
// the following symbols. They might not be referenced in the program.
addRef := func(name string) {
r, _ := moduledata.AddRel(objabi.R_XCOFFREF)
r.SetSym(ldr.Lookup(name, 0))
@ -685,6 +685,12 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
addRef("runtime.rodata")
addRef("runtime.erodata")
addRef("runtime.epclntab")
// As we use relative addressing for text symbols in functab, it is
// important that the offsets we computed stay unchanged by the external
// linker, i.e. all symbols in Textp should not be removed.
// Most of them are actually referenced (our deadcode pass ensures that),
// except go.buildid which is generated late and not used by the program.
addRef("go.buildid")
}
// text section information