Files
TheRock/compiler/amd-llvm/bolt/test/runtime/AArch64/bti-long-jmp-plt.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

68 lines
2.0 KiB
C

// This test checks that LongJmp can add BTI instructions to PLT entries when
// targeting them using stubs.
//
// The test uses a non-default layout, where the .plt section is placed before
// the text section. This is needed so the new code placed under the .data
// section is far enough from the PLt to trigger shortJmp stubs.
//
// In practice, the PLT section can also be placed after the original text
// section. In this scenario, the text section has to be large enough to trigger
// shortJmp stubs.
// REQUIRES: system-linux
// RUN: split-file %s %t
// RUN: %clang --target=aarch64-unknown-linux-gnu -mbranch-protection=standard \
// RUN: -no-pie %t/bti-plt.c -o %t.exe -Wl,-q -fuse-ld=lld \
// RUN: -Wl,-T,%t/link.ld -Wl,-z,force-bti
// RUN: llvm-bolt %t.exe -o %t.bolt | FileCheck %s
// CHECK: BOLT-INFO: binary is using BTI
// Checking PLT entries before running BOLT
// RUN: llvm-objdump -d -j .plt %t.exe | FileCheck %s --check-prefix=CHECK-EXE
// CHECK-EXE: <abort@plt>
// CHECK-EXE-NEXT: adrp x16, {{0x[0-9a-f]+}}
// CHECK-EXE-NEXT: ldr x17, [x16, #{{0x[0-9a-f]+}}]
// CHECK-EXE-NEXT: add x16, x16, #{{0x[0-9a-f]+}}
// CHECK-EXE-NEXT: br x17
// CHECK-EXE-NEXT: nop
// CHECK-EXE-NEXT: nop
// Checking PLT entries after patching them in BOLT
// RUN: llvm-objdump -d -j .plt %t.bolt | FileCheck %s \
// RUN: --check-prefix=CHECK-BOLT
// CHECK-BOLT: <abort@plt>
// CHECK-BOLT-NEXT: bti c
// CHECK-BOLT-NEXT: adrp x16, {{0x[0-9a-f]+}}
// CHECK-BOLT-NEXT: ldr x17, [x16, #{{0x[0-9a-f]+}}]
// CHECK-BOLT-NEXT: add x16, x16, #{{0x[0-9a-f]+}}
// CHECK-BOLT-NEXT: br x17
// CHECK-BOLT-NEXT: nop
/*
#--- link.ld
SECTIONS {
.plt : { *(.plt .plt.*) }
} INSERT BEFORE .text;
#--- bti-plt.c
//*/
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}
// .data big enough so the new code placed after it has to use stubs to reach
// PLTs:
__asm__(".section .data\n"
".globl space\n"
"space:\n"
".fill 0x8000000,1,0x0\n"
".text\n");