Hello,
I'm actually learning assembly and I have a problem even though I am copying word for word what my book tells me. Here's the code:
1 .section .data
2 helloworld:
3 .ascii "hello world\n\0"
4 .section .text
5 .globl _start
6 _start:
7 pushq $helloworld
8 call printf
9 pushq $0
10 call exit
(there used to be 'pushl's but as I am using an AMD64 I had to replace them with 'pushq's)
It is then written that I must compile and link in this way:
as helloworld-lib.s -o helloworld-lib.o
ld -dynamic-linker /lib/ld-linux.so.2 \
-o helloworld-lib helloworld-lib.o -lc
It works without printing out an error but during execution of the newly generated executable, it crashes immediately and I get this:
"bash: ./helloworld-lib: Accessing a corrupted shared library"
I also tried replacing "-dynamic-linker /lib/ld-linux.so.2" by "-dynamic-linker /lib/ld-linux-x86-64.so.2" but I get this error now when I execute "Illegal instruction".
After checking with gdb, I conclude that the SIGILL is sent during the fprintf function call.
Any idea how I could solve this problem?
Thanks.