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 80df13ef8babe6051702808e46df14a240e13ea5..d95d0b92f4dacb6ae4926c8db0dc9279dc928326 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -976,7 +976,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 b796cdb95b65c6182b14c80b0c6589b33cbf340e..ee888e5af271a8c2c8a3612b58ad78e05716a579 100644 --- a/src/debug/elf/file_test.go +++ b/src/debug/elf/file_test.go @@ -1036,6 +1036,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