[lld] r252757 - Canonicalize the type of .eh_frame.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 09:33:22 PST 2015
Author: rafael
Date: Wed Nov 11 11:33:22 2015
New Revision: 252757
URL: http://llvm.org/viewvc/llvm-project?rev=252757&view=rev
Log:
Canonicalize the type of .eh_frame.
GNU as can give it type SHT_PROGBITS or SHT_X86_64_UNWIND depending on
teh construct.
MC gives it type SHT_X86_64_UNWIND.
The linker has to canonicalize to one or the other so that there is only
one .eh_frame in the end.
Added:
lld/trunk/test/elf2/eh-frame-type.test
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=252757&r1=252756&r2=252757&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Nov 11 11:33:22 2015
@@ -489,8 +489,12 @@ template <class ELFT> void Writer<ELFT>:
// mapping from input to output.
auto *IS = dyn_cast<InputSection<ELFT>>(C);
uintX_t EntSize = IS ? 0 : H->sh_entsize;
+ uint32_t OutType = H->sh_type;
+ if (OutType == SHT_PROGBITS && C->getSectionName() == ".eh_frame" &&
+ Config->EMachine == EM_X86_64)
+ OutType = SHT_X86_64_UNWIND;
SectionKey<ELFT::Is64Bits> Key{getOutputName(C->getSectionName()),
- H->sh_type, OutFlags, EntSize};
+ OutType, OutFlags, EntSize};
OutputSectionBase<ELFT> *&Sec = Map[Key];
if (!Sec) {
if (IS)
Added: lld/trunk/test/elf2/eh-frame-type.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/eh-frame-type.test?rev=252757&view=auto
==============================================================================
--- lld/trunk/test/elf2/eh-frame-type.test (added)
+++ lld/trunk/test/elf2/eh-frame-type.test Wed Nov 11 11:33:22 2015
@@ -0,0 +1,16 @@
+# RUN: yaml2obj -format elf %s -o %t.o
+# RUN: ld.lld2 %t.o -o %t -shared
+# RUN: llvm-readobj -s %t | FileCheck %s
+
+# CHECK: Name: .eh_frame
+# CHECK-NEXT: Type: SHT_X86_64_UNWIND
+
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .eh_frame
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
More information about the llvm-commits
mailing list