0

Hi i am getting several errors while linking my ".s" file together.

  • First of all, i compile the file via "gcc -S -m32 search.c" to get my 32-bit assembler code.

  • Secondly i want to link the program back together by using "gcc -o
    search search.s"

If i do this i get the following error: "Error: invalid instruction suffix for `push." I tried to use google to solve the problem and found a solution by using the --32 option flag. But this did not work either. The following error shows up as an result: usr/bin/ld: i386 architecture of input file is incompatible with i386:x86-64 output. The third option by adding .code32 to the .s file, gcc let me compile it. Though by executing the console immediately says "core dumped".

So i really do not know what to do now. Anyone has an idea how i get things working?

Cheers

MrCotton
  • 47
  • 1
  • 7

1 Answers1

2

Assemble with --32, and link with -m32.

gcc -m32 -o search search.s

Without -m32, the output is going to be a 64-bit executable. The error message is due to the input object being a 32-bit object; you can't produce a 64-bit executable from 32-bit objects.

davmac
  • 20,150
  • 1
  • 40
  • 68