-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cranelift: implement PIC relocations on AArch64 #2907
Comments
Thanks for the report @syrusakbary ! Indeed this is a missing feature in the current aarch64 backend; it hasn't been needed yet but it should certainly be implemented at some point. In the short term it could make sense to assert not-PIC, so at least the failure is correct; but I'd be happy to review a PR, if you would like to take a crack at this. (Otherwise I don't know if anyone currently has the bandwidth to do this offhand, to assign this issue, though @bnjbvr please correct me if you have any plans for PIC as part of the M1 focus!) |
I'd love to create a PR, but I will need a bit of guidance since I'm not very familiar with the new backend architecture. Thanks! |
I don't have any plans to work on this as part of the M1 focus, so anyone feel free to take this! |
Issue #1657 seems to be related to this. |
@syrusakbary a top-level check/assert in The actual GOT-reference implementation is probably not too bad either -- the main thing is to match the relocations and instructions that the linker expects, which one could get by building e.g. some C code and looking at the resulting .o. |
@cfallin thanks for the insights, I just did a quick check on the code. The main reason for that is that setting up a Backend would never cause an abort/exit, even if it's provided with a flag that exists, but is not supported in a specific backend (in that case it will return an |
Sure, that sounds reasonable -- it's plausible there may be other "unsupported configuration errors" in the future. This would propagate a |
Someone on the zulip got hit by this. Android requires position independent code and the dynamic linker refuses to run any executables with relocations in the |
Cranelift emits AbsoluteRelocation
Reloc::Abs8
whenis_pic
setting is enabled in architectureaarch64
Steps to Reproduce
Code emitted
fac.o
has absolute relocations.Expected Results
Is expected for Cranelift to emit a relative relocation for aarch64 when
is_pic
is enabled.Actual Results
Code emitted with an absolute relocation.
Versions and Environment
Cranelift version:
cranelift-codegen = "0.73.0"
Operating system: Any
Architecture: Aarch64
Extra info
Here's where the wrong code is emitted:
wasmtime/cranelift/codegen/src/isa/aarch64/inst/emit.rs
Lines 2440 to 2462 in 207da98
In the new x86 backend however, the
is_pic
case is properly handled:wasmtime/cranelift/codegen/src/isa/x64/inst/emit.rs
Lines 2350 to 2387 in e676589
The text was updated successfully, but these errors were encountered: