[PATCH 0/2] s390: Improve GOT access relaxation in linker

Jens Remus jremus@linux.ibm.com
Thu May 15 15:10:06 GMT 2025
Ilya reported an issue building BCC [1], where the GNU linker failed
with the following error, due to erroneous relaxation of a GOT access
(rewrite of lgrl to larl) for a symbol for C++ type information in a
COMDAT section:

  /usr/lib/gcc/s390x-linux-gnu/14/libstdc++.a(shared_ptr.o)
  (.text._ZNSt19_Sp_make_shared_tag5_S_eqERKSt9type_info+0x2):
  misaligned symbol `_ZTSSt19_Sp_make_shared_tag' (0x8574f77) for
  relocation R_390_PC32DBL

Reproduction instructions can be found in the patch 2 notes.

Patch 1 improves the (above) linker error message for relocation against
misaligned symbol, as it was painful to determine where the offending
symbol was defined.

Patch 2 prevents the erroneous relaxation of GOT accesses for misaligned
symbols.  At the same time it improves it by enabling relaxation for
symbols that coincidentally end up properly aligned.  The former
resolves the reported build issue.  The latter greatly improves the
relaxation of GOT accesses using lgrl in a Linux Kernel vmlinux
(by ~15k down to a remaining handful).

Regards,
Jens

Jens Remus (2):
  s390: Improve diagnostic for reloc against misaligned sym
  s390: Prevent GOT access rewrite for misaligned symbols

 bfd/elf64-s390.c                     | 13 ++++++-------
 ld/testsuite/ld-s390/pr32969_64-1.dd | 15 +++++++++++++++
 ld/testsuite/ld-s390/pr32969_64-2.dd | 15 +++++++++++++++
 ld/testsuite/ld-s390/pr32969a.s      | 14 ++++++++++++++
 ld/testsuite/ld-s390/pr32969b.s      | 10 ++++++++++
 ld/testsuite/ld-s390/pr32969c.s      | 10 ++++++++++
 ld/testsuite/ld-s390/s390.exp        |  8 ++++++++
 7 files changed, 78 insertions(+), 7 deletions(-)
 create mode 100644 ld/testsuite/ld-s390/pr32969_64-1.dd
 create mode 100644 ld/testsuite/ld-s390/pr32969_64-2.dd
 create mode 100644 ld/testsuite/ld-s390/pr32969a.s
 create mode 100644 ld/testsuite/ld-s390/pr32969b.s
 create mode 100644 ld/testsuite/ld-s390/pr32969c.s

-- 
2.45.2



More information about the Binutils mailing list