koldewb
koldewb

Reputation: 462

Assembly unknown mnemonic AArch64 ARMv8

I'm trying to compile a project (from GitHub: link) with a couple of assembly files, which are written for the ARMv8 AArch64 architecture. When I try to compile these files I get the same error on pretty much every line, it starts with:

authenc_ac_gcm_low.S: Assembler messages:

authenc_ac_gcm_low.S:80: Error: unknown mnemonic `ld1.16b' -- `ld1.16b {v0},[x1]'
authenc_ac_gcm_low.S:81: Error: unknown mnemonic `rbit.16b' -- `rbit.16b v0,v0'
authenc_ac_gcm_low.S:82: Error: unknown mnemonic `st1.16b' -- `st1.16b {v0},[x0]'
authenc_ac_gcm_low.S:90: Error: unknown mnemonic `ld1.16b' -- `ld1.16b {v24},[x0]'
authenc_ac_gcm_low.S:92: Error: unknown mnemonic `ld1.16b' -- `ld1.16b {v0,v1,v2,v3},[x1],#64'
authenc_ac_gcm_low.S:93: Error: unknown mnemonic `ld1.16b' -- `ld1.16b {v4,v5,v6,v7},[x1]'

Small part of the code:(line 78 till 87)

ac_gcm_convert_low:
_ac_gcm_convert_low:
    ld1.16b {v0}, [x1]
    rbit.16b v0, v0
    st1.16b {v0}, [x0]
    ret

ac_gcm_ghash_low:
_ac_gcm_ghash_low:
    cbz x3, exit //this might be the only line it doesn't error

I'm using the Linaro cross compiler for AArch64, for compiling I make use of the -mcpu=cortex-a53+crypto flag; not doing this results in "no such instruction" errors. I have very little experience with Assembly and obviously I make some mistake here, but I can't find it. How to get rid of the errors?

Upvotes: 4

Views: 17015

Answers (1)

Notlikethat
Notlikethat

Reputation: 20984

Looks like that's the wonky Apple syntax - GCC uses the marginally-more-verbose architectural syntax, where the size specifiers go on each register argument, rather than the instruction itself, e.g.

ld1 {v0.16b}, [x1]
rbit v0.16b, v0.16b
st1 {v0.16b}, [x0]

I don't believe AArch64 binutils has any way to support the Apple syntax, so I think the available solutions are limited to "fix the code up manually" or "try Clang/LLVM instead".

Upvotes: 4

Related Questions