[llvm-commits] [llvm] r171979 - in /llvm/trunk: include/llvm/Support/ELF.h lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp lib/MC/MCObjectFileInfo.cpp lib/Target/PowerPC/PPCAsmPrinter.cpp test/MC/PowerPC/ppc64-initial-cfa.ll
Adhemerval Zanella
azanella at linux.vnet.ibm.com
Wed Jan 9 09:08:15 PST 2013
Author: azanella
Date: Wed Jan 9 11:08:15 2013
New Revision: 171979
URL: http://llvm.org/viewvc/llvm-project?rev=171979&view=rev
Log:
PowerPC: EH adjustments
This patch adjust the r171506 to make all DWARF enconding pc-relative
for PPC64. It also adds the R_PPC64_REL32 relocation handling in MCJIT
(since the eh_frame will not generate PIC-relative relocation) and also
adds the emission of stubs created by the TTypeEncoding.
Modified:
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/trunk/test/MC/PowerPC/ppc64-initial-cfa.ll
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=171979&r1=171978&r2=171979&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Wed Jan 9 11:08:15 2013
@@ -469,6 +469,7 @@
R_PPC64_ADDR16_HI = 5,
R_PPC64_ADDR14 = 7,
R_PPC64_REL24 = 10,
+ R_PPC64_REL32 = 26,
R_PPC64_ADDR64 = 38,
R_PPC64_ADDR16_HIGHER = 39,
R_PPC64_ADDR16_HIGHEST = 41,
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=171979&r1=171978&r2=171979&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Wed Jan 9 11:08:15 2013
@@ -523,7 +523,7 @@
case ELF::R_PPC64_ADDR32 : {
int32_t Result = static_cast<int32_t>(Value + Addend);
if (SignExtend32<32>(Result) != Result)
- llvm_unreachable("Relocation R_PPC64_REL32 overflow");
+ llvm_unreachable("Relocation R_PPC64_ADDR32 overflow");
writeInt32BE(LocalAddress, Result);
} break;
case ELF::R_PPC64_REL24 : {
@@ -534,6 +534,13 @@
// Generates a 'bl <address>' instruction
writeInt32BE(LocalAddress, 0x48000001 | (delta & 0x03FFFFFC));
} break;
+ case ELF::R_PPC64_REL32 : {
+ uint64_t FinalAddress = (Section.LoadAddress + Offset);
+ int32_t delta = static_cast<int32_t>(Value - FinalAddress + Addend);
+ if (SignExtend32<32>(delta) != delta)
+ llvm_unreachable("Relocation R_PPC64_REL32 overflow");
+ writeInt32BE(LocalAddress, delta);
+ } break;
case ELF::R_PPC64_ADDR64 :
writeInt64BE(LocalAddress, Value + Addend);
break;
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=171979&r1=171978&r2=171979&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Wed Jan 9 11:08:15 2013
@@ -257,16 +257,13 @@
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
}
} else if (T.getArch() == Triple::ppc64) {
- PersonalityEncoding = dwarf::DW_EH_PE_udata8;
- PersonalityEncoding |= (RelocM == Reloc::PIC_)
- ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
- : dwarf::DW_EH_PE_absptr;
- unsigned PICFlag = (RelocM == Reloc::PIC_) ? dwarf::DW_EH_PE_pcrel
- : dwarf::DW_EH_PE_absptr;
- FDECFIEncoding = PICFlag | dwarf::DW_EH_PE_sdata4;
- LSDAEncoding = PICFlag | dwarf::DW_EH_PE_udata8;
- FDEEncoding = PICFlag | dwarf::DW_EH_PE_sdata4;
- TTypeEncoding = PICFlag | dwarf::DW_EH_PE_sdata4;
+ PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_udata8;
+ FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
+ LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
+ FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
+ TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_udata8;
}
// Solaris requires different flags for .eh_frame to seemingly every other
Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=171979&r1=171978&r2=171979&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Wed Jan 9 11:08:15 2013
@@ -768,6 +768,25 @@
}
}
+ MachineModuleInfoELF &MMIELF =
+ MMI->getObjFileInfo<MachineModuleInfoELF>();
+
+ MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
+ if (!Stubs.empty()) {
+ OutStreamer.SwitchSection(getObjFileLowering().getDataSection());
+ for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+ // L_foo$stub:
+ OutStreamer.EmitLabel(Stubs[i].first);
+ // .long _foo
+ OutStreamer.EmitValue(MCSymbolRefExpr::Create(Stubs[i].second.getPointer(),
+ OutContext),
+ isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);
+ }
+
+ Stubs.clear();
+ OutStreamer.AddBlankLine();
+ }
+
return AsmPrinter::doFinalization(M);
}
Modified: llvm/trunk/test/MC/PowerPC/ppc64-initial-cfa.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc64-initial-cfa.ll?rev=171979&r1=171978&r2=171979&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-initial-cfa.ll (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-initial-cfa.ll Wed Jan 9 11:08:15 2013
@@ -20,7 +20,7 @@
; STATIC-NEXT: ('sh_info', 0x00000000)
; STATIC-NEXT: ('sh_addralign', 0x0000000000000008)
; STATIC-NEXT: ('sh_entsize', 0x0000000000000000)
-; STATIC-NEXT: ('_section_data', '00000010 00000000 017a5200 01784101 0b0c0100 00000010 00000018 00000000 00000010 00000000')
+; STATIC-NEXT: ('_section_data', '00000010 00000000 017a5200 01784101 1b0c0100 00000010 00000018 00000000 00000010 00000000')
; STATIC: ('sh_name', 0x{{.*}}) # '.rela.eh_frame'
; STATIC-NEXT: ('sh_type', 0x00000004)
@@ -34,11 +34,11 @@
; STATIC-NEXT: ('sh_entsize', 0x0000000000000018)
; STATIC-NEXT: ('_relocations', [
-; Static build should create R_PPC64_ADDR32 relocations
+; Static build should create R_PPC64_REL32 relocations
; STATIC-NEXT: # Relocation 0
; STATIC-NEXT: (('r_offset', 0x000000000000001c)
; STATIC-NEXT: ('r_sym', 0x{{.*}})
-; STATIC-NEXT: ('r_type', 0x00000001)
+; STATIC-NEXT: ('r_type', 0x0000001a)
; STATIC-NEXT: ('r_addend', 0x0000000000000000)
; STATIC-NEXT: ),
; STATIC-NEXT: ])
More information about the llvm-commits
mailing list