This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there any way to enforce padding between subroutines using the scatter file?

Hi!

I am using an ARM Cortex-M23 microcontroller. I wish to pad every subroutine with certain number of bytes. Using the ALIGNALL attribute on an execution region I am able to achieve some success but I cannot control the number of bytes. Further, the ALIGNALL attribute does not seem to work on veneer code. While I can place the veneer code in a separate execution region, I cannot align the veneer code as I please. Is there any way to achieve what I am trying to do?

Thank you

Parents
  • Yes. ER_ROM_CODE2 does not align. For example, this is an excerpt from the NonSecure.txt file generated by the linker.

    ** Section #2 'ER_ROM_CODE2' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR + SHF_ARM_PURECODE]
        Size   : 120 bytes (alignment 32)
        Address: 0x10050000
    
        $t
        $Ven$TT$L$$SecureContext_SaveContext
            0x10050000:    b403        ..      PUSH     {r0,r1}
            0x10050002:    2000        .       MOVS     r0,#0
            0x10050004:    0200        ..      LSLS     r0,r0,#8
            0x10050006:    3000        .0      ADDS     r0,#0
            0x10050008:    0200        ..      LSLS     r0,r0,#8
            0x1005000a:    300c        .0      ADDS     r0,r0,#0xc
            0x1005000c:    0200        ..      LSLS     r0,r0,#8
            0x1005000e:    30a9        .0      ADDS     r0,r0,#0xa9
            0x10050010:    9001        ..      STR      r0,[sp,#4]
            0x10050012:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_LoadContext
            0x10050014:    b403        ..      PUSH     {r0,r1}
            0x10050016:    2000        .       MOVS     r0,#0
            0x10050018:    0200        ..      LSLS     r0,r0,#8
            0x1005001a:    3000        .0      ADDS     r0,#0
            0x1005001c:    0200        ..      LSLS     r0,r0,#8
            0x1005001e:    300c        .0      ADDS     r0,r0,#0xc
            0x10050020:    0200        ..      LSLS     r0,r0,#8
            0x10050022:    30a1        .0      ADDS     r0,r0,#0xa1
            0x10050024:    9001        ..      STR      r0,[sp,#4]
            0x10050026:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_AllocateContext
            0x10050028:    b403        ..      PUSH     {r0,r1}
            0x1005002a:    2000        .       MOVS     r0,#0
            0x1005002c:    0200        ..      LSLS     r0,r0,#8
            0x1005002e:    3000        .0      ADDS     r0,#0
            0x10050030:    0200        ..      LSLS     r0,r0,#8
            0x10050032:    300c        .0      ADDS     r0,r0,#0xc
            0x10050034:    0200        ..      LSLS     r0,r0,#8
            0x10050036:    3089        .0      ADDS     r0,r0,#0x89
            0x10050038:    9001        ..      STR      r0,[sp,#4]
            0x1005003a:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_FreeContext
            0x1005003c:    b403        ..      PUSH     {r0,r1}
            0x1005003e:    2000        .       MOVS     r0,#0
            0x10050040:    0200        ..      LSLS     r0,r0,#8
            0x10050042:    3000        .0      ADDS     r0,#0
            0x10050044:    0200        ..      LSLS     r0,r0,#8
            0x10050046:    300c        .0      ADDS     r0,r0,#0xc
            0x10050048:    0200        ..      LSLS     r0,r0,#8
            0x1005004a:    3091        .0      ADDS     r0,r0,#0x91
            0x1005004c:    9001        ..      STR      r0,[sp,#4]
            0x1005004e:    bd01        ..      POP      {r0,pc}

    Any ideas why this happens? Please let me know.

    Thanks

Reply
  • Yes. ER_ROM_CODE2 does not align. For example, this is an excerpt from the NonSecure.txt file generated by the linker.

    ** Section #2 'ER_ROM_CODE2' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR + SHF_ARM_PURECODE]
        Size   : 120 bytes (alignment 32)
        Address: 0x10050000
    
        $t
        $Ven$TT$L$$SecureContext_SaveContext
            0x10050000:    b403        ..      PUSH     {r0,r1}
            0x10050002:    2000        .       MOVS     r0,#0
            0x10050004:    0200        ..      LSLS     r0,r0,#8
            0x10050006:    3000        .0      ADDS     r0,#0
            0x10050008:    0200        ..      LSLS     r0,r0,#8
            0x1005000a:    300c        .0      ADDS     r0,r0,#0xc
            0x1005000c:    0200        ..      LSLS     r0,r0,#8
            0x1005000e:    30a9        .0      ADDS     r0,r0,#0xa9
            0x10050010:    9001        ..      STR      r0,[sp,#4]
            0x10050012:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_LoadContext
            0x10050014:    b403        ..      PUSH     {r0,r1}
            0x10050016:    2000        .       MOVS     r0,#0
            0x10050018:    0200        ..      LSLS     r0,r0,#8
            0x1005001a:    3000        .0      ADDS     r0,#0
            0x1005001c:    0200        ..      LSLS     r0,r0,#8
            0x1005001e:    300c        .0      ADDS     r0,r0,#0xc
            0x10050020:    0200        ..      LSLS     r0,r0,#8
            0x10050022:    30a1        .0      ADDS     r0,r0,#0xa1
            0x10050024:    9001        ..      STR      r0,[sp,#4]
            0x10050026:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_AllocateContext
            0x10050028:    b403        ..      PUSH     {r0,r1}
            0x1005002a:    2000        .       MOVS     r0,#0
            0x1005002c:    0200        ..      LSLS     r0,r0,#8
            0x1005002e:    3000        .0      ADDS     r0,#0
            0x10050030:    0200        ..      LSLS     r0,r0,#8
            0x10050032:    300c        .0      ADDS     r0,r0,#0xc
            0x10050034:    0200        ..      LSLS     r0,r0,#8
            0x10050036:    3089        .0      ADDS     r0,r0,#0x89
            0x10050038:    9001        ..      STR      r0,[sp,#4]
            0x1005003a:    bd01        ..      POP      {r0,pc}
        $Ven$TT$L$$SecureContext_FreeContext
            0x1005003c:    b403        ..      PUSH     {r0,r1}
            0x1005003e:    2000        .       MOVS     r0,#0
            0x10050040:    0200        ..      LSLS     r0,r0,#8
            0x10050042:    3000        .0      ADDS     r0,#0
            0x10050044:    0200        ..      LSLS     r0,r0,#8
            0x10050046:    300c        .0      ADDS     r0,r0,#0xc
            0x10050048:    0200        ..      LSLS     r0,r0,#8
            0x1005004a:    3091        .0      ADDS     r0,r0,#0x91
            0x1005004c:    9001        ..      STR      r0,[sp,#4]
            0x1005004e:    bd01        ..      POP      {r0,pc}

    Any ideas why this happens? Please let me know.

    Thanks

Children