kinetis with fPIC (position independent code)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

kinetis with fPIC (position independent code)

2,271 Views
robotjosh
Contributor IV

Enabling -fPIC in kinetis design studio results in this error:

 

c:/freescale/kds_1.1.1/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: section .got loaded at [000012bc,000012cf] overlaps section .romp loaded at [000012bc,000012df]

 

I'm using kds 1.1.1 with FRDM-K22F, project has ksdk disabled and processor expert enabled.  Is there a way to use -fPIC or otherwise compile for position independent code on kinetis?  If not, is there a way to compile code to be placed in a specific flash address?  I'm trying to implement a bootloader.

Labels (1)
0 Kudos
Reply
2 Replies

1,069 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hello Josh,

GCC does support the compiler directive for position independent code, here are some links that might be helpful for you:

https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html

http://www.delorie.com/gnu/docs/gcc/gccint_143.html

http://www.embedded.com/design/mcus-processors-and-socs/4026075/Building-Bare-Metal-ARM-Systems-with...

Regarding your question on how to place code in a specific flash address, here is a document that explains this:

Relocating Code and Data Using the CW GCC Linker File for Kinetis

Hope it helps.

Best regards!

Carlos


1,069 Views
jonathanwong
Contributor I

Hi, Carlos,

According to the first webpage you listed ( Code Gen Options - Using the GNU Compiler Collection (GCC) ), it says:

-fpic

  Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine.

So gcc supports -fpic and -fPIC, but does it work for Kinetis MCUs, specifically?

In terms of Josh's original question, this is a good article: Adapting KDS project for KBOOT flash resident bootloader

Thanks,

Jonathan

0 Kudos
Reply