Topic : _fini section in linker script

Forum : ARM

Original Post
Post Information Post
April 29, 2009 - 11:20am
Guest

Hi all.

First of all, thank you for reading my post. I am currently writing a project for the STM32 ARM cortex M3.

I use the default startup and linker files in the project.

I have to use some parts of the libc (stdio, etc) which seems to require lib_a-fini.o. But the compiler complains :

c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fini.o): In function `__libc_fini_array':
fini.c:(.text+0x28): undefined reference to `_fini'

As I use Raisonance's defaults script files, I tried to look inside the different .ld files : first the automatically generated STM32F101_256K_32K_FLASH.ld, then the sections_FLASH.ld file.
I wasn't able to see a .fini section.

Could someone please help me to solve this problem ?

Thank you very much !

Sam

Replies
Post Information Post
+1
0
-1
April 29, 2009 - 2:14pm
Raisonance Support Team

Hi,

There is no .fini or ._fini section in the linker script. The linker error you report means that the "_fini" symbol is missing. Or are there other messages that made you think it was referring to a section?

Now, _fini is an obsolete function used to initialize things for dynamic linking. So the _fini symbol should not be required unless you are using the tools in some unusual (and quite possibly invalid) way. The sure thing is we have made and validated applications that use parts of stdio using all the official versions of Ride for ARM and we never got this error. We will need more information for answering more precisely...

Which version of Ride are you using? (we need the versions of both the Ride and ARM kits)
Are you doing C++?
Dynamic linking?
Dynamic memory allocation?
Are you using a Makefile?
Have you typed anything in the 'More' linker option?
Can you send us a project that shows the problem?
(to 'support@raisonance.com', send a zip of the complete project's folder and include a link to this thread in the email)

Best Regards,

Vincent

+1
0
-1
April 29, 2009 - 2:34pm
Guest

Dear Vincent,

Thank you very much for your answer.

I just send you the file as an attachment.

No, there’s nothing else that let me think that it was referring to a section. I looked on internet what I was able to find, and several places talked about a section missing in the linker script.

Here’s the complete linking process :

Building STmicroWin1.rapp
Running: LD
\"C:\Program Files\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gcc.exe" -mcpu=cortex-m3 -mthumb -Wl,-T -Xlinker "D:\Projects\SB\RTOS\Own\App\Ride7\STmicroWin1.elf.ld" -u _start -Wl,-static -Wl,--gc-sections -nostartfiles -Wl,-Map -Xlinker "D:\Projects\SB\RTOS\Own\App\Ride7\STmicroWin1.map"
c:/program files/raisonance/ride/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.3.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fini.o): In function `__libc_fini_array':
fini.c:(.text+0x28): undefined reference to `_fini'
collect2: ld returned 1 exit status

Build failed

To answer all of your questions : I use Ride7 version 7.16.00 with RKit-ARM version 1.16.0930
I only do C
I don’t do dynamic linking (I only want static, but maybe I set a wrong parameter ??)
I do dynamic memory allocation, but using another allocator than malloc and free (TLSF to be exact)
I use no makedile
I typed nothing in the “More” linker option

Thank you again,

Sam

+1
0
-1
April 29, 2009 - 9:54pm
Guest

I just looked a bit around the code, and it looks like I have a call to the "exit" function (it's in winmain.c, just in case Vincent would like to check it). This is the function responsible for the _fini complain.

I don't need this function in my case, so I just replaced it by a simple return, and this solves my problem.

But maybe it doesn't explain what is happening ?

+1
0
-1
April 30, 2009 - 10:19am
Raisonance Support Team

Hi,

Calling the exit function, at least the version from gcc, makes little sense in your context. You should try to understand by which function and why it was called. I guess that there are other functions in your project that should not be called.

We haven't received your email. Can you post the map file of the version that compiles here?

Best Regards,

Vincent

+1
0
-1
May 4, 2009 - 9:11am
Guest

Hi !

I fully agree, that's why I replaced it by "return". I am trying to make several open sources projects to run together. My code contains almost nothing that I've written myself.

The map file is huge, about 450ko, but maybe I can send you a part of it here ? I retried to send the zip file to your support, could you confirm if you received it ?

By the way (sorry, it's out of this topic), I just noticed in the simulator that the SVC instruction of the ARM Cortex M3 is disassembled in a SWI instruction. I know it's the same opcode, but it could be a good idea to use the same notation than ARM and CodeSourcery's compiler. Maybe it's possible to correct this in Ride7 ? Are SVC calls correctly simulated by Ride ?

Best regards,

Sam