[PATCH 0/2] s390: Avoid relocation overflows on undefined weak symbols
Fangrui Song
i@maskray.me
Wed Jun 26 18:26:51 GMT 2024
On Wed, Jun 26, 2024 at 8:20 AM Jens Remus <jremus@linux.ibm.com> wrote:
>
> Patch 1 corrects commit 896a639babe2 ("s390: Avoid reloc overflows on
> undefined weak symbols") not to replace Branch Relative on Count High
> (brcth) referencing an undefined weak symbol definitively resolving to
> zero by a trap, as it is not guaranteed that the conditional branch is
> taken in any case.
>
> Patch 2 complements commit 896a639babe2 ("s390: Avoid reloc overflows
> on undefined weak symbols") by applying similar replacements of
> instructions referencing undefined weak symbols that definitively
> resolve to zero. This time for PLT32DBL relocations.
>
> Regards,
> Jens
>
> Jens Remus (2):
> s390: Do not replace brcth referencing undefined weak symbol
> s390: Avoid reloc overflows on undefined weak symbols (cont)
>
> bfd/elf64-s390.c | 42 ++++++++++++++++++++++++++---
> ld/testsuite/ld-s390/s390.exp | 5 +++-
> ld/testsuite/ld-s390/weakundef-1.dd | 6 ++---
> ld/testsuite/ld-s390/weakundef-1.s | 1 -
> ld/testsuite/ld-s390/weakundef-2.dd | 17 ++++++++++++
> ld/testsuite/ld-s390/weakundef-2.s | 17 ++++++++++++
> 6 files changed, 80 insertions(+), 8 deletions(-)
> create mode 100644 ld/testsuite/ld-s390/weakundef-2.dd
> create mode 100644 ld/testsuite/ld-s390/weakundef-2.s
>
> --
> 2.40.1
>
Other ports have simpler strategies for unresolved undefined weak symbols
https://reviews.llvm.org/D103001
aarch64: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to
the next instruction
mips: GNU ld: branch to the start of the text segment (?); ld.lld:
branch to zero
ppc32: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to the
current instruction
ppc64: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to the
current instruction
riscv: GNU ld: branch to the absolute zero address (with instruction rewriting)
i386/x86_64: GNU ld/ld.lld: branch to the link-time zero address
I haven't checked the patch closely, but it seems to add quite a few lines.
More information about the Binutils
mailing list