mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 20:59:51 +00:00
Compute the size of the FDE encoding instead of hard coding it. Update
X8664_ELFTargetObjectFile::getFDEEncoding to match reality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129959 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e8cfbd843d
commit
abf9af60ad
@ -58,6 +58,10 @@ public:
|
||||
return TLOF->getEHFrameSection();
|
||||
}
|
||||
|
||||
const unsigned getFDEEncoding() const {
|
||||
return TLOF->getFDEEncoding();
|
||||
}
|
||||
|
||||
unsigned getDwarfRARegNum(bool isEH) const {
|
||||
return TRI->getDwarfRegNum(TRI->getRARegister(), isEH);
|
||||
}
|
||||
|
@ -439,33 +439,35 @@ static int getDataAlignmentFactor(MCStreamer &streamer) {
|
||||
return -size;
|
||||
}
|
||||
|
||||
static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
|
||||
unsigned symbolEncoding) {
|
||||
static unsigned getSizeForEncoding(MCStreamer &streamer,
|
||||
unsigned symbolEncoding) {
|
||||
MCContext &context = streamer.getContext();
|
||||
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
||||
unsigned format = symbolEncoding & 0x0f;
|
||||
unsigned application = symbolEncoding & 0x70;
|
||||
unsigned size;
|
||||
switch (format) {
|
||||
default:
|
||||
assert(0 && "Unknown Encoding");
|
||||
case dwarf::DW_EH_PE_absptr:
|
||||
case dwarf::DW_EH_PE_signed:
|
||||
size = asmInfo.getPointerSize();
|
||||
break;
|
||||
return asmInfo.getPointerSize();
|
||||
case dwarf::DW_EH_PE_udata2:
|
||||
case dwarf::DW_EH_PE_sdata2:
|
||||
size = 2;
|
||||
break;
|
||||
return 2;
|
||||
case dwarf::DW_EH_PE_udata4:
|
||||
case dwarf::DW_EH_PE_sdata4:
|
||||
size = 4;
|
||||
break;
|
||||
return 4;
|
||||
case dwarf::DW_EH_PE_udata8:
|
||||
case dwarf::DW_EH_PE_sdata8:
|
||||
size = 8;
|
||||
break;
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
|
||||
unsigned symbolEncoding) {
|
||||
MCContext &context = streamer.getContext();
|
||||
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
||||
unsigned size = getSizeForEncoding(streamer, symbolEncoding);
|
||||
unsigned application = symbolEncoding & 0x70;
|
||||
switch (application) {
|
||||
default:
|
||||
assert(0 && "Unknown Encoding");
|
||||
@ -678,7 +680,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
|
||||
streamer.EmitIntValue(lsdaEncoding, 1);
|
||||
}
|
||||
// Encoding of the FDE pointers
|
||||
streamer.EmitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
|
||||
streamer.EmitIntValue(asmInfo.getFDEEncoding(), 1);
|
||||
streamer.EmitLabel(augmentationEnd);
|
||||
|
||||
// Initial Instructions
|
||||
@ -711,6 +713,7 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
|
||||
MCContext &context = streamer.getContext();
|
||||
MCSymbol *fdeStart = context.CreateTempSymbol();
|
||||
MCSymbol *fdeEnd = context.CreateTempSymbol();
|
||||
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
||||
|
||||
// Length
|
||||
const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
|
||||
@ -721,14 +724,16 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
|
||||
const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
|
||||
0);
|
||||
streamer.EmitValue(offset, 4);
|
||||
unsigned fdeEncoding = asmInfo.getFDEEncoding();
|
||||
unsigned size = getSizeForEncoding(streamer, fdeEncoding);
|
||||
|
||||
// PC Begin
|
||||
streamer.EmitPCRelSymbolValue(frame.Begin, 4);
|
||||
streamer.EmitPCRelSymbolValue(frame.Begin, size);
|
||||
|
||||
// PC Range
|
||||
const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
|
||||
*frame.End, 0);
|
||||
streamer.EmitValue(Range, 4);
|
||||
streamer.EmitValue(Range, size);
|
||||
|
||||
// Augmentation Data Length
|
||||
MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol();
|
||||
|
@ -92,16 +92,7 @@ unsigned X8664_ELFTargetObjectFile::getLSDAEncoding() const {
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const {
|
||||
CodeModel::Model Model = TM.getCodeModel();
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_pcrel | (Model == CodeModel::Small ||
|
||||
Model == CodeModel::Medium ?
|
||||
DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
|
||||
|
||||
if (Model == CodeModel::Small || Model == CodeModel::Medium)
|
||||
return DW_EH_PE_udata4;
|
||||
|
||||
return DW_EH_PE_absptr;
|
||||
return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const {
|
||||
|
Loading…
Reference in New Issue
Block a user