1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Add a beta-test for placing the LSDA into the TEXT section on X86.

llvm-svn: 98370
This commit is contained in:
Bill Wendling 2010-03-12 19:20:40 +00:00
parent 04d151f5a6
commit 21a9744045
2 changed files with 57 additions and 2 deletions

View File

@ -523,10 +523,18 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
// L_foo$non_lazy_ptr:
OutStreamer.EmitLabel(Stubs[i].first);
// .indirect_symbol _foo
OutStreamer.EmitSymbolAttribute(Stubs[i].second.getPointer(),
MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
OutStreamer.EmitSymbolAttribute(MCSym.getPointer(),
MCSA_IndirectSymbol);
// .long 0
OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
if (MCSym.getInt())
// External to current translation unit.
OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
else
// Internal to current translation unit.
OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
OutContext),
4/*size*/, 0/*addrspace*/);
}
Stubs.clear();
OutStreamer.AddBlankLine();

View File

@ -37,6 +37,7 @@
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallSet.h"
@ -45,10 +46,12 @@
#include "llvm/ADT/VectorExtras.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace dwarf;
STATISTIC(NumTailCalls, "Number of tail calls");
@ -67,10 +70,54 @@ Disable16Bit("disable-16bit", cl::Hidden,
static SDValue getMOVL(SelectionDAG &DAG, DebugLoc dl, EVT VT, SDValue V1,
SDValue V2);
// FIXME: This is for a test.
static cl::opt<bool>
EnableX86EHTest("enable-x86-eh-test", cl::Hidden);
namespace llvm {
class X86_test_MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
public:
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM) {
TargetLoweringObjectFileMachO::Initialize(Ctx, TM);
// Exception Handling.
LSDASection = getMachOSection("__TEXT", "__gcc_except_tab", 0,
SectionKind::getReadOnlyWithRel());
}
virtual unsigned getTTypeEncoding() const {
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
}
};
class X8664_test_MachoTargetObjectFile : public X8664_MachoTargetObjectFile {
public:
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM) {
TargetLoweringObjectFileMachO::Initialize(Ctx, TM);
// Exception Handling.
LSDASection = getMachOSection("__TEXT", "__gcc_except_tab", 0,
SectionKind::getReadOnlyWithRel());
}
virtual unsigned getTTypeEncoding() const {
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
}
};
}
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
default: llvm_unreachable("unknown subtarget type");
case X86Subtarget::isDarwin:
// FIXME: This is for an EH test.
if (EnableX86EHTest) {
if (TM.getSubtarget<X86Subtarget>().is64Bit())
return new X8664_test_MachoTargetObjectFile();
else
return new X86_test_MachoTargetObjectFile();
}
if (TM.getSubtarget<X86Subtarget>().is64Bit())
return new X8664_MachoTargetObjectFile();
return new TargetLoweringObjectFileMachO();