Wierd cross-compiler problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Wierd cross-compiler problem

Post 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. :)
The cake is a lie | rackbits.com
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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.
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

You know... it's the smallest things you miss. :roll:

Thanks
The cake is a lie | rackbits.com
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post 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?
Post Reply