[PATCH v3] gas: add --reloc-section-sym={all,internal,none} option for ELF
Fangrui Song
i@maskray.me
Mon Apr 20 17:01:34 GMT 2026
On Thu, Mar 19, 2026 at 9:49 AM Fangrui Song <i@maskray.me> wrote:
>
> On Fri, Feb 27, 2026 at 10:19 PM Fangrui Song <i@maskray.me> wrote:
> >
> > From: Fangrui Song <maskray@sourceware.org>
> >
> > 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-section-sym to control this conversion:
> >
> > - all (default): convert all eligible local symbols
> > - internal: only convert compiler-generated locals (.L prefix)
> > - none: never convert; keep all symbols as-is in relocations
> >
> > This is useful for debugging and for tools that benefit from preserved
> > symbol names.
> >
> > PR gas/33885
> > ---
> > gas/NEWS | 4 ++++
> > gas/as.c | 20 +++++++++++++++-
> > gas/as.h | 10 ++++++++
> > gas/doc/as.texi | 11 +++++++++
> > gas/testsuite/gas/elf/elf.exp | 9 +++++---
> > gas/testsuite/gas/elf/reloc-section-sym-all.d | 12 ++++++++++
> > .../gas/elf/reloc-section-sym-internal.d | 12 ++++++++++
> > .../gas/elf/reloc-section-sym-none.d | 12 ++++++++++
> > gas/testsuite/gas/elf/reloc-section-sym.s | 9 ++++++++
> > .../gas/i386/reloc-section-sym-all.d | 23 +++++++++++++++++++
> > .../gas/i386/reloc-section-sym-internal.d | 23 +++++++++++++++++++
> > .../gas/i386/reloc-section-sym-none.d | 23 +++++++++++++++++++
> > gas/testsuite/gas/i386/reloc-section-sym.s | 14 +++++++++++
> > gas/testsuite/gas/i386/x86-64.exp | 4 ++++
> > gas/write.c | 8 +++++++
> > 15 files changed, 190 insertions(+), 4 deletions(-)
> > create mode 100644 gas/testsuite/gas/elf/reloc-section-sym-all.d
> > create mode 100644 gas/testsuite/gas/elf/reloc-section-sym-internal.d
> > create mode 100644 gas/testsuite/gas/elf/reloc-section-sym-none.d
> > create mode 100644 gas/testsuite/gas/elf/reloc-section-sym.s
> > create mode 100644 gas/testsuite/gas/i386/reloc-section-sym-all.d
> > create mode 100644 gas/testsuite/gas/i386/reloc-section-sym-internal.d
> > create mode 100644 gas/testsuite/gas/i386/reloc-section-sym-none.d
> > create mode 100644 gas/testsuite/gas/i386/reloc-section-sym.s
> >
>
> Ping:)
Ping:)
More information about the Binutils
mailing list