[PATCH] D94323: [dsymutil] Support finding relocations in debug_addr for DWARF5

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 11:10:08 PST 2021


JDevlieghere created this revision.
JDevlieghere added reviewers: friss, aprantl, dblaikie, avl.
JDevlieghere requested review of this revision.
Herald added a project: LLVM.

Support finding relocations in debug_addr for DWARF5. Before this patch
dsymutil would only look at the debug_info section.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94323

Files:
  llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.o
  llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out
  llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out.dSYM/Contents/Info.plist
  llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out.dSYM/Contents/Resources/DWARF/dwarf5.out
  llvm/test/tools/dsymutil/X86/dwarf5.test
  llvm/tools/dsymutil/DwarfLinkerForBinary.cpp


Index: llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
===================================================================
--- llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -582,10 +582,10 @@
   return true;
 }
 
-/// Look for relocations in the debug_info section that match
-/// entries in the debug map. These relocations will drive the Dwarf
-/// link by indicating which DIEs refer to symbols present in the
-/// linked binary.
+/// Look for relocations in either the debug_info or the debug_addr sections
+/// that match entries in the debug map. These relocations will drive the Dwarf
+/// link by indicating which DIEs refer to symbols present in the linked
+/// binary.
 /// \returns whether there are any valid relocations in the debug info.
 bool DwarfLinkerForBinary::AddressManager::findValidRelocsInDebugInfo(
     const object::ObjectFile &Obj, const DebugMapObject &DMO) {
@@ -598,9 +598,9 @@
       consumeError(NameOrErr.takeError());
 
     SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
-    if (SectionName != "debug_info")
-      continue;
-    return findValidRelocs(Section, Obj, DMO);
+    if (SectionName == "debug_info" || SectionName == "debug_addr")
+      if(findValidRelocs(Section, Obj, DMO))
+        return true;
   }
   return false;
 }
Index: llvm/test/tools/dsymutil/X86/dwarf5.test
===================================================================
--- /dev/null
+++ llvm/test/tools/dsymutil/X86/dwarf5.test
@@ -0,0 +1,18 @@
+Test DWARF5 support in dsymutil. Currently this still generates an empty dSYM.
+
+$ cat dwarf5.c
+__attribute__ ((optnone))
+int foo() {
+  volatile i;
+  return i;
+}
+
+int main(int argc, char** argv) {
+  return foo();
+}
+
+$ clang -gdwarf-5 dwarf5.c -c -o dwarf5.o
+$ clang dwarf5.o -o dwarf5.out
+
+RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/dwarf5/dwarf5.out 2>&1 | FileCheck %s
+CHECK: warning: Unsupported attribute form in cloneAttribute. Dropping.
Index: llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out.dSYM/Contents/Info.plist
===================================================================
--- /dev/null
+++ llvm/test/tools/dsymutil/Inputs/private/tmp/dwarf5/dwarf5.out.dSYM/Contents/Info.plist
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+	<dict>
+		<key>CFBundleDevelopmentRegion</key>
+		<string>English</string>
+		<key>CFBundleIdentifier</key>
+		<string>com.apple.xcode.dsym.Foo&Bar</string>
+		<key>CFBundleInfoDictionaryVersion</key>
+		<string>6.0</string>
+		<key>CFBundlePackageType</key>
+		<string>dSYM</string>
+		<key>CFBundleSignature</key>
+		<string>????</string>
+		<key>CFBundleShortVersionString</key>
+		<string>2.0</string>
+		<key>CFBundleVersion</key>
+		<string>2</string>
+	</dict>
+</plist>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94323.315456.patch
Type: text/x-patch
Size: 2967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210108/7097806a/attachment.bin>


More information about the llvm-commits mailing list