undefined reference to `_fini'

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

danw
Posts: 2
Joined: Mon Aug 14, 2017 9:37 pm

undefined reference to `_fini'

Postby danw » Mon Aug 14, 2017 9:48 pm

Hi All,

I'm currently using ChibiStudio19 with GCC 6.3 and RT 17.6.0 on a STM32F765

When I try to use C++ classes like std::string and std::vector, I get the linker error:

Code: Select all

c:/chibistudio/tools/gnu tools arm embedded/6.3 2017q1/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv5/hard\libg.a(lib_a-fini.o): In function `__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x26): undefined reference to `_fini'
collect2.exe: error: ld returned 1 exit status

From what I gather, _fini() is run after main() which doesn't normally happen with a microcontroller. I can work around this by adding:

Code: Select all

__attribute__((used))
void _fini(void) { }

In syscalls.c. Is this the correct way to handle this? Are there any potential problems with this approach.

Thanks!

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: undefined reference to `_fini'

Postby Giovanni » Mon Aug 14, 2017 10:00 pm

Hi,

I think you should provide it in your application because it is there that you decide what to do in that function, if anything.

Is the exact purpose documented somewhere? it is possible that the startup code should provide a "weak" stub implementation.

Edit: I only find references of those functions in association with shared libs which make no sense in an embedded system and labeled as obsolete anyway.

Giovanni

danw
Posts: 2
Joined: Mon Aug 14, 2017 9:37 pm

Re: undefined reference to `_fini'

Postby danw » Mon Aug 14, 2017 10:25 pm

Hi Giovanni,

Thank you for the fast reply. I haven't been able to find much documentation but also saw that it was obsolete.

I agree that it doesn't make sense so I'm not sure why GCC is trying to link against it. I will place the stub in my application for now and leave it at that.

Thanks!


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 20 guests