bl2.ld.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. RAM_REGION_START = ORIGIN(RAM);
  16. RAM_REGION_LENGTH = LENGTH(RAM);
  17. . = BL2_BASE;
  18. ASSERT(. == ALIGN(PAGE_SIZE),
  19. "BL2_BASE address is not aligned on a page boundary.")
  20. #if SEPARATE_CODE_AND_RODATA
  21. .text . : {
  22. ASSERT(. == ALIGN(PAGE_SIZE),
  23. ".text address is not aligned on a page boundary.");
  24. __TEXT_START__ = .;
  25. #if ENABLE_RME
  26. *bl2_rme_entrypoint.o(.text*)
  27. #else /* ENABLE_RME */
  28. *bl2_entrypoint.o(.text*)
  29. #endif /* ENABLE_RME */
  30. *(SORT_BY_ALIGNMENT(.text*))
  31. *(.vectors)
  32. __TEXT_END_UNALIGNED__ = .;
  33. . = ALIGN(PAGE_SIZE);
  34. __TEXT_END__ = .;
  35. } >RAM
  36. /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
  37. .ARM.extab . : {
  38. *(.ARM.extab* .gnu.linkonce.armextab.*)
  39. } >RAM
  40. .ARM.exidx . : {
  41. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  42. } >RAM
  43. .rodata . : {
  44. __RODATA_START__ = .;
  45. *(SORT_BY_ALIGNMENT(.rodata*))
  46. RODATA_COMMON
  47. __RODATA_END_UNALIGNED__ = .;
  48. . = ALIGN(PAGE_SIZE);
  49. __RODATA_END__ = .;
  50. } >RAM
  51. #else /* SEPARATE_CODE_AND_RODATA */
  52. .ro . : {
  53. ASSERT(. == ALIGN(PAGE_SIZE),
  54. ".ro address is not aligned on a page boundary.");
  55. __RO_START__ = .;
  56. *bl2_entrypoint.o(.text*)
  57. *(SORT_BY_ALIGNMENT(.text*))
  58. *(SORT_BY_ALIGNMENT(.rodata*))
  59. RODATA_COMMON
  60. *(.vectors)
  61. __RO_END_UNALIGNED__ = .;
  62. /*
  63. * Memory page(s) mapped to this section will be marked as read-only,
  64. * executable. No RW data from the next section must creep in. Ensure
  65. * that the rest of the current memory page is unused.
  66. */
  67. . = ALIGN(PAGE_SIZE);
  68. __RO_END__ = .;
  69. } >RAM
  70. #endif /* SEPARATE_CODE_AND_RODATA */
  71. __RW_START__ = .;
  72. DATA_SECTION >RAM
  73. STACK_SECTION >RAM
  74. BSS_SECTION >RAM
  75. XLAT_TABLE_SECTION >RAM
  76. #if USE_COHERENT_MEM
  77. /*
  78. * The base address of the coherent memory section must be page-aligned to
  79. * guarantee that the coherent data are stored on their own pages and are
  80. * not mixed with normal data. This is required to set up the correct
  81. * memory attributes for the coherent data page tables.
  82. */
  83. .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
  84. __COHERENT_RAM_START__ = .;
  85. *(.tzfw_coherent_mem)
  86. __COHERENT_RAM_END_UNALIGNED__ = .;
  87. /*
  88. * Memory page(s) mapped to this section will be marked as device
  89. * memory. No other unexpected data must creep in. Ensure the rest of
  90. * the current memory page is unused.
  91. */
  92. . = ALIGN(PAGE_SIZE);
  93. __COHERENT_RAM_END__ = .;
  94. } >RAM
  95. #endif /* USE_COHERENT_MEM */
  96. __RW_END__ = .;
  97. __BL2_END__ = .;
  98. RAM_REGION_END = .;
  99. __BSS_SIZE__ = SIZEOF(.bss);
  100. #if USE_COHERENT_MEM
  101. __COHERENT_RAM_UNALIGNED_SIZE__ =
  102. __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
  103. #endif /* USE_COHERENT_MEM */
  104. ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
  105. }