8000 Ditto for Intel Macs · python/cpython@68a87a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 68a87a1

Browse files
committed
Ditto for Intel Macs
1 parent 57a8019 commit 68a87a1

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Tools/jit/build.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,25 @@ def _handle_relocation(
687687
"Offset": int(offset),
688688
"PCRel": 1,
689689
"Symbol": {"Value": str(symbol)},
690-
"Type": {"Value": "X86_64_RELOC_GOT_LOAD"},
690+
"Type": {"Value": "X86_64_RELOC_BRANCH" | "X86_64_RELOC_SIGNED"},
691+
}:
692+
offset += base
693+
8000 where = slice(offset, offset + 4)
694+
what = int.from_bytes(self.body[where], sys.byteorder)
695+
addend = what
696+
self.body[where] = [0] * 4
697+
symbol = symbol.removeprefix(self.SYMBOL_PREFIX)
698+
return Hole(HoleKind.REL_32, symbol, offset, addend - 4)
699+
case {
700+
"Length": 2,
701+
"Offset": int(offset),
702+
"PCRel": 1,
703+
"Symbol": {"Value": str(symbol)},
704+
"Type": {"Value": "X86_64_RELOC_GOT" | "X86_64_RELOC_GOT_LOAD"},
691705
}:
692706
offset += base
693707
where = slice(offset, offset + 4)
694708
what = int.from_bytes(self.body[where], "little", signed=False)
695-
assert not what, what
696709
addend = what
697710
self.body[where] = [0] * 4
698711
symbol = remove_prefix(symbol, self.SYMBOL_PREFIX)
@@ -707,20 +720,19 @@ def _handle_relocation(
707720
self.body[where] = addend.to_bytes(4, sys.byteorder)
708721
return None
709722
case {
710-
"Length": 3,
723+
"Length": 2,
711724
"Offset": int(offset),
712-
"PCRel": 0,
725+
"PCRel": 1,
713726
"Section": {"Value": str(section)},
714-
"Type": {"Value": "X86_64_RELOC_UNSIGNED"},
727+
"Type": {"Value": "X86_64_RELOC_SIGNED"},
715728
}:
716729
offset += base
717-
where = slice(offset, offset + 8)
730+
where = slice(offset, offset + 4)
718731
what = int.from_bytes(self.body[where], sys.byteorder)
719-
# assert not what, what
720732
addend = what
721-
self.body[where] = [0] * 8
722-
section = remove_prefix(section, self.SYMBOL_PREFIX)
723-
return Hole(HoleKind.ABS_64, section, offset, addend)
733+
self.body[where] = [0] * 4
734+
section = section.removeprefix(self.SYMBOL_PREFIX)
735+
return Hole(HoleKind.REL_32, section, offset, addend - 4)
724736
case {
725737
"Length": 3,
726738
"Offset": int(offset),
@@ -731,7 +743,6 @@ def _handle_relocation(
731743
offset += base
732744
where = slice(offset, offset + 8)
733745
what = int.from_bytes(self.body[where], sys.byteorder)
734-
# assert not what, what
735746
addend = what
736747
self.body[where] = [0] * 8
737748
symbol = remove_prefix(symbol, self.SYMBOL_PREFIX)
@@ -1219,7 +1230,7 @@ def main(host: str) -> None:
12191230
(aarch64_apple_darwin, False, [f"-I{ROOT}"]),
12201231
(aarch64_unknown_linux_gnu, False, [f"-I{ROOT}", "-fno-pic", "-mcmodel=large"]),
12211232
(i686_pc_windows_msvc, True, [f"-I{PC}", "-fno-pic", "-mcmodel=large"]),
1222-
(x86_64_apple_darwin, True, [f"-I{ROOT}", "-fno-pic", "-mcmodel=large"]),
1233+
(x86_64_apple_darwin, True, [f"-I{ROOT}"]),
12231234
(x86_64_pc_windows_msvc, True, [f"-I{PC}", "-fno-pic", "-mcmodel=large"]),
12241235
(x86_64_unknown_linux_gnu, True, [f"-I{ROOT}"]),
12251236
]:

0 commit comments

Comments
 (0)
0