ld: Don't define section symbols for excluded sections.
Linker avoids defining section symbols for ELF sections explicitly excluded.
The linker (ld) will no longer define special symbols like __start, __stop, .startof., and .sizeof. for sections marked with the ELF SHF_EXCLUDE flag, unless the output is relocatable or the flag is cleared. This change addresses PR ld/34448 by ensuring these symbols are only created when relevant, preventing potential issues with excluded section content.
In Details
This change modifies ldlang.c to conditionally define section symbols (__start, __stop, etc.) based on the SEC_EXCLUDE flag and the output format. Previously, these symbols could be defined even for sections intended to be excluded from non-relocatable output. The fix ensures symbol definition aligns with section exclusion semantics, referencing PR ld/34448.
- ld
- The GNU linker, responsible for combining object files into an executable or library.
- section symbols
- Special symbols automatically defined by the linker to represent the start, end, or other properties of a section within an object file or executable.
- ELF
- Executable and Linkable Format, a common standard file format for object files, executables, and shared libraries on many Unix-like systems.
- SHF_EXCLUDE
- A flag within an ELF section header that indicates the section's contents should be excluded from the final output, typically for non-relocatable executables.
- relocatable link
- A type of linking process that produces an intermediate object file or library containing undefined symbols and relocation information, intended to be linked again later.
- PR ld/34448
- Problem Report number 34448, referring to a specific bug filed against the GNU linker.