Lines Matching defs:pReloc

28 static Relocator::DWord getThumbBit(const Relocation& pReloc)
33 ((!pReloc.symInfo()->isUndef() || pReloc.symInfo()->isDyn()) &&
34 (pReloc.symInfo()->type() == ResolveInfo::Function) &&
35 ((pReloc.symValue() & 0x1) != 0))?
91 ARMGOTEntry& helper_GOT_init(Relocation& pReloc,
96 ResolveInfo* rsym = pReloc.symInfo();
143 ARMPLT1& helper_PLT_init(Relocation& pReloc, ARMRelocator& pParent)
146 ResolveInfo* rsym = pReloc.symInfo();
168 // its FragmentRef to pReloc->targetFrag() and its ResolveInfo to
169 // pReloc->symInfo()
171 void helper_DynRel_init(Relocation& pReloc,
176 ResolveInfo* rsym = pReloc.symInfo();
181 rel_entry.targetRef() = pReloc.targetRef();
322 typedef Relocator::Result (*ApplyFunctionType)(Relocation& pReloc,
437 void ARMRelocator::checkValidReloc(Relocation& pReloc) const
443 switch(pReloc.type()) {
457 error(diag::non_pic_relocation) << (int)pReloc.type()
458 << pReloc.symInfo()->name();
463 bool ARMRelocator::mayHaveFunctionPointerAccess(const Relocation& pReloc) const
465 switch (pReloc.type()) {
487 ARMRelocator::scanLocalReloc(Relocation& pReloc, const LDSection& pSection)
490 ResolveInfo* rsym = pReloc.symInfo();
492 switch(pReloc.type()){
499 pReloc.setType(llvm::ELF::R_ARM_ABS32);
506 helper_DynRel_init(pReloc, llvm::ELF::R_ARM_RELATIVE, *this);
525 error(diag::non_pic_relocation) << (int)pReloc.type()
526 << pReloc.symInfo()->name();
540 pReloc.setType(llvm::ELF::R_ARM_GOT_PREL);
551 helper_GOT_init(pReloc, true, *this);
553 helper_GOT_init(pReloc, false, *this);
563 fatal(diag::base_relocation) << (int)pReloc.type() << rsym->name()
573 fatal(diag::dynamic_relocation) << (int)pReloc.type();
582 void ARMRelocator::scanGlobalReloc(Relocation& pReloc,
587 ResolveInfo* rsym = pReloc.symInfo();
589 switch(pReloc.type()) {
596 pReloc.setType(llvm::ELF::R_ARM_ABS32);
616 helper_PLT_init(pReloc, *this);
624 if (getTarget().symbolNeedsCopyReloc(pReloc, *rsym)) {
629 checkValidReloc(pReloc);
632 helper_DynRel_init(pReloc, llvm::ELF::R_ARM_RELATIVE, *this);
634 helper_DynRel_init(pReloc, pReloc.type(), *this);
655 fatal(diag::base_relocation) << (int)pReloc.type() << rsym->name()
703 if (getTarget().symbolNeedsCopyReloc(pReloc, *rsym)) {
708 checkValidReloc(pReloc);
710 //helper_DynRel_init(pReloc, pReloc.type(), *this);
751 helper_PLT_init(pReloc, *this);
761 pReloc.setType(llvm::ELF::R_ARM_GOT_PREL);
772 helper_GOT_init(pReloc, true, *this);
774 helper_GOT_init(pReloc, false, *this);
786 fatal(diag::dynamic_relocation) << (int)pReloc.type();
795 void ARMRelocator::scanRelocation(Relocation& pReloc,
802 ResolveInfo* rsym = pReloc.symInfo();
816 scanLocalReloc(pReloc, pSection);
820 scanGlobalReloc(pReloc, pBuilder, pSection);
825 issueUndefRef(pReloc, pSection, pInput);
833 ARMRelocator::Result none(Relocation& pReloc, ARMRelocator& pParent)
839 ARMRelocator::Result abs32(Relocation& pReloc, ARMRelocator& pParent)
841 ResolveInfo* rsym = pReloc.symInfo();
842 Relocator::DWord T = getThumbBit(pReloc);
843 Relocator::DWord A = pReloc.target() + pReloc.addend();
844 Relocator::DWord S = pReloc.symValue();
851 pReloc.targetRef().frag()->getParent()->getSection().flag())) {
852 pReloc.target() = (S + A) | T;
871 pReloc.target() = (S + A) | T;
876 ARMRelocator::Result rel32(Relocation& pReloc, ARMRelocator& pParent)
879 Relocator::Address S = pReloc.symValue();
880 Relocator::DWord T = getThumbBit(pReloc);
881 Relocator::DWord A = pReloc.target() + pReloc.addend();
884 if (!pReloc.symInfo()->isLocal()) {
885 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT) {
886 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
895 pReloc.target() = ((S + A) | T) - pReloc.place();
901 ARMRelocator::Result base_prel(Relocation& pReloc, ARMRelocator& pParent)
904 Relocator::DWord A = pReloc.target() + pReloc.addend();
905 pReloc.target() = pReloc.symValue() + A - pReloc.place();
910 ARMRelocator::Result gotoff32(Relocation& pReloc, ARMRelocator& pParent)
912 Relocator::DWord T = getThumbBit(pReloc);
913 Relocator::DWord A = pReloc.target() + pReloc.addend();
915 Relocator::Address S = pReloc.symValue();
919 pReloc.target() = ((S + A) | T) - GOT_ORG;
924 ARMRelocator::Result got_brel(Relocation& pReloc, ARMRelocator& pParent)
926 if (!(pReloc.symInfo()->reserved() & ARMRelocator::ReserveGOT))
929 Relocator::Address GOT_S = helper_get_GOT_address(*pReloc.symInfo(), pParent);
930 Relocator::DWord A = pReloc.target() + pReloc.addend();
933 pReloc.target() = GOT_S + A - GOT_ORG;
936 ARMGOTEntry* got_entry = pParent.getSymGOTMap().lookUp(*pReloc.symInfo());
938 got_entry->setValue(pReloc.symValue());
943 ARMRelocator::Result got_prel(Relocation& pReloc, ARMRelocator& pParent)
945 if (!(pReloc.symInfo()->reserved() & ARMRelocator::ReserveGOT)) {
948 Relocator::Address GOT_S = helper_get_GOT_address(*pReloc.symInfo(), pParent);
949 Relocator::DWord A = pReloc.target() + pReloc.addend();
950 Relocator::Address P = pReloc.place();
953 pReloc.target() = GOT_S + A - P;
956 ARMGOTEntry* got_entry = pParent.getSymGOTMap().lookUp(*pReloc.symInfo());
958 got_entry->setValue(pReloc.symValue());
963 ARMRelocator::Result thm_jump8(Relocation& pReloc, ARMRelocator& pParent)
965 Relocator::DWord P = pReloc.place();
966 Relocator::DWord A = helper_sign_extend((pReloc.target() & 0x00ff) << 1, 8) +
967 pReloc.addend();
969 Relocator::Address S = pReloc.symValue();
970 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT)
971 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
977 pReloc.target() = (pReloc.target() & 0xFFFFFF00u) | ((X & 0x01FEu) >> 1);
982 ARMRelocator::Result thm_jump11(Relocation& pReloc, ARMRelocator& pParent)
984 Relocator::DWord P = pReloc.place();
985 Relocator::DWord A = helper_sign_extend((pReloc.target() & 0x07ff) << 1, 11) +
986 pReloc.addend();
988 Relocator::Address S = pReloc.symValue();
989 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT)
990 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
996 pReloc.target() = (pReloc.target() & 0xFFFFF800u) | ((X & 0x0FFEu) >> 1);
1001 ARMRelocator::Result thm_jump19(Relocation& pReloc, ARMRelocator& pParent)
1004 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1005 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1007 Relocator::DWord T = getThumbBit(pReloc);
1010 Relocator::Address P = pReloc.place();
1013 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT) {
1014 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
1018 S = pReloc.symValue();
1025 error(diag::unsupport_cond_branch_reloc) << (int)pReloc.type();
1036 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = upper_inst;
1037 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = lower_inst;
1046 ARMRelocator::Result call(Relocation& pReloc, ARMRelocator& pParent)
1051 if (pReloc.symInfo()->isWeak() &&
1052 pReloc.symInfo()->isUndef() &&
1053 !pReloc.symInfo()->isDyn() &&
1054 !(pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT)) {
1056 pReloc.target() = (pReloc.target() & 0xf0000000U) | 0x01a00000;
1060 Relocator::DWord T = getThumbBit(pReloc);
1062 helper_sign_extend((pReloc.target() & 0x00FFFFFFu) << 2, 26) +
1063 pReloc.addend();
1064 Relocator::Address P = pReloc.place();
1065 Relocator::Address S = pReloc.symValue();
1070 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT) {
1071 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
1081 if (pReloc.type() == llvm::ELF::R_ARM_JUMP24)
1083 if (pReloc.type() == llvm::ELF::R_ARM_PC24)
1086 pReloc.target() = (pReloc.target() & 0xffffff) |
1096 pReloc.target() = (pReloc.target() & 0xFF000000u) | ((X & 0x03FFFFFEu) >> 2);
1102 ARMRelocator::Result thm_call(Relocation& pReloc, ARMRelocator& pParent)
1107 if (pReloc.symInfo()->isWeak() &&
1108 pReloc.symInfo()->isUndef() &&
1109 !pReloc.symInfo()->isDyn() &&
1110 !(pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT)) {
1111 pReloc.target() = (0xe000U << 16) | 0xbf00U;
1116 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1117 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1119 Relocator::DWord T = getThumbBit(pReloc);
1121 Relocator::Address P = pReloc.place();
1125 if (pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT) {
1126 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
1130 S = pReloc.symValue();
1143 if (pReloc.type() == llvm::ELF::R_ARM_THM_JUMP24)
1167 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = upper_inst;
1168 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = lower_inst;
1174 ARMRelocator::Result movw_abs_nc(Relocation& pReloc, ARMRelocator& pParent)
1176 ResolveInfo* rsym = pReloc.symInfo();
1177 Relocator::Address S = pReloc.symValue();
1178 Relocator::DWord T = getThumbBit(pReloc);
1180 helper_extract_movw_movt_addend(pReloc.target()) + pReloc.addend();
1184 LDSection& target_sect = pReloc.targetRef().frag()->getParent()->getSection();
1198 pReloc.target() = helper_insert_val_movw_movt_inst(
1199 pReloc.target() + pReloc.addend(), X);
1204 ARMRelocator::Result movw_prel_nc(Relocation& pReloc, ARMRelocator& pParent)
1206 Relocator::Address S = pReloc.symValue();
1207 Relocator::DWord T = getThumbBit(pReloc);
1208 Relocator::DWord P = pReloc.place();
1210 helper_extract_movw_movt_addend(pReloc.target()) + pReloc.addend();
1218 pReloc.target() = helper_insert_val_movw_movt_inst(pReloc.target(), X);
1224 ARMRelocator::Result movt_abs(Relocation& pReloc, ARMRelocator& pParent)
1226 ResolveInfo* rsym = pReloc.symInfo();
1227 Relocator::Address S = pReloc.symValue();
1229 helper_extract_movw_movt_addend(pReloc.target()) + pReloc.addend();
1231 LDSection& target_sect = pReloc.targetRef().frag()->getParent()->getSection();
1245 pReloc.target() = helper_insert_val_movw_movt_inst(pReloc.target(), X);
1250 ARMRelocator::Result movt_prel(Relocation& pReloc, ARMRelocator& pParent)
1252 Relocator::Address S = pReloc.symValue();
1253 Relocator::DWord P = pReloc.place();
1255 helper_extract_movw_movt_addend(pReloc.target()) + pReloc.addend();
1259 pReloc.target() = helper_insert_val_movw_movt_inst(pReloc.target(), X);
1264 ARMRelocator::Result thm_movw_abs_nc(Relocation& pReloc, ARMRelocator& pParent)
1266 ResolveInfo* rsym = pReloc.symInfo();
1267 Relocator::Address S = pReloc.symValue();
1268 Relocator::DWord T = getThumbBit(pReloc);
1273 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1274 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1277 helper_extract_thumb_movw_movt_addend(val) + pReloc.addend();
1279 LDSection& target_sect = pReloc.targetRef().frag()->getParent()->getSection();
1292 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = val >> 16;
1293 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = val & 0xFFFFu;
1299 ARMRelocator::Result thm_movw_prel_nc(Relocation& pReloc, ARMRelocator& pParent)
1301 Relocator::Address S = pReloc.symValue();
1302 Relocator::DWord T = getThumbBit(pReloc);
1303 Relocator::DWord P = pReloc.place();
1308 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1309 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1312 helper_extract_thumb_movw_movt_addend(val) + pReloc.addend();
1316 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = val >> 16;
1317 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = val & 0xFFFFu;
1324 ARMRelocator::Result thm_movw_brel(Relocation& pReloc, ARMRelocator& pParent)
1326 Relocator::Address S = pReloc.symValue();
1327 Relocator::DWord T = getThumbBit(pReloc);
1328 Relocator::DWord P = pReloc.place();
1333 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1334 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1337 helper_extract_thumb_movw_movt_addend(val) + pReloc.addend();
1342 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = val >> 16;
1343 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = val & 0xFFFFu;
1349 ARMRelocator::Result thm_movt_abs(Relocation& pReloc, ARMRelocator& pParent)
1351 ResolveInfo* rsym = pReloc.symInfo();
1352 Relocator::Address S = pReloc.symValue();
1355 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1356 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1359 helper_extract_thumb_movw_movt_addend(val) + pReloc.addend();
1361 LDSection& target_sect = pReloc.targetRef().frag()->getParent()->getSection();
1378 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = val >> 16;
1379 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = val & 0xFFFFu;
1386 ARMRelocator::Result thm_movt_prel(Relocation& pReloc, ARMRelocator& pParent)
1388 Relocator::Address S = pReloc.symValue();
1389 Relocator::DWord P = pReloc.place();
1392 uint16_t upper_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()));
1393 uint16_t lower_inst = *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1);
1396 helper_extract_thumb_movw_movt_addend(val) + pReloc.addend();
1401 *(reinterpret_cast<uint16_t*>(&pReloc.target())) = val >> 16;
1402 *(reinterpret_cast<uint16_t*>(&pReloc.target()) + 1) = val & 0xFFFFu;
1408 ARMRelocator::Result prel31(Relocation& pReloc, ARMRelocator& pParent)
1410 Relocator::DWord target = pReloc.target();
1411 Relocator::DWord T = getThumbBit(pReloc);
1412 Relocator::DWord A = helper_sign_extend(target, 31) + pReloc.addend();
1413 Relocator::DWord P = pReloc.place();
1414 Relocator::Address S = pReloc.symValue();
1419 if ( pReloc.symInfo()->reserved() & ARMRelocator::ReservePLT) {
1420 S = helper_get_PLT_address(*pReloc.symInfo(), pParent);
1425 pReloc.target() = helper_bit_select(target, X, 0x7fffffffU);
1434 ARMRelocator::Result tls(Relocation& pReloc, ARMRelocator& pParent)
1439 ARMRelocator::Result unsupport(Relocation& pReloc, ARMRelocator& pParent)