syrusakbary opened issue #2907:
Cranelift emits AbsoluteRelocation
Reloc::Abs8
whenis_pic
setting is enabled in architectureaarch64
Steps to Reproduce
(module ;; Recursive factorial (func (export "fac-rec") (param i64) (result i64) (if (result i64) (i64.eq (local.get 0) (i64.const 0)) (then (i64.const 1)) (else (i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1)))) ) ) ) )
$ wasmtime wasm2obj fac.wat fac.o
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: Aarch64Extra info
Here's where the wrong code is emitted:
https://github.com/bytecodealliance/wasmtime/blob/207da989acf5c6d828dd5d1704c05c0d01b1dead/cranelift/codegen/src/isa/aarch64/inst/emit.rs#L2440-L2462In the new x86 backend however, the
is_pic
case is properly handled:
syrusakbary labeled issue #2907:
Cranelift emits AbsoluteRelocation
Reloc::Abs8
whenis_pic
setting is enabled in architectureaarch64
Steps to Reproduce
(module ;; Recursive factorial (func (export "fac-rec") (param i64) (result i64) (if (result i64) (i64.eq (local.get 0) (i64.const 0)) (then (i64.const 1)) (else (i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1)))) ) ) ) )
$ wasmtime wasm2obj fac.wat fac.o
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: Aarch64Extra info
Here's where the wrong code is emitted:
https://github.com/bytecodealliance/wasmtime/blob/207da989acf5c6d828dd5d1704c05c0d01b1dead/cranelift/codegen/src/isa/aarch64/inst/emit.rs#L2440-L2462In the new x86 backend however, the
is_pic
case is properly handled:
syrusakbary labeled issue #2907:
Cranelift emits AbsoluteRelocation
Reloc::Abs8
whenis_pic
setting is enabled in architectureaarch64
Steps to Reproduce
(module ;; Recursive factorial (func (export "fac-rec") (param i64) (result i64) (if (result i64) (i64.eq (local.get 0) (i64.const 0)) (then (i64.const 1)) (else (i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1)))) ) ) ) )
$ wasmtime wasm2obj fac.wat fac.o
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: Aarch64Extra info
Here's where the wrong code is emitted:
https://github.com/bytecodealliance/wasmtime/blob/207da989acf5c6d828dd5d1704c05c0d01b1dead/cranelift/codegen/src/isa/aarch64/inst/emit.rs#L2440-L2462In the new x86 backend however, the
is_pic
case is properly handled:
cfallin commented on issue #2907:
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!)
Last updated: Dec 23 2024 at 12:05 UTC