ld: creating a dynamically linked executable ...
John Reiser
jreiser@bitwagon.com
Thu Jul 11 15:56:00 GMT 2013
> $> gcc -o use-of-lib use-of-lib.o
> use-of-lib.o: In function `_start':
> (.text+0x0): multiple definition of `_start'
> /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info):
> relocation 0 has invalid symbol index 11
<<snip>>
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o:/build/buildd/eglibc-2.15/csu/../sysdeps/i386/elf/start.S:119:
> first defined here
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/crt1.o: In
> function `_start':
> (.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status
use-of-lib.s has:
.global _start
_start:
When using gcc to perform static linking then the crt*.o routines define _start,
so your _start conflicts. Use 'main' instead. Also do "gcc -S hello.c"
(where hello.c is the obvious program which prints "Hello, world!\n")
then look at hello.s. [In general: when trying a new thing, then search
for previous examples which are related, and see what you can learn
from the similarities and from the differences.]
More information about the Binutils
mailing list