Undefined reference to '_fini'

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I don't know why, but I do get this linker message very often in XMC4000 applications.
What I do, is specifying it in the Linker script. This helps but might have side effects.

Who can tell me who is referring to it? What is the best way to avoid this linker message?

Heinz

Message is:

In function '__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x42): undefined reference to '_fini'



DAVE is 3.1.10
0 Likes
9 Replies
Not applicable
Heinz wrote:


In function '__libc_fini_array':
fini.c:(.text.__libc_fini_array+0x42): undefined reference to '_fini'



The problem was calling exit() from libc because the application was inherited from a Linux CANopen project.
I added my own version of exit().

Heinz
0 Likes
Not applicable
Hi Heinz,

Can you provide the details on where and how do you call the exit()? Would you mind to share your own version of exit() or even your project?

Best regards,
Sophia
0 Likes
Not applicable
sophia wrote:
Hi Heinz,

Can you provide the details on where and how do you call the exit()? Would you mind to share your own version of exit() or even your project?

Best regards,
Sophia


Hello Sophia,
for all our CANopen stuff we first develop the protocol stack and applications on a Linux machine.
Later on do test portability we try the same software on different embedded platforms like XMC using DAvE.
The Linux application typically calls exit(errorcode) if something goes wrong to finish a single program.
On the embedded platform you can not end a program. But what you can is specific to the hardware you have.
In he simplest case exit() can disable all interrupts and run an endless loop. If some LEDs are available,
they can be used to show the reason for stopping by using different LEDs, different colors or blinking sequences.
That said, the simplest version can be

void exit(int reason) { while(1); }

regards
Heinz
0 Likes
Not applicable
Hi Heinz,

The root cause is that the exit() function uses a NewLib routine "_fini" which needs to be defined in LibcStubs.c. Currently it is missing.
Pls follow up the eTicket 671808605.

Best regards,
Sophia
0 Likes
Not applicable
wrong Ticket Link ?
0 Likes
Not applicable
I'm not able to use the "Tickets Manager" and search for a specific Ticket Id. :mad:
0 Likes
Not applicable
Hi Heinz,

You should be able to search for a specific eTicket by input the id in Search field:

730.attach

In addition, thank you very much for the feedback. The ticket link has been corrected.

Best regards,
Sophia
0 Likes
Not applicable
Hello Sophia,

searching for the ticket Id only works if I'm NOT logged in. Which is a bit strange.
Heinz
0 Likes
Not applicable
Hi Heinz,

You need to check "All tickets" as it is not submitted by you.

775.attach

Best regards,
Sophia
0 Likes