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