]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: keep go.buildid alive on AIX external linking
authorCherry Mui <cherryyz@google.com>
Wed, 6 Oct 2021 16:39:41 +0000 (12:39 -0400)
committerCherry Mui <cherryyz@google.com>
Wed, 6 Oct 2021 17:38:01 +0000 (17:38 +0000)
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>

src/cmd/link/internal/ld/symtab.go

index 878d30b5f17c56fd2b495ce04efb634f5a9acd3e..8eca250131047f1433fb8e29ef57bae0f789e231 100644 (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