u-boot.lds 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * (C) Copyright 2008 - 2013 Tensilica, Inc.
  3. * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <config.h>
  8. #include <asm/ldscript.h>
  9. #include <asm/arch/core.h>
  10. #include <asm/addrspace.h>
  11. #include <asm-offsets.h>
  12. OUTPUT_ARCH(xtensa)
  13. ENTRY(_start)
  14. /*
  15. * U-Boot resets from SYSROM and unpacks itself from a ROM store to RAM.
  16. * The reset vector is usually near the base of SYSROM and has room
  17. * above it for the ROM store into which the rest of U-Boot is packed.
  18. * The ROM store also needs to be above any other vectors that are in ROM.
  19. * If a core has its vectors near the top of ROM, this must be edited.
  20. *
  21. * Note that to run C code out of ROM, the processor would have to support
  22. * 'relocatable' exception vectors and provide a scratch memory for the
  23. * initial stack. Not all Xtensa processor configurations support that, so
  24. * we can simplify the boot process and unpack U-Boot to RAM immediately.
  25. * This, however, requires that memory have been initialized throug some
  26. * other means (serial ROM, for example) or are initialized early (requiring
  27. * an assembler function. See start.S for more details)
  28. */
  29. SECTIONS
  30. {
  31. . = + SIZEOF_HEADERS;
  32. SECTION_ResetVector(XCHAL_RESET_VECTOR_VADDR, LMA_EQ_VMA)
  33. .reloc_table ALIGN(4) : FOLLOWING(.ResetVector.text)
  34. {
  35. __reloc_table_start = ABSOLUTE(.);
  36. #if XCHAL_HAVE_WINDOWED
  37. RELOCATE2(WindowVectors,text);
  38. #endif
  39. RELOCATE2(KernelExceptionVector,literal);
  40. RELOCATE2(KernelExceptionVector,text);
  41. RELOCATE2(UserExceptionVector,literal);
  42. RELOCATE2(UserExceptionVector,text);
  43. RELOCATE2(DoubleExceptionVector,literal);
  44. RELOCATE2(DoubleExceptionVector,text);
  45. RELOCATE1(text);
  46. RELOCATE1(rodata);
  47. RELOCATE1(data);
  48. RELOCATE1(u_boot_list);
  49. __reloc_table_end = ABSOLUTE(.);
  50. }
  51. #if XCHAL_HAVE_WINDOWED
  52. SECTION_VECTOR(WindowVectors,text,XCHAL_WINDOW_VECTORS_VADDR,
  53. FOLLOWING(.reloc_table))
  54. SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
  55. FOLLOWING(.WindowVectors.text))
  56. #else
  57. SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
  58. FOLLOWING(.reloc_table))
  59. #endif
  60. SECTION_VECTOR(KernelExceptionVector,text,XCHAL_KERNEL_VECTOR_VADDR,
  61. FOLLOWING(.KernelExceptionVector.literal))
  62. SECTION_VECTOR(UserExceptionVector,literal,XCHAL_USER_VECTOR_VADDR-8,
  63. FOLLOWING(.KernelExceptionVector.text))
  64. SECTION_VECTOR(UserExceptionVector,text,XCHAL_USER_VECTOR_VADDR,
  65. FOLLOWING(.UserExceptionVector.literal))
  66. SECTION_VECTOR(DoubleExceptionVector,literal,XCHAL_DOUBLEEXC_VECTOR_VADDR-8,
  67. FOLLOWING(.UserExceptionVector.text))
  68. SECTION_VECTOR(DoubleExceptionVector,text,XCHAL_DOUBLEEXC_VECTOR_VADDR,
  69. FOLLOWING(.DoubleExceptionVector.literal))
  70. __monitor_start = CONFIG_SYS_TEXT_ADDR;
  71. SECTION_text(CONFIG_SYS_TEXT_ADDR, FOLLOWING(.DoubleExceptionVector.text))
  72. SECTION_rodata(ALIGN(16), FOLLOWING(.text))
  73. SECTION_u_boot_list(ALIGN(16), FOLLOWING(.rodata))
  74. SECTION_data(ALIGN(16), FOLLOWING(.u_boot_list))
  75. __reloc_end = .;
  76. __init_end = .;
  77. SECTION_bss(__init_end (OVERLAY),)
  78. __monitor_end = .;
  79. /*
  80. * On many Xtensa boards a region of RAM may be mapped to the ROM address
  81. * space to facilitate on-chip-debug, and U-Boot must fit with that region.
  82. * The config variables CONFIG_SYS_MONITOR_* define the region.
  83. * If U-Boot extends beyond this region it will appear discontiguous in the
  84. * address space and is in danger of overwriting itself during unpacking
  85. * ("relocation").
  86. * This causes U-Boot to crash in a way that is difficult to debug. On some
  87. * boards (such as xtav60) the region is small enough that U-Boot will not
  88. * fit if compiled entirely with -O0 (a common scenario). To avoid a lengthy
  89. * debugging session when this happens, ensure a link-time error occurs.
  90. *
  91. */
  92. ASSERT(__monitor_end - __monitor_start <= CONFIG_SYS_MONITOR_LEN,
  93. "U-Boot ROM image is too large. Check optimization level.")
  94. SECTION_xtensa
  95. SECTION_debug
  96. /DISCARD/ : { *(.dynstr*) }
  97. /DISCARD/ : { *(.hash*) }
  98. /DISCARD/ : { *(.interp) }
  99. /DISCARD/ : { *(.got*) }
  100. /DISCARD/ : { *(.dynsym) }
  101. }