linking problem wuth crt0.o

Michael Eager eager@eagercon.com
Fri May 4 01:16:00 GMT 2007


salut ! wrote:
> hello !
> 
> Here is my problem  :
> 
> I am trying to link a simple c program, which only increments a variable,
> with crt0.o.
> I am working with gnuarm-3.4.3 on a linux x 86 machine.

Gcc-help is the mailing list for help with GCC.  Questions
about the linker and other binutils should be addressed to
binutils@sources.redhat.com.

> when I enter the command : 
> /gnuarm-3.4.3/bin/arm-elf-ld -o incrementation.x crt0.o incrementation.o
> 
> I get : 
> incrementation.o(.text+0xf4):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> multiple definition of `_mainCRTStartup'
> crt0.o(.text+0x0):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> first defined here
> incrementation.o(.data+0x10): In function `__stack_base__':
> : multiple definition of `__stack_base__'
> crt0.o(.data+0x8):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:38:
> first defined here
> incrementation.o(.text+0xf4):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> multiple definition of `_start'
> crt0.o(.text+0x0):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> first defined here
> incrementation.o(.text+0xf4):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> multiple definition of `start'
> crt0.o(.text+0x0):../../../../../../newlib-1.12.0/newlib/libc/sys/arm/crt0.S:36:
> first defined here
> 
> I would be really grateful if someone could tell me what it means.
> Thank you in advance !

The linker messages are self-explanatory.  There are more than
one definition for _start, start, and the other symbols.  The
messages tell you where the linker found both the original
and the duplicate definitions.   It even tells you the offsets
in the object files, the source file names and line numbers.

It appears that the object file for incrementation.o was
actually built using the source for crt0.S.  Explains the
duplicate definitions.

BTW, it's almost always a bad idea to use the linker by itself.
You are much better using the gcc driver (cleverly named gcc)
which will invoke the linker and pass it object files and
the correct options.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Gcc-help mailing list