]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/scripttempl/elf32cr16.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / elf32cr16.sc
1 # Linker Script for National Semiconductor's CR16-ELF32.
2 #
3 # Copyright (C) 2014-2021 Free Software Foundation, Inc.
4 #
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved.
8
9 # Using an empty script for ld -r is better than mashing together
10 # sections. This hack likely leaves ld -Ur broken.
11 test -n "${RELOCATING}" || exit 0
12
13 # The next line should be uncommented if it is desired to link
14 # without libstart.o and directly enter main.
15
16 # ENTRY=_main
17
18 test -z "$ENTRY" && ENTRY=_start
19 cat <<EOF
20
21 /* Example Linker Script for linking NS CR16 elf32 files.
22 Copyright (C) 2014-2021 Free Software Foundation, Inc.
23
24 Copying and distribution of this script, with or without modification,
25 are permitted in any medium without royalty provided the copyright
26 notice and this notice are preserved. */
27
28 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
29 OUTPUT_ARCH(${ARCH})
30 EOF
31
32 test -n "${RELOCATING}" && cat <<EOF
33 ENTRY(${ENTRY})
34
35 /* Define memory regions. */
36 MEMORY
37 {
38 rom : ORIGIN = 0x2, LENGTH = 3M
39 ram : ORIGIN = 4M, LENGTH = 10M
40 }
41
42 EOF
43
44 cat <<EOF
45 /* Many sections come in three flavours. There is the 'real' section,
46 like ".data". Then there are the per-procedure or per-variable
47 sections, generated by -ffunction-sections and -fdata-sections in GCC,
48 and useful for --gc-sections, which for a variable "foo" might be
49 ".data.foo". Then there are the linkonce sections, for which the linker
50 eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
51 The exact correspondences are:
52
53 Section Linkonce section
54 .text .gnu.linkonce.t.foo
55 .rdata .gnu.linkonce.r.foo
56 .data .gnu.linkonce.d.foo
57 .bss .gnu.linkonce.b.foo
58 .debug_info .gnu.linkonce.wi.foo */
59
60 SECTIONS
61 {
62 .init :
63 {
64 __INIT_START = .;
65 KEEP (*(SORT_NONE(.init)))
66 __INIT_END = .;
67 }${RELOCATING+ > rom}
68
69 .fini :
70 {
71 __FINI_START = .;
72 KEEP (*(SORT_NONE(.fini)))
73 __FINI_END = .;
74 }${RELOCATING+ > rom}
75
76 .jcr :
77 {
78 KEEP (*(.jcr))
79 }${RELOCATING+ > rom}
80
81 .text :
82 {
83 __TEXT_START = .;
84 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
85 __TEXT_END = .;
86 }${RELOCATING+ > rom}
87
88 .rdata :
89 {
90 __RDATA_START = .;
91 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
92 __RDATA_END = .;
93 }${RELOCATING+ > rom}
94
95 .ctor ALIGN(4) :
96 {
97 __CTOR_START = .;
98 /* The compiler uses crtbegin.o to find the start
99 of the constructors, so we make sure it is
100 first. Because this is a wildcard, it
101 doesn't matter if the user does not
102 actually link against crtbegin.o; the
103 linker won't look for a file to match a
104 wildcard. The wildcard also means that it
105 doesn't matter which directory crtbegin.o
106 is in. */
107
108 KEEP (*crtbegin*.o(.ctors))
109
110 /* We don't want to include the .ctor section from
111 the crtend.o file until after the sorted ctors.
112 The .ctor section from the crtend file contains the
113 end of ctors marker and it must be last */
114
115 KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
116 KEEP (*(SORT(.ctors.*)))
117 KEEP (*(.ctors))
118 __CTOR_END = .;
119 }${RELOCATING+ > rom}
120
121 .dtor ALIGN(4) :
122 {
123 __DTOR_START = .;
124 KEEP (*crtbegin*.o(.dtors))
125 KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
126 KEEP (*(SORT(.dtors.*)))
127 KEEP (*(.dtors))
128 __DTOR_END = .;
129 }${RELOCATING+ > rom}
130
131 .data :
132 {
133 __DATA_START = .;
134 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
135 __DATA_END = .;
136 }${RELOCATING+ > ram AT > rom}
137
138 .bss (NOLOAD) :
139 {
140 __BSS_START = .;
141 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
142 __BSS_END = .;
143 }${RELOCATING+ > ram}
144
145 /* You may change the sizes of the following sections to fit the actual
146 size your program requires.
147
148 The heap and stack are aligned to the bus width, as a speed optimization
149 for accessing data located there. */
150
151 .heap (NOLOAD) :
152 {
153 . = ALIGN(4);
154 __HEAP_START = .;
155 . += 0x2000; __HEAP_MAX = .;
156 }${RELOCATING+ > ram}
157
158 .stack (NOLOAD) :
159 {
160 . = ALIGN(4);
161 . += 0x6000;
162 __STACK_START = .;
163 }${RELOCATING+ > ram}
164
165 .istack (NOLOAD) :
166 {
167 . = ALIGN(4);
168 . += 0x100;
169 __ISTACK_START = .;
170 }${RELOCATING+ > ram}
171
172 .comment 0 : { *(.comment) }
173
174 EOF
175
176 . $srcdir/scripttempl/DWARF.sc
177
178 cat <<EOF
179 }
180
181 ${RELOCATING+__DATA_IMAGE_START = LOADADDR(.data);}
182 EOF