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