1 # Linker Script for National Semiconductor's CR16-ELF32.
2 test -z "$RELOCATING" && exit 0
4 # The next line should be uncommented if it is desired to link
5 # without libstart.o and directly enter main.
9 test -z "$ENTRY" && ENTRY=_start
12 /* Example Linker Script for linking NS CR16 elf32 files. */
14 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
18 /* Define memory regions. */
21 rom : ORIGIN = 0x2, LENGTH = 3M
22 ram : ORIGIN = 4M, LENGTH = 10M
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:
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 */
64 *(.text) *(.text.*) *(.gnu.linkonce.t.*)
71 *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
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
88 KEEP (*crtbegin*.o(.ctors))
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 */
95 KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
96 KEEP (*(SORT(.ctors.*)))
104 KEEP (*crtbegin*.o(.dtors))
105 KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
106 KEEP (*(SORT(.dtors.*)))
114 *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
121 *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
125 /* You may change the sizes of the following sections to fit the actual
126 size your program requires.
128 The heap and stack are aligned to the bus width, as a speed optimization
129 for accessing data located there. */
135 . += 0x2000; __HEAP_MAX = .;
152 .comment 0 : { *(.comment) }
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. */
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) }
169 __DATA_IMAGE_START = LOADADDR(.data);