[PATCH] gas: add --reloc-section-sym={all, internal, none} option for ELF
Jan Beulich
jbeulich@suse.com
Fri Feb 20 11:29:54 GMT 2026
On 16.02.2026 08:20, Fangrui Song wrote:
> When generating relocations for non-ifunc local symbols that satisfies
> several conditions, GAS converts them to reference the section symbol
> (STT_SECTION) instead, folding the original symbol's offset into the
> addend. This allows the original local symbol to be omitted from
> .symtab, but the STT_SECTION symbol itself must be present, so the
> conversion saves .symtab entries only when a section has more than one
> local symbol referenced by relocations.
>
> Add --reloc-use-section-sym to control this conversion:
Besides, as Maciej has already pointed out, this one still needing updating, ...
> @@ -523,7 +527,8 @@ parse_args (int * pargc, char *** pargv)
> OPTION_SFRAME_3,
> OPTION_SCFI,
> OPTION_INFO,
> - OPTION_NOINFO
> + OPTION_NOINFO,
> + OPTION_RELOC_USE_SECTION_SYM
... this also should lose the USE, as should ...
> @@ -1043,6 +1049,18 @@ This program has absolutely no warranty.\n"));
> flag_sectname_subst = 1;
> break;
>
> + case OPTION_RELOC_USE_SECTION_SYM:
> + if (strcasecmp (optarg, "all") == 0)
> + flag_reloc_use_section_sym = reloc_use_section_sym_all;
... the flag variable, the enum, and the enumerators.
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/reloc-section-sym.s
> @@ -0,0 +1,14 @@
> +.text
> + nop
> +named_local:
> + nop
> +.Ltemp:
> + nop
> +
> +.section .text1,"ax"
> + call named_local
> + call .Ltemp
> +
> +.data
> +.quad named_local + 16
> +.quad .Ltemp + 16
Please can all directives be indented by at least one position?
Okay with these adjustments.
Jan
More information about the Binutils
mailing list