plt section with cortex m4

Asked by mich

Hi all,
I'm writing a boot loader for STM32F4 DISCOVERY that embeds a cortex m4 core. The BOOT LOADER need PIC code, I tried different compiler and linker options, but I can't get no plt section, only got and got.plt. I saw this fixed bug https://sourceware.org/bugzilla/show_bug.cgi?id=16017 and then I thought that you could get the plt sections, was I wrong?

Kind regards
Michele Marra

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andre Vieira (andre-simoesdiasvieira) said :
#1

Hi Michele,

Could you execute the same command line to compile with -v appended and copy paste the output?

Cheers,
Andre

Revision history for this message
mich (mich79) said :
#2

Hi Andre,
thank you for your answer, I got the plt section using the -pie option.
Previously I was using -fpic for compiling and -fpie for linking. I'm working with OPENSTM32 (System Workbench for STM32) and "GNU ARM Eclipse" by Livius, then I'm not using command line.
For now I have treated only the case in which there are global variables (no external function). I wrote the startup files in PIC assembly and wrote a program that extracts the PT_LOAD segments from the ELF executable and relocates symbols pointed out by the Section GOT. It works great!
Now I have to figure out how to achieve something similar with functions. Unfortunately I have not understood yet the meaning of the code contained in the PLT section, but this is due to my ignorance on these topics!

Kind regards
Michele Marra

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#3

Hi Michele,

I am a bit confused at what you are asking. Do you want PLT or not? My reading of your first message is that you do not want it but cannot manage to get rid of it.

One thing that confuses me is that you use -fpic for compiling and -fpie for linking. GCC manual says you should use -fpic/-fPIC for compiling and and nothing for linking or -fpie/-fPIE for compiling and -pie for linking (see documentation for -pie).

As to your last question, PLT is used to do lazy resolution of function symbols, that is, the address associated with a function is only resolved the first time the function is called. That makes loading faster. The code sequence in the PLT is used to push on the stack an identifier for the function being called and then call the dynamic loader that will perform the relocation in the associated GOT entry.

Best regards.

Revision history for this message
mich (mich79) said :
#4

Hi Andre, thanks for your explanations.
I'm sorry if I have not explained well, this is due to my lack of knowledge on these topics.
I read this article on the ARM website:
https://community.arm.com/groups/tools/blog/2015/05/12/easy-as-pie--creating-bare-metal-position-independent-executables-with-arm-compiler-6
I'm trying to achieve something similar using the GNU tools.

Kind regards

Revision history for this message
mich (mich79) said :
#5

Sorry Thomas,
the last answer was for you

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#6

Hi Michele,

Sadly, unless I missed something, this does not seem to be possible with the GNU toolchain. To support position independent executable there needs a way to process relocation at load or runtime in order to set the actual address of symbols. I did not code to do that in newlib.

Best regards.

Can you help with this problem?

Provide an answer of your own, or ask mich for more information if necessary.

To post a message you must log in.