diff options
| author | Ian Lance Taylor <iant@golang.org> | 2026-01-30 19:15:31 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-02-06 15:30:44 -0800 |
| commit | ad170e18540be19bd6db012ff221c01e8c9745e9 (patch) | |
| tree | 5c4ea7725903a76d07199285c1e7e517b0a73e5e /src | |
| parent | 9fd5a5fa7d9d629ded8d4685dcc5984268258edb (diff) | |
| download | go-ad170e18540be19bd6db012ff221c01e8c9745e9.tar.xz | |
cmd/link: make TestTypePlacement work on AIX
The existing code was just wrong. On AIX the go.type section is
folded into the .text section (when internally linking),
or the .data section (when externally linking).
It follows that the data section adjustment is useless when
internally linking, which is currently what happens with this test.
Change-Id: Icf8ac07f754fdcf08b9d3dfffde83b3391c9404b
Reviewed-on: https://go-review.googlesource.com/c/go/+/740821
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/link/link_test.go | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index 541733b8e6..19607c324c 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -2416,20 +2416,37 @@ func TestTypePlacement(t *testing.T) { case xf != nil: defer xf.Close() - for _, sec := range xf.Sections { - if sec.Name == ".go.type" { - typeStart = sec.VirtualAddress - typeEnd = sec.VirtualAddress + sec.Size - break + // On XCOFF the .go.type section, + // like all relro sections, + // gets folded into the .data section. + var typeSym, eTypeSym *xcoff.Symbol + for _, sym := range xf.Symbols { + switch sym.Name { + case "runtime.types": + typeSym = sym + case "runtime.etypes": + eTypeSym = sym + case globalName: + globalSec := xf.Sections[sym.SectionNumber-1] + globalObjAddr = uint64(globalSec.VirtualAddress + sym.Value) } } - for _, sym := range xf.Symbols { - if sym.Name == globalName { - globalObjAddr = sym.Value - break - } + if typeSym == nil { + t.Fatal("could not find symbol runtime.types") } + if eTypeSym == nil { + t.Fatal("could not find symbol runtime.etypes") + } + if typeSym.SectionNumber != eTypeSym.SectionNumber { + t.Fatalf("runtime.types section %d != runtime.etypes section %d", typeSym.SectionNumber, eTypeSym.SectionNumber) + } + + sec := xf.Sections[typeSym.SectionNumber-1] + + typeStart = uint64(sec.VirtualAddress + typeSym.Value) + + typeEnd = uint64(sec.VirtualAddress + eTypeSym.Value) } if typeStart == 0 || typeEnd == 0 { @@ -2440,6 +2457,14 @@ func TestTypePlacement(t *testing.T) { offset := globalExeAddr - globalObjAddr t.Logf("execution offset: %#x", offset) + // On AIX with internal linking the type descriptors are + // currently put in the .text section, whereas the global + // variable will be in the .data section. We must ignore + // the offset. This would change if using external linking. + if runtime.GOOS == "aix" { + offset = 0 + } + for _, addr := range addrs { addr -= offset if addr < typeStart || addr >= typeEnd { |
