Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 593 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: invalid instruction suffix for `push'

#1
I am trying to study passing arguments into a function via stack in assembly. I am using fedora 20, a 64-bit system.

when I try the following code,
```assembly
pushl %ebp

popl %ebp
```
I get the error,
```Error: invalid instruction suffix for `push'```

how will I overcome this error!

i compiled it by,
as -ggstabs -o Function_Stack.o Function_Stack.c
Reply

#2
The error you're getting comes out from a very simple fact : the `push` instruction in 32-bit mode accepts 16-bit and 32-bit immediates as arguments. However, the `push` instruction used in 64-bit mode accepts only 16-bit and 64-bit immediates. Since you're clearly compiling your code as 64-bit, the assembler throws an error, since it cannot possibly encode such an instruction. Also, do keep in mind that you force the operand size yourself by adding the `l` suffix to the `push` instruction. Everything I just wrote here is exactly the same for `pop`, except that it accepts registers/memory, not immediates.

However, you also **need** to keep in mind the differences in the ABI between 32-bit and 64-bit Linux systems. The ABI specifies, among other things, how parameters are passed to functions, and how to call the kernel from user-mode applications. Your code is clearly written for 32-bit mode, seeing how it uses the stack for passing arguments and the (very) obsolete `int $0x80` way of invoking syscalls. In order to learn about the 64-bit ABI, see [this document][1].

Alternatively, you have the option of compiling 32-bit code on a 64-bit system. Such an executable will work if you have the necessary 32-bit runtime libraries installed on your 64-bit system. Most distributions allow you to do that in different ways. Your compiler, `as`, has the `--32` switch for emitting 32-bit code.

[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through