This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: undefined reference to __aeabi_unwind_cpp_pr1, __cxa_end_cleanup
Ian,
I'm now trying to build the binary with the standard libraries built
in. In the linking stage, gcc throws two assertion failures and some
undefined references - __exidx_end, __exidx_start, __fini_array_start,
__fini_array_end, __preinit_array_end, __preinit_array_start,
__init_array_start, __init_array_end.
$ cross-linux-gnueabi-g++ -static -T temp.ld -o output_file abc.o
xyz.o -lc -lgcc -lsupc++
/tools/…c ross-linux-gnueabi/bin/ld: BFD (Sourcery G++ Lite 2008q3-41)
2.18.50.20080215 assertion fail
cross-linux-gnueabi-i686-pc-linux-gnu/bfd/elf.c:3916
/tools/…cross-linux-gnueabi/bin/ld: BFD (Sourcery G++ Lite 2008q3-41)
2.18.50.20080215 assertion fail
..linux/obj/binutils-src-2008q3-41-arm-none-linux-gnueabi-i686-pc-linux-gnu/bfd/elf.c:3916
/tools/vendor/arm/gnu_crosstools/codesourcery/arm-2008q3/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/libgcc_eh.a(unwind-arm.o):
In function `ge
t_eit_entry':
unwind-arm.c:(.text+0x72c): undefined reference to `__exidx_end'
unwind-arm.c:(.text+0x730): undefined reference to `__exidx_start'
/tools/..-linux-gnueabi/libc/usr/lib/libc.a(elf-init.o): In function `__libc_csu
_fini':
elf-init.c:(.text+0x38): undefined reference to `__fini_array_start'
elf-init.c:(.text+0x3c): undefined reference to `__fini_array_end'
/tools/..-linux-gnueabi/libc/usr/lib/libc.a(elf-init.o): In function `__libc_csu
_init':
elf-init.c:(.text+0xc8): undefined reference to `__preinit_array_end'
elf-init.c:(.text+0xcc): undefined reference to `__preinit_array_start'
elf-init.c:(.text+0xd0): undefined reference to `__init_array_start'
elf-init.c:(.text+0xd4): undefined reference to `__init_array_end'
collect2: ld returned 1 exit status
I tried adding a couple of libraries but it didn't help.
I also want to rewrite the "_start" function in assembly. If I add
this file in, g++ complains that _start is defined twice. Is there a
way to do this?
JJ
On Mon, Oct 26, 2009 at 10:01 AM, Ian Lance Taylor <iant@google.com> wrote:
> JJ <alchemistmba@gmail.com> writes:
>
>>> _aeabi_unwind_cpp_pr1 is normally defined in libgcc. ?If the undefined
>>> reference is coming from libc, then you need to use -lgcc -lc -lgcc
>>> (and, yes, sometimes you need -lgcc -lc -lgcc -lc -lgcc, which you can
>>> also write as -Wl,--start-group,-lgcc,-lc,--end-group).
>>
>> It still complains about _aeabi_unwind_cpp_pr1. If I use only -lgcc,
>> the linker complains about both? "_aeabi_unwind_cpp_pr1"
>> "__cxa_end_cleanup" as well as "memset". I added the -lc option to get
>> rid of the "memset" undefined reference error.
>
> Does your libgcc define _aeabi_unwind_cpp_pr1? ?If not, then you will
> need to figure out why it doesn't. ?It should normally be defined in
> an arm-eabi libgcc.
>
>
>>> __cxa_end_cleanup is normally defined lib libsupc++. ?Since you are
>>> linking C++ code with -nodefaultlibs, you probably need an explicit
>>> -lsupc++.
>>
>> When I add this option, it complains about many more standard symbols:
>> strlen, free, malloc, __aeabi_unwind_cpp_pr0, __cxa_pure_virtual etc.
>
> You may need to write your own __cxa_end_cleanup.
>
> Ian
>