bl2.ld.S 3.2 KB

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