Donovaaan
Donovaaan

Reputation: 11

Illegal instruction CMOVE - Compile for i586

I have a x86_64 machine and want to compile for a machine, which has i586 arch.

I installed: libc6-dev-x32 and libc6-dev:i386

Then I tried to compile a simple hello world like this:

gcc -m32 -march=i586 -mcpu=i586 test.c -o test -static

It works on my machine but on the target I get the illegal instruction error on the CMOVE instruction. So he doesn't know CMOVE.

How can I solve this problem?

Upvotes: 0

Views: 417

Answers (2)

J.J. Hakala
J.J. Hakala

Reputation: 6214

A quick check on debian / jessie, and command

objdump -D /lib32/libc-2.19.so | grep cmove

reveals that there are cmove instructions there. wikipedia mentions that they were added for pentium pro.

According to this blog

Sept. 2014 update: GCC and other dev tools are now part of the official linux image you can download from Intel Developer Zone.

there should be something available either IoT installers page or Software Downloads for Boards and Kits

Building a cross-compiler toolset could be another option.

Upvotes: 0

Ctx
Ctx

Reputation: 18410

You statically link against the glibc of your host system, which makes use of the CMOV*-instructions. So compiler switches won't help.

One option is to link against dietlibc:

  • Install the package dietlibc-dev:i386

  • Link against it: diet gcc -m32 -march=i586 -mcpu=i586 test.c -o test -static

Now your binary should not include the offending instructions.

Upvotes: 2

Related Questions