svn commit: r358776 - stable/12/contrib/elftoolchain/libdwarf

Ed Maste emaste at FreeBSD.org
Sun Mar 8 20:05:34 UTC 2020


Author: emaste
Date: Sun Mar  8 20:05:34 2020
New Revision: 358776
URL: https://svnweb.freebsd.org/changeset/base/358776

Log:
  MFC r348347 (jhibbits): libdwarf: add missing 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
  (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), you will find that the dwarf data appears corrupt, with
  repeated references to the compiler version where things like types and
  function names should appear.
  
  This happens because the 0 offset of .debug_str contains the compiler
  version, and without applying the relocations, *all* indirect strings in
  .dwarf_info will end up pointing to it.
  
  This corruption then propogates to the CTF data, as ctfconvert relies on
  libdwarf to read the dwarf info, for every compiled object (when building a
  kernel.)
  
  However, if you examine the dwarf data on a compiled executable, it will
  appear correct, because during final link the relocations get applied and
  baked in by the linker.
  
  Submitted by:	Brandon Bergren

Modified:
  stable/12/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
==============================================================================
--- stable/12/contrib/elftoolchain/libdwarf/libdwarf_reloc.c	Sun Mar  8 20:03:17 2020	(r358775)
+++ stable/12/contrib/elftoolchain/libdwarf/libdwarf_reloc.c	Sun Mar  8 20:05:34 2020	(r358776)
@@ -44,7 +44,7 @@ _dwarf_get_reloc_type(Dwarf_P_Debug dbg, int is64)
 	case DW_ISA_SPARC:
 		return (is64 ? R_SPARC_UA64 : R_SPARC_UA32);
 	case DW_ISA_PPC:
-		return (R_PPC_ADDR32);
+		return (is64 ? R_PPC64_ADDR64 : R_PPC_ADDR32);
 	case DW_ISA_ARM:
 		return (R_ARM_ABS32);
 	case DW_ISA_MIPS:
@@ -96,6 +96,12 @@ _dwarf_get_reloc_size(Dwarf_Debug dbg, Dwarf_Unsigned 
 	case EM_PPC:
 		if (rel_type == R_PPC_ADDR32)
 			return (4);
+		break;
+	case EM_PPC64:
+		if (rel_type == R_PPC_ADDR32)
+			return (4);
+		else if (rel_type == R_PPC64_ADDR64)
+			return (8);
 		break;
 	case EM_MIPS:
 		if (rel_type == R_MIPS_32)


More information about the svn-src-all mailing list