This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld: creating a dynamically linked executable ...

> $> 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
> /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

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.]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]