Skip to content

Commit ba32120

Browse files
committed
GH-115802: Remove no-plt for Linux targets
1 parent 0b20bff commit ba32120

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Python/jit.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,25 @@ patch_32(unsigned char *location, uint64_t value)
316316
memcpy(location, &final_value, sizeof(final_value));
317317
}
318318

319-
// 32-bit relative address.
319+
// 32-bit absolute address, sign-extended by the instruction.
320320
void
321-
patch_32r(unsigned char *location, uint64_t value)
321+
patch_32s(unsigned char *location, uint64_t value)
322322
{
323-
value -= (uintptr_t)location;
324323
// Check that we're not out of range of 32 signed bits:
325324
assert((int64_t)value >= -(1LL << 31));
326325
assert((int64_t)value < (1LL << 31));
327-
uint32_t final_value = (uint32_t)value;
326+
int32_t final_value = (int32_t)value;
328327
memcpy(location, &final_value, sizeof(final_value));
329328
}
330329

330+
// 32-bit relative address.
331+
void
332+
patch_32r(unsigned char *location, uint64_t value)
333+
{
334+
value -= (uintptr_t)location;
335+
patch_32s(location, value);
336+
}
337+
331338
// 64-bit absolute address.
332339
void
333340
patch_64(unsigned char *location, uint64_t value)

Tools/jit/_stencils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class HoleValue(enum.Enum):
9090
"R_AARCH64_MOVW_UABS_G2_NC": "patch_aarch64_16c",
9191
"R_AARCH64_MOVW_UABS_G3": "patch_aarch64_16d",
9292
# x86_64-unknown-linux-gnu:
93+
"R_X86_64_32S": "patch_32s",
9394
"R_X86_64_64": "patch_64",
9495
"R_X86_64_GOTPCRELX": "patch_x86_64_32rx",
9596
"R_X86_64_PLT32": "patch_32r",

Tools/jit/_targets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
594594
host = "aarch64-unknown-linux-gnu"
595595
condition = "defined(__aarch64__) && defined(__linux__)"
596596
# -mno-outline-atomics: Keep intrinsics from being emitted.
597-
args = ["-fpic", "-mno-outline-atomics", "-fno-plt"]
597+
args = ["-fpic", "-mno-outline-atomics"]
598598
optimizer = _optimizers.OptimizerAArch64
599599
target = _ELF(
600600
host, condition, args=args, optimizer=optimizer, frame_pointers=True
@@ -622,7 +622,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
622622
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
623623
host = "x86_64-unknown-linux-gnu"
624624
condition = "defined(__x86_64__) && defined(__linux__)"
625-
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0", "-fno-plt"]
625+
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
626626
optimizer = _optimizers.OptimizerX86
627627
target = _ELF(
628628
host, condition, args=args, optimizer=optimizer, frame_pointers=True

0 commit comments

Comments
 (0)