[PATCH] D13104: Mips - Mark the section .eh_frame as writeable for pic

Dean De Leo via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 09:31:14 PDT 2015


dean updated this revision to Diff 35519.
dean added a comment.

Source indentation


Repository:
  rL LLVM

http://reviews.llvm.org/D13104

Files:
  lib/MC/MCObjectFileInfo.cpp

Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -246,6 +246,8 @@
 }
 
 void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) {
+  bool eh_frame_writable = false;
+
   switch (T.getArch()) {
   case Triple::mips:
   case Triple::mipsel:
@@ -338,6 +340,15 @@
                     dwarf::DW_EH_PE_sdata4;
     // We don't support PC-relative LSDA references in GAS so we use the default
     // DW_EH_PE_absptr for those.
+
+    // The section .eh_frame exhibits absolute addresses which require fixups.
+    // While the gnu linker can transform them in relative references at
+    // linking time, at the moment the mclinker does not provide this
+    // functionality. Setting the section as writable allows the fixups to be
+    // resolved at run time.
+    if (RelocM == Reloc::PIC_) {
+      eh_frame_writable = true;
+    }
     break;
   case Triple::ppc64:
   case Triple::ppc64le:
@@ -402,6 +413,9 @@
     else
       EHSectionFlags |= ELF::SHF_WRITE;
   }
+  if (eh_frame_writable) {
+    EHSectionFlags |= ELF::SHF_WRITE;
+  }
 
   // ELF
   BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13104.35519.patch
Type: text/x-patch
Size: 1234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150923/ab826719/attachment.bin>


More information about the llvm-commits mailing list