ld: Account for .tbss size on Arm embedded targets
Ensures .tbss occupies VMA for ARM embedded targets, aligning with LLVM lld.
This commit modifies the GNU linker (ld) to account for the size of the .tbss section on ARM embedded targets by making it occupy a virtual memory address (VMA). This behavior is necessary for embedded systems where TLS storage is allocated directly and prevents overlap with subsequent sections like .bss. The change introduces a new build-time property tls_nobits_occupies_vma and sets it to true for ARM embedded targets, aligning with LLVM’s lld behavior. New tests are added to cover static, executable, PIE, and dynamic link scenarios.
In Details
Introduces tls_nobits_occupies_vma to ld.h and conditionally sets it in armelf.em for embedded ARM targets. When true, .tbss (uninitialized TLS data) will occupy VMA in the output, preventing overlap with later sections like .bss. This aligns with lld behavior and is tested with various link types in ld/testsuite/ld-arm/.
- .tbss
- A section in object files that holds uninitialized data for Thread-Local Storage (TLS). Unlike .bss, .tbss is specifically for TLS variables.
- VMA
- Virtual Memory Address. The address at which an object file section is loaded into memory when the program is executed.
- TLS
- Thread-Local Storage. A mechanism that provides thread-specific data, ensuring that each thread has its own copy of certain variables.
- GNU ld
- The GNU linker, responsible for combining object files and creating executable files or shared libraries.
- LLVM lld
- The LLVM linker, part of the LLVM compiler infrastructure, known for its speed and modern design.