Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] attribute __attribute__ ((ifunc("resolve_multiver"))) is accepted even when not supported by the platform (linux-musl) #91313

Open
mablinov opened this issue May 7, 2024 · 2 comments
Labels
accepts-invalid clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@mablinov
Copy link

mablinov commented May 7, 2024

Hi all,

The symptoms of this issue are identical to #64631: The musl dynamic linker will complain about unknown relocation 37.

I stumbled into this issue when porting a GCC test (ipa-pta-19.c) into RISC-V Clang, except of course in RISC-V the relocation number is different, so I see unsupported relocation type 58 instead (R_RISCV_IRELATIVE)

two items of note:

So far I've tried with the following LLVM versions:

  • 18.1.5
  • 17.0.5
  • commit 0c3a02b8c09bb (the exact commit that should have introduced the fix)

Perhaps it never got tested? I noticed while debugging clang, that the function supportsIFunc never actually gets called

@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 7, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" accepts-invalid and removed clang Clang issues not falling into any other category labels May 7, 2024
@llvmbot
Copy link

llvmbot commented May 7, 2024

@llvm/issue-subscribers-clang-frontend

Author: Maxim Blinov (mablinov)

Hi all,

The symptoms of this issue are identical to #64631: The musl dynamic linker will complain about unknown relocation 37.

I stumbled into this issue when porting a GCC test (ipa-pta-19.c) into RISC-V Clang, except of course in RISC-V the relocation number is different, so I see unsupported relocation type 58 instead (R_RISCV_IRELATIVE)

two items of note:

So far I've tried with the following LLVM versions:

  • 18.1.5
  • 17.0.5
  • commit 0c3a02b8c09bb (the exact commit that should have introduced the fix)

Perhaps it never got tested? I noticed while debugging clang, that the function supportsIFunc never actually gets called

@MaskRay
Copy link
Member

MaskRay commented May 9, 2024

While target_clones allows multiple implementations that Clang can readily adopt a portable one (not using ifunc), __attribute__((ifunc("resolve_multiver"))) instructs Clang to generate STT_GNU_IFUNC symbols.
This raises the question of whether Clang should check all Linux environments whether ifunc is supported.

Firefox used/uses elfhack/relrhack to support relative relocations.
A similar mechanism can be used to handle IRELATIVE relocations.
Lacking dynamic loader doesn't mean ifunc cannot be emulated in an environment.

I feel that the compiler might not be the playce to enforce this.
A much more common way to use ifunc is inline assembly, and Clang cannot reject it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts-invalid clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants