1 # Linker Script for National Semiconductor's CR16-ELF32.
3 # Copyright (C) 2014-2016 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 # The next line should be uncommented if it is desired to link
10 # without libstart.o and directly enter main.
14 test -z "$ENTRY" && ENTRY=_start
17 /* Example Linker Script for linking NS CR16 elf32 files.
18 Copyright (C) 2014-2016 Free Software Foundation, Inc.
20 Copying and distribution of this script, with or without modification,
21 are permitted in any medium without royalty provided the copyright
22 notice and this notice are preserved. */
24 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
26 ${RELOCATING+ENTRY(${ENTRY})}
28 /* Define memory regions. */
31 rom : ORIGIN = 0x2, LENGTH = 3M
32 ram : ORIGIN = 4M, LENGTH = 10M
35 /* Many sections come in three flavours. There is the 'real' section,
36 like ".data". Then there are the per-procedure or per-variable
37 sections, generated by -ffunction-sections and -fdata-sections in GCC,
38 and useful for --gc-sections, which for a variable "foo" might be
39 ".data.foo". Then there are the linkonce sections, for which the linker
40 eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
41 The exact correspondences are:
43 Section Linkonce section
44 .text .gnu.linkonce.t.foo
45 .rdata .gnu.linkonce.r.foo
46 .data .gnu.linkonce.d.foo
47 .bss .gnu.linkonce.b.foo
48 .debug_info .gnu.linkonce.wi.foo */
74 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
81 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
88 /* The compiler uses crtbegin.o to find the start
89 of the constructors, so we make sure it is
90 first. Because this is a wildcard, it
91 doesn't matter if the user does not
92 actually link against crtbegin.o; the
93 linker won't look for a file to match a
94 wildcard. The wildcard also means that it
95 doesn't matter which directory crtbegin.o
98 KEEP (*crtbegin*.o(.ctors))
100 /* We don't want to include the .ctor section from
101 the crtend.o file until after the sorted ctors.
102 The .ctor section from the crtend file contains the
103 end of ctors marker and it must be last */
105 KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
106 KEEP (*(SORT(.ctors.*)))
114 KEEP (*crtbegin*.o(.dtors))
115 KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
116 KEEP (*(SORT(.dtors.*)))
124 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
131 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
135 /* You may change the sizes of the following sections to fit the actual
136 size your program requires.
138 The heap and stack are aligned to the bus width, as a speed optimization
139 for accessing data located there. */
145 . += 0x2000; __HEAP_MAX = .;
162 .comment 0 : { *(.comment) }
166 . $srcdir/scripttempl/DWARF.sc
171 __DATA_IMAGE_START = LOADADDR(.data);