]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: fix ppc64-specific bug in genelfsym
authorThan McIntosh <thanm@google.com>
Wed, 8 Jul 2020 14:43:42 +0000 (10:43 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 10 Aug 2020 11:37:47 +0000 (11:37 +0000)
The code in the the linker's genelfsym() routine was not properly
including runtime.text.%d marker symbols that are emitted on PPC64
when a very large text section is split into chunks. This bug was
introduced in CL 233338 when portions of asmb2() were converted
from sym.Symbol to loader.Sym usage.

Change-Id: Idfed944c41e1805f78f35be67bcdd18bdefd7819
Reviewed-on: https://go-review.googlesource.com/c/go/+/241498
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/symtab.go

index 97d7a22537e26dba6191c3e84248c1d8163bca5d..bc880955b8ca965a6b4b09af8a83cc1bbc77e204 100644 (file)
@@ -180,12 +180,31 @@ func putelfsectionsym(ctxt *Link, out *OutBuf, s loader.Sym, shndx int) {
 func genelfsym(ctxt *Link, elfbind int) {
        ldr := ctxt.loader
 
-       // Text symbols.
+       // runtime.text marker symbol(s).
        s := ldr.Lookup("runtime.text", 0)
        putelfsym(ctxt, s, STT_FUNC, elfbind)
+       for k, sect := range Segtext.Sections[1:] {
+               n := k + 1
+               if sect.Name != ".text" || (ctxt.IsAIX() && ctxt.IsExternal()) {
+                       // On AIX, runtime.text.X are symbols already in the symtab.
+                       break
+               }
+               s = ldr.Lookup(fmt.Sprintf("runtime.text.%d", n), 0)
+               if s == 0 {
+                       break
+               }
+               if ldr.SymType(s) != sym.STEXT {
+                       panic("unexpected type for runtime.text symbol")
+               }
+               putelfsym(ctxt, s, STT_FUNC, elfbind)
+       }
+
+       // Text symbols.
        for _, s := range ctxt.Textp {
                putelfsym(ctxt, s, STT_FUNC, elfbind)
        }
+
+       // runtime.etext marker symbol.
        s = ldr.Lookup("runtime.etext", 0)
        if ldr.SymType(s) == sym.STEXT {
                putelfsym(ctxt, s, STT_FUNC, elfbind)