Commit | Line | Data |
---|---|---|
b3adc24a | 1 | # Copyright (C) 2014-2020 Free Software Foundation, Inc. |
6c19b93b | 2 | # |
c18392d8 EB |
3 | # Copying and distribution of this file, with or without modification, |
4 | # are permitted in any medium without royalty provided the copyright | |
5 | # notice and this notice are preserved. | |
6 | ||
7 | # Many sections come in three flavours. There is the 'real' section, | |
8 | # like ".data". Then there are the per-procedure or per-variable | |
9 | # sections, generated by -ffunction-sections and -fdata-sections in GCC, | |
10 | # and useful for --gc-sections, which for a variable "foo" might be | |
11 | # ".data.foo". Then there are the linkonce sections, for which the linker | |
12 | # eliminates duplicates, which are named like ".gnu.linkonce.d.foo". | |
13 | # The exact correspondences are: | |
14 | # | |
15 | # Section Linkonce section | |
16 | # .text .gnu.linkonce.t.foo | |
17 | # .rodata .gnu.linkonce.r.foo | |
18 | # .data .gnu.linkonce.d.foo | |
19 | # .bss .gnu.linkonce.b.foo | |
20 | # .sdata .gnu.linkonce.s.foo | |
21 | # .sbss .gnu.linkonce.sb.foo | |
22 | # .sdata2 .gnu.linkonce.s2.foo | |
23 | # .sbss2 .gnu.linkonce.sb2.foo | |
24 | # .debug_info .gnu.linkonce.wi.foo | |
25 | # .tdata .gnu.linkonce.td.foo | |
26 | # .tbss .gnu.linkonce.tb.foo | |
27 | # .lrodata .gnu.linkonce.lr.foo | |
28 | # .ldata .gnu.linkonce.l.foo | |
29 | # .lbss .gnu.linkonce.lb.foo | |
30 | # | |
31 | # Each of these can also have corresponding .rel.* and .rela.* sections. | |
32 | ||
33 | test -z "$ENTRY" && ENTRY=__start | |
34 | cat <<EOF | |
35 | OUTPUT_FORMAT("${OUTPUT_FORMAT}") | |
36 | ||
37 | ENTRY(${ENTRY}) | |
2bf2bf23 | 38 | EOF |
c18392d8 | 39 | |
2bf2bf23 | 40 | test -n "${RELOCATING}" && cat <<EOF |
c18392d8 | 41 | /* Start and end of main stack. Assumes 256K of RAM. */ |
2bf2bf23 AM |
42 | _estack = 0xe0040000 - 4; |
43 | _sstack = 0xe0040000 - 64K; | |
c18392d8 EB |
44 | |
45 | /* End of heap. */ | |
2bf2bf23 | 46 | _eheap = _sstack - 4; |
c18392d8 EB |
47 | |
48 | MEMORY | |
49 | { | |
50 | init : ORIGIN = 0x00000000, LENGTH = 0x0003fffc | |
51 | scr : ORIGIN = 0x0003fffc, LENGTH = 0x00000004 | |
52 | rom : ORIGIN = 0x00044000, LENGTH = 0x1ffbc000 | |
53 | ram : ORIGIN = 0xe0000000, LENGTH = 0x10000000 | |
54 | saferam : ORIGIN = 0xf0000000, LENGTH = 0x10000000 | |
55 | } | |
56 | ||
2bf2bf23 | 57 | EOF |
c18392d8 | 58 | |
2bf2bf23 | 59 | cat <<EOF |
c18392d8 EB |
60 | SECTIONS |
61 | { | |
62 | .init ${RELOCATING-0} : { | |
2d3181c7 AM |
63 | KEEP (*(SORT_NONE(.init))) |
64 | ${RELOCATING+KEEP (*(SORT_NONE(.fini)))} | |
c18392d8 EB |
65 | ${RELOCATING+ _einit = .;} |
66 | } ${RELOCATING+ > init} | |
67 | ||
68 | .text ${RELOCATING-0} : { | |
69 | ${RELOCATING+ _ftext = .;} | |
70 | *(.text) | |
71 | ${RELOCATING+*(.text.*)} | |
72 | ${RELOCATING+*(.gnu.linkonce.t.*)} | |
73 | ${RELOCATING+ _etext = .;} | |
74 | } ${RELOCATING+ > rom} | |
75 | ||
76 | .ctors ${RELOCATING-0} : { | |
77 | ${CONSTRUCTING+ . = ALIGN(4);} | |
78 | ${CONSTRUCTING+ __CTOR_LIST__ = .;} | |
79 | /* gcc uses crtbegin.o to find the start of | |
80 | the constructors, so we make sure it is | |
81 | first. Because this is a wildcard, it | |
82 | doesn't matter if the user does not | |
83 | actually link against crtbegin.o; the | |
84 | linker won't look for a file to match a | |
85 | wildcard. The wildcard also means that it | |
86 | doesn't matter which directory crtbegin.o | |
87 | is in. */ | |
88 | ||
89 | KEEP (*crtbegin*.o(.ctors)) | |
90 | ||
91 | /* We don't want to include the .ctor section from | |
92 | from the crtend.o file until after the sorted ctors. | |
93 | The .ctor section from the crtend file contains the | |
94 | end of ctors marker and it must be last. */ | |
95 | ||
96 | KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) | |
2bf2bf23 | 97 | ${RELOCATING+KEEP (*(SORT(.ctors.*)))} |
c18392d8 EB |
98 | KEEP (*(.ctors)) |
99 | ${CONSTRUCTING+ __CTOR_END__ = .;} | |
100 | } ${RELOCATING+ > rom} | |
101 | ||
102 | .dtors ${RELOCATING-0} : { | |
103 | ${CONSTRUCTING+ __DTOR_LIST__ = .;} | |
104 | KEEP (*crtbegin*.o(.dtors)) | |
105 | KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) | |
2bf2bf23 | 106 | ${RELOCATING+KEEP (*(SORT(.dtors.*)))} |
c18392d8 EB |
107 | KEEP (*(.dtors)) |
108 | ${CONSTRUCTING+ __DTOR_END__ = .;} | |
109 | } ${RELOCATING+ > rom} | |
110 | .rodata ${RELOCATING-0} : { | |
111 | ${RELOCATING+ . = ALIGN(4);} | |
112 | ${RELOCATING+ _srdata = .;} | |
2bf2bf23 | 113 | ${RELOCATING+*(.rdata)} |
c18392d8 EB |
114 | *(.rodata) |
115 | ${RELOCATING+*(.rodata.*)} | |
116 | ${RELOCATING+*(.gnu.linkonce.r.*)} | |
117 | ${RELOCATING+ . = ALIGN(4);} | |
118 | ${RELOCATING+ _erdata = .;} | |
119 | } ${RELOCATING+ > rom} | |
120 | ||
121 | .eh_frame ${RELOCATING-0} : | |
122 | { | |
123 | ${RELOCATING+PROVIDE (__eh_frame_begin = .);} | |
124 | *(.eh_frame) | |
125 | ${RELOCATING+ LONG (0);} | |
126 | ${RELOCATING+PROVIDE (__eh_frame_end = .);} | |
127 | } ${RELOCATING+ > rom} | |
128 | .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) } ${RELOCATING+ > rom} | |
129 | .jcr ${RELOCATING-0} : { *(.jcr) } ${RELOCATING+ > rom} | |
130 | ||
131 | .data ${RELOCATING-0} : { | |
132 | ${RELOCATING+ . = ALIGN(4);} | |
133 | ${RELOCATING+ _sdata = .;} | |
134 | *(.data) | |
135 | ${RELOCATING+*(.data.*)} | |
136 | ${RELOCATING+*(.gnu.linkonce.d.*)} | |
137 | ${RELOCATING+ . = ALIGN(4);} | |
138 | ${RELOCATING+ _edata = .;} | |
139 | } ${RELOCATING+ > ram} | |
6c19b93b | 140 | .bss ${RELOCATING-0} : { |
c18392d8 EB |
141 | ${RELOCATING+ . = ALIGN(4);} |
142 | ${RELOCATING+ __bss_start = .;} | |
143 | *(.bss) | |
144 | ${RELOCATING+*(.bss.*)} | |
145 | ${RELOCATING+*(.gnu.linkonce.b.*)} | |
2bf2bf23 | 146 | ${RELOCATING+*(COMMON)} |
c18392d8 EB |
147 | ${RELOCATING+ . = ALIGN(4);} |
148 | ${RELOCATING+ __bss_end = .;} | |
149 | ${RELOCATING+ _sheap = .;} | |
150 | } ${RELOCATING+ > ram} | |
151 | ||
152 | saferam ${RELOCATING-0} : { | |
153 | *(saferam) | |
154 | ${RELOCATING+ . = ALIGN(4);} | |
155 | ${RELOCATING+ unitidentry = .;} | |
156 | } ${RELOCATING+ > saferam} | |
157 | ||
158 | /* Stabs debugging sections. */ | |
159 | .stab 0 : { *(.stab) } | |
160 | .stabstr 0 : { *(.stabstr) } | |
161 | .stab.excl 0 : { *(.stab.excl) } | |
162 | .stab.exclstr 0 : { *(.stab.exclstr) } | |
163 | .stab.index 0 : { *(.stab.index) } | |
164 | .stab.indexstr 0 : { *(.stab.indexstr) } | |
165 | ||
166 | .comment 0 : { *(.comment) } | |
167 | ||
168 | EOF | |
169 | ||
170 | . $srcdir/scripttempl/DWARF.sc | |
171 | ||
172 | cat <<EOF | |
173 | } | |
2bf2bf23 | 174 | ${RELOCATING+ |
c18392d8 EB |
175 | /* Provide a default address for the simulated file-I/O device. */ |
176 | PROVIDE (_sim_fileio_register = 0x2fff0000); | |
177 | ||
178 | /* Provide a default address for the simulated command line device. */ | |
179 | PROVIDE (_sim_cmdline_header = 0x2ffe0000); | |
180 | ||
181 | /* Provide a default address for the simulated 1 MHz clock. */ | |
2bf2bf23 | 182 | PROVIDE (_sim_clock = 0x20002100);} |
c18392d8 EB |
183 | |
184 | EOF |