How to link .a to specific address?

Showing results for 
Search instead for 
Did you mean: 

How to link .a to specific address?

NXP Employee
NXP Employee



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

Senior Contributor III

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

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

Senior Contributor III

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

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



Senior Contributor III

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

0 Kudos

NXP Employee
NXP Employee



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