aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-09-18 21:14:36 +0000
committerBill Wendling <isanbard@gmail.com>2009-09-18 21:14:36 +0000
commit296ab7e5445f0402d0aae3814c38f964d6f547fb (patch)
treefd057fa26ae18da3a708fec29f684670c68601bc /lib
parentfb2e752e4175920d0531f2afc93a23d0cdf4db14 (diff)
downloadexternal_llvm-296ab7e5445f0402d0aae3814c38f964d6f547fb.zip
external_llvm-296ab7e5445f0402d0aae3814c38f964d6f547fb.tar.gz
external_llvm-296ab7e5445f0402d0aae3814c38f964d6f547fb.tar.bz2
It's inefficient to have place the exception tables (which contain the LSDA)
into the __DATA section. At launch time, dyld has to update most of the section to fix up the type info pointers. It's better to place it into the __TEXT section and use pc-rel indirect pointer encodings. Similar to the personality routine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp45
-rw-r--r--lib/Target/TargetLoweringObjectFile.cpp4
2 files changed, 42 insertions, 7 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index 626523b..f3897ff 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -893,14 +893,49 @@ void DwarfException::EmitExceptionTable() {
// of the catch clauses as they appear in the source code, and must be kept in
// the same order. As a result, changing the order of the catch clause would
// change the semantics of the program.
+ const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
+ unsigned Index = 1;
+
for (std::vector<GlobalVariable *>::const_reverse_iterator
- I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
- const GlobalVariable *GV = *I;
- PrintRelDirective();
+ I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I, ++Index) {
+ const GlobalVariable *TI = *I;
+
+ if (TI) {
+ if (TTypeFormat == dwarf::DW_EH_PE_absptr) {
+ // Print out the unadorned name of the type info.
+ PrintRelDirective();
+ O << Asm->Mang->getMangledName(TI);
+ } else {
+ bool IsTypeInfoIndirect = false, IsTypeInfoPCRel = false;
+ const MCExpr *TypeInfoRef =
+ TLOF.getSymbolForDwarfGlobalReference(TI, Asm->Mang, Asm->MMI,
+ IsTypeInfoIndirect,
+ IsTypeInfoPCRel);
+
+ if (!IsTypeInfoPCRel) {
+ // If the reference to the type info symbol is not already
+ // pc-relative, then we need to subtract our current address from it.
+ // Do this by emitting a label and subtracting it from the expression
+ // we already have. This is equivalent to emitting "foo - .", but we
+ // have to emit the label for "." directly.
+ SmallString<64> Name;
+ raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix()
+ << "typeinforef_addr" << Asm->getFunctionNumber() << "_" << Index;
+ MCSymbol *DotSym = Asm->OutContext.GetOrCreateSymbol(Name.str());
+ Asm->OutStreamer.EmitLabel(DotSym);
+
+ TypeInfoRef =
+ MCBinaryExpr::CreateSub(TypeInfoRef,
+ MCSymbolRefExpr::Create(DotSym,
+ Asm->OutContext),
+ Asm->OutContext);
+ }
- if (GV) {
- O << Asm->Mang->getMangledName(GV);
+ O << MAI->getData32bitsDirective();
+ TypeInfoRef->print(O, MAI);
+ }
} else {
+ PrintRelDirective();
O << "0x0";
}
diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp
index c1aab99..b49164a 100644
--- a/lib/Target/TargetLoweringObjectFile.cpp
+++ b/lib/Target/TargetLoweringObjectFile.cpp
@@ -782,8 +782,8 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
}
// Exception Handling.
- LSDASection = getMachOSection("__DATA", "__gcc_except_tab", 0,
- SectionKind::getDataRel());
+ LSDASection = getMachOSection("__TEXT", "__gcc_except_tab", 0,
+ SectionKind::getReadOnly());
EHFrameSection =
getMachOSection("__TEXT", "__eh_frame",
MCSectionMachO::S_COALESCED |