]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/scripttempl/elf32cr16.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / elf32cr16.sc
CommitLineData
3d3d428f 1# Linker Script for National Semiconductor's CR16-ELF32.
985743c7 2#
250d07de 3# Copyright (C) 2014-2021 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.
3d3d428f 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
3d3d428f
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 21/* Example Linker Script for linking NS CR16 elf32 files.
250d07de 22 Copyright (C) 2014-2021 Free Software Foundation, Inc.
985743c7
NC
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. */
3d3d428f 27
3d3d428f
NC
28OUTPUT_FORMAT("${OUTPUT_FORMAT}")
29OUTPUT_ARCH(${ARCH})
2bf2bf23
AM
30EOF
31
32test -n "${RELOCATING}" && cat <<EOF
33ENTRY(${ENTRY})
3d3d428f
NC
34
35/* Define memory regions. */
36MEMORY
37{
6c19b93b
AM
38 rom : ORIGIN = 0x2, LENGTH = 3M
39 ram : ORIGIN = 4M, LENGTH = 10M
3d3d428f
NC
40}
41
2bf2bf23
AM
42EOF
43
44cat <<EOF
3d3d428f
NC
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
60SECTIONS
61{
62 .init :
6c19b93b
AM
63 {
64 __INIT_START = .;
2d3181c7 65 KEEP (*(SORT_NONE(.init)))
6c19b93b 66 __INIT_END = .;
2bf2bf23 67 }${RELOCATING+ > rom}
3d3d428f
NC
68
69 .fini :
6c19b93b
AM
70 {
71 __FINI_START = .;
2d3181c7 72 KEEP (*(SORT_NONE(.fini)))
6c19b93b 73 __FINI_END = .;
2bf2bf23 74 }${RELOCATING+ > rom}
3d3d428f
NC
75
76 .jcr :
6c19b93b 77 {
3d3d428f 78 KEEP (*(.jcr))
2bf2bf23 79 }${RELOCATING+ > rom}
3d3d428f 80
6c19b93b 81 .text :
3d3d428f
NC
82 {
83 __TEXT_START = .;
84 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
85 __TEXT_END = .;
2bf2bf23 86 }${RELOCATING+ > rom}
3d3d428f
NC
87
88 .rdata :
89 {
90 __RDATA_START = .;
91 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
92 __RDATA_END = .;
2bf2bf23 93 }${RELOCATING+ > rom}
3d3d428f 94
6c19b93b
AM
95 .ctor ALIGN(4) :
96 {
97 __CTOR_START = .;
3d3d428f
NC
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))
6c19b93b 118 __CTOR_END = .;
2bf2bf23 119 }${RELOCATING+ > rom}
3d3d428f 120
6c19b93b
AM
121 .dtor ALIGN(4) :
122 {
123 __DTOR_START = .;
3d3d428f
NC
124 KEEP (*crtbegin*.o(.dtors))
125 KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
126 KEEP (*(SORT(.dtors.*)))
127 KEEP (*(.dtors))
6c19b93b 128 __DTOR_END = .;
2bf2bf23 129 }${RELOCATING+ > rom}
3d3d428f
NC
130
131 .data :
132 {
133 __DATA_START = .;
134 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
135 __DATA_END = .;
2bf2bf23 136 }${RELOCATING+ > ram AT > rom}
3d3d428f
NC
137
138 .bss (NOLOAD) :
139 {
140 __BSS_START = .;
141 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
142 __BSS_END = .;
2bf2bf23 143 }${RELOCATING+ > ram}
3d3d428f
NC
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
7ba29e2a 151 .heap (NOLOAD) :
3d3d428f
NC
152 {
153 . = ALIGN(4);
154 __HEAP_START = .;
155 . += 0x2000; __HEAP_MAX = .;
2bf2bf23 156 }${RELOCATING+ > ram}
3d3d428f 157
7ba29e2a 158 .stack (NOLOAD) :
3d3d428f
NC
159 {
160 . = ALIGN(4);
161 . += 0x6000;
162 __STACK_START = .;
2bf2bf23 163 }${RELOCATING+ > ram}
3d3d428f 164
7ba29e2a 165 .istack (NOLOAD) :
3d3d428f
NC
166 {
167 . = ALIGN(4);
168 . += 0x100;
169 __ISTACK_START = .;
2bf2bf23 170 }${RELOCATING+ > ram}
3d3d428f
NC
171
172 .comment 0 : { *(.comment) }
173
ceb0a680
NC
174EOF
175
d061dfac 176. $srcdir/scripttempl/DWARF.sc
ceb0a680
NC
177
178cat <<EOF
3d3d428f
NC
179}
180
2bf2bf23 181${RELOCATING+__DATA_IMAGE_START = LOADADDR(.data);}
3d3d428f 182EOF