Lines Matching refs:loc
159 const uint8_t *loc) const override;
167 void relocate(uint8_t *loc, const Relocation &rel,
177 const uint8_t *loc) const override;
178 void relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) const;
181 bool adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end,
185 void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel, uint64_t val) const;
186 void relaxTlsGdToLe(uint8_t *loc, const Relocation &rel, uint64_t val) const;
187 void relaxTlsLdToLe(uint8_t *loc, const Relocation &rel, uint64_t val) const;
188 void relaxTlsIeToLe(uint8_t *loc, const Relocation &rel, uint64_t val) const;
231 void elf::writePrefixedInstruction(uint8_t *loc, uint64_t insn) { in writePrefixedInstruction() argument
233 write64(loc, insn); in writePrefixedInstruction()
552 static void writeFromHalf16(uint8_t *loc, uint32_t insn) { in writeFromHalf16() argument
553 write32(config->isLE ? loc : loc - 2, insn); in writeFromHalf16()
556 static uint32_t readFromHalf16(const uint8_t *loc) { in readFromHalf16() argument
557 return read32(config->isLE ? loc : loc - 2); in readFromHalf16()
560 static uint64_t readPrefixedInstruction(const uint8_t *loc) { in readPrefixedInstruction() argument
561 uint64_t fullInstr = read64(loc); in readPrefixedInstruction()
640 void PPC64::relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) const { in relaxGot() argument
644 relocate(loc, rel, val); in relaxGot()
649 uint32_t insn = readFromHalf16(loc); in relaxGot()
652 writeFromHalf16(loc, (insn & 0x03ffffff) | 0x38000000); in relaxGot()
653 relocateNoSym(loc, R_PPC64_TOC16_LO, val); in relaxGot()
659 uint64_t insn = readPrefixedInstruction(loc); in relaxGot()
666 writePrefixedInstruction(loc, insn); in relaxGot()
667 relocate(loc, rel, val); in relaxGot()
674 uint64_t insn = readPrefixedInstruction(loc); in relaxGot()
675 uint32_t accessInsn = read32(loc + rel.addend); in relaxGot()
693 writePrefixedInstruction(loc, pcRelInsn | in relaxGot()
696 write32(loc + rel.addend, NOP); // nop accessInsn. in relaxGot()
704 void PPC64::relaxTlsGdToLe(uint8_t *loc, const Relocation &rel, in relaxTlsGdToLe() argument
723 writeFromHalf16(loc, NOP); in relaxTlsGdToLe()
727 writeFromHalf16(loc, 0x3c6d0000); // addis r3, r13 in relaxTlsGdToLe()
728 relocateNoSym(loc, R_PPC64_TPREL16_HA, val); in relaxTlsGdToLe()
733 writePrefixedInstruction(loc, 0x06000000386d0000); in relaxTlsGdToLe()
734 relocateNoSym(loc, R_PPC64_TPREL34, val); in relaxTlsGdToLe()
746 const uintptr_t locAsInt = reinterpret_cast<uintptr_t>(loc); in relaxTlsGdToLe()
748 write32(loc, NOP); // nop in relaxTlsGdToLe()
749 write32(loc + 4, 0x38630000); // addi r3, r3 in relaxTlsGdToLe()
753 relocateNoSym(loc + 4 + (config->ekind == ELF64BEKind ? 2 : 0), in relaxTlsGdToLe()
756 write32(loc - 1, NOP); in relaxTlsGdToLe()
767 void PPC64::relaxTlsLdToLe(uint8_t *loc, const Relocation &rel, in relaxTlsLdToLe() argument
786 writeFromHalf16(loc, NOP); in relaxTlsLdToLe()
789 writeFromHalf16(loc, 0x3c6d0000); // addis r3, r13, 0 in relaxTlsLdToLe()
794 writePrefixedInstruction(loc, 0x06000000386d1000); in relaxTlsLdToLe()
807 const uintptr_t locAsInt = reinterpret_cast<uintptr_t>(loc); in relaxTlsLdToLe()
809 write32(loc, NOP); in relaxTlsLdToLe()
810 write32(loc + 4, 0x38631000); // addi r3, r3, 4096 in relaxTlsLdToLe()
812 write32(loc - 1, NOP); in relaxTlsLdToLe()
825 relocate(loc, rel, val); in relaxTlsLdToLe()
857 void PPC64::relaxTlsIeToLe(uint8_t *loc, const Relocation &rel, in relaxTlsIeToLe() argument
881 write32(loc - offset, NOP); in relaxTlsIeToLe()
885 uint32_t regNo = read32(loc - offset) & 0x03E00000; // bits 6-10 in relaxTlsIeToLe()
886 write32(loc - offset, 0x3C0D0000 | regNo); // addis RegNo, r13 in relaxTlsIeToLe()
887 relocateNoSym(loc, R_PPC64_TPREL16_HA, val); in relaxTlsIeToLe()
891 const uint64_t pldRT = readPrefixedInstruction(loc) & 0x0000000003e00000; in relaxTlsIeToLe()
893 writePrefixedInstruction(loc, 0x06000000380d0000 | pldRT); in relaxTlsIeToLe()
894 relocateNoSym(loc, R_PPC64_TPREL34, val); in relaxTlsIeToLe()
898 const uintptr_t locAsInt = reinterpret_cast<uintptr_t>(loc); in relaxTlsIeToLe()
900 uint32_t primaryOp = getPrimaryOpCode(read32(loc)); in relaxTlsIeToLe()
903 uint32_t secondaryOp = (read32(loc) & 0x000007FE) >> 1; // bits 21-30 in relaxTlsIeToLe()
907 write32(loc, ((dFormOp << 26) | (read32(loc) & 0x03FFFFFF))); in relaxTlsIeToLe()
908 relocateNoSym(loc + offset, R_PPC64_TPREL16_LO, val); in relaxTlsIeToLe()
913 uint32_t tlsInstr = read32(loc - 1); in relaxTlsIeToLe()
926 write32(loc - 1, NOP); in relaxTlsIeToLe()
929 write32(loc - 1, 0x7C000378 | (rt << 16) | (ra << 21) | (ra << 11)); in relaxTlsIeToLe()
935 write32(loc - 1, ((dFormOp << 26) | (tlsInstr & 0x03FF0000))); in relaxTlsIeToLe()
950 const uint8_t *loc) const { in getRelExpr()
1057 error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + in getRelExpr()
1228 void PPC64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { in relocate() argument
1237 checkAlignment(loc, val, 4, rel); in relocate()
1239 uint8_t aalk = loc[3]; in relocate()
1240 write16(loc + 2, (aalk & 3) | (val & 0xfffc)); in relocate()
1244 checkIntUInt(loc, val, 16, rel); in relocate()
1245 write16(loc, val); in relocate()
1248 checkIntUInt(loc, val, 32, rel); in relocate()
1249 write32(loc, val); in relocate()
1253 checkInt(loc, val, 16, rel); in relocate()
1256 uint16_t mask = isDQFormInstruction(readFromHalf16(loc)) ? 0xf : 0x3; in relocate()
1257 checkAlignment(loc, lo(val), mask + 1, rel); in relocate()
1258 write16(loc, (read16(loc) & mask) | lo(val)); in relocate()
1264 writeFromHalf16(loc, NOP); in relocate()
1266 checkInt(loc, val + 0x8000, 32, rel); in relocate()
1267 write16(loc, ha(val)); in relocate()
1273 checkInt(loc, val, 32, rel); in relocate()
1274 write16(loc, hi(val)); in relocate()
1277 write16(loc, hi(val)); in relocate()
1281 write16(loc, higher(val)); in relocate()
1285 write16(loc, highera(val)); in relocate()
1289 write16(loc, highest(val)); in relocate()
1293 write16(loc, highesta(val)); in relocate()
1302 uint32_t insn = readFromHalf16(loc); in relocate()
1304 error(getErrorLocation(loc) + in relocate()
1307 writeFromHalf16(loc, (insn & 0xffe00000) | 0x00020000 | lo(val)); in relocate()
1309 write16(loc, lo(val)); in relocate()
1316 uint32_t insn = readFromHalf16(loc); in relocate()
1318 checkAlignment(loc, lo(val), mask + 1, rel); in relocate()
1324 error(getErrorLocation(loc) + in relocate()
1328 writeFromHalf16(loc, insn | 0x00020000 | lo(val)); in relocate()
1330 write16(loc, (read16(loc) & mask) | lo(val)); in relocate()
1334 checkInt(loc, val, 16, rel); in relocate()
1335 write16(loc, val); in relocate()
1338 checkInt(loc, val, 32, rel); in relocate()
1339 write32(loc, val); in relocate()
1344 write64(loc, val); in relocate()
1348 checkInt(loc, val, 16, rel); in relocate()
1349 checkAlignment(loc, val, 4, rel); in relocate()
1350 write32(loc, (read32(loc) & ~mask) | (val & mask)); in relocate()
1356 checkInt(loc, val, 26, rel); in relocate()
1357 checkAlignment(loc, val, 4, rel); in relocate()
1358 write32(loc, (read32(loc) & ~mask) | (val & mask)); in relocate()
1362 write64(loc, val - dynamicThreadPointerOffset); in relocate()
1379 checkInt(loc, val, 34, rel); in relocate()
1381 uint64_t instr = readPrefixedInstruction(loc) & ~fullMask; in relocate()
1382 writePrefixedInstruction(loc, instr | ((val & si0Mask) << 16) | in relocate()
1453 const uint8_t *loc) const { in adjustGotPcExpr()
1458 if ((readPrefixedInstruction(loc) & 0xfc000000) == 0xe4000000) in adjustGotPcExpr()
1481 void PPC64::relaxTlsGdToIe(uint8_t *loc, const Relocation &rel, in relaxTlsGdToIe() argument
1487 relocateNoSym(loc, R_PPC64_GOT_TPREL16_HA, val); in relaxTlsGdToIe()
1493 uint32_t ra = (readFromHalf16(loc) & (0x1f << 16)); in relaxTlsGdToIe()
1494 writeFromHalf16(loc, 0xe8600000 | ra); in relaxTlsGdToIe()
1495 relocateNoSym(loc, R_PPC64_GOT_TPREL16_LO_DS, val); in relaxTlsGdToIe()
1501 writePrefixedInstruction(loc, 0x04100000e4600000); in relaxTlsGdToIe()
1502 relocateNoSym(loc, R_PPC64_GOT_TPREL_PCREL34, val); in relaxTlsGdToIe()
1515 const uintptr_t locAsInt = reinterpret_cast<uintptr_t>(loc); in relaxTlsGdToIe()
1517 write32(loc, NOP); // bl __tls_get_addr(sym@tlsgd) --> nop in relaxTlsGdToIe()
1518 write32(loc + 4, 0x7c636A14); // nop --> add r3, r3, r13 in relaxTlsGdToIe()
1521 write32(loc - 1, 0x7c636a14); in relaxTlsGdToIe()
1538 uint8_t *loc = buf + rel.offset; in relocateAlloc() local
1554 relaxGot(loc, rel, val); in relocateAlloc()
1564 !tryRelaxPPC64TocIndirection(rel, loc)) in relocateAlloc()
1565 relocate(loc, rel, val); in relocateAlloc()
1571 if (read32(loc) == 0x60000000) // nop in relocateAlloc()
1581 read32(loc + 4) != 0x60000000) && in relocateAlloc()
1584 errorOrWarn(getErrorLocation(loc) + "call to " + in relocateAlloc()
1589 write32(loc + 4, 0xe8410018); // ld %r2, 24(%r1) in relocateAlloc()
1591 relocate(loc, rel, val); in relocateAlloc()
1595 relaxTlsGdToIe(loc, rel, val); in relocateAlloc()
1598 relaxTlsGdToLe(loc, rel, val); in relocateAlloc()
1601 relaxTlsLdToLe(loc, rel, val); in relocateAlloc()
1604 relaxTlsIeToLe(loc, rel, val); in relocateAlloc()
1607 relocate(loc, rel, val); in relocateAlloc()
1641 bool PPC64::adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end, in adjustPrologueForCrossSplitStack() argument
1645 loc += getPPC64GlobalEntryToLocalEntryOffset(stOther); in adjustPrologueForCrossSplitStack()
1651 if (loc + 12 >= end) in adjustPrologueForCrossSplitStack()
1655 if (read32(loc) != 0xe80d8fc0) in adjustPrologueForCrossSplitStack()
1662 int32_t firstInstr = read32(loc + 4); in adjustPrologueForCrossSplitStack()
1673 uint32_t secondInstr = read32(loc + 8); in adjustPrologueForCrossSplitStack()
1697 error(getErrorLocation(loc) + "split-stack prologue adjustment overflows"); in adjustPrologueForCrossSplitStack()
1707 write32(loc + 4, 0x3D810000 | (uint16_t)hiImm); in adjustPrologueForCrossSplitStack()
1710 write32(loc + 8, secondInstr); in adjustPrologueForCrossSplitStack()
1713 write32(loc + 4, (0x39810000) | (uint16_t)loImm); in adjustPrologueForCrossSplitStack()
1714 write32(loc + 8, NOP); in adjustPrologueForCrossSplitStack()