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

Lulu Cai cailulu@loongson.cn
Thu Sep 18 12:30:53 GMT 2025


On 9/18/25 8:00 PM, H.J. Lu wrote:
> 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.

It works, thank you.

>> 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.




More information about the Binutils mailing list