1 # Linker Script for National Semiconductor's CR16-ELF32.
3 # Copyright (C) 2014-2018 Free Software Foundation, Inc.
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.
9 # Using an empty script for ld -r is better than mashing together
10 # sections. This hack likely leaves ld -Ur broken.
11 test -n "${RELOCATING}" || exit 0
13 # The next line should be uncommented if it is desired to link
14 # without libstart.o and directly enter main.
18 test -z "$ENTRY" && ENTRY=_start
21 /* Example Linker Script for linking NS CR16 elf32 files.
22 Copyright (C) 2014-2018 Free Software Foundation, Inc.
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. */
28 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
32 test -n "${RELOCATING}" && cat <<EOF
35 /* Define memory regions. */
38 rom : ORIGIN = 0x2, LENGTH = 3M
39 ram : ORIGIN = 4M, LENGTH = 10M
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:
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 */
84 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
91 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
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
108 KEEP (*crtbegin*.o(.ctors))
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 */
115 KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
116 KEEP (*(SORT(.ctors.*)))
119 }${RELOCATING+ > rom}
124 KEEP (*crtbegin*.o(.dtors))
125 KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
126 KEEP (*(SORT(.dtors.*)))
129 }${RELOCATING+ > rom}
134 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
136 }${RELOCATING+ > ram AT > rom}
141 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
143 }${RELOCATING+ > ram}
145 /* You may change the sizes of the following sections to fit the actual
146 size your program requires.
148 The heap and stack are aligned to the bus width, as a speed optimization
149 for accessing data located there. */
155 . += 0x2000; __HEAP_MAX = .;
156 }${RELOCATING+ > ram}
163 }${RELOCATING+ > ram}
170 }${RELOCATING+ > ram}
172 .comment 0 : { *(.comment) }
176 . $srcdir/scripttempl/DWARF.sc
181 ${RELOCATING+__DATA_IMAGE_START = LOADADDR(.data);}