u-boot.lds 4.1 KB

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