Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2019 02:02:56 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348347 - head/contrib/elftoolchain/libdwarf
Message-ID:  <201905290202.x4T22uXG045558@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Wed May 29 02:02:56 2019
New Revision: 348347
URL: https://svnweb.freebsd.org/changeset/base/348347

Log:
  Add missing powerpc64 relocation support to libdwarf
  
  Summary:
  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
  Reviewed By:	emaste
  Differential Revision: https://reviews.freebsd.org/D20367

Modified:
  head/contrib/elftoolchain/libdwarf/libdwarf_reloc.c

Modified: head/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
==============================================================================
--- head/contrib/elftoolchain/libdwarf/libdwarf_reloc.c	Wed May 29 01:08:30 2019	(r348346)
+++ head/contrib/elftoolchain/libdwarf/libdwarf_reloc.c	Wed May 29 02:02:56 2019	(r348347)
@@ -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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905290202.x4T22uXG045558>