Building for aarch64-apple-ios produces the following error:
$ cargo build -p graviola --target aarch64-apple-ios
Compiling libc v0.2.177
Compiling cfg-if v1.0.4
Compiling getrandom v0.3.4
Compiling graviola v0.3.0 (/Users/filipw/dev/graviola/graviola)
error: ADR/ADRP relocations must be GOT relative
--> graviola/src/low/aarch64/curve25519_x25519base.rs:431:9
|
431 | Q!(" adrp " "x10, " PageRef!("curve25519_x25519base_alt_edwards25519_0g")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:13:26
|
13 | adrp x10, __ZN8graviola3low7aarch6421curve25519_x25519base41curve25519_x25519base_alt_edwards25519_0g17h1c5472b3dd5ad20dE
| ^
error: unknown AArch64 fixup kind!
--> graviola/src/low/aarch64/curve25519_x25519base.rs:431:9
|
431 | Q!(" adrp " "x10, " PageRef!("curve25519_x25519base_alt_edwards25519_0g")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:13:26
|
13 | adrp x10, __ZN8graviola3low7aarch6421curve25519_x25519base41curve25519_x25519base_alt_edwards25519_0g17h1c5472b3dd5ad20dE
| ^
error: ADR/ADRP relocations must be GOT relative
--> graviola/src/low/aarch64/curve25519_x25519base.rs:432:9
|
432 | Q!(" adrp " "x11, " PageRef!("curve25519_x25519base_alt_edwards25519_8g")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:14:26
|
14 | adrp x11, __ZN8graviola3low7aarch6421curve25519_x25519base41curve25519_x25519base_alt_edwards25519_8g17hcb13392432c6bc31E
| ^
error: unknown AArch64 fixup kind!
--> graviola/src/low/aarch64/curve25519_x25519base.rs:432:9
|
432 | Q!(" adrp " "x11, " PageRef!("curve25519_x25519base_alt_edwards25519_8g")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:14:26
|
14 | adrp x11, __ZN8graviola3low7aarch6421curve25519_x25519base41curve25519_x25519base_alt_edwards25519_8g17hcb13392432c6bc31E
| ^
error: ADR/ADRP relocations must be GOT relative
--> graviola/src/low/aarch64/curve25519_x25519base.rs:488:9
|
488 | Q!(" adrp " tab!() ", " PageRef!("curve25519_x25519base_alt_edwards25519_gtable")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:49:26
|
49 | adrp x19, __ZN8graviola3low7aarch6421curve25519_x25519base45curve25519_x25519base_alt_edwards25519_gtable17h38071b409089997fE
| ^
error: unknown AArch64 fixup kind!
--> graviola/src/low/aarch64/curve25519_x25519base.rs:488:9
|
488 | Q!(" adrp " tab!() ", " PageRef!("curve25519_x25519base_alt_edwards25519_gtable")),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: instantiated into assembly here
--> <inline asm>:49:26
|
49 | adrp x19, __ZN8graviola3low7aarch6421curve25519_x25519base45curve25519_x25519base_alt_edwards25519_gtable17h38071b409089997fE
| ^
error: could not compile `graviola` (lib) due to 6 previous errors
The problem seems to be that iOS (and other related Apple platforms that are non-Darwin) do not allow adrp direct addressing, you need to go over GOT.
So the fix would be something like this:
#[allow(unused_macros)]
#[cfg(all(target_vendor = "apple", not(target_os = "macos")))]
macro_rules! PageRef {
($sym:literal) => { Q!( "{" $sym "}@GOTPAGE" ) }
}
#[allow(unused_macros)]
#[cfg(not(target_vendor = "apple"))]
macro_rules! PageRef {
($sym:literal) => { Q!( "{" $sym "}" ) }
}
#[allow(unused_macros)]
#[cfg(target_os = "macos")]
macro_rules! GotLoad {
($reg:literal, $sym:literal) => {
""
};
}
#[allow(unused_macros)]
#[cfg(all(target_vendor = "apple", not(target_os = "macos")))]
macro_rules! GotLoad {
($reg:literal, $sym:literal) => { Q!(" ldr " $reg ", [" $reg ", " "{" $sym "}@GOTPAGEOFF" "]\n") }
}
#[allow(unused_macros)]
#[cfg(not(target_vendor = "apple"))]
macro_rules! GotLoad {
($reg:literal, $sym:literal) => {
""
};
}
And then in the curve code:
GotLoad!("x10", "curve25519_x25519base_alt_edwards25519_0g"),
GotLoad!("x11", "curve25519_x25519base_alt_edwards25519_8g"),
....
GotLoad!("x19", "curve25519_x25519base_alt_edwards25519_gtable")
which would be no-op everywhere but resolve the iOS issue.
Building for
aarch64-apple-iosproduces the following error:The problem seems to be that iOS (and other related Apple platforms that are non-Darwin) do not allow
adrpdirect addressing, you need to go over GOT.So the fix would be something like this:
And then in the curve code:
which would be no-op everywhere but resolve the iOS issue.