Commit 0c9e0c25 authored by Clément Chigot's avatar Clément Chigot Committed by Brad Fitzpatrick

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 <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 9f12e2e0
...@@ -2265,11 +2265,23 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6 ...@@ -2265,11 +2265,23 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
} }
} }
for _, s := range ctxt.Syms.Allsym { shouldBeInSymbolTable := func(s *sym.Symbol) bool {
if s.Attr.NotInSymbolTable() { if s.Attr.NotInSymbolTable() {
continue return false
}
if ctxt.HeadType == objabi.Haix && s.Name == ".go.buildinfo" {
// On AIX, .go.buildinfo must be in the symbol table as
// it has relocations.
return true
} }
if (s.Name == "" || s.Name[0] == '.') && !s.IsFileLocal() && s.Name != ".rathole" && s.Name != ".TOC." { if (s.Name == "" || s.Name[0] == '.') && !s.IsFileLocal() && s.Name != ".rathole" && s.Name != ".TOC." {
return false
}
return true
}
for _, s := range ctxt.Syms.Allsym {
if !shouldBeInSymbolTable(s) {
continue continue
} }
switch s.Type { switch s.Type {
......
...@@ -513,16 +513,13 @@ func (f *xcoffFile) getXCOFFscnum(sect *sym.Section) int16 { ...@@ -513,16 +513,13 @@ func (f *xcoffFile) getXCOFFscnum(sect *sym.Section) int16 {
case &Segtext: case &Segtext:
return f.sectNameToScnum[".text"] return f.sectNameToScnum[".text"]
case &Segdata: case &Segdata:
if sect.Name == ".noptrdata" || sect.Name == ".data" {
return f.sectNameToScnum[".data"]
}
if sect.Name == ".noptrbss" || sect.Name == ".bss" { if sect.Name == ".noptrbss" || sect.Name == ".bss" {
return f.sectNameToScnum[".bss"] return f.sectNameToScnum[".bss"]
} }
if sect.Name == ".tbss" { if sect.Name == ".tbss" {
return f.sectNameToScnum[".tbss"] return f.sectNameToScnum[".tbss"]
} }
Errorf(nil, "unknown XCOFF segment data section: %s", sect.Name) return f.sectNameToScnum[".data"]
case &Segdwarf: case &Segdwarf:
name, _ := xcoffGetDwarfSubtype(sect.Name) name, _ := xcoffGetDwarfSubtype(sect.Name)
return f.sectNameToScnum[name] return f.sectNameToScnum[name]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment