[PATCH] D32899: [RuntimeDyld] Fix debug section relocation (pr20457)

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 02:00:52 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL303239: [RuntimeDyld] Fix debug section relocation (pr20457) (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D32899?vs=98967&id=99257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32899

Files:
  llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_debug_frame.s


Index: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
===================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -705,7 +705,7 @@
   unsigned Alignment = (unsigned)Alignment64 & 0xffffffffL;
   unsigned PaddingSize = 0;
   unsigned StubBufSize = 0;
-  bool IsRequired = isRequiredForExecution(Section) || ProcessAllSections;
+  bool IsRequired = isRequiredForExecution(Section);
   bool IsVirtual = Section.isVirtual();
   bool IsZeroInit = isZeroInit(Section);
   bool IsReadOnly = isReadOnlyData(Section);
@@ -745,8 +745,8 @@
     Alignment = std::max(Alignment, getStubAlignment());
 
   // Some sections, such as debug info, don't need to be loaded for execution.
-  // Leave those where they are.
-  if (IsRequired) {
+  // Process those only if explicitly requested.
+  if (IsRequired || ProcessAllSections) {
     Allocate = DataSize + PaddingSize + StubBufSize;
     if (!Allocate)
       Allocate = 1;
@@ -790,6 +790,10 @@
   Sections.push_back(
       SectionEntry(Name, Addr, DataSize, Allocate, (uintptr_t)pData));
 
+  // Debug info sections are linked as if their load address was zero
+  if (!IsRequired)
+    Sections.back().setLoadAddress(0);
+
   if (Checker)
     Checker->registerSection(Obj.getFileName(), SectionID);
 
Index: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_debug_frame.s
===================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_debug_frame.s
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_debug_frame.s
@@ -0,0 +1,20 @@
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj -o %T/ELF_x86-64_debug_frame.o %s
+# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify -check=%s %T/ELF_x86-64_debug_frame.o
+
+        .text
+        .file   "debug_frame_test.c"
+        .align  16, 0x90
+        .type   foo, at function
+foo:
+        .cfi_startproc
+        retq
+.Ltmp0:
+        .size   foo, .Ltmp0-foo
+        .cfi_endproc
+        .cfi_sections .debug_frame
+
+# Check that .debug_frame is mapped to 0.
+# rtdyld-check: section_addr(ELF_x86-64_debug_frame.o, .debug_frame) = 0
+
+# Check that The relocated FDE's CIE offset also points to zero.
+# rtdyld-check: *{4}(section_addr(ELF_x86-64_debug_frame.o, .debug_frame) + 0x1C) = 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32899.99257.patch
Type: text/x-patch
Size: 2418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/e5192329/attachment.bin>


More information about the llvm-commits mailing list