i\'m trying to create a dynamically linked executable (elf_i386) without gcc. The program is very simple (only a printf)...here the commands:
$ gcc -c simple
Lose the --entry main
. main
isn't your entry point, _start
is. Try this:
$ gcc -c hello.c
$ ld -o hello -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o hello.o -lc /usr/lib/crtn.o
$ ./hello
hello, world
$
It is not necessary to include the C
run time environment i guess unless you are using return
from your main()
.
We can strip the CRT and just link using :
ld -o hello -lc -dynamic-linker /lib/ld-linux.so.2 hello.o -e main
Will work.