binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
alpha

Alpha: Initialize all fields of new GOT entries

Fixes uninitialized memory reads in Alpha GOT entry handling by using bfd_zalloc.

This commit addresses a bug in the Alpha ELF backend where newly allocated GOT (Global Offset Table) entries were not fully initialized, leading to potential reads of uninitialized memory. The get_got_entry function previously used bfd_alloc, leaving fields like flags uninitialized. This was particularly problematic for GOT entries created for TLS relocations. The fix changes the allocation to bfd_zalloc, which zeroes out the memory, and subsequently only assigns fields that require non-zero initial values, ensuring all fields are properly initialized.

In Details

The functions get_got_entry and elf64_alpha_relax_tls_get_addr allocated GOT entries using bfd_alloc. get_got_entry failed to initialize the flags field, while elf64_alpha_relax_tls_get_addr left both flags and plt_offset uninitialized. This resulted in uninitialized memory reads when elf64_alpha_merge_gots processed these entries. By switching to bfd_zalloc, the memory is zero-initialized, and only explicit non-zero fields need to be assigned, resolving the issue found by Valgrind.

For Context
GOT
Global Offset Table. A table used in position-independent code (PIC) to hold addresses of external functions and global variables, allowing indirect access at runtime.
relocation
A directive in an object file that tells the linker how to modify addresses to correctly reference symbols or locations in the final executable or shared library.
TLS
Thread-Local Storage. A mechanism for allocating data that is specific to each thread of execution.
bfd_alloc
A Binutils BFD library function to allocate memory.
bfd_zalloc
A Binutils BFD library function to allocate memory and zero-initialize it.
Valgrind
A instrumentation framework for dynamic analysis tools. It was used here to detect memory errors, such as reading uninitialized memory.
Filed Under: linkeralphaELFGOTmemory error