[PATCH v2] gas: add --reloc-section-sym={all, internal, none} option for ELF
Fangrui Song
i@maskray.me
Mon Feb 23 17:36:06 GMT 2026
On Sun, Feb 22, 2026 at 11:20 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 22.02.2026 03:03, Fangrui Song wrote:
> > --- a/gas/testsuite/gas/elf/elf.exp
> > +++ b/gas/testsuite/gas/elf/elf.exp
> > @@ -4,15 +4,15 @@
> > # it under the terms of the GNU General Public License as published by
> > # the Free Software Foundation; either version 3 of the License, or
> > # (at your option) any later version.
> > -#
> > +#
> > # This program is distributed in the hope that it will be useful,
> > # but WITHOUT ANY WARRANTY; without even the implied warranty of
> > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > # GNU General Public License for more details.
> > -#
> > +#
> > # You should have received a copy of the GNU General Public License
> > # along with this program; if not, write to the Free Software
> > -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
> > +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
> >
> > #
> > # elf tests
> > @@ -170,30 +170,32 @@ if { [is_elf_format] } then {
> > switch -glob $target_triplet {
> > alpha*-*-* { }
> > am3*-*-* { }
> > + avr-*-* { }
> > *c54x*-*-* { }
> > cr16*-*-* { }
> > crx*-*-* { }
> > h8300-*-* { }
> > - hppa*-*-* { }
> > - iq2000*-*-* { }
> > - mips*-*-* { }
> > + loongarch*-*-* { }
> > + m681*-*-* { }
> > + m68hc*-*-* { }
> > mn10200-*-* { }
> > mn10300-*-* { }
> > msp43*-*-* { }
> > - rl78-*-* { }
> > riscv*-*-* { }
> > + rl78-*-* { }
> > rx-*-* { }
> > - loongarch*-*-* { }
> > + xgate-*-* { }
> > + vax-*-* { }
> > default {
> > - # The next test can fail if the target does not convert fixups
> > - # against ordinary symbols into relocations against section symbols.
> > - # This is usually revealed by the error message:
> > - # symbol `sym' required but not present
> > - setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" "avr-*-*"
> > - run_dump_test redef
> > + # The following tests require that the target adjusts relocations
> > + # referencing local binding symbols to be against section symbols.
> > run_dump_test equ-reloc
> > + run_dump_test redef
> > + run_dump_test "reloc-section-sym-all"
> > + run_dump_test "reloc-section-sym-internal"
> > }
> > }
> > + run_dump_test "reloc-section-sym-none"
> > run_dump_test "pseudo"
> > run_dump_test "text-prev" $dump_opts
> > run_dump_test "text-subsect" $dump_opts
> > @@ -245,7 +247,7 @@ if { [is_elf_format] } then {
> > # in the symbol type test.
> > # We also need to exclude targets that do not support unique objects.
> > if { [istarget "*-*-hpux*"]
> > - || [istarget "arm*-*-*"]
> > + || [istarget "arm*-*-*"]
> > || [istarget "mips*-*-*"]
> > || [istarget "msp*-*-*"]
> > || [istarget "visium-*-*"]
> > @@ -380,7 +382,7 @@ if { [is_elf_format] } then {
> > run_dump_test "startof"
> >
> > run_dump_test "missing-build-notes"
> > -
> > +
> > run_dump_test "common1"
> > run_dump_test "common2"
> >
>
> This became much more of a change than what v1 had, and I question parts thereof.
> You're dropping XFAILs. If there's a proper reason for doing so, it needs stating
> in the description. You're further excluding the equ-reloc test for more targets.
> This pretty likely is wrong?
>
> You apparently also try to re-sort the list of excluded targets in that switch,
> yet then vax ends up after xgate.
I have used a build-all-gas.sh script to build 40+ triplets, including
every triplet mentioned in elf.exp.
I have determined that the equ-reloc and redef tests actually pass on
the disabled hppa and iq2000.
The list is now sorted alphabetically.
vax is special: its tc_fix_adjustable macro in gas/config/tc-vax.h
includes the condition S_IS_LOCAL ((FIX)->fx_addsy)), causing
reloc-section-sym-all to fail.
setup_xfail only works for the next run_dump_test. I think it's easier
to just exclude it.
I feel like xfail is often just a placeholder for 'this target is
weird but I don't have time to fix it.' These tests are really just
highlighting specific tc_fix_adjustable opt-ins (though many major
targets choose the aggressive behavior).
("internal" probably makes more sense as a general default.)
> I'm also unconvinced all the whitespace changes should go here.
While I understand the issue of interleaving functional changes with
whitespace noise, I noticed our .editorconfig has
trim_trailing_whitespace = true enabled, which is causing neovim to
automatically scrub spaces on save.
To save everyone the headache of messy diffs, we should probably do a
one-time sweep in batch.
> With changes like these, btw, a revlog would also have been helpful.
>
> Jan
What is revlog?
More information about the Binutils
mailing list