bl2.ld.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/bl_common.ld.h>
  7. #include <lib/xlat_tables/xlat_tables_defs.h>
  8. OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
  9. OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
  10. ENTRY(bl2_entrypoint)
  11. MEMORY {
  12. RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
  13. }
  14. SECTIONS {
  15. . = BL2_BASE;
  16. ASSERT(. == ALIGN(PAGE_SIZE),
  17. "BL2_BASE address is not aligned on a page boundary.")
  18. #if SEPARATE_CODE_AND_RODATA
  19. .text . : {
  20. __TEXT_START__ = .;
  21. #if ENABLE_RME
  22. *bl2_rme_entrypoint.o(.text*)
  23. #else /* ENABLE_RME */
  24. *bl2_entrypoint.o(.text*)
  25. #endif /* ENABLE_RME */
  26. *(SORT_BY_ALIGNMENT(.text*))
  27. *(.vectors)
  28. . = ALIGN(PAGE_SIZE);
  29. __TEXT_END__ = .;
  30. } >RAM
  31. /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
  32. .ARM.extab . : {
  33. *(.ARM.extab* .gnu.linkonce.armextab.*)
  34. } >RAM
  35. .ARM.exidx . : {
  36. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  37. } >RAM
  38. .rodata . : {
  39. __RODATA_START__ = .;
  40. *(SORT_BY_ALIGNMENT(.rodata*))
  41. RODATA_COMMON
  42. . = ALIGN(PAGE_SIZE);
  43. __RODATA_END__ = .;
  44. } >RAM
  45. #else /* SEPARATE_CODE_AND_RODATA */
  46. .ro . : {
  47. __RO_START__ = .;
  48. *bl2_entrypoint.o(.text*)
  49. *(SORT_BY_ALIGNMENT(.text*))
  50. *(SORT_BY_ALIGNMENT(.rodata*))
  51. RODATA_COMMON
  52. *(.vectors)
  53. __RO_END_UNALIGNED__ = .;
  54. /*
  55. * Memory page(s) mapped to this section will be marked as read-only,
  56. * executable. No RW data from the next section must creep in. Ensure
  57. * that the rest of the current memory page is unused.
  58. */
  59. . = ALIGN(PAGE_SIZE);
  60. __RO_END__ = .;
  61. } >RAM
  62. #endif /* SEPARATE_CODE_AND_RODATA */
  63. __RW_START__ = .;
  64. DATA_SECTION >RAM
  65. STACK_SECTION >RAM
  66. BSS_SECTION >RAM
  67. XLAT_TABLE_SECTION >RAM
  68. #if USE_COHERENT_MEM
  69. /*
  70. * The base address of the coherent memory section must be page-aligned to
  71. * guarantee that the coherent data are stored on their own pages and are
  72. * not mixed with normal data. This is required to set up the correct
  73. * memory attributes for the coherent data page tables.
  74. */
  75. .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
  76. __COHERENT_RAM_START__ = .;
  77. *(.tzfw_coherent_mem)
  78. __COHERENT_RAM_END_UNALIGNED__ = .;
  79. /*
  80. * Memory page(s) mapped to this section will be marked as device
  81. * memory. No other unexpected data must creep in. Ensure the rest of
  82. * the current memory page is unused.
  83. */
  84. . = ALIGN(PAGE_SIZE);
  85. __COHERENT_RAM_END__ = .;
  86. } >RAM
  87. #endif /* USE_COHERENT_MEM */
  88. __RW_END__ = .;
  89. __BL2_END__ = .;
  90. __BSS_SIZE__ = SIZEOF(.bss);
  91. #if USE_COHERENT_MEM
  92. __COHERENT_RAM_UNALIGNED_SIZE__ =
  93. __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
  94. #endif /* USE_COHERENT_MEM */
  95. ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
  96. }