Hi, I am trying to compile a C++ program using templates for uClinux. I get massive problems with weak symbols - it looks like the elf2flt and/or ld is not able to use the weak symbols. The toolchain is a self-compiled binutils 2.17, gcc 4.2.1-based one.
Compiling and linking the files in attach gets me bogus message ERROR: text=0xbec0 overlaps data=0x0 ? collect2: ld returned 1 exit status The code compiles fine with -fno-weak, but this is an unsupported flag and creates other problems. objdump gives me (uninteresting debug/comment sections stripped): weak1.o: file format elf32-littlearm Sections: Idx Name Size VMA LMA File off Algn 0 _ZN7MyClassIiEC1Ev 00000008 00000000 00000000 00000034 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 1 _ZN7MyClassIiED0Ev 00000008 00000000 00000000 0000003c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 2 _ZN7MyClassIiED1Ev 00000008 00000000 00000000 00000044 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 3 _ZTV7MyClassIiE 00000008 00000000 00000000 0000004c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 4 .text 00000070 00000000 00000000 00000054 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 5 .data 00000000 00000000 00000000 000000c4 2**0 CONTENTS, ALLOC, LOAD, DATA 6 .bss 00000000 00000000 00000000 000000c4 2**0 ALLOC 10 .text._ZN7MyClassIiEC1Ev 00000028 00000000 00000000 0000046c 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 11 .text._ZN7MyClassIiED0Ev 00000040 00000000 00000000 00000494 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 12 .text._ZN7MyClassIiED1Ev 00000040 00000000 00000000 000004d4 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 13 .rodata._ZTV7MyClassIiE 00000010 00000000 00000000 00000514 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA weak2.o: file format elf32-littlearm Sections: Idx Name Size VMA LMA File off Algn 0 _ZN7MyClassIiEC1Ev 00000008 00000000 00000000 00000034 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 1 _ZN7MyClassIiED0Ev 00000008 00000000 00000000 0000003c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 2 _ZN7MyClassIiED1Ev 00000008 00000000 00000000 00000044 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 3 _ZTV7MyClassIiE 00000008 00000000 00000000 0000004c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 4 .text 00000048 00000000 00000000 00000054 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 5 .data 00000000 00000000 00000000 0000009c 2**0 CONTENTS, ALLOC, LOAD, DATA 6 .bss 00000000 00000000 00000000 0000009c 2**0 ALLOC 10 .text._ZN7MyClassIiEC1Ev 00000028 00000000 00000000 000003c8 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 11 .text._ZN7MyClassIiED0Ev 00000040 00000000 00000000 000003f0 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 12 .text._ZN7MyClassIiED1Ev 00000040 00000000 00000000 00000430 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 13 .rodata._ZTV7MyClassIiE 00000010 00000000 00000000 00000470 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA The elf-linked file as produced by the elf2flt script: weak.elf: file format elf32-littlearm Sections: Idx Name Size VMA LMA File off Algn 0 _ZN7MyClassIiEC1Ev 00000008 00000000 00000000 00000034 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 1 _ZN7MyClassIiED0Ev 00000008 00000000 00000000 0000003c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 2 _ZN7MyClassIiED1Ev 00000008 00000000 00000000 00000044 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 3 _ZTV7MyClassIiE 00000008 00000000 00000000 0000004c 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD 4 .text 0000bec0 00000000 00000000 00000060 2**4 CONTENTS, ALLOC, LOAD, RELOC, CODE 5 .text._ZN7MyClassIiEC1Ev 00000028 00000000 00000000 0000bf20 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 6 .text._ZN7MyClassIiED0Ev 00000040 00000000 00000000 0000bf48 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 7 .text._ZN7MyClassIiED1Ev 00000040 00000000 00000000 0000bf88 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 8 .rodata._ZTV7MyClassIiE 00000010 00000000 00000000 0000bfc8 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 9 .data 00001130 0000bec0 0000bec0 0000bfd8 2**2 CONTENTS, ALLOC, LOAD, RELOC, DATA 10 .bss 00000a50 0000cff0 0000cff0 0000d108 2**2 ALLOC 11 .stack 00000000 00000010 00000010 0000d108 2**0 CONTENTS 18 .note.GNU-stack 00000000 00000000 00000000 0000ef80 2**0 CONTENTS, READONLY, CODE The .gdb linked file looks ok: weak.gdb: file format elf32-littlearm Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000bf60 00000000 00000000 00008000 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .data 00001110 0000bf60 0000bf60 00013f60 2**2 CONTENTS, ALLOC, LOAD, DATA 2 .bss 00000a50 0000d070 0000d070 00015070 2**2 ALLOC 3 .comment 000001c6 00000000 00000000 00015070 2**0 CONTENTS, READONLY I don't understand the linker script and flags enough to be able to debug and fix this - it looks like the elf2flt step has problems with LINK_ONCE_DISCARD or .text.* symbols and is not able to put them to the .text section where they belong. Any hints? Regards -- Stano
#include "weak.h" void foo() { MyClass<int> c; } main(int argc, char **argv) { }
#include "weak.h" void bar() { MyClass<int> c; }
template <typename T> class MyClass { public: virtual ~MyClass() {} private: T m; };
_______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev