Control section symbol conversion for ELF relocations
GAS now lets users control whether local symbols in ELF relocations are converted to section symbols.
GAS for ELF will now respect a new —reloc-section-sym option to control the conversion of local symbols in relocations. The default behavior converts eligible local symbols to reference the section symbol, which can reduce .symtab size when multiple local symbols are in a single section. Users can now choose to convert all symbols, only compiler-generated locals (e.g., .L prefix), or never perform this conversion.
In Details
This CL adds --reloc-section-sym to gas for ELF object files. The option controls an optimization where local symbols referenced by relocations are replaced by section symbols (STT_SECTION). The original symbol's offset is folded into the relocation's addend. This optimization saves space in .symtab only when multiple local symbols in a section are relocated. The new option provides control over this behavior to aid debugging or tools that benefit from explicit symbol names.
- GAS
- The GNU Assembler, a component of the GNU Binutils package that translates assembly language code into object files.
- ELF
- Executable and Linkable Format, a common standard file format for object files, executables, and shared libraries on Unix-like systems.
- relocation
- Information in an object file that describes how to modify relocation sections of code and data in the process of linking. This typically involves adjusting addresses or symbols.
- local symbol
- A symbol that is not intended to be referenced from outside the current object file. In ELF, these are often given a
LOCALbinding and can be compiler-generated (e.g., .Lfoo). - section symbol
- A symbol of type
STT_SECTIONin ELF, which represents an entire section. When used in a relocation, it implies an offset within that section. - .symtab
- The symbol table section in an ELF object file, which contains information about the symbols defined or referenced by the file. It is used by linkers and debuggers.
- addend
- A constant value included in an ELF relocation entry that is added to the relocated symbol's value and the offset of the relocation.