aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-10-06 12:39:41 -0400
committerCherry Mui <cherryyz@google.com>2021-10-06 17:38:01 +0000
commit415f0a33750a7cb4ad282fc5aa664d3fde244f84 (patch)
tree90fd8abdc6266e8d35aaf8187c8a532a64b9dc0f /src/cmd/link
parent316057142cc6055952621ccbaccc53d58d88be3f (diff)
downloadgo-415f0a33750a7cb4ad282fc5aa664d3fde244f84.tar.gz
go-415f0a33750a7cb4ad282fc5aa664d3fde244f84.zip
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>
Diffstat (limited to 'src/cmd/link')
-rw-r--r--src/cmd/link/internal/ld/symtab.go8
1 files changed, 7 insertions, 1 deletions
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