[PATCH v2 0/3] LoongArch: Allow and correctly resolve PC-relative relocs against local undefined weak symbols

Lulu Cai cailulu@loongson.cn
Fri Dec 27 10:04:41 GMT 2024


On 12/25/24 12:41 PM, Xi Ruoyao wrote:
> Prompted by https://lore.kernel.org/loongarch/20241206085810.112341-1-chenhuacai@loongson.cn/.
>
> Changes from [v1]:
>
> - In the message of patch 2, refer to the correct commit where the check
>    against undefined weak symbol was introduced.
> - In patch 3:
>    - always suggest -fPIC for DSO
>    - always suggest -mno-direct-extern-access for PDE
>    - for PIE, if the bad reloc is already PC-relative, suggest
>      -mno-direct-extern-access; otherwise suggest -fPIE
>    - if the bad reloc is already PC-relative or linking a PDE, suggest
>      checking the symbol visibility
>
> [v1]:https://sourceware.org/pipermail/binutils/2024-December/138080.html:

Thanks, these patches have been pushed to Binutils trunk.

> Cc: mengqinggang@loongson.cn
> Cc: Lulu Cai <cailulu@loongson.cn>
> Cc: Chenghua Xu <xuchenghua@loongson.cn>
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: WANG Xuerui <kernel@xen0n.name>
>
> *** BLURB HERE ***
>
> Xi Ruoyao (3):
>    LoongArch: Fix resolution of undefined weak hidden/protected symbols
>    LoongArch: Allow R_LARCH_PCALA_HI20 or R_LARCH_PCREL20_S2 against
>      undefined weak symbols for static PIE
>    LoongArch: Reword message for unresolvable relocs
>
>   bfd/elfnn-loongarch.c                         | 123 +++++++++++++-----
>   include/opcode/loongarch.h                    |   2 +
>   .../ld-loongarch-elf/bad_pcala_hi20_global.d  |   2 +-
>   .../bad_pcala_hi20_global_pie.d               |   2 +-
>   .../ld-loongarch-elf/bad_pcala_hi20_weak.d    |   2 +-
>   .../bad_pcala_hi20_weak_pie.d                 |   2 +-
>   .../ld-loongarch-elf/bad_pcrel20_s2_global.d  |   2 +-
>   .../ld-loongarch-elf/bad_pcrel20_s2_weak.d    |   2 +-
>   .../ld-loongarch-elf/ld-loongarch-elf.exp     |   3 +
>   .../ld-loongarch-elf/weak-undef-hidden-pie.d  |  14 ++
>   .../weak-undef-hidden-shared.d                |  14 ++
>   .../ld-loongarch-elf/weak-undef-hidden.s      |   9 ++
>   .../ld-loongarch-elf/weak-undef-static-pie.d  |  13 ++
>   .../ld-loongarch-elf/weak-undef-static-pie.s  |   8 ++
>   14 files changed, 160 insertions(+), 38 deletions(-)
>   create mode 100644 ld/testsuite/ld-loongarch-elf/weak-undef-hidden-pie.d
>   create mode 100644 ld/testsuite/ld-loongarch-elf/weak-undef-hidden-shared.d
>   create mode 100644 ld/testsuite/ld-loongarch-elf/weak-undef-hidden.s
>   create mode 100644 ld/testsuite/ld-loongarch-elf/weak-undef-static-pie.d
>   create mode 100644 ld/testsuite/ld-loongarch-elf/weak-undef-static-pie.s
>



More information about the Binutils mailing list