[PATCH] D30566: [ELF] - Do not try to create .eh_frame_hdr for relocatable output.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 01:55:05 PST 2017


grimar updated this revision to Diff 90662.
grimar added a comment.

- Added warning when -r used together with --eh-frame-hdr


https://reviews.llvm.org/D30566

Files:
  ELF/Driver.cpp
  ELF/Writer.cpp
  test/ELF/relocatable-eh-frame-hdr.s


Index: test/ELF/relocatable-eh-frame-hdr.s
===================================================================
--- test/ELF/relocatable-eh-frame-hdr.s
+++ test/ELF/relocatable-eh-frame-hdr.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --eh-frame-hdr -r %t.o -o %t 2>&1 | FileCheck -check-prefix=WARN %s
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# WARN: --eh-frame-hdr is ignored when using -r
+
+# CHECK:       Sections [
+# CHECK-NOT:    Name: .eh_frame_hdr
+
+.section .foo,"ax", at progbits
+.cfi_startproc
+.cfi_endproc
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -435,12 +435,11 @@
   In<ELFT>::Iplt = make<PltSection<ELFT>>(0);
   Add(In<ELFT>::Iplt);
 
-  if (Config->EhFrameHdr) {
-    In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
-    Add(In<ELFT>::EhFrameHdr);
-  }
-
   if (!Config->Relocatable) {
+    if (Config->EhFrameHdr) {
+      In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>();
+      Add(In<ELFT>::EhFrameHdr);
+    }
     In<ELFT>::EhFrame = make<EhFrameSection<ELFT>>();
     Add(In<ELFT>::EhFrame);
   }
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -226,6 +226,9 @@
     error("-shared and -pie may not be used together");
 
   if (Config->Relocatable) {
+    if (Config->EhFrameHdr)
+      warn("--eh-frame-hdr is ignored when using -r");
+
     if (Config->Shared)
       error("-r and -shared may not be used together");
     if (Config->GcSections)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30566.90662.patch
Type: text/x-patch
Size: 1628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170306/9bde01e6/attachment.bin>


More information about the llvm-commits mailing list