aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/nm
diff options
context:
space:
mode:
authorClément Chigot <clement.chigot@atos.net>2018-10-22 17:00:37 +0200
committerIan Lance Taylor <iant@golang.org>2018-10-31 13:47:42 +0000
commit49dafc70c8558271fc2205061d07eed490f2bc18 (patch)
tree25415a8f720ef6b3d698bbb6dba121baca3405a2 /src/cmd/nm
parent5cc80899486027db5f0de00870f1e022e1cfb9c5 (diff)
downloadgo-49dafc70c8558271fc2205061d07eed490f2bc18.tar.gz
go-49dafc70c8558271fc2205061d07eed490f2bc18.zip
cmd: add XCOFF objfile and adapt cmd/nm tests
This commit adds a new file format in cmd/internal/objfile for XCOFF. It also adapts tests inside cmd/nm for AIX. Updates: #25893 Change-Id: I1e55ea0b7f7d08a871343bee27d11e2d3baad254 Reviewed-on: https://go-review.googlesource.com/c/145397 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/nm')
-rw-r--r--src/cmd/nm/nm_test.go37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go
index ccf5682d69..87baa09d38 100644
--- a/src/cmd/nm/nm_test.go
+++ b/src/cmd/nm/nm_test.go
@@ -56,17 +56,18 @@ func testMain(m *testing.M) int {
func TestNonGoExecs(t *testing.T) {
testfiles := []string{
- "elf/testdata/gcc-386-freebsd-exec",
- "elf/testdata/gcc-amd64-linux-exec",
- "macho/testdata/gcc-386-darwin-exec",
- "macho/testdata/gcc-amd64-darwin-exec",
- // "pe/testdata/gcc-amd64-mingw-exec", // no symbols!
- "pe/testdata/gcc-386-mingw-exec",
- "plan9obj/testdata/amd64-plan9-exec",
- "plan9obj/testdata/386-plan9-exec",
+ "debug/elf/testdata/gcc-386-freebsd-exec",
+ "debug/elf/testdata/gcc-amd64-linux-exec",
+ "debug/macho/testdata/gcc-386-darwin-exec",
+ "debug/macho/testdata/gcc-amd64-darwin-exec",
+ // "debug/pe/testdata/gcc-amd64-mingw-exec", // no symbols!
+ "debug/pe/testdata/gcc-386-mingw-exec",
+ "debug/plan9obj/testdata/amd64-plan9-exec",
+ "debug/plan9obj/testdata/386-plan9-exec",
+ "cmd/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec",
}
for _, f := range testfiles {
- exepath := filepath.Join(runtime.GOROOT(), "src", "debug", f)
+ exepath := filepath.Join(runtime.GOROOT(), "src", f)
cmd := exec.Command(testnmpath, exepath)
out, err := cmd.CombinedOutput()
if err != nil {
@@ -139,6 +140,20 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
if err != nil {
t.Fatalf("go tool nm: %v\n%s", err, string(out))
}
+
+ relocated := func(code string) bool {
+ if runtime.GOOS == "aix" {
+ // On AIX, .data and .bss addresses are changed by the loader.
+ // Therefore, the values returned by the exec aren't the same
+ // than the ones inside the symbol table.
+ switch code {
+ case "D", "d", "B", "b":
+ return true
+ }
+ }
+ return false
+ }
+
scanner := bufio.NewScanner(bytes.NewBuffer(out))
dups := make(map[string]bool)
for scanner.Scan() {
@@ -149,7 +164,9 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
name := f[2]
if addr, found := names[name]; found {
if want, have := addr, "0x"+f[0]; have != want {
- t.Errorf("want %s address for %s symbol, but have %s", want, name, have)
+ if !relocated(f[1]) {
+ t.Errorf("want %s address for %s symbol, but have %s", want, name, have)
+ }
}
delete(names, name)
}