blob: 72e4b9a706e59623aa2fc171ed40282b068ac2e9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Chris Zankel1387dab2016-08-10 18:36:44 +03002/*
3 * (C) Copyright 2008 - 2013 Tensilica, Inc.
4 * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
Chris Zankel1387dab2016-08-10 18:36:44 +03005 */
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
13OUTPUT_ARCH(xtensa)
14ENTRY(_start)
15
16/*
17 * U-Boot resets from SYSROM and unpacks itself from a ROM store to RAM.
18 * The reset vector is usually near the base of SYSROM and has room
19 * above it for the ROM store into which the rest of U-Boot is packed.
20 * The ROM store also needs to be above any other vectors that are in ROM.
21 * If a core has its vectors near the top of ROM, this must be edited.
22 *
23 * Note that to run C code out of ROM, the processor would have to support
24 * 'relocatable' exception vectors and provide a scratch memory for the
25 * initial stack. Not all Xtensa processor configurations support that, so
26 * we can simplify the boot process and unpack U-Boot to RAM immediately.
27 * This, however, requires that memory have been initialized throug some
28 * other means (serial ROM, for example) or are initialized early (requiring
29 * an assembler function. See start.S for more details)
30 */
31
32SECTIONS
33{
34 . = + SIZEOF_HEADERS;
35 SECTION_ResetVector(XCHAL_RESET_VECTOR_VADDR, LMA_EQ_VMA)
36
37 .reloc_table ALIGN(4) : FOLLOWING(.ResetVector.text)
38 {
39 __reloc_table_start = ABSOLUTE(.);
40#if XCHAL_HAVE_WINDOWED
41 RELOCATE2(WindowVectors,text);
42#endif
43 RELOCATE2(KernelExceptionVector,literal);
44 RELOCATE2(KernelExceptionVector,text);
45 RELOCATE2(UserExceptionVector,literal);
46 RELOCATE2(UserExceptionVector,text);
47 RELOCATE2(DoubleExceptionVector,literal);
48 RELOCATE2(DoubleExceptionVector,text);
49 RELOCATE1(text);
50 RELOCATE1(rodata);
51 RELOCATE1(data);
Andrew Scull5a9095c2022-05-30 10:00:04 +000052 RELOCATE_USER1(__u_boot_list);
Chris Zankel1387dab2016-08-10 18:36:44 +030053 __reloc_table_end = ABSOLUTE(.);
54 }
55
56#if XCHAL_HAVE_WINDOWED
57 SECTION_VECTOR(WindowVectors,text,XCHAL_WINDOW_VECTORS_VADDR,
58 FOLLOWING(.reloc_table))
59 SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
60 FOLLOWING(.WindowVectors.text))
61#else
62 SECTION_VECTOR(KernelExceptionVector,literal,XCHAL_KERNEL_VECTOR_VADDR-8,
63 FOLLOWING(.reloc_table))
64#endif
65 SECTION_VECTOR(KernelExceptionVector,text,XCHAL_KERNEL_VECTOR_VADDR,
66 FOLLOWING(.KernelExceptionVector.literal))
67 SECTION_VECTOR(UserExceptionVector,literal,XCHAL_USER_VECTOR_VADDR-8,
68 FOLLOWING(.KernelExceptionVector.text))
69 SECTION_VECTOR(UserExceptionVector,text,XCHAL_USER_VECTOR_VADDR,
70 FOLLOWING(.UserExceptionVector.literal))
71 SECTION_VECTOR(DoubleExceptionVector,literal,XCHAL_DOUBLEEXC_VECTOR_VADDR-8,
72 FOLLOWING(.UserExceptionVector.text))
73 SECTION_VECTOR(DoubleExceptionVector,text,XCHAL_DOUBLEEXC_VECTOR_VADDR,
74 FOLLOWING(.DoubleExceptionVector.literal))
75
Max Filippove2e0ac52018-02-12 15:39:19 -080076 __monitor_start = XTENSA_SYS_TEXT_ADDR;
Chris Zankel1387dab2016-08-10 18:36:44 +030077
Max Filippove2e0ac52018-02-12 15:39:19 -080078 SECTION_text(XTENSA_SYS_TEXT_ADDR, FOLLOWING(.DoubleExceptionVector.text))
Chris Zankel1387dab2016-08-10 18:36:44 +030079 SECTION_rodata(ALIGN(16), FOLLOWING(.text))
80 SECTION_u_boot_list(ALIGN(16), FOLLOWING(.rodata))
Andrew Scull5a9095c2022-05-30 10:00:04 +000081 SECTION_data(ALIGN(16), FOLLOWING(__u_boot_list))
Chris Zankel1387dab2016-08-10 18:36:44 +030082
83 __reloc_end = .;
84 __init_end = .;
Jiaxun Yang3fab9dc2024-06-18 14:56:02 +010085 /* Calculation to get end address in ROM */
86 _end = LOADADDR(.data) + (_data_end - _data_start);
Chris Zankel1387dab2016-08-10 18:36:44 +030087
88 SECTION_bss(__init_end (OVERLAY),)
89
90 __monitor_end = .;
91
92 /*
93 * On many Xtensa boards a region of RAM may be mapped to the ROM address
94 * space to facilitate on-chip-debug, and U-Boot must fit with that region.
95 * The config variables CONFIG_SYS_MONITOR_* define the region.
96 * If U-Boot extends beyond this region it will appear discontiguous in the
97 * address space and is in danger of overwriting itself during unpacking
98 * ("relocation").
99 * This causes U-Boot to crash in a way that is difficult to debug. On some
100 * boards (such as xtav60) the region is small enough that U-Boot will not
101 * fit if compiled entirely with -O0 (a common scenario). To avoid a lengthy
102 * debugging session when this happens, ensure a link-time error occurs.
103 *
104 */
105
106 ASSERT(__monitor_end - __monitor_start <= CONFIG_SYS_MONITOR_LEN,
107 "U-Boot ROM image is too large. Check optimization level.")
108
109 SECTION_xtensa
110 SECTION_debug
111
112 /DISCARD/ : { *(.dynstr*) }
113 /DISCARD/ : { *(.hash*) }
114 /DISCARD/ : { *(.interp) }
115 /DISCARD/ : { *(.got*) }
116 /DISCARD/ : { *(.dynsym) }
117}