Page 1 of 1

Wierd cross-compiler problem

Posted: Sat Mar 17, 2007 6:15 am
by ucosty
I've been osdeving on and off for a while. For background I am using cygwin and a cross compiler created using the tutorial on the wiki.

When I make my project, I get this error at the linking stage.

Code: Select all

/usr/cross/bin/i586-elf-ld.exe -T kernel.ld -o kernel.elf kernel/init/init.o kernel/memory/mm.o

kernel/memory/mm.o: In function `_end':
mm.cpp:(*ABS*+0x8049074): multiple definition of `__bss_start'
mm.cpp:(*ABS*+0x8049074): multiple definition of `_edata'
mm.cpp:(*ABS*+0x8049074): multiple definition of `_end'
make: *** [kernel.elf] Error 1
Each .o file is being given these symbols by G++ (I used objdump -x)

Code: Select all

08049074 g       *ABS*  00000000 __bss_start
08049074 g       *ABS*  00000000 _edata
08049074 g       *ABS*  00000000 _end
My compilation string for each CPP file like this:

Code: Select all

/usr/cross/bin/i586-elf-g++.exe -Wall -Wextra -pedantic -I./kernel/headers -nostdinc -fno-builtin -n
ostdlib -fno-rtti -fno-exceptions kernel/init/init.cpp -o kernel/init/init.o
Pretty generic, it just disables everything and makes sure there are a pile of warnings. There are no warnings or errors during the compilation process. None of those symbols are referenced in any of the source files.

I have fairly extensively googled for any leads and haven't found anything useful.

I then completely disassembled my xcompiler and rebuilt it using earlier matching versions of GCC/G++ and Binutils.

Code: Select all

gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
I am pretty damn confused. Anybody come across this before? Any help would be muchly appreciated. :)

Posted: Sat Mar 17, 2007 5:16 pm
by pcmattman
Your GCC command doesn't have a '-c' option, so GCC is automatically linking as well, which you definitely don't want.

Try this:

Code: Select all

/usr/cross/bin/i586-elf-g++.exe -Wall -Wextra -pedantic -I./kernel/headers -nostdinc -fno-builtin -n 
ostdlib -fno-rtti -fno-exceptions -c kernel/init/init.cpp -o kernel/init/init.o 
If you don't tell GCC to 'just compile' then it'll try to compile and link into kernel/init/init.o... when you try to link this, the errors come because init.o is an already-linked file.

Posted: Sat Mar 17, 2007 11:05 pm
by ucosty
You know... it's the smallest things you miss. :roll:

Thanks

Posted: Sat Mar 17, 2007 11:20 pm
by pcmattman
No worries, it usually takes a fresh look at something to figure out what's wrong with it.

I take it you now have everything working?