Skip to content

Commit f3db9ac

Browse files
committed
libdwarf: add powerpc64 relocation support
Due to missing relocation support in libdwarf for powerpc64, handling of dwarf info on unlinked objects was bogus. Examining raw dwarf data on objects compiled on ppc64 with a modern compiler, one would find that the dwarf data appeared corrupt, with repeated references to the compiler version where things like types and function names should appear. This happenend because the 0 offset of .debug_str contains the compiler version, and without applying the relocations, *all* indirect strings in .dwarf_info end up pointing to it. However, examining the dwarf data on a compiled executable appeared correct because during final link the relocations get applied and baked in by the linker. On FreeBSD this corruption then propogated to CTF data, as ctfconvert relies on libdwarf to read the dwarf info, for every compiled object (when building a kernel). FreeBSD's older in-tree gcc tends to hide the issue, since it only rarely generates relocations in .debug_info and uses DW_FORM_str instead of DW_FORM_strp for everything. Submitted by: Brandon Bergren, via Justin Hibbits Obtained from: FreeBSD r348347
1 parent 5508eba commit f3db9ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libdwarf/libdwarf_reloc.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ _dwarf_get_reloc_type(Dwarf_P_Debug dbg, int is64)
4444
case DW_ISA_SPARC:
4545
return (is64 ? R_SPARC_UA64 : R_SPARC_UA32);
4646
case DW_ISA_PPC:
47-
return (R_PPC_ADDR32);
47+
return (is64 ? R_PPC64_ADDR64 : R_PPC_ADDR32);
4848
case DW_ISA_ARM:
4949
return (R_ARM_ABS32);
5050
case DW_ISA_MIPS:
@@ -97,6 +97,12 @@ _dwarf_get_reloc_size(Dwarf_Debug dbg, Dwarf_Unsigned rel_type)
9797
if (rel_type == R_PPC_ADDR32)
9898
return (4);
9999
break;
100+
case EM_PPC64:
101+
if (rel_type == R_PPC_ADDR32)
102+
return (4);
103+
else if (rel_type == R_PPC64_ADDR64)
104+
return (8);
105+
break;
100106
case EM_MIPS:
101107
if (rel_type == R_MIPS_32)
102108
return (4);

0 commit comments

Comments
 (0)