Problem linking assembly program with C lib.
I am trying to link my simple program to the C library, here is the code:
example.asm Code:
segment .data Code:
nasm -f elf example.asm Code:
./example bash: ./example: No such file or directory If I omit the printf call, and don't link with the C library (don't include the -lc) then it runs it fine. Can anyone tell me what is wrong? |
Nevermind, I got it. The C library uses it's own entry point for your program. I guess the C library has to do some stuff first (and some stuff afterwards). It then calls your programs main. So, instead of _start, it's main. And I shouldn't have used linux's exit system call, but just return instead. The C library flushes the buffers and frees the files and whatnot. Example:
new_example.asm Code:
extern printf gcc -o new_example new_example.o |
All times are GMT -5. The time now is 06:05 AM. |