8000 Fix relocations · python/cpython@32b2708 · GitHub
[go: up one dir, main page]

Skip to content

Commit 32b2708

Browse files
committed
Fix relocations
1 parent 7b33e21 commit 32b2708

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Tools/jit/build.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,14 @@ async def parse(self):
295295
if padding:
296296
disassembly.append(f"{offset:x}: {' '.join(padding * ['00'])}")
297297
offset += padding
298-
for symbol, offset in self.got.items():
298+
for symbol, got_offset in self.got.items():
299299
if symbol in self.body_symbols:
300300
addend = self.body_symbols[symbol]
301301
symbol = "_JIT_BASE"
302+
else:
303+
addend = 0
302304
# XXX: ABS_32 on 32-bit platforms?
303-
holes.append(Hole("R_X86_64_64", symbol, offset, 0))
305+
holes.append(Hole("R_X86_64_64", symbol, got + got_offset, addend))
304306
disassembly.append(f"{offset:x}: &{symbol}")
305307
offset += 8
306308
self.body.extend([0] * 8 * len(self.got))
@@ -403,7 +405,7 @@ def _handle_relocation(self, base: int, relocation: RelocationType) -> Hole | No
403405
"Addend": addend,
404406
}:
405407
offset += base
406-
value = len(self.body)
408+
value = len(self.body) - offset
407409
self.write_u32(offset, value + addend)
408410
return None
409411
case {
@@ -413,7 +415,7 @@ def _handle_relocation(self, base: int, relocation: RelocationType) -> Hole | No
413415
"Addend": addend,
414416
}:
415417
offset += base
416-
value = len(self.body) + self._got_lookup(symbol) - offset
418+
value = self._got_lookup(symbol) - offset
417419
self.write_u32(offset, value + addend)
418420
return None
419421
case {

0 commit comments

Comments
 (0)
0