Hello Kevin,

The image need padding to be added because the region is executed in place on flash.

So the issue is that the compiler does link successfully if the start address  (LR_CODE 0x0c024400)

Is not aligned on 0x2000.

 

Best Regards

 

From: Kevin Peng <Kevin.Peng@arm.com>
Sent: mercredi 17 mars 2021 03:08
To: Michel JAOUEN <michel.jaouen@st.com>; tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question

 

Hi Michel,

 

Quote from the armlink user guide:

ALIGN on an execution region causes both the load address and execution address to be aligned.

This can result in padding being added to the ELF file. To align only the execution address, use

the AlignExpr expression on the base address.

 

So I guess the alignment on execution regions (TFM_UNPRIV_CODE) overrides the alignment of the Load Region.

And the fix is easy – as the user guide suggests – use AlignExpr

 

In you case, could you try:

+0 ALIGN 0x2000 -> AlignExpr(+0, 0x2000)

 

Best Regards,

Kevin

 

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Michel JAOUEN via TF-M
Sent: Tuesday, March 16, 2021 10:33 PM
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Armclang linker alignement question

 

Hello,

 

This question is relative to linker script with Compiler armclang 'V6.14' (For the other toolchain IAR , GNUARM ,it works )

 

I need to place code  aligned  to flash PAGE SIZE (0x2000 or 8192) to be able to set hardware protection.

 

 

As follow , here is the description of the issue.

 

With a Linker file having the following value  for Code placement

LR_CODE 0x0c024400 0x20000 {

 

     ER_TFM_CODE 0x0c024400 {

        *.o (RESET +First)

        * (+RO)

 

     }

     TFM_UNPRIV_CODE  +0 ALIGN 0x2000 {

        stm32u5xx_hal*.o (+RO)

        tick.o (+RO)

        *(SFN)

        *armlib*

    }

   

}

 

We get the following error :

 

Build started: Project: Project_s

*** Using Compiler 'V6.14', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'

Build Project 'Project_s' - Target xxxxxxxxxxx _TFM_Appli_S'

linking...

xxxxxxxxxxx_S\Exe\Project.axf: Error: L6244E: Load region LR_CODE address (0x0c024400) not aligned on a 8192 byte boundary.

Not enough information to list image symbols.

Finished: 1 information, 0 warning and 1 error messages.

" xxxxxxxxxxx _S\Exe\Project.axf" - 1 Error(s), 0 Warning(s).

Target not created.

Build Time Elapsed:  00:00:03

 

 

If we change  the linker file as follow :

LR_CODE 0x0c024400 0x20000 {

 

     ER_TFM_CODE 0x0c024400 {

        *.o (RESET +First)

        * (+RO)

 

     }

     TFM_UNPRIV_CODE  +0 ALIGN 0x400 {

        stm32u5xx_hal*.o (+RO)

        tick.o (+RO)

        *(SFN)

        *armlib*

    }

   

}

No Error is reported.

 

Is this an known issue with ARMCLANG ?

 

Best Regards

 

.