How to link .a to specific address?

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

How to link .a to specific address?

2,527 Views
daweiyou
NXP Employee
NXP Employee

Hi:

 

In the SDK example, there is *library.ld file to specific some c library to integrate.

But for some special cause, need link these .a to specific address for example 0x1000-0x2000,

so for this purpose, how to modify the link file? thanks.

0 Kudos
5 Replies

2,506 Views
converse
Senior Contributor V

Sorry, this is not totally clear:

- Is the 'stable' part built separately from the 'unstable' part?

- Do you expect to be able to update the unstable part independently of the stable part?

This is going to need more than just placing a library at a known address.

0 Kudos

2,492 Views
daweiyou
NXP Employee
NXP Employee

Hi Coverse:

 

Actually, to seperate two parts not for upgrade seperately, mainly for safety purpose.

In some safety certification, the safety SW part(stable part) binary content are assumed not changed even if other code is modified.

If C library is not fixed to specific address, then will un-stable SW is modified, maybe stable part's binary content will be changed. What's why need put C library code in specific address, also make it stable.

So for your questions:

- Is the 'stable' part built separately from the 'unstable' part? No

- Do you expect to be able to update the unstable part independently of the stable part? No

0 Kudos

2,485 Views
converse
Senior Contributor V

In that case, I do not understand why you want to put the C library into a fixed address. As you are building the whole application, then you will automatically get the same 'stable' C library. If you upgrade your tools, you will get a different 'stable' C library. 

If you want to pursue this, read the documentation

1. read the LD manual

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_mono/ld.html

You will need to read about Output Sections and Section placement. You can use the syntax

*library.a:* to place a whole library into a named section

2. Read the MCUXpresso manual, section on Freemarker linker scripts. This allows you to add modification to the generated linker scripts without writing a whole linker script.

This FAQ may help you in placing code into a know location

https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Placing-data-at-an-address/m-p/473552

 

 

2,520 Views
converse
Senior Contributor V

Libraries do not have any address information. Only applications have address information. Can you explain what you are trying to do?

0 Kudos

2,514 Views
daweiyou
NXP Employee
NXP Employee

Hello:

 

Yes, in MCUX project, there are some standard C library, when they are linked, then they are allocated real address.

There is one special case to address this:

When one APP is split as two parts: stable parts and non-stable parts.

they are put into two section of flash address,non-stable part could be upgraded, but stable parts must keep same always for safty cause.

but C library function, for example memcpy API, maybe stay with non-stable parts, which maybe called by stable part. 

So we need "stable" C library in specific address, then other two parts could refer it as stable reference address.

0 Kudos