Lines Matching refs:loc
32 const uint8_t *loc) const override;
40 void relocate(uint8_t *loc, const Relocation &rel,
43 void applyJumpInstrMod(uint8_t *loc, JumpModType type,
46 const uint8_t *loc) const override;
48 bool adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end,
353 const uint8_t *loc) const { in getRelExpr()
403 error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + in getRelExpr()
462 static void relaxTlsGdToLe(uint8_t *loc, const Relocation &rel, uint64_t val) { in relaxTlsGdToLe() argument
476 memcpy(loc - 4, inst, sizeof(inst)); in relaxTlsGdToLe()
480 write32le(loc + 8, val + 4); in relaxTlsGdToLe()
483 if ((loc[-3] & 0xfb) != 0x48 || loc[-2] != 0x8d || in relaxTlsGdToLe()
484 (loc[-1] & 0xc7) != 0x05) { in relaxTlsGdToLe()
485 errorOrWarn(getErrorLocation(loc - 3) + in relaxTlsGdToLe()
490 loc[-3] = 0x48 | ((loc[-3] >> 2) & 1); in relaxTlsGdToLe()
491 loc[-2] = 0xc7; in relaxTlsGdToLe()
492 loc[-1] = 0xc0 | ((loc[-1] >> 3) & 7); in relaxTlsGdToLe()
493 write32le(loc, val + 4); in relaxTlsGdToLe()
497 loc[0] = 0x66; in relaxTlsGdToLe()
498 loc[1] = 0x90; in relaxTlsGdToLe()
502 static void relaxTlsGdToIe(uint8_t *loc, const Relocation &rel, uint64_t val) { in relaxTlsGdToIe() argument
516 memcpy(loc - 4, inst, sizeof(inst)); in relaxTlsGdToIe()
520 write32le(loc + 8, val - 8); in relaxTlsGdToIe()
524 if ((loc[-3] & 0xfb) != 0x48 || loc[-2] != 0x8d || in relaxTlsGdToIe()
525 (loc[-1] & 0xc7) != 0x05) { in relaxTlsGdToIe()
526 errorOrWarn(getErrorLocation(loc - 3) + in relaxTlsGdToIe()
531 loc[-2] = 0x8b; in relaxTlsGdToIe()
532 write32le(loc, val); in relaxTlsGdToIe()
536 loc[0] = 0x66; in relaxTlsGdToIe()
537 loc[1] = 0x90; in relaxTlsGdToIe()
543 static void relaxTlsIeToLe(uint8_t *loc, const Relocation &, uint64_t val) { in relaxTlsIeToLe() argument
544 uint8_t *inst = loc - 3; in relaxTlsIeToLe()
545 uint8_t reg = loc[-1] >> 3; in relaxTlsIeToLe()
546 uint8_t *regSlot = loc - 1; in relaxTlsIeToLe()
575 error(getErrorLocation(loc - 3) + in relaxTlsIeToLe()
581 write32le(loc, val + 4); in relaxTlsIeToLe()
584 static void relaxTlsLdToLe(uint8_t *loc, const Relocation &rel, uint64_t val) { in relaxTlsLdToLe() argument
591 if (loc[4] == 0xe8) { in relaxTlsLdToLe()
601 memcpy(loc - 3, inst, sizeof(inst)); in relaxTlsLdToLe()
605 if (loc[4] == 0xff && loc[5] == 0x15) { in relaxTlsLdToLe()
614 loc[-3] = 0x66; in relaxTlsLdToLe()
615 memcpy(loc - 2, inst, sizeof(inst)); in relaxTlsLdToLe()
619 error(getErrorLocation(loc - 3) + in relaxTlsLdToLe()
627 void X86_64::applyJumpInstrMod(uint8_t *loc, JumpModType type, in applyJumpInstrMod() argument
632 *loc = 0xe9; in applyJumpInstrMod()
634 *loc = 0xeb; in applyJumpInstrMod()
638 loc[-1] = 0x0f; in applyJumpInstrMod()
639 *loc = 0x84; in applyJumpInstrMod()
641 *loc = 0x74; in applyJumpInstrMod()
645 loc[-1] = 0x0f; in applyJumpInstrMod()
646 *loc = 0x85; in applyJumpInstrMod()
648 *loc = 0x75; in applyJumpInstrMod()
652 loc[-1] = 0x0f; in applyJumpInstrMod()
653 *loc = 0x8f; in applyJumpInstrMod()
655 *loc = 0x7f; in applyJumpInstrMod()
659 loc[-1] = 0x0f; in applyJumpInstrMod()
660 *loc = 0x8d; in applyJumpInstrMod()
662 *loc = 0x7d; in applyJumpInstrMod()
666 loc[-1] = 0x0f; in applyJumpInstrMod()
667 *loc = 0x82; in applyJumpInstrMod()
669 *loc = 0x72; in applyJumpInstrMod()
673 loc[-1] = 0x0f; in applyJumpInstrMod()
674 *loc = 0x86; in applyJumpInstrMod()
676 *loc = 0x76; in applyJumpInstrMod()
680 loc[-1] = 0x0f; in applyJumpInstrMod()
681 *loc = 0x8c; in applyJumpInstrMod()
683 *loc = 0x7c; in applyJumpInstrMod()
687 loc[-1] = 0x0f; in applyJumpInstrMod()
688 *loc = 0x8e; in applyJumpInstrMod()
690 *loc = 0x7e; in applyJumpInstrMod()
694 loc[-1] = 0x0f; in applyJumpInstrMod()
695 *loc = 0x87; in applyJumpInstrMod()
697 *loc = 0x77; in applyJumpInstrMod()
701 loc[-1] = 0x0f; in applyJumpInstrMod()
702 *loc = 0x83; in applyJumpInstrMod()
704 *loc = 0x73; in applyJumpInstrMod()
763 static void relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val);
765 void X86_64::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { in relocate() argument
768 checkIntUInt(loc, val, 8, rel); in relocate()
769 *loc = val; in relocate()
772 checkInt(loc, val, 8, rel); in relocate()
773 *loc = val; in relocate()
776 checkIntUInt(loc, val, 16, rel); in relocate()
777 write16le(loc, val); in relocate()
780 checkInt(loc, val, 16, rel); in relocate()
781 write16le(loc, val); in relocate()
784 checkUInt(loc, val, 32, rel); in relocate()
785 write32le(loc, val); in relocate()
795 checkInt(loc, val, 32, rel); in relocate()
796 write32le(loc, val); in relocate()
807 write64le(loc, val); in relocate()
812 relaxGot(loc, rel, val); in relocate()
814 checkInt(loc, val, 32, rel); in relocate()
815 write32le(loc, val); in relocate()
822 relaxTlsGdToLe(loc, rel, val); in relocate()
824 relaxTlsGdToIe(loc, rel, val); in relocate()
826 checkInt(loc, val, 32, rel); in relocate()
827 write32le(loc, val); in relocate()
832 relaxTlsLdToLe(loc, rel, val); in relocate()
834 checkInt(loc, val, 32, rel); in relocate()
835 write32le(loc, val); in relocate()
840 relaxTlsIeToLe(loc, rel, val); in relocate()
842 checkInt(loc, val, 32, rel); in relocate()
843 write32le(loc, val); in relocate()
847 checkInt(loc, val, 32, rel); in relocate()
848 write32le(loc, val); in relocate()
853 write64le(loc + 8, val); in relocate()
861 const uint8_t *loc) const { in adjustGotPcExpr()
869 const uint8_t op = loc[-2]; in adjustGotPcExpr()
870 const uint8_t modRm = loc[-1]; in adjustGotPcExpr()
897 static void relaxGotNoPic(uint8_t *loc, uint64_t val, uint8_t op, in relaxGotNoPic() argument
899 const uint8_t rex = loc[-3]; in relaxGotNoPic()
918 loc[-1] = 0xc0 | (modRm & 0x38) >> 3; // ModR/M byte. in relaxGotNoPic()
922 loc[-2] = 0xf7; in relaxGotNoPic()
935 loc[-3] = (rex & ~0x4) | (rex & 0x4) >> 2; in relaxGotNoPic()
936 write32le(loc, val); in relaxGotNoPic()
946 loc[-1] = 0xc0 | (modRm & 0x38) >> 3 | (op & 0x3c); // ModR/M byte. in relaxGotNoPic()
955 loc[-2] = 0x81; in relaxGotNoPic()
956 loc[-3] = (rex & ~0x4) | (rex & 0x4) >> 2; in relaxGotNoPic()
957 write32le(loc, val); in relaxGotNoPic()
960 static void relaxGot(uint8_t *loc, const Relocation &rel, uint64_t val) { in relaxGot() argument
963 const uint8_t op = loc[-2]; in relaxGot()
964 const uint8_t modRm = loc[-1]; in relaxGot()
968 loc[-2] = 0x8d; in relaxGot()
969 write32le(loc, val); in relaxGot()
977 relaxGotNoPic(loc, val + 4, op, modRm); in relaxGot()
986 loc[-2] = 0x67; // addr32 prefix in relaxGot()
987 loc[-1] = 0xe8; // call in relaxGot()
988 write32le(loc, val); in relaxGot()
995 loc[-2] = 0xe9; // jmp in relaxGot()
996 loc[3] = 0x90; // nop in relaxGot()
997 write32le(loc - 1, val + 1); in relaxGot()
1004 bool X86_64::adjustPrologueForCrossSplitStack(uint8_t *loc, uint8_t *end, in adjustPrologueForCrossSplitStack() argument
1011 if (loc + 8 >= end) in adjustPrologueForCrossSplitStack()
1016 if (memcmp(loc, "\x64\x48\x3b\x24\x25", 5) == 0) { in adjustPrologueForCrossSplitStack()
1017 memcpy(loc, "\xf9\x0f\x1f\x84\x00\x00\x00\x00", 8); in adjustPrologueForCrossSplitStack()
1025 if (memcmp(loc, "\x4c\x8d\x94\x24", 4) == 0 || in adjustPrologueForCrossSplitStack()
1026 memcmp(loc, "\x4c\x8d\x9c\x24", 4) == 0) { in adjustPrologueForCrossSplitStack()
1029 write32le(loc + 4, read32le(loc + 4) - 0x4000); in adjustPrologueForCrossSplitStack()
1044 uint8_t *loc = buf + rel.offset; in relocateAlloc() local
1048 relocate(loc, rel, val); in relocateAlloc()