2009-11-06 Sebastian Pop <sebastian.pop@amd.com>
[binutils.git] / ld / scripttempl / elf32cr16.sc
blob61351c579bdfa6e2ddf54a641afdf4782dc05970
1 # Linker Script for National Semiconductor's CR16-ELF32.
3 # The next line should be uncommented if it is desired to link
4 # without libstart.o and directly enter main.
6 # ENTRY=_main
8 test -z "$ENTRY" && ENTRY=_start
9 cat <<EOF
11 /* Example Linker Script for linking NS CR16 elf32 files. */
13 OUTPUT_FORMAT("${OUTPUT_FORMAT}")
14 OUTPUT_ARCH(${ARCH})
15 ${RELOCATING+ENTRY(${ENTRY})}
17 /* Define memory regions.  */
18 MEMORY
20         rom         : ORIGIN = 0x2,         LENGTH = 3M
21         ram         : ORIGIN = 4M,          LENGTH = 10M
24 /*  Many sections come in three flavours.  There is the 'real' section,
25     like ".data".  Then there are the per-procedure or per-variable
26     sections, generated by -ffunction-sections and -fdata-sections in GCC,
27     and useful for --gc-sections, which for a variable "foo" might be
28     ".data.foo".  Then there are the linkonce sections, for which the linker
29     eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
30     The exact correspondences are:
32     Section     Linkonce section
33     .text       .gnu.linkonce.t.foo
34     .rdata      .gnu.linkonce.r.foo
35     .data       .gnu.linkonce.d.foo
36     .bss        .gnu.linkonce.b.foo
37     .debug_info .gnu.linkonce.wi.foo  */
39 SECTIONS
41   .init :
42   { 
43     __INIT_START = .; 
44     KEEP (*(.init))
45     __INIT_END = .; 
46   } > rom
48   .fini :
49   { 
50     __FINI_START = .; 
51     KEEP (*(.fini))
52     __FINI_END = .; 
53   } > rom
55   .jcr :
56   { 
57     KEEP (*(.jcr))
58   } > rom
60   .text : 
61   {
62     __TEXT_START = .;
63     *(.text) *(.text.*) *(.gnu.linkonce.t.*)
64     __TEXT_END = .;
65   } > rom
67   .rdata :
68   {
69     __RDATA_START = .;
70     *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*)
71     __RDATA_END = .;
72   } > rom
74   .ctor ALIGN(4) : 
75   { 
76     __CTOR_START = .; 
77     /* The compiler uses crtbegin.o to find the start
78        of the constructors, so we make sure it is
79        first.  Because this is a wildcard, it
80        doesn't matter if the user does not
81        actually link against crtbegin.o; the
82        linker won't look for a file to match a
83        wildcard.  The wildcard also means that it
84        doesn't matter which directory crtbegin.o
85        is in.  */
87     KEEP (*crtbegin*.o(.ctors))
89     /* We don't want to include the .ctor section from
90        the crtend.o file until after the sorted ctors.
91        The .ctor section from the crtend file contains the
92        end of ctors marker and it must be last */
94     KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
95     KEEP (*(SORT(.ctors.*)))
96     KEEP (*(.ctors))
97     __CTOR_END = .; 
98   } > rom
100   .dtor ALIGN(4) : 
101   { 
102     __DTOR_START = .; 
103     KEEP (*crtbegin*.o(.dtors))
104     KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
105     KEEP (*(SORT(.dtors.*)))
106     KEEP (*(.dtors))
107     __DTOR_END = .; 
108   } > rom
110   .data :
111   {
112     __DATA_START = .;
113     *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
114     __DATA_END = .;
115   } > ram AT > rom
117   .bss (NOLOAD) :
118   {
119     __BSS_START = .;
120     *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
121     __BSS_END = .;
122   } > ram
124 /* You may change the sizes of the following sections to fit the actual
125    size your program requires.
127    The heap and stack are aligned to the bus width, as a speed optimization
128    for accessing data located there.  */
130   .heap (NOLOAD) :
131   {
132     . = ALIGN(4);
133     __HEAP_START = .;
134     . += 0x2000; __HEAP_MAX = .;
135   } > ram
137   .stack (NOLOAD) :
138   {
139     . = ALIGN(4);
140     . += 0x6000;
141     __STACK_START = .;
142   } > ram
144   .istack (NOLOAD) :
145   {
146     . = ALIGN(4);
147     . += 0x100;
148     __ISTACK_START = .;
149   } > ram
151   .comment        0 : { *(.comment) }
153   /* DWARF debug sections.
154      Symbols in the DWARF debugging sections are relative to the beginning
155      of the section so we begin them at 0.  */
157   .debug_aranges  0 : { *(.debug_aranges) }
158   .debug_pubnames 0 : { *(.debug_pubnames) }
159   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
160   .debug_abbrev   0 : { *(.debug_abbrev) }
161   .debug_line     0 : { *(.debug_line) }
162   .debug_frame    0 : { *(.debug_frame) }
163   .debug_str      0 : { *(.debug_str) }
164   .debug_loc      0 : { *(.debug_loc) }
165   .debug_macinfo  0 : { *(.debug_macinfo) }
168 __DATA_IMAGE_START = LOADADDR(.data);