Problem Description
Hi AMD ROCm team,
I'm trying to inject a global variable (global_launch_time) into a manually assembled kernel and access it using global_load / global_store instructions on MI300 (gfx942). Despite ensuring it’s placed in .hsa.data.global and properly aligned using ld.lld with an explicit linker script, I get a runtime crash:
HSA_STATUS_ERROR_MEMORY_APERTURE_VIOLATION: The agent attempted to access memory beyond the largest legal address.
What I did
Assembled .s file using:
clang -target amdgcn-amd-amdhsa -mcpu=gfx942 -c kernel.s -o my_kernel.o
Linking using:
SECTIONS {
. = 0x1000;
.hsa.data.global : { *(.hsa.data.global) } :data
.text : { *(.text) } :text
}
ld.lld -shared -T linked.ld --image-base=0x1000 my_kernel.o -o my_kernel.co
Verified placement using:
llvm-readelf -s my_kernel.co | grep global_launch_time
llvm-readelf -l my_kernel.co
Confirmed relocations:
llvm-readobj --relocations my_kernel.o | grep global_launch_time
Kernel uses:
global_store_dwordx2 v[2:3], v[0:1], off
Observations
global_launch_time symbol is at 0x100a8 in .hsa.data.global
It appears in two LOAD segments marked RW
Relocation type used: R_AMDGPU_GOTPCREL32_LO/HI
Crash always happens at first global store/load using this symbol
Using llvm-objdump -d shows correct instruction encoding
Manually encoding .amdhsa_kernel metadata as required
Operating System
Ununtu 22
CPU
Na
GPU
Amd Instinct mi300x
ROCm Version
Rocm 6.3.1
ROCm Component
No response
Steps to Reproduce
No response
(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support
No response
Additional Information
No response