[lld] r256439 - Add comment on .eh_frame sh_type.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 25 23:13:39 PST 2015
Author: ruiu
Date: Sat Dec 26 01:13:38 2015
New Revision: 256439
URL: http://llvm.org/viewvc/llvm-project?rev=256439&view=rev
Log:
Add comment on .eh_frame sh_type.
Also simplifies the code a bit.
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=256439&r1=256438&r2=256439&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Sat Dec 26 01:13:38 2015
@@ -679,17 +679,22 @@ SectionKey<ELFT::Is64Bits>
OutputSectionFactory<ELFT>::createKey(InputSectionBase<ELFT> *C,
StringRef OutsecName) {
const Elf_Shdr *H = C->getSectionHdr();
- uintX_t OutFlags = H->sh_flags & ~SHF_GROUP;
+ uintX_t Flags = H->sh_flags & ~SHF_GROUP;
// For SHF_MERGE we create different output sections for each sh_entsize.
// This makes each output section simple and keeps a single level
// mapping from input to output.
uintX_t EntSize = isa<MergeInputSection<ELFT>>(C) ? H->sh_entsize : 0;
- uint32_t OutType = H->sh_type;
- if (OutType == SHT_PROGBITS && C->getSectionName() == ".eh_frame" &&
- Config->EMachine == EM_X86_64)
- OutType = SHT_X86_64_UNWIND;
- return SectionKey<ELFT::Is64Bits>{OutsecName, OutType, OutFlags, EntSize};
+
+ // GNU as can give .eh_frame secion type SHT_PROGBITS or SHT_X86_64_UNWIND
+ // depending on the construct. We want to canonicalize it so that
+ // there is only one .eh_frame in the end.
+ uint32_t Type = H->sh_type;
+ if (Type == SHT_PROGBITS && Config->EMachine == EM_X86_64 &&
+ isa<EHInputSection<ELFT>>(C))
+ Type = SHT_X86_64_UNWIND;
+
+ return SectionKey<ELFT::Is64Bits>{OutsecName, Type, Flags, EntSize};
}
// Create output section objects and add them to OutputSections.
More information about the llvm-commits
mailing list