[PATCH] ld: Don't use -mdirect-extern-access for LoongArch

H.J. Lu hjl.tools@gmail.com
Thu Sep 18 12:00:39 GMT 2025


On Thu, Sep 18, 2025 at 12:03 AM Lulu Cai <cailulu@loongson.cn> wrote:
>
> Hi,
> The test case added by this patch fails on LoongArch:
> FAIL: Run pr33409.
> This is because LoongArch's `-mdirect-extern-access` is only suitable
> for environments where no dynamic link is performed, like firmwares, OS
> kernels, and executables linked with `-static` or `-static-pie`.

Please try the enclosed patch.

> On 9/10/25 9:44 AM, H.J. Lu wrote:
> > Copy non_got_ref_without_indirect_extern_access when copying indirect
> > symbol for weak alias so that _bfd_x86_elf_adjust_dynamic_symbol will
> > properly handle GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.
> >
> > bfd/
> >
> >       PR ld/33409
> >       * elfxx-x86.c (_bfd_x86_elf_copy_indirect_symbol): Copy
> >       non_got_ref_without_indirect_extern_access.
> >
> > ld/
> >
> >       PR ld/33409
> >       * testsuite/config/default.exp (NO_DIRECT_EXTERN_ACCESS_CFLAGS):
> >       New.
> >       * testsuite/ld-elf/shared.exp: Run PR ld/33409 tests.
> >       * testsuite/ld-elf/pr33409a.c: New file.
> >       * testsuite/ld-elf/pr33409b.c: Likewise.
> >       * testsuite/ld-elf/pr33409c.c: Likewise.
> >


--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ld-Don-t-use-mdirect-extern-access-for-LoongArch.patch
Type: application/x-patch
Size: 2064 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250918/a6b96306/attachment.bin>


More information about the Binutils mailing list