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