src/debug/elf/file.go | 2 +- src/debug/elf/file_test.go | 24 ++++++++++++++++++++++++ diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index a9c13212284ebe60974c75c7da9ad4ee1fa1d966..7409ecd2ab9e7037f0e1f45d3e63b5b029fbe362 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -1003,7 +1003,7 @@ } switch t { case R_PPC_ADDR32: - putUint(f.ByteOrder, dst, uint64(rela.Off), 4, sym.Value, 0, false) + putUint(f.ByteOrder, dst, uint64(rela.Off), 4, sym.Value, int64(rela.Addend), false) } } diff --git a/src/debug/elf/file_test.go b/src/debug/elf/file_test.go index 138a958c92abe6e2acd476717bbf801caf258349..e976f744c0165a234612fc3ac2b110c36f8cbebd 100644 --- a/src/debug/elf/file_test.go +++ b/src/debug/elf/file_test.go @@ -1038,6 +1038,30 @@ }, }, }, }, + { + "testdata/go-relocation-test-gcc133-ppc.obj", + []relocationTestEntry{ + { + entry: &dwarf.Entry{ + Offset: 0xc, + Tag: dwarf.TagCompileUnit, + Children: true, + Field: []dwarf.Field{ + {Attr: dwarf.AttrProducer, Val: "GNU C17 13.3.0 -msecure-plt -g2 -fstack-protector-strong", Class: dwarf.ClassString}, + {Attr: dwarf.AttrLanguage, Val: int64(29), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrName, Val: "hello.c", Class: dwarf.ClassString}, + {Attr: dwarf.AttrCompDir, Val: "/home/exedev", Class: dwarf.ClassString}, + {Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress}, + {Attr: dwarf.AttrHighpc, Val: int64(68), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, + }, + }, + pcRanges: [][2]uint64{ + {0, 0x44}, + }, + }, + }, + }, } func TestDWARFRelocations(t *testing.T) { diff --git a/src/debug/elf/testdata/go-relocation-test-gcc133-ppc.obj b/src/debug/elf/testdata/go-relocation-test-gcc133-ppc.obj new file mode 100644 index 0000000000000000000000000000000000000000..434e2711d92b8ee0184bd11a31b9ff4906fa8619 Binary files /dev/null and b/src/debug/elf/testdata/go-relocation-test-gcc133-ppc.obj differ