User-land linker - duplicate symbols
Posted: Tue Sep 25, 2007 3:09 am
Hi,
I'm having a few problems compiling my kernel on another machine. It's using a slightly different (updated) version of G++ and binutils.
Every user-land program is linked with a shared library of kernel functions, so that any undefined symbols can be linked to kernel symbols dynamically at runtime. This works fine. However, on this new machine, the linker is complaining of duplicate new(), new[](), delete() and delete[]() symbols (One set for the kernel, defined in kernel files and exposed as a side-effect in libkernel.so, and another for user-land allocation, in _premain.cc (src/lib/lib.a) ).
With any other symbols I could just rename them or extern "C" them to get around this, but new and delete etc are a bit special, I can't rename them. Does anyone have any ideas as to how to tell the linker to ignore duplicate symbols in the library libkernel.so? (I've tried the obvious linker command-line options).
Cheers guys.
{linker cmd}
{linker output}
JamesM
I'm having a few problems compiling my kernel on another machine. It's using a slightly different (updated) version of G++ and binutils.
Every user-land program is linked with a shared library of kernel functions, so that any undefined symbols can be linked to kernel symbols dynamically at runtime. This works fine. However, on this new machine, the linker is complaining of duplicate new(), new[](), delete() and delete[]() symbols (One set for the kernel, defined in kernel files and exposed as a side-effect in libkernel.so, and another for user-land allocation, in _premain.cc (src/lib/lib.a) ).
With any other symbols I could just rename them or extern "C" them to get around this, but new and delete etc are a bit special, I can't rename them. Does anyone have any ideas as to how to tell the linker to ignore duplicate symbols in the library libkernel.so? (I've tried the obvious linker command-line options).
Cheers guys.
{linker cmd}
Code: Select all
/usr/local/bin/i386-elf-g++ -I../../newlib-1.15.0/newlib/libc/include/ -I../../src/ -I../../newlib-1.15.0/newlib/libc/sys/jimix/include/ -nostdlib -fno-stack-protector -m32 -fno-rtti -fno-builtin ../../src/lib/crt0.o -o test main.o -L/home/jamesmol/trunk/jimix/src ../../src/lib/lib.a -L/home/jamesmol/trunk/jimix/newlib-1.15.0/newlib -lc -lkernel
Code: Select all
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `syscall(unsigned int)':
(.text+0x7e98): multiple definition of `syscall(unsigned int)'
../../src/lib/lib.a(libcWrapper.o):libcWrapper.cc:(.text+0x0): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `operator new(unsigned long)':
(.text+0x314c): multiple definition of `operator new(unsigned long)'
../../src/lib/lib.a(_premain.o):_premain.cc:(.text+0x1b8): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `memcpy':
(.text+0x2a78): multiple definition of `memcpy'
/home/jamesmol/trunk/jimix/newlib-1.15.0/newlib/libc.a(lib_a-memcpy.o):memcpy.S:(.text+0x0): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `operator delete(void*)':
(.text+0x30c8): multiple definition of `operator delete(void*)'
../../src/lib/lib.a(_premain.o):_premain.cc:(.text+0x18c): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `syscall1(unsigned int, int)':
(.text+0x7eac): multiple definition of `syscall1(unsigned int, int)'
../../src/lib/lib.a(libcWrapper.o):libcWrapper.cc:(.text+0x14): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `operator delete[](void*)':
(.text+0x30ac): multiple definition of `operator delete[](void*)'
../../src/lib/lib.a(_premain.o):_premain.cc:(.text+0x176): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `strcmp':
(.text+0x2a94): multiple definition of `strcmp'
/home/jamesmol/trunk/jimix/newlib-1.15.0/newlib/libc.a(lib_a-strcmp.o):strcmp.c:(.text+0x0): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `operator new[](unsigned long)':
(.text+0x30e4): multiple definition of `operator new[](unsigned long)'
../../src/lib/lib.a(_premain.o):_premain.cc:(.text+0x1a2): first defined here
/home/jamesmol/trunk/jimix/src/libkernel.so: In function `__bss':
(.bss+0x100c): multiple definition of `currentKernelStack'
../../src/lib/lib.a(_premain.o):(.bss+0x10): first defined here
collect2: ld returned 1 exit status