From: Cherry Mui Date: Wed, 6 Oct 2021 16:39:41 +0000 (-0400) Subject: cmd/link: keep go.buildid alive on AIX external linking X-Git-Tag: go1.18beta1~1020 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=415f0a33750a7cb4ad282fc5aa664d3fde244f84;p=gostls13.git 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 Trust: Josh Bleecher Snyder Run-TryBot: Cherry Mui Reviewed-by: Than McIntosh Reviewed-by: Josh Bleecher Snyder TryBot-Result: Go Bot --- diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 878d30b5f1..8eca250131 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -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