ARM-software / tf-issues

Issue tracking for the ARM Trusted Firmware project
37 stars 16 forks source link

questions about stack for BL1/BL2 etc #17

Closed chinamao closed 10 years ago

chinamao commented 10 years ago

hi, experts: I have a question about stack setting for BL1/BL2 etc. Take BL1 code as an example: STACKS_START = 0x0400 0000 STACKS_END = 0x0400 4000

platform_normal_stacks array points to STACKS_START. it means: CPU would setup stack at here.

so, my question is: bl1_entrypoint.S would copy data section to 0x0400 0000 area. Would these saved data section area be damaged by following stack operations?

best wishes,

sandrine-bailleux-arm commented 10 years ago

Hello,

BL1, BL2 and BL31 images start with the same memory layout:

  1. Read-only section (.text and .rodata)
  2. Initialised data section (.data)
  3. Stacks section

The linker will ensure that these sections do not overlap each other.

I think that your confusion comes from the fact that BL1 doesn't have any initialised data currently so the size of its .data section is zero. Although the .data section would normally start at the beginning of the trusted RAM (0x0400_0000), there's no need to reserve some space for it because it is empty. Therefore the next section, i.e. the stacks section, can be put at that very same address without any risk.

Take BL31 as an example. BL31's data section is not empty so the linker will make sure it reserves some space for it and it will put the stacks section after. See bl31.map link map file: 0x0000000004016000 DATA_START = . 0x0000000004016030 DATA_END = .

0x0000000004016040 STACKS_START = . 0x000000000401a040 STACKS_END = .

I hope this answers your question.

Regards,

chinamao commented 10 years ago

hi, sandrine: Your answer is very clear! Thank you very much!