From 508217604edc5f098783b2b9513ffdec321d9b07 Mon Sep 17 00:00:00 2001 From: zaniebot <242828183+zaniebot@users.noreply.github.com> Date: Wed, 21 Oct 2026 18:19:30 +0000 Subject: [PATCH 1/2] Keep the perf trampoline end marker inside its text section --- .../Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst | 2 ++ Python/asm_trampoline_aarch64.S | 1 + Python/asm_trampoline_riscv64.S | 1 + Python/asm_trampoline_x86_64.S | 1 + 4 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst diff --git a/Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst b/Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst new file mode 100644 index 00000000000000..f5b066d31ec71c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst @@ -0,0 +1,2 @@ +Add a byte after the ELF perf trampoline end marker so it does not share +the following function's address, which BOLT may otherwise move. diff --git a/Python/asm_trampoline_aarch64.S b/Python/asm_trampoline_aarch64.S index b3aeb728de200c..aef34014ae8552 100644 --- a/Python/asm_trampoline_aarch64.S +++ b/Python/asm_trampoline_aarch64.S @@ -57,6 +57,7 @@ __Py_trampoline_func_end: #else .globl _Py_trampoline_func_end _Py_trampoline_func_end: + .byte 0 .section .note.GNU-stack,"",@progbits #endif diff --git a/Python/asm_trampoline_riscv64.S b/Python/asm_trampoline_riscv64.S index 6125ba95373f95..21aafbcf23d6f0 100644 --- a/Python/asm_trampoline_riscv64.S +++ b/Python/asm_trampoline_riscv64.S @@ -9,4 +9,5 @@ _Py_trampoline_func_start: jr ra .globl _Py_trampoline_func_end _Py_trampoline_func_end: + .byte 0 .section .note.GNU-stack,"",@progbits diff --git a/Python/asm_trampoline_x86_64.S b/Python/asm_trampoline_x86_64.S index 0e6b11589eafc8..e1a714413abfd4 100644 --- a/Python/asm_trampoline_x86_64.S +++ b/Python/asm_trampoline_x86_64.S @@ -21,6 +21,7 @@ __Py_trampoline_func_end: #else .globl _Py_trampoline_func_end _Py_trampoline_func_end: + .byte 0 .section .note.GNU-stack,"",@progbits #endif # Note for indicating the assembly code supports CET From 36ee3ab4f34ea5590df87a74ac0db30416b2d575 Mon Sep 17 00:00:00 2001 From: zaniebot <242828183+zaniebot@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:07:11 +0000 Subject: [PATCH 2/2] Link `NEWS` entry to the upstream issue --- ...st => 2026-10-21-18-00-00.gh-issue-128883.perf-trampoline.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/Build/{2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst => 2026-10-21-18-00-00.gh-issue-128883.perf-trampoline.rst} (100%) diff --git a/Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst b/Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-128883.perf-trampoline.rst similarity index 100% rename from Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-0.perf-trampoline.rst rename to Misc/NEWS.d/next/Build/2026-10-21-18-00-00.gh-issue-128883.perf-trampoline.rst