ARM Assembly illegal hardware instruction ./executable

21 Views Asked by At

I am trying to execute a simple assembly program that simply indirect addresses an array. This is my .s file:

.global _start

_start:
    ldr x0, =list

.data
list:
    .word 1,-2,3,-4,5,-6

But, when I assemble, link and try to execute it, I get this error:

$ make play
as -arch arm64 -o play.o play.s
ld -o play play.o -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _start -arch arm64

$ ./play
[1]    2274 illegal hardware instruction  ./play

What is interesting is, when I keep trying to execute it, I get a different number before the "illegal hardware instruction" like so:

❯ ./play
[1]    2278 illegal hardware instruction  ./play
❯ ./play
[1]    2281 illegal hardware instruction  ./play
❯ ./play
[1]    2285 illegal hardware instruction  ./play
❯ ./play
[1]    2288 illegal hardware instruction  ./play
❯ ./play
[1]    2292 illegal hardware instruction  ./play
❯ ./play
[1]    2303 illegal hardware instruction  ./play
❯ ./play
[1]    2306 illegal hardware instruction  ./play
❯ ./play
[1]    2309 illegal hardware instruction  ./play
❯ ./play
[1]    2313 illegal hardware instruction  ./play
❯ ./play
[1]    2317 illegal hardware instruction  ./play
❯ ./play
[1]    2320 illegal hardware instruction  ./play

And it seems that the longer I wait before executing again, the difference between the numbers get larger.

Any help is greatly appreciated.

Hardware: M2 chip
Architecture: Armv8 (I think M series chips use Armv8)
OS: macOS Sonoma 14.3.1
Assembler: Aarch64

0

There are 0 best solutions below