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
81 lines
2.7 KiB
ArmAsm
81 lines
2.7 KiB
ArmAsm
# REQUIRES: aarch64
|
|
|
|
## Test that branch relocations with non-zero addends correctly target the
|
|
## actual function address, not the stub address. When a symbol is accessed
|
|
## via both a regular call (goes through stub) and a branch with addend
|
|
## (targeting an interior point), the addend must be applied to the real
|
|
## function VA, not the stub VA.
|
|
##
|
|
## This test uses -flat_namespace on a dylib, which makes locally-defined
|
|
## symbols interposable and thus accessible via stubs. This creates the
|
|
## scenario where a function is both defined locally AND in stubs.
|
|
|
|
# RUN: rm -rf %t; mkdir -p %t
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/test.o
|
|
# RUN: %lld -arch arm64 -dylib -lSystem -flat_namespace %t/test.o -o %t/test.dylib
|
|
|
|
# RUN: llvm-objdump --no-print-imm-hex --macho -d %t/test.dylib | FileCheck %s
|
|
|
|
## With -flat_namespace, _target_func is interposable so regular calls go
|
|
## through stubs. But the branch with addend must go to the actual function
|
|
## address + addend, not stub + addend.
|
|
##
|
|
## Note: This means `bl _target_func` and `bl _target_func+16` could target
|
|
## different functions if interposition occurs at runtime. This is intentional:
|
|
## branching to an interior point implies reliance on the original function's
|
|
## layout, which an interposed replacement wouldn't preserve. There's no
|
|
## meaningful way to "interpose" an interior offset, so we target the original.
|
|
|
|
## _target_func layout:
|
|
## offset 0: nop
|
|
## offset 4: nop
|
|
## offset 8: nop
|
|
## offset 12: nop
|
|
## offset 16: mov w0, #42 <- this is what _target_func+16 should reach
|
|
## offset 20: ret
|
|
|
|
## Verify _target_func layout and capture the address of the mov instruction
|
|
## (which is at _target_func + 16)
|
|
# CHECK-LABEL: _target_func:
|
|
# CHECK: nop
|
|
# CHECK-NEXT: nop
|
|
# CHECK-NEXT: nop
|
|
# CHECK-NEXT: nop
|
|
# CHECK-NEXT: [[#%x,INTERIOR:]]:{{.*}}mov w0, #42
|
|
# CHECK-NEXT: ret
|
|
|
|
## Verify the caller structure:
|
|
## - First bl goes to stub (marked with "symbol stub for:")
|
|
## - Second bl goes to [[INTERIOR]] (the _target_func+16 address captured above)
|
|
##
|
|
## The key assertion: the second bl MUST target _target_func+16 (INTERIOR),
|
|
## NOT stub+16. If the bug exists, it would target stub+16 which would be
|
|
## garbage (pointing past the stub section).
|
|
# CHECK-LABEL: _caller:
|
|
# CHECK: bl {{.*}} symbol stub for: _target_func
|
|
# CHECK-NEXT: bl 0x[[#INTERIOR]]
|
|
# CHECK-NEXT: ret
|
|
|
|
.text
|
|
.globl _target_func, _caller
|
|
.p2align 2
|
|
|
|
_target_func:
|
|
## 4 nops = 16 bytes to offset 0x10
|
|
nop
|
|
nop
|
|
nop
|
|
nop
|
|
## This is at _target_func + 16
|
|
mov w0, #42
|
|
ret
|
|
|
|
_caller:
|
|
## Regular call to _target_func - goes through stub due to -flat_namespace
|
|
bl _target_func
|
|
## Branch with addend - must go to actual function + 16, not stub + 16
|
|
bl _target_func + 16
|
|
ret
|
|
|
|
.subsections_via_symbols
|