How to change function linking order in S32DS?

Showing results for 
Search instead for 
Did you mean: 

How to change function linking order in S32DS?

Contributor I

I'am working with MPC5744P, and I'd like to understand how to change the function linking order with S32DS. Creating a new project, after building, S32DS assign function address by default, from low to high address, main()->dummy()->SetIVPR->InitINTC->enableIrg->xcptn_xmpl, as bellow.

 .text.main     0x01002bc8       0x28 ./src/main.o
                0x01002bc8                main
 .text.dummy    0x01002bf0        0xc ./src/intc_SW_mode_isr_vectors_MPC5744P.o
                0x01002bf0                dummy
 .text.SetIVPR  0x01002bfc       0x1a ./src/MPC57xx__Interrupt_Init.o
                0x01002bfc                SetIVPR
                0x01002c16       0x3c ./src/MPC57xx__Interrupt_Init.o
                0x01002c16                InitINTC
                0x01002c52       0x24 ./src/MPC57xx__Interrupt_Init.o
                0x01002c52                enableIrq
                0x01002c76       0x34 ./src/MPC57xx__Interrupt_Init.o
                0x01002c76                xcptn_xmpl


Now, I need to change linking order, moving main() to the bottom, dummy()->SetIVPR->InitINTC->enableIrg->xcptn_xmpl->main(). How can I set this in S32DS to control linking order?

Labels (2)
2 Replies

NXP Employee
NXP Employee


another approach and is to control the link order of specific functions directly in the linker file. See the snippet below:

    .text :












      . = ALIGN(16);

    } > m_text

This solution will work when ‘-ffunction-sections’ compiler option is used (set by default in a new project).

This option causes each function is associated with its own section.

This solution does not in fact change linker order. It will change only functions relative location in memory but this might the the main reason for changing the linking order.


NXP Employee
NXP Employee


Currently it's not possible to change the link order in IDE (as opposed to e.g. CodeWarrior).

There is a related feature request already logged in our database so this feature might be implemented in a future release.

The only workaround I can think of is to disable makefile generation and adjust the link order manually. See below the workaround instructions:

1) Build the project first - makefiles and .args files are created automatically in the output directory:


2) In the project properties turn off Makefile automatic generation:


3) Change the link order directly in .args file (e.g Startup.o has been moved at the end of the object files):



If you need to add a source file into your project you should turn on the makefile generation again and rebuild to update your makefile/.args files.

Hope it helps.