aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfException.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-11-18 23:18:46 +0000
committerBill Wendling <isanbard@gmail.com>2009-11-18 23:18:46 +0000
commitec0445855179d2c9fb98a2c8a42e03525762f45f (patch)
treeb935b1d1c5bae99ab13e8982dd4f10f839a09105 /lib/CodeGen/AsmPrinter/DwarfException.cpp
parent60f34b9fb0323688e93cf347d63b56327d6250f8 (diff)
Attempt #2:
Place the EH table in the __TEXT section on MachO. It saves space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89270 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfException.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index 1c8b8f4647..4f6e685a37 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -727,7 +727,8 @@ void DwarfException::EmitExceptionTable() {
// somewhere. This predicate should be moved to a shared location that is
// in target-independent code.
//
- if (LSDASection->getKind().isWriteable() ||
+ if ((LSDASection->getKind().isWriteable() &&
+ !LSDASection->getKind().isDataRel()) ||
Asm->TM.getRelocationModel() == Reloc::Static)
TTypeFormat = dwarf::DW_EH_PE_absptr;
else
@@ -917,14 +918,35 @@ void DwarfException::EmitExceptionTable() {
}
// Emit the Catch TypeInfos.
+ 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 (!LSDASection->getKind().isDataRel() &&
+ (TTypeFormat == dwarf::DW_EH_PE_absptr ||
+ TI->getLinkage() == GlobalValue::InternalLinkage)) {
+ // 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 (GV) {
- O << Asm->Mang->getMangledName(GV);
+ if (!IsTypeInfoPCRel)
+ TypeInfoRef = CreateLabelDiff(TypeInfoRef, "typeinforef_addr", Index);
+
+ O << MAI->getData32bitsDirective();
+ TypeInfoRef->print(O, MAI);
+ }
} else {
+ PrintRelDirective();
O << "0x0";
}