PR ld/10569
[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
13/* The next line forces the entry point (${ENTRY} in this script)
14 to be entered in the output file as an undefined symbol.
15 It is needed in case the entry point is not called explicitly
16 (which is the usual case) AND is in an archive. */
17
18OUTPUT_FORMAT("${OUTPUT_FORMAT}")
19OUTPUT_ARCH(${ARCH})
b34c1498
NC
20${RELOCATING+EXTERN(${ENTRY})}
21${RELOCATING+ENTRY(${ENTRY})}
1fe1f39c
NC
22
23/* Define memory regions. */
24MEMORY
25{
26 rom : ORIGIN = 0x2, LENGTH = 3M
27 ram : ORIGIN = 4M, LENGTH = 10M
28}
29
42851540
NC
30/* Many sections come in three flavours. There is the 'real' section,
31 like ".data". Then there are the per-procedure or per-variable
32 sections, generated by -ffunction-sections and -fdata-sections in GCC,
33 and useful for --gc-sections, which for a variable "foo" might be
34 ".data.foo". Then there are the linkonce sections, for which the linker
35 eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
36 The exact correspondences are:
37
38 Section Linkonce section
39 .text .gnu.linkonce.t.foo
40 .rdata .gnu.linkonce.r.foo
41 .data .gnu.linkonce.d.foo
42 .bss .gnu.linkonce.b.foo
43 .debug_info .gnu.linkonce.wi.foo */
44
1fe1f39c
NC
45SECTIONS
46{
42851540
NC
47 .init :
48 {
49 __INIT_START = .;
1fa32646 50 KEEP (*(.init))
42851540
NC
51 __INIT_END = .;
52 } > rom
53
54 .fini :
55 {
56 __FINI_START = .;
1fa32646 57 KEEP (*(.fini))
42851540
NC
58 __FINI_END = .;
59 } > rom
60
61 .jcr :
62 {
1fa32646 63 KEEP (*(.jcr))
42851540
NC
64 } > rom
65
66 .text :
67 {
68 __TEXT_START = .;
69 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
70 __TEXT_END = .;
71 } > rom
72
73 .rdata :
74 {
75 __RDATA_START = .;
b7309ada 76 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata.*)
42851540
NC
77 __RDATA_END = .;
78 } > rom
79
80 .ctor ALIGN(4) :
81 {
82 __CTOR_START = .;
83 /* The compiler uses crtbegin.o to find the start
84 of the constructors, so we make sure it is
85 first. Because this is a wildcard, it
86 doesn't matter if the user does not
87 actually link against crtbegin.o; the
88 linker won't look for a file to match a
89 wildcard. The wildcard also means that it
90 doesn't matter which directory crtbegin.o
91 is in. */
92
40cf2291
AM
93 KEEP (*crtbegin.o(.ctors))
94 KEEP (*crtbegin?.o(.ctors))
95
42851540
NC
96 /* We don't want to include the .ctor section from
97 the crtend.o file until after the sorted ctors.
98 The .ctor section from the crtend file contains the
99 end of ctors marker and it must be last */
100
40cf2291 101 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))
42851540
NC
102 KEEP (*(SORT(.ctors.*)))
103 KEEP (*(.ctors))
104 __CTOR_END = .;
105 } > rom
106
107 .dtor ALIGN(4) :
108 {
109 __DTOR_START = .;
40cf2291
AM
110 KEEP (*crtbegin.o(.dtors))
111 KEEP (*crtbegin?.o(.dtors))
112 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))
42851540
NC
113 KEEP (*(SORT(.dtors.*)))
114 KEEP (*(.dtors))
115 __DTOR_END = .;
116 } > rom
117
118 .data :
119 {
120 __DATA_START = .;
121 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
122 __DATA_END = .;
123 } > ram AT > rom
124
125 .bss (NOLOAD) :
126 {
127 __BSS_START = .;
128 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
129 __BSS_END = .;
130 } > ram
1fe1f39c
NC
131
132/* You may change the sizes of the following sections to fit the actual
133 size your program requires.
134
135 The heap and stack are aligned to the bus width, as a speed optimization
136 for accessing data located there. */
137
7ba29e2a 138 .heap (NOLOAD) :
42851540
NC
139 {
140 . = ALIGN(4);
141 __HEAP_START = .;
142 . += 0x2000; __HEAP_MAX = .;
143 } > ram
144
7ba29e2a 145 .stack (NOLOAD) :
42851540
NC
146 {
147 . = ALIGN(4);
148 . += 0x6000;
149 __STACK_START = .;
150 } > ram
151
7ba29e2a 152 .istack (NOLOAD) :
42851540
NC
153 {
154 . = ALIGN(4);
155 . += 0x100;
156 __ISTACK_START = .;
157 } > ram
158
159 .comment 0 : { *(.comment) }
160
161 /* DWARF debug sections.
162 Symbols in the DWARF debugging sections are relative to the beginning
163 of the section so we begin them at 0. */
164
165 .debug_aranges 0 : { *(.debug_aranges) }
166 .debug_pubnames 0 : { *(.debug_pubnames) }
167 .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
168 .debug_abbrev 0 : { *(.debug_abbrev) }
169 .debug_line 0 : { *(.debug_line) }
170 .debug_frame 0 : { *(.debug_frame) }
171 .debug_str 0 : { *(.debug_str) }
172 .debug_loc 0 : { *(.debug_loc) }
173 .debug_macinfo 0 : { *(.debug_macinfo) }
1fe1f39c
NC
174}
175
176__DATA_IMAGE_START = LOADADDR(.data);
177EOF
This page took 0.201104 seconds and 4 git commands to generate.