GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/alpha

Prevent ASan's $LASANPC label from being placed in small data sections.

Fixes an Alpha relocation issue where ASan's stack protection label was incorrectly placed in small data, causing relocation errors.

This commit resolves a relocation error on the Alpha architecture related to AddressSanitizer (ASan). ASan stores a label ($LASANPC) in each instrumented frame to mark the end of stack protection. On Alpha with -fpic, this label declaration was being accepted into the small data section. However, the label resides in the text section, and forming its address using a GPREL16 relocation against .text caused a ‘relocation truncated to fit’ error due to the 32KB range limitation. The fix prevents such declarations from being considered ‘small data’.

In Details

The asan_emit_stack_protection function in ASan stores the address of the $LASANPC label within each instrumented function frame. On Alpha, alpha_in_small_data_p incorrectly accepted a VAR_DECL for this label, especially when compiled with -fpic (implying -msmall-data). This resulted in the label's address being formed with a single GPREL16 lda relocation against the .text section, which is outside the 32KB range of this relocation type. The fix modifies alpha_in_small_data_p to return false for declarations where DECL_INITIAL points to the declaration itself, thus exclu…

For Context
ASan
AddressSanitizer, a memory error detector for C/C++. It instruments code to detect out-of-bounds accesses, use-after-free, and other memory errors at runtime.
$LASANPC
A specific label used by AddressSanitizer on some architectures to mark the end of a function's instrumented code for stack protection purposes.
small data
A memory addressing optimization where frequently accessed global or static variables are placed in a dedicated, small-addressable memory region (e.g., .sdata, .sbss) to allow for more efficient, PC-relative addressing.
GPREL16
A type of relocation used on some architectures (like Alpha) for addressing data relative to the global pointer register (GP). The '16' indicates a 16-bit offset.
Alpha
A RISC instruction set architecture developed by Digital Equipment Corporation (DEC). GCC has support for targeting Alpha processors.
relocation
A process performed by the linker to adjust addresses in machine code after it has been compiled, typically to correctly link references between different code modules or to absolute addresses.
Filed Under: gccalphaasanrelocation