mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Rename getPersonalityPICSymbol to getCFIPersonalitySymbol, document it, and
give it a bit more responsibility. Also implement it for MachO. If hacked to use cfi, 32 bit MachO will produce .cfi_personality 155, L___gxx_personality_v0$non_lazy_ptr and 64 bit will produce .cfi_presonality ___gxx_personality_v0 The general idea is that .cfi_personality gets passed the final symbol. It is up to codegen to produce it if using indirect representation (like 32 bit MachO), but it is up to MC to decide which relocations to create. llvm-svn: 130341
This commit is contained in:
parent
652ca6a95a
commit
0525497a16
@ -58,7 +58,6 @@ public:
|
||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||
|
||||
virtual const MCSection *getEHFrameSection() const;
|
||||
virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
|
||||
|
||||
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
||||
const TargetMachine &TM,
|
||||
@ -86,6 +85,11 @@ public:
|
||||
getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
|
||||
Mangler *Mang, MachineModuleInfo *MMI) const;
|
||||
};
|
||||
|
||||
|
||||
@ -177,6 +181,11 @@ public:
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
|
||||
Mangler *Mang, MachineModuleInfo *MMI) const;
|
||||
|
||||
virtual unsigned getPersonalityEncoding() const;
|
||||
virtual unsigned getLSDAEncoding() const;
|
||||
virtual unsigned getFDEEncoding() const;
|
||||
|
@ -140,7 +140,6 @@ public:
|
||||
const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
|
||||
const MCSection *getLSDASection() const { return LSDASection; }
|
||||
virtual const MCSection *getEHFrameSection() const = 0;
|
||||
virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
|
||||
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
||||
const TargetMachine &TM,
|
||||
const MCSymbol *Sym) const;
|
||||
@ -222,6 +221,11 @@ public:
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
|
||||
Mangler *Mang, MachineModuleInfo *MMI) const;
|
||||
|
||||
///
|
||||
const MCExpr *
|
||||
getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
|
||||
|
@ -109,17 +109,8 @@ void DwarfCFIException::BeginFunction(const MachineFunction *MF) {
|
||||
if (PerEncoding == dwarf::DW_EH_PE_omit || !Per)
|
||||
return;
|
||||
|
||||
const MCSymbol *Sym;
|
||||
switch (PerEncoding & 0x70) {
|
||||
default:
|
||||
report_fatal_error("We do not support this DWARF encoding yet!");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
Sym = Asm->Mang->getSymbol(Per);
|
||||
break;
|
||||
case dwarf::DW_EH_PE_pcrel:
|
||||
Sym = TLOF.getPersonalityPICSymbol(Per->getName());
|
||||
break;
|
||||
}
|
||||
const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, PerEncoding,
|
||||
Asm->Mang, MMI);
|
||||
Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
|
||||
}
|
||||
|
||||
|
@ -178,15 +178,29 @@ const MCSection *TargetLoweringObjectFileELF::getEHFrameSection() const {
|
||||
}
|
||||
|
||||
MCSymbol *
|
||||
TargetLoweringObjectFileELF::getPersonalityPICSymbol(StringRef Name) const {
|
||||
Twine FullName = StringRef("DW.ref.") + Name;
|
||||
return getContext().GetOrCreateSymbol(FullName);
|
||||
TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV,
|
||||
unsigned Encoding,
|
||||
Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
switch (Encoding & 0x70) {
|
||||
default:
|
||||
report_fatal_error("We do not support this DWARF encoding yet!");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
return Mang->getSymbol(GV);
|
||||
break;
|
||||
case dwarf::DW_EH_PE_pcrel: {
|
||||
Twine FullName = StringRef("DW.ref.") + Mang->getSymbol(GV)->getName();
|
||||
return getContext().GetOrCreateSymbol(FullName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
|
||||
const TargetMachine &TM,
|
||||
const MCSymbol *Sym) const {
|
||||
MCSymbol *Label = getPersonalityPICSymbol(Sym->getName());
|
||||
const MCSymbol *Sym) const {
|
||||
Twine FullName = StringRef("DW.ref.") + Sym->getName();
|
||||
MCSymbol *Label = getContext().GetOrCreateSymbol(FullName);
|
||||
Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
|
||||
Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
|
||||
Twine SectionName = StringRef(".data.") + Label->getName();
|
||||
@ -834,6 +848,29 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, Streamer);
|
||||
}
|
||||
|
||||
MCSymbol *TargetLoweringObjectFileMachO::
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
// The mach-o version of this method defaults to returning a stub reference.
|
||||
MachineModuleInfoMachO &MachOMMI =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
||||
|
||||
SmallString<128> Name;
|
||||
Mang->getNameWithPrefix(Name, GV, true);
|
||||
Name += "$non_lazy_ptr";
|
||||
|
||||
// Add information about the stub reference to MachOMMI so that the stub
|
||||
// gets emitted by the asmprinter.
|
||||
MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str());
|
||||
MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
|
||||
if (StubSym.getPointer() == 0) {
|
||||
MCSymbol *Sym = Mang->getSymbol(GV);
|
||||
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
||||
}
|
||||
|
||||
return SSym;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const {
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
}
|
||||
|
@ -120,16 +120,15 @@ static bool IsNullTerminatedString(const Constant *C) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MCSymbol *
|
||||
TargetLoweringObjectFile::getPersonalityPICSymbol(StringRef Name) const {
|
||||
assert(0 && "Not Available in this format.");
|
||||
return 0;
|
||||
MCSymbol *TargetLoweringObjectFile::
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return Mang->getSymbol(GV);
|
||||
}
|
||||
|
||||
void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
|
||||
const TargetMachine &TM,
|
||||
const MCSymbol *Sym) const {
|
||||
assert(0 && "Not Available in this format.");
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,6 +38,12 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, Streamer);
|
||||
}
|
||||
|
||||
MCSymbol *X8664_MachoTargetObjectFile::
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return Mang->getSymbol(GV);
|
||||
}
|
||||
|
||||
unsigned X8632_ELFTargetObjectFile::getPersonalityEncoding() const {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
|
@ -25,6 +25,12 @@ namespace llvm {
|
||||
getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
// getCFIPersonalitySymbol - The symbol that gets passed to
|
||||
// .cfi_personality.
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding,
|
||||
Mangler *Mang, MachineModuleInfo *MMI) const;
|
||||
};
|
||||
|
||||
class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
||||
|
Loading…
Reference in New Issue
Block a user