Skip to content

Commit 0c9e0c2

Browse files
Clément Chigotbradfitz
Clément Chigot
authored andcommitted
cmd/link: add .go.buildinfo in XCOFF symbol table
.go.buildinfo must be added to the symbol table on AIX. Otherwise, ld won't be able to handle its relocations. This patch also make ".data" the default section for all symbols inside the data segment. Change-Id: I83ac2bf1050e0ef6ef9c96ff793efd4ddc8e98d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/174298 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 9f12e2e commit 0c9e0c2

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,11 +2265,23 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
22652265
}
22662266
}
22672267

2268-
for _, s := range ctxt.Syms.Allsym {
2268+
shouldBeInSymbolTable := func(s *sym.Symbol) bool {
22692269
if s.Attr.NotInSymbolTable() {
2270-
continue
2270+
return false
2271+
}
2272+
if ctxt.HeadType == objabi.Haix && s.Name == ".go.buildinfo" {
2273+
// On AIX, .go.buildinfo must be in the symbol table as
2274+
// it has relocations.
2275+
return true
22712276
}
22722277
if (s.Name == "" || s.Name[0] == '.') && !s.IsFileLocal() && s.Name != ".rathole" && s.Name != ".TOC." {
2278+
return false
2279+
}
2280+
return true
2281+
}
2282+
2283+
for _, s := range ctxt.Syms.Allsym {
2284+
if !shouldBeInSymbolTable(s) {
22732285
continue
22742286
}
22752287
switch s.Type {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,13 @@ func (f *xcoffFile) getXCOFFscnum(sect *sym.Section) int16 {
513513
case &Segtext:
514514
return f.sectNameToScnum[".text"]
515515
case &Segdata:
516-
if sect.Name == ".noptrdata" || sect.Name == ".data" {
517-
return f.sectNameToScnum[".data"]
518-
}
519516
if sect.Name == ".noptrbss" || sect.Name == ".bss" {
520517
return f.sectNameToScnum[".bss"]
521518
}
522519
if sect.Name == ".tbss" {
523520
return f.sectNameToScnum[".tbss"]
524521
}
525-
Errorf(nil, "unknown XCOFF segment data section: %s", sect.Name)
522+
return f.sectNameToScnum[".data"]
526523
case &Segdwarf:
527524
name, _ := xcoffGetDwarfSubtype(sect.Name)
528525
return f.sectNameToScnum[name]

0 commit comments

Comments
 (0)