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

Illegal instruction mcr on ARM926EJ-S #138666

Closed
2 tasks done
oold opened this issue Mar 18, 2025 · 7 comments
Closed
2 tasks done

Illegal instruction mcr on ARM926EJ-S #138666

oold opened this issue Mar 18, 2025 · 7 comments
Labels
needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.

Comments

@oold
Copy link

oold commented Mar 18, 2025

Verification

Problem

Binaries compiled for ARM926EJ-S fail with SIGILL.

GDB output:

Program received signal SIGILL, Illegal instruction.
0xb6e514c4 in ?? ()
(gdb) display/i $pc
1: x/i $pc
=> 0xb6e514c4:  mcr     15, 0, r0, cr7, cr10, {5}

Steps

  1. Build binary with
set RUSTFLAGS=-C target-cpu=arm926ej-s -C linker=arm-unknown-linux-gnueabi-gcc
cargo build --bin cf-debug-helper-server --release --target=arm-unknown-linux-gnueabi
  1. Run binary on target system.
  2. Illegal instruction

Possible Solution(s)

No response

Notes

No response

Rustup version

rustup 1.28.1 (f9edccde0 2025-03-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.85.0 (4d91de4e4 2025-02-17)`

Installed toolchains

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\oli011\.rustup

installed toolchains
--------------------
stable-x86_64-pc-windows-msvc (active, default)

active toolchain
----------------
name: stable-x86_64-pc-windows-msvc
active because: it's the default toolchain
installed targets:
  arm-unknown-linux-gnueabi
  x86_64-pc-windows-msvc

OS version

Build: Windows 11 26100.3476
Target: Linux 3.10.108
@oold
Copy link
Author

oold commented Mar 18, 2025

Backtrace with symbols:

Program received signal SIGILL, Illegal instruction.
core::sync::atomic::atomic_store<isize> (dst=0xb6f49514 <std::sys::pal::unix::args::imp::ARGC>,
    val=1, order=core::sync::atomic::Ordering::Relaxed)
    at C:\Users\oli011\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\sync/atomic.rs:3716
3716            match order {
(gdb) bt
#0  core::sync::atomic::atomic_store<isize> (
    dst=0xb6f49514 <std::sys::pal::unix::args::imp::ARGC>, val=1,
    order=core::sync::atomic::Ordering::Relaxed)
    at C:\Users\oli011\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\sync/atomic.rs:3716
rust-lang/rustup#1  0xb6d0d040 in core::sync::atomic::AtomicIsize::store (
    self=0xb6f49514 <std::sys::pal::unix::args::imp::ARGC>, val=1,
    order=core::sync::atomic::Ordering::Relaxed)
    at C:\Users\oli011\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\sync/atomic.rs:2728
rust-lang/rustup#2  0xb6d82edc in std::sys::pal::unix::args::imp::really_init (argc=1, argv=0xbea69de4)
    at src\sys\pal\unix/args.rs:136
rust-lang/rustup#3  0xb6d82f24 in std::sys::pal::unix::args::imp::ARGV_INIT_ARRAY::init_wrapper (argc=1,
    argv=0xbea69de4, _envp=0xbea69dec) at src\sys\pal\unix/args.rs:163
rust-lang/rustup#4  0xb658e9d8 in __libc_start_main () from target:/lib/libc.so.6
rust-lang/rustup#5  0xb67b3bd0 in _start () at ../sysdeps/arm/start.S:105
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

@rami3l
Copy link
Member

rami3l commented Mar 18, 2025

@rustbot transfer rust-lang/rust

@rustbot rustbot transferred this issue from rust-lang/rustup Mar 18, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 18, 2025
@rami3l
Copy link
Member

rami3l commented Mar 18, 2025

(Transferring since it looks like it's about rustup's use of Rust instead of rustup itself. Please correct me if this is not the case.)

@taiki-e
Copy link
Member

taiki-e commented Mar 18, 2025

IIRC ARM926EJ-S is Armv5TE, so I think you have to use armv5te-unknown-linux-gnueabi (Armv5TE) instead of arm-unknown-linux-gnueabi (Armv6).

@oold
Copy link
Author

oold commented Mar 18, 2025

Using armv5te-unknown-linux-gnueabi also results in an illegal mcr instruction being emitted.

@taiki-e
Copy link
Member

taiki-e commented Mar 18, 2025

Hmm, maybe just changing the target is not enough, because if the linked library is armv6, the final binary will be too.

Could you tell us the result of the arm-unknown-linux-gnueabi-readelf --arch-specific /path/to/binary?

@oold
Copy link
Author

oold commented Mar 18, 2025

Oh, sorry. That was a user error. I've uploaded the wrong binary. It works with armv5te-unknown-linux-gnueabi.

@oold oold closed this as completed Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This issue may need triage. Remove it if it has been sufficiently triaged.
Projects
None yet
Development

No branches or pull requests

4 participants