]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: use __got as the .got section name
authorqmuntal <quimmuntal@gmail.com>
Tue, 25 Feb 2025 20:56:29 +0000 (21:56 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Fri, 28 Feb 2025 20:43:36 +0000 (12:43 -0800)
The __nl_symbol_ptr is not a common section name anymore. LLVM prefers
__got for GOT symbols in the __DATA_CONST segment.

Note that the Go linker used to place the GOT section in the __DATA
segment, but since CL 644055 we place it in the __DATA_CONST segment.

Updates #71416.

Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64-longtest
Change-Id: Icb776e19855eaabb4777a9b1eb433497842413b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/652555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/macho_test.go

index 93b54d81c555ba0e6afbcdd0e7247eedb9cecbbb..45f395358a1e3b0708eee1bbc3c087929b75ab45 100644 (file)
@@ -461,7 +461,7 @@ func (ctxt *Link) domacho() {
                sb.SetType(sym.SMACHOPLT)
                sb.SetReachable(true)
 
-               s = ctxt.loader.LookupOrCreateSym(".got", 0) // will be __nl_symbol_ptr
+               s = ctxt.loader.LookupOrCreateSym(".got", 0) // will be __got
                sb = ctxt.loader.MakeSymbolUpdater(s)
                if ctxt.UseRelro() {
                        sb.SetType(sym.SMACHORELROSECT)
@@ -587,7 +587,7 @@ func machoshbits(ctxt *Link, mseg *MachoSeg, sect *sym.Section, segname string)
        }
 
        if sect.Name == ".got" {
-               msect.name = "__nl_symbol_ptr"
+               msect.name = "__got"
                msect.flag = S_NON_LAZY_SYMBOL_POINTERS
                msect.res1 = uint32(ctxt.loader.SymSize(ctxt.ArchSyms.LinkEditPLT) / 4) /* offset into indirect symbol table */
        }
index 253abd30a4d58896f0adba7121d14629cfb93614..ad02731d3a5d9310aeda77631d067192f286f4db 100644 (file)
@@ -37,7 +37,7 @@ func TestMachoSectionsReadOnly(t *testing.T) {
                        args:             []string{"-ldflags", "-linkmode=internal"},
                        prog:             prog,
                        mustInternalLink: true,
-                       wantSecsRO:       []string{"__nl_symbol_ptr", "__rodata", "__itablink", "__typelink", "__gosymtab", "__gopclntab"},
+                       wantSecsRO:       []string{"__got", "__rodata", "__itablink", "__typelink", "__gosymtab", "__gopclntab"},
                },
                {
                        name:        "linkmode-external",