I am building a bare-metal code for ARM926 and I need the generated output to be as tight as possible.
In my best effort, though, I still receive this error:
yocto/poky/build-idprint/tmp/work/idprint-poky-linux-gnueabi/idpr/1.0-r0/
recipe-sysroot/usr/lib/libc.a(raise.o):
(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr1'
In my Makefile I put this linker flags:
LD_OPT = -Wl,-gc-sections -Wl,-build-id=none -flto
LD_LINK = -static -nostartfiles -nostdlib -Wl,--start-group,-lgcc,-lc,--end-group
LDFLAGS = -T $(BINARY).ld -Xlinker -Map=$(BINARY).map $(LD_OPT)
And the link command is
$(LINK.cc) $(OBJS) $(LD_LINK) src/lib_dummies.o -o $(BINARY).elf
Finally I have a custom linker script as simple as possible:
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(fiq_main)
SECTIONS
{
. = 0x0;
.text : {
KEEP(*(.textEntry));
*(.text*)
*(.text .gnu.linkonce.t.*)
}
. = ALIGN(1024);
_bss_start = .;
.data : { *(.data) }
.bss : { *(.bss) }
_bss_end = .;
}
I added a custom dummy __aeabi_unwind_cpp_pr1 to my code (inspired from libgcc sources) but it didn't help.
I have read about quite a few pages around the web but none explained me why is libgcc trying to link a C++ function to my C-only project.
Okay, $(LINK.cc) is evaluated to arm-poky-linux-gnueabi-g++ but I still se no sense trying to link a C++ function to libgcc. It would make sense if I was linking libstdc++. Moreover, $(LD) fails for othre reasons (can't find -lgcc).
No optimization flags I could find helped me with this either.
Look, it is very important that my code doesn't add any uneeded stuff.
Everything started only because I need to use integer division (unresolved __aeabi_idiv...)
I omitted the optimization flags for simplicity but, if needed, please tell me and I'll add them.
Any help will be greatly appreciated. Thanks.