llvm.org GIT mirror llvm / abf9af6
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 Rafael Espindola 9 years ago
3 changed file(s) with 26 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
5757 return TLOF->getEHFrameSection();
5858 }
5959
60 const unsigned getFDEEncoding() const {
61 return TLOF->getFDEEncoding();
62 }
63
6064 unsigned getDwarfRARegNum(bool isEH) const {
6165 return TRI->getDwarfRegNum(TRI->getRARegister(), isEH);
6266 }
438438 return -size;
439439 }
440440
441 static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
442 unsigned symbolEncoding) {
441 static unsigned getSizeForEncoding(MCStreamer &streamer,
442 unsigned symbolEncoding) {
443443 MCContext &context = streamer.getContext();
444444 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
445445 unsigned format = symbolEncoding & 0x0f;
446 unsigned application = symbolEncoding & 0x70;
447 unsigned size;
448446 switch (format) {
449447 default:
450448 assert(0 && "Unknown Encoding");
451449 case dwarf::DW_EH_PE_absptr:
452450 case dwarf::DW_EH_PE_signed:
453 size = asmInfo.getPointerSize();
454 break;
451 return asmInfo.getPointerSize();
455452 case dwarf::DW_EH_PE_udata2:
456453 case dwarf::DW_EH_PE_sdata2:
457 size = 2;
458 break;
454 return 2;
459455 case dwarf::DW_EH_PE_udata4:
460456 case dwarf::DW_EH_PE_sdata4:
461 size = 4;
462 break;
457 return 4;
463458 case dwarf::DW_EH_PE_udata8:
464459 case dwarf::DW_EH_PE_sdata8:
465 size = 8;
466 break;
467 }
460 return 8;
461 }
462 }
463
464 static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
465 unsigned symbolEncoding) {
466 MCContext &context = streamer.getContext();
467 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
468 unsigned size = getSizeForEncoding(streamer, symbolEncoding);
469 unsigned application = symbolEncoding & 0x70;
468470 switch (application) {
469471 default:
470472 assert(0 && "Unknown Encoding");
677679 streamer.EmitIntValue(lsdaEncoding, 1);
678680 }
679681 // Encoding of the FDE pointers
680 streamer.EmitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
682 streamer.EmitIntValue(asmInfo.getFDEEncoding(), 1);
681683 streamer.EmitLabel(augmentationEnd);
682684
683685 // Initial Instructions
710712 MCContext &context = streamer.getContext();
711713 MCSymbol *fdeStart = context.CreateTempSymbol();
712714 MCSymbol *fdeEnd = context.CreateTempSymbol();
715 const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
713716
714717 // Length
715718 const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
720723 const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
721724 0);
722725 streamer.EmitValue(offset, 4);
726 unsigned fdeEncoding = asmInfo.getFDEEncoding();
727 unsigned size = getSizeForEncoding(streamer, fdeEncoding);
723728
724729 // PC Begin
725 streamer.EmitPCRelSymbolValue(frame.Begin, 4);
730 streamer.EmitPCRelSymbolValue(frame.Begin, size);
726731
727732 // PC Range
728733 const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
729734 *frame.End, 0);
730 streamer.EmitValue(Range, 4);
735 streamer.EmitValue(Range, size);
731736
732737 // Augmentation Data Length
733738 MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol();
9191 }
9292
9393 unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const {
94 CodeModel::Model Model = TM.getCodeModel();
95 if (TM.getRelocationModel() == Reloc::PIC_)
96 return DW_EH_PE_pcrel | (Model == CodeModel::Small ||
97 Model == CodeModel::Medium ?
98 DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
99
100 if (Model == CodeModel::Small || Model == CodeModel::Medium)
101 return DW_EH_PE_udata4;
102
103 return DW_EH_PE_absptr;
94 return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
10495 }
10596
10697 unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const {