1 # Linker Script for National Semiconductor's CRX-ELF32.
3 # Copyright (C) 2014-2019 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 CRX elf32 files.
23 Copyright (C) 2014-2019 Free Software Foundation, Inc.
25 Copying and distribution of this script, with or without modification,
26 are permitted in any medium without royalty provided the copyright
27 notice and this notice are preserved. */
30 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
32 ${RELOCATING+ENTRY(${ENTRY})}
34 /* Define memory regions. */
37 rom : ORIGIN = 0x2, LENGTH = 3M
38 ram : ORIGIN = 4M, LENGTH = 10M
41 /* Many sections come in three flavours. There is the 'real' section,
42 like ".data". Then there are the per-procedure or per-variable
43 sections, generated by -ffunction-sections and -fdata-sections in GCC,
44 and useful for --gc-sections, which for a variable "foo" might be
45 ".data.foo". Then there are the linkonce sections, for which the linker
46 eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
47 The exact correspondences are:
49 Section Linkonce section
50 .text .gnu.linkonce.t.foo
51 .rdata .gnu.linkonce.r.foo
52 .data .gnu.linkonce.d.foo
53 .bss .gnu.linkonce.b.foo
54 .debug_info .gnu.linkonce.wi.foo */
61 KEEP (*(SORT_NONE(.init)))
68 KEEP (*(SORT_NONE(.fini)))
80 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
87 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata.*)
94 /* The compiler uses crtbegin.o to find the start
95 of the constructors, so we make sure it is
96 first. Because this is a wildcard, it
97 doesn't matter if the user does not
98 actually link against crtbegin.o; the
99 linker won't look for a file to match a
100 wildcard. The wildcard also means that it
101 doesn't matter which directory crtbegin.o
104 KEEP (*crtbegin.o(.ctors))
105 KEEP (*crtbegin?.o(.ctors))
107 /* We don't want to include the .ctor section from
108 the crtend.o file until after the sorted ctors.
109 The .ctor section from the crtend file contains the
110 end of ctors marker and it must be last */
112 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))
113 KEEP (*(SORT(.ctors.*)))
121 KEEP (*crtbegin.o(.dtors))
122 KEEP (*crtbegin?.o(.dtors))
123 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))
124 KEEP (*(SORT(.dtors.*)))
132 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
139 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
143 /* You may change the sizes of the following sections to fit the actual
144 size your program requires.
146 The heap and stack are aligned to the bus width, as a speed optimization
147 for accessing data located there. */
153 . += 0x2000; __HEAP_MAX = .;
170 .comment 0 : { *(.comment) }
174 . $srcdir/scripttempl/DWARF.sc
179 __DATA_IMAGE_START = LOADADDR(.data);