Skip to content

Commit 85dd309

Browse files
author
David Chisnall
committed
Revert r150814. It turns out that there is a good reason for this after all...
llvm-svn: 150818
1 parent 23b0541 commit 85dd309

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

llvm/include/llvm/MC/MCObjectFileInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ class MCObjectFileInfo {
284284
const MCSection *getXDataSection() const { return XDataSection; }
285285

286286
const MCSection *getEHFrameSection() {
287+
if (!EHFrameSection)
288+
InitEHFrameSection();
287289
return EHFrameSection;
288290
}
289291

@@ -298,6 +300,9 @@ class MCObjectFileInfo {
298300
void InitELFMCObjectFileInfo(Triple T);
299301
void InitCOFFMCObjectFileInfo(Triple T);
300302

303+
/// InitEHFrameSection - Initialize EHFrameSection on demand.
304+
///
305+
void InitEHFrameSection();
301306
};
302307

303308
} // end namespace llvm

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
142142
}
143143

144144
// Exception Handling.
145-
EHFrameSection =
146-
Ctx->getMachOSection("__TEXT", "__eh_frame",
147-
MCSectionMachO::S_COALESCED |
148-
MCSectionMachO::S_ATTR_NO_TOC |
149-
MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS |
150-
MCSectionMachO::S_ATTR_LIVE_SUPPORT,
151-
SectionKind::getReadOnly());
152-
153145
LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
154146
SectionKind::getReadOnlyWithRel());
155147

@@ -347,17 +339,6 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
347339

348340
// Exception Handling Sections.
349341

350-
// Solaris requires different flags for .eh_frame to seemingly every other
351-
// platform.
352-
unsigned EHSectionFlags = ELF::SHF_ALLOC;
353-
if (T.getOS() == Triple::Solaris)
354-
EHSectionFlags |= ELF::SHF_WRITE;
355-
356-
EHFrameSection =
357-
Ctx->getELFSection(".eh_frame", ELF::SHT_PROGBITS,
358-
EHSectionFlags,
359-
SectionKind::getDataRel());
360-
361342
// FIXME: We're emitting LSDA info into a readonly section on ELF, even though
362343
// it contains relocatable pointers. In PIC mode, this is probably a big
363344
// runtime hit for C++ apps. Either the contents of the LSDA need to be
@@ -434,13 +415,6 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
434415
COFF::IMAGE_SCN_MEM_WRITE,
435416
SectionKind::getDataRel());
436417

437-
EHFrameSection =
438-
Ctx->getCOFFSection(".eh_frame",
439-
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
440-
COFF::IMAGE_SCN_MEM_READ |
441-
COFF::IMAGE_SCN_MEM_WRITE,
442-
SectionKind::getDataRel());
443-
444418
// FIXME: We're emitting LSDA info into a readonly section on COFF, even
445419
// though it contains relocatable pointers. In PIC mode, this is probably a
446420
// big runtime hit for C++ apps. Either the contents of the LSDA need to be
@@ -573,3 +547,25 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
573547
}
574548
}
575549

550+
void MCObjectFileInfo::InitEHFrameSection() {
551+
if (Env == IsMachO)
552+
EHFrameSection =
553+
Ctx->getMachOSection("__TEXT", "__eh_frame",
554+
MCSectionMachO::S_COALESCED |
555+
MCSectionMachO::S_ATTR_NO_TOC |
556+
MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS |
557+
MCSectionMachO::S_ATTR_LIVE_SUPPORT,
558+
SectionKind::getReadOnly());
559+
else if (Env == IsELF)
560+
EHFrameSection =
561+
Ctx->getELFSection(".eh_frame", ELF::SHT_PROGBITS,
562+
ELF::SHF_ALLOC,
563+
SectionKind::getDataRel());
564+
else
565+
EHFrameSection =
566+
Ctx->getCOFFSection(".eh_frame",
567+
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
568+
COFF::IMAGE_SCN_MEM_READ |
569+
COFF::IMAGE_SCN_MEM_WRITE,
570+
SectionKind::getDataRel());
571+
}

0 commit comments

Comments
 (0)