forked from OSchip/llvm-project
[RuntimeDyld] Make sure we emit MachO __eh_frame and __gcc_except_tab sections,
even if there are no references to them in the code. This allows exceptions thrown from JIT'd code to be caught by the JIT itself. llvm-svn: 234975
This commit is contained in:
parent
46f2cc9e44
commit
38aac6495a
|
@ -178,25 +178,30 @@ bool RuntimeDyldMachO::isCompatibleFile(const object::ObjectFile &Obj) const {
|
|||
}
|
||||
|
||||
template <typename Impl>
|
||||
void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &ObjImg,
|
||||
void RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &Obj,
|
||||
ObjSectionToIDMap &SectionMap) {
|
||||
unsigned EHFrameSID = RTDYLD_INVALID_SECTION_ID;
|
||||
unsigned TextSID = RTDYLD_INVALID_SECTION_ID;
|
||||
unsigned ExceptTabSID = RTDYLD_INVALID_SECTION_ID;
|
||||
ObjSectionToIDMap::iterator i, e;
|
||||
|
||||
for (i = SectionMap.begin(), e = SectionMap.end(); i != e; ++i) {
|
||||
const SectionRef &Section = i->first;
|
||||
for (const auto &Section : Obj.sections()) {
|
||||
StringRef Name;
|
||||
Section.getName(Name);
|
||||
if (Name == "__eh_frame")
|
||||
EHFrameSID = i->second;
|
||||
else if (Name == "__text")
|
||||
TextSID = i->second;
|
||||
|
||||
// Force emission of the __text, __eh_frame, and __gcc_except_tab sections
|
||||
// if they're present. Otherwise call down to the impl to handle other
|
||||
// sections that have already been emitted.
|
||||
if (Name == "__text")
|
||||
TextSID = findOrEmitSection(Obj, Section, true, SectionMap);
|
||||
else if (Name == "__eh_frame")
|
||||
EHFrameSID = findOrEmitSection(Obj, Section, false, SectionMap);
|
||||
else if (Name == "__gcc_except_tab")
|
||||
ExceptTabSID = i->second;
|
||||
else
|
||||
impl().finalizeSection(ObjImg, i->second, Section);
|
||||
ExceptTabSID = findOrEmitSection(Obj, Section, true, SectionMap);
|
||||
else {
|
||||
auto I = SectionMap.find(Section);
|
||||
if (I != SectionMap.end())
|
||||
impl().finalizeSection(Obj, I->second, Section);
|
||||
}
|
||||
}
|
||||
UnregisteredEHFrameSections.push_back(
|
||||
EHFrameRelatedSections(EHFrameSID, TextSID, ExceptTabSID));
|
||||
|
|
|
@ -31,6 +31,13 @@ insn3:
|
|||
movl $0, %eax
|
||||
retq
|
||||
|
||||
# Test processing of the __eh_frame section.
|
||||
# rtdyld-check: *{8}(section_addr(test_x86-64.o, __eh_frame) + 0x20) = eh_frame_test - (section_addr(test_x86-64.o, __eh_frame) + 0x20)
|
||||
eh_frame_test:
|
||||
.cfi_startproc
|
||||
retq
|
||||
.cfi_endproc
|
||||
|
||||
.comm y,4,2
|
||||
|
||||
.section __DATA,__data
|
||||
|
|
Loading…
Reference in New Issue