]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: resolve relocations to .TOC. symbol
authorCherry Mui <cherryyz@google.com>
Fri, 6 May 2022 19:57:21 +0000 (15:57 -0400)
committerDavid Chase <drchase@google.com>
Fri, 6 May 2022 20:41:13 +0000 (20:41 +0000)
CL 404296 breaks the PPC64LE build because the .TOC. symbol is
visibility hidden and was skipped from the "unresolved symbol"
check (the check needs to be fix). In face, the .TOC. symbol is
special in that it doesn't have a type but we have special logic
to assign a value to it in the address pass. So we can actually
resolve a relocation to .TOC.. We already have a special case
for PIE. It also applies to non-PIE as well.

Fix PPC64LE builds.

Change-Id: Iaf7e36f10c4d0a40fc56b2135e5ff38815e203b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/404302
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

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

index ce86f73cdab9354a102793191c1218a26feb180e..8d1a81ed1d17fa91bf6f4634ba093a1422f34acf 100644 (file)
@@ -227,8 +227,10 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                                        // DWARF info between the compiler and linker.
                                        continue
                                }
-                       } else if target.IsPPC64() && target.IsPIE() && ldr.SymName(rs) == ".TOC." {
-                               // This is a TOC relative relocation generated from a go object. It is safe to resolve.
+                       } else if target.IsPPC64() && ldr.SymName(rs) == ".TOC." {
+                               // TOC symbol doesn't have a type but we do assign a value
+                               // (see the address pass) and we can resolve it.
+                               // TODO: give it a type.
                        } else {
                                st.err.errorUnresolved(ldr, s, rs)
                                continue