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.

llvm-svn: 252757
This commit is contained in:
Rafael Espindola
2015-11-11 17:33:22 +00:00
parent 9b54b41f7b
commit a016b1e186
2 changed files with 21 additions and 1 deletions

View File

@@ -489,8 +489,12 @@ template <class ELFT> void Writer<ELFT>::createSections() {
// 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)

View File

@@ -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 ]