summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/MC/MCObjectFileInfo.h9
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp42
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp2
-rw-r--r--llvm/test/CodeGen/X86/eh_frame.ll4
4 files changed, 22 insertions, 35 deletions
diff --git a/llvm/include/llvm/MC/MCObjectFileInfo.h b/llvm/include/llvm/MC/MCObjectFileInfo.h
index ec8627ca7c1..6e325cc21f2 100644
--- a/llvm/include/llvm/MC/MCObjectFileInfo.h
+++ b/llvm/include/llvm/MC/MCObjectFileInfo.h
@@ -47,10 +47,6 @@ protected:
unsigned FDECFIEncoding;
unsigned TTypeEncoding;
- /// Section flags for eh_frame
- unsigned EHSectionType;
- unsigned EHSectionFlags;
-
/// Compact unwind encoding indicating that we should emit only an EH frame.
unsigned CompactUnwindDwarfEHFrameOnly;
@@ -336,8 +332,6 @@ public:
MCSection *getSXDataSection() const { return SXDataSection; }
MCSection *getEHFrameSection() {
- if (!EHFrameSection)
- InitEHFrameSection();
return EHFrameSection;
}
@@ -357,9 +351,6 @@ private:
void initELFMCObjectFileInfo(Triple T);
void initCOFFMCObjectFileInfo(Triple T);
- /// Initialize EHFrameSection on demand.
- void InitEHFrameSection();
-
public:
const Triple &getTargetTriple() const { return TT; }
};
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 8849f5d4d12..253564e6d49 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -49,6 +49,12 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(Triple T) {
// MachO
SupportsWeakOmittedEHFrame = false;
+ EHFrameSection = Ctx->getMachOSection(
+ "__TEXT", "__eh_frame",
+ MachO::S_COALESCED | MachO::S_ATTR_NO_TOC |
+ MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT,
+ SectionKind::getReadOnly());
+
if (T.isOSDarwin() && T.getArch() == Triple::aarch64)
SupportsCompactUnwindWithoutEHFrame = true;
@@ -416,12 +422,13 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) {
break;
}
- EHSectionType = T.getArch() == Triple::x86_64 ? ELF::SHT_X86_64_UNWIND
- : ELF::SHT_PROGBITS;
+ unsigned EHSectionType = T.getArch() == Triple::x86_64
+ ? ELF::SHT_X86_64_UNWIND
+ : ELF::SHT_PROGBITS;
// Solaris requires different flags for .eh_frame to seemingly every other
// platform.
- EHSectionFlags = ELF::SHF_ALLOC;
+ unsigned EHSectionFlags = ELF::SHF_ALLOC;
if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
EHSectionFlags |= ELF::SHF_WRITE;
@@ -546,9 +553,17 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) {
FaultMapSection =
Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
+
+ EHFrameSection =
+ Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
}
void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) {
+ EHFrameSection = Ctx->getCOFFSection(
+ ".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getDataRel());
+
bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb;
CommDirectiveSupportsAlignment = true;
@@ -822,24 +837,3 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
0, utostr(Hash));
}
-
-void MCObjectFileInfo::InitEHFrameSection() {
- if (Env == IsMachO)
- EHFrameSection =
- Ctx->getMachOSection("__TEXT", "__eh_frame",
- MachO::S_COALESCED |
- MachO::S_ATTR_NO_TOC |
- MachO::S_ATTR_STRIP_STATIC_SYMS |
- MachO::S_ATTR_LIVE_SUPPORT,
- SectionKind::getReadOnly());
- else if (Env == IsELF)
- EHFrameSection =
- Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- else
- EHFrameSection =
- Ctx->getCOFFSection(".eh_frame",
- COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
- COFF::IMAGE_SCN_MEM_READ |
- COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
-}
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 92d2b9667c8..5a0bb7fe986 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -133,6 +133,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
OS << "note";
else if (Type == ELF::SHT_PROGBITS)
OS << "progbits";
+ else if (Type == ELF::SHT_X86_64_UNWIND)
+ OS << "unwind";
if (EntrySize) {
assert(Flags & ELF::SHF_MERGE);
diff --git a/llvm/test/CodeGen/X86/eh_frame.ll b/llvm/test/CodeGen/X86/eh_frame.ll
index 3b792b235cb..0472e773df5 100644
--- a/llvm/test/CodeGen/X86/eh_frame.ll
+++ b/llvm/test/CodeGen/X86/eh_frame.ll
@@ -7,8 +7,8 @@
@bar1 = constant i8* bitcast (i32* @foo to i8*), section "my_bar1", align 8
-; STATIC: .section .eh_frame,"a",@progbits
+; STATIC: .section .eh_frame,"a",@unwind
; STATIC: .section my_bar1,"a",@progbits
-; PIC: .section .eh_frame,"a",@progbits
+; PIC: .section .eh_frame,"a",@unwind
; PIC: .section my_bar1,"aw",@progbits
OpenPOWER on IntegriCloud