Ring: out of range immediate fixup value for ndk r18b and arm

Created on 25 Feb 2019  路  14Comments  路  Source: briansmith/ring

Error:

running "arm-linux-androideabi-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-march=armv7-a" "-mthumb" "-mfpu=vfpv3-d16" "-mfloat-abi=softfp" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-declarations" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-Wno-cast-align" "-fstack-protector" "-g3" "-D_XOPEN_SOURCE=700" "-c" "-o/home/ccwu/git/karaoke/midiplay/cargo/target/armv7-linux-androideabi/debug/build/ring-27b2bc1ece367170/out/poly1305-armv4-linux32.o" "/home/ccwu/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/pregenerated/poly1305-armv4-linux32.S"

--- stderr
clang70: error: no input files
/home/ccwu/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/pregenerated/poly1305-armv4-linux32.S:180:2: error: out of range immediate fixup value
 addeq r12,r11,#(GFp_poly1305_emit-.Lpoly1305_init)
 ^
/home/ccwu/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/pregenerated/poly1305-armv4-linux32.S:181:2: error: out of range immediate fixup value
 addne r12,r11,#(poly1305_emit_neon-.Lpoly1305_init)
 ^
/home/ccwu/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.13.5/pregenerated/poly1305-armv4-linux32.S:183:2: error: out of range immediate fixup value
 addne r11,r11,#(poly1305_blocks_neon-.Lpoly1305_init)
 ^

The compilation only fails with arm, not with x86 or aarch64.
I have found some reports by other projects which may be useful:

If I want to use -marm instead of -mthumb to workaround this problem, where in the code should I look at?

Most helpful comment

Hi everyone,

I was experiencing this same problem. I upgraded to NDK R20 and also noticed that its no longer required to make a standalone toolchain if using NDK R19 and later according to:
https://developer.android.com/ndk/guides/other_build_systems

So I went ahead and tried to build aarch64, armv7a, and i686 android using the NDK software that was installed via android-studio sdkmanager. Which worked when building with the following environment variables set (note that my android-studio software is installed in $HOME/Android/ in the following)

PATH=$HOME/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
CC=aarch64-linux-android21-clang cargo build --target aarch64-linux-android --release
CC=armv7a-linux-androideabi21-clang cargo build --target armv7-linux-androideabi --release
CC=i686-linux-android21-clang cargo build --target i686-linux-android --release

and this now builds without error.

All 14 comments

I've cloned cc, renamed -mthumb to -marm, added a path in .cargo/config pointing to the cloned cc, which solved my probem.

I hit this same issue. Can you provide your cloned cc? How do that?

@chengchangwu and @mamcx do you have issues if you you clang too?

@pietro Yes, my config is with clang:

linker = ".NDK/arm/bin/arm-linux-androideabi-clang" linker = ".NDK/arm64/bin/aarch64-linux-android-clang"

for example...

Please try removing the mention of poly1305-armv4.pl from build.rs and report back what error(s) you get.

In particular, do you get "error: out of range immediate fixup value" from any other files? If so, please post all of them.

In particular, if the problem is only in the function GFp_poly1305_init_asm then we can just rewrite GFp_poly1305_init_asm in Rust to solve this problem.

Also, does this happen when you use the cross Android toolchain? Do things work correctly with a new Android NDK?

The latest stable version of the NDK is r19b. So, let's see if this happens with r19b.

https://github.com/openssl/openssl/issues/7878#issuecomment-462328720 indicates that NDK r19 might have a similar issue compiling the AES module but nobody has said anything about r19 and the poly1305 module. If poly1305-armv4 works in R19 then I probably won't change poly1305-armv4. If the AES module doesn't work in R19 then I will consider replacing the AES module, depending on where the fixup error is.

Thanks for suggesting the workaround of using -marm instead of -mthumb. I don't think switching from thumb to non-thumb mode on Android ARM is the best long-term solution but it might help people in the interim.

Hi everyone,

I was experiencing this same problem. I upgraded to NDK R20 and also noticed that its no longer required to make a standalone toolchain if using NDK R19 and later according to:
https://developer.android.com/ndk/guides/other_build_systems

So I went ahead and tried to build aarch64, armv7a, and i686 android using the NDK software that was installed via android-studio sdkmanager. Which worked when building with the following environment variables set (note that my android-studio software is installed in $HOME/Android/ in the following)

PATH=$HOME/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/:$PATH
CC=aarch64-linux-android21-clang cargo build --target aarch64-linux-android --release
CC=armv7a-linux-androideabi21-clang cargo build --target armv7-linux-androideabi --release
CC=i686-linux-android21-clang cargo build --target i686-linux-android --release

and this now builds without error.

I think it is OK to make the minimum NDK version R20. Let me know if there is any objection to this. Also, it would be great to have a PR to use NDK R20 in CI.

I didn't experience this using NDK 20 with either
TARGET_CC=aarch64-linux-android21-clang cargo build --target=aarch64-linux-android or TARGET_CC=armv7a-linux-androideabi21-clang cargo build --target=armv7-linux-androideabi. So I think the solution is to clang from NDK 20 or newer.

the original bug report had "arm-linux-androideabi-gcc" as the C compiler. Another user privately reported similar trouble using the GCC-based toolchain. I think the solution is to use clang.

I am using ndk 20b and armv7a-linux-androideabi28-clang, and got the error as in the first comment. I need to remove 'poly1305-armv4.pl' to get it to build passed.

Was this page helpful?
0 / 5 - 0 ratings