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