bl1.ld.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /*
  7. * The .data section gets copied from ROM to RAM at runtime.
  8. * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes
  9. * aligned regions in it.
  10. * Its VMA must be page-aligned as it marks the first read/write page.
  11. */
  12. #define DATA_ALIGN 16
  13. #include <common/bl_common.ld.h>
  14. #include <lib/xlat_tables/xlat_tables_defs.h>
  15. OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
  16. OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
  17. ENTRY(bl1_entrypoint)
  18. MEMORY {
  19. ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
  20. RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
  21. }
  22. SECTIONS
  23. {
  24. . = BL1_RO_BASE;
  25. ASSERT(. == ALIGN(PAGE_SIZE),
  26. "BL1_RO_BASE address is not aligned on a page boundary.")
  27. #if SEPARATE_CODE_AND_RODATA
  28. .text . : {
  29. __TEXT_START__ = .;
  30. *bl1_entrypoint.o(.text*)
  31. *(SORT_BY_ALIGNMENT(.text*))
  32. *(.vectors)
  33. . = ALIGN(PAGE_SIZE);
  34. __TEXT_END__ = .;
  35. } >ROM
  36. /* .ARM.extab and .ARM.exidx are only added because Clang need them */
  37. .ARM.extab . : {
  38. *(.ARM.extab* .gnu.linkonce.armextab.*)
  39. } >ROM
  40. .ARM.exidx . : {
  41. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  42. } >ROM
  43. .rodata . : {
  44. __RODATA_START__ = .;
  45. *(SORT_BY_ALIGNMENT(.rodata*))
  46. RODATA_COMMON
  47. /*
  48. * No need to pad out the .rodata section to a page boundary. Next is
  49. * the .data section, which can mapped in ROM with the same memory
  50. * attributes as the .rodata section.
  51. *
  52. * Pad out to 16 bytes though as .data section needs to be 16 byte
  53. * aligned and lld does not align the LMA to the aligment specified
  54. * on the .data section.
  55. */
  56. __RODATA_END__ = .;
  57. . = ALIGN(16);
  58. } >ROM
  59. #else
  60. ro . : {
  61. __RO_START__ = .;
  62. *bl1_entrypoint.o(.text*)
  63. *(SORT_BY_ALIGNMENT(.text*))
  64. *(SORT_BY_ALIGNMENT(.rodata*))
  65. RODATA_COMMON
  66. *(.vectors)
  67. __RO_END__ = .;
  68. /*
  69. * Pad out to 16 bytes as .data section needs to be 16 byte aligned and
  70. * lld does not align the LMA to the aligment specified on the .data
  71. * section.
  72. */
  73. . = ALIGN(16);
  74. } >ROM
  75. #endif
  76. ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
  77. "cpu_ops not defined for this platform.")
  78. . = BL1_RW_BASE;
  79. ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
  80. "BL1_RW_BASE address is not aligned on a page boundary.")
  81. DATA_SECTION >RAM AT>ROM
  82. __DATA_RAM_START__ = __DATA_START__;
  83. __DATA_RAM_END__ = __DATA_END__;
  84. STACK_SECTION >RAM
  85. BSS_SECTION >RAM
  86. XLAT_TABLE_SECTION >RAM
  87. #if USE_COHERENT_MEM
  88. /*
  89. * The base address of the coherent memory section must be page-aligned (4K)
  90. * to guarantee that the coherent data are stored on their own pages and
  91. * are not mixed with normal data. This is required to set up the correct
  92. * memory attributes for the coherent data page tables.
  93. */
  94. coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
  95. __COHERENT_RAM_START__ = .;
  96. *(tzfw_coherent_mem)
  97. __COHERENT_RAM_END_UNALIGNED__ = .;
  98. /*
  99. * Memory page(s) mapped to this section will be marked
  100. * as device memory. No other unexpected data must creep in.
  101. * Ensure the rest of the current memory page is unused.
  102. */
  103. . = ALIGN(PAGE_SIZE);
  104. __COHERENT_RAM_END__ = .;
  105. } >RAM
  106. #endif
  107. __BL1_RAM_START__ = ADDR(.data);
  108. __BL1_RAM_END__ = .;
  109. __DATA_ROM_START__ = LOADADDR(.data);
  110. __DATA_SIZE__ = SIZEOF(.data);
  111. /*
  112. * The .data section is the last PROGBITS section so its end marks the end
  113. * of BL1's actual content in Trusted ROM.
  114. */
  115. __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__;
  116. ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
  117. "BL1's ROM content has exceeded its limit.")
  118. __BSS_SIZE__ = SIZEOF(.bss);
  119. #if USE_COHERENT_MEM
  120. __COHERENT_RAM_UNALIGNED_SIZE__ =
  121. __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
  122. #endif
  123. ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
  124. }