OSDN Git Service

when debugging a flat loader problem involving relocs, i found it very
[uclinux-h8/elf2flt.git] / elf2flt.ld
1
2 ENTRY (_start)
3
4 MEMORY {
5         flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff
6 }
7
8 SECTIONS {
9
10         .text 0x0 : {
11                 . = . + 4;
12                 . = ALIGN(0x4) ;
13                 _stext = . ;
14                 *(.text)
15                 *(.text.*)
16                 *(.gnu.warning)
17                 *(.stub)
18                 *(.gnu.linkonce.t*)
19                 *(.glue_7t)
20                 *(.glue_7)
21                 *(.jcr)
22                 *(.init)
23                 *(.fini)
24
25 W_RODAT         *(.rodata)
26 W_RODAT         *(.rodata1)
27 W_RODAT         *(.rodata.*)
28 W_RODAT         *(.gnu.linkonce.r*)
29
30                 /* This is special code area at the end of the normal
31                    text section.  It contains a small lookup table at
32                    the start followed by the code pointed to by entries
33                    in the lookup table.  */
34                 . = ALIGN (4) ;
35                 PROVIDE(__ctbp = .);
36                 *(.call_table_data)
37                 *(.call_table_text)
38
39                 . = ALIGN(0x20) ;
40                 _etext = . ;
41         } > flatmem
42
43         .data : {
44                 . = ALIGN(0x4) ;
45                 _sdata = . ;
46                 __data_start = . ;
47                 data_start = . ;
48                 *(.got.plt)
49                 *(.got)
50                 FILL(0) ;
51                 . = ALIGN(0x20) ; 
52                 LONG(-1)
53                 . = ALIGN(0x20) ; 
54 R_RODAT         *(.rodata)
55 R_RODAT         *(.rodata1)
56 R_RODAT         *(.rodata.*)
57 R_RODAT         *(.gnu.linkonce.r*)
58                 *(.data)
59                 *(.data1)
60                 *(.data.*)
61                 *(.gnu.linkonce.d*)
62                 *(.eh_frame_hdr)
63                 *(.eh_frame)
64                 *(.gcc_except_table)
65
66                 /* Microblaze has .sdata and .sbss (small bss).  They must
67                    be contiguous, so please don't move any of this. JW */
68                 _ssrw = . ;                     
69                 *(.sdata) 
70                 *(.sdata.*)
71                 *(.sbss)                        /* Don't move this! */
72                 *(.gnu.linkonce.sb*)
73                 _essrw = . ;
74
75                 _ssrw_size = _essrw - _ssrw;
76                 PROVIDE(_SDA_BASE_ = _ssrw + (_ssrw_size / 2));
77
78                 *(.gnu.linkonce.s.*)
79                 *(__libc_atexit)
80                 *(__libc_subinit)
81                 *(__libc_subfreeres)
82                 *(.note.ABI-tag)
83
84                 /* microblaze-specific read-only small data area
85                    and associated locating symbols */
86                 _ssro = . ;
87                 *(.sdata2)
88                 _essro = . ;
89                 _ssro_size = _essro - _ssro;
90                 PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2));
91
92                 . = ALIGN(4) ;
93                 __CTOR_LIST__ = .;
94                 LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
95 SINGLE_LINK:    /* gcc uses crtbegin.o to find the start of
96 SINGLE_LINK:       the constructors, so we make sure it is
97 SINGLE_LINK:       first.  Because this is a wildcard, it
98 SINGLE_LINK:       doesn't matter if the user does not
99 SINGLE_LINK:       actually link against crtbegin.o; the
100 SINGLE_LINK:       linker won't look for a file to match a
101 SINGLE_LINK:       wildcard.  The wildcard also means that it
102 SINGLE_LINK:       doesn't matter which directory crtbegin.o
103 SINGLE_LINK:       is in.  */
104 SINGLE_LINK:    KEEP (*crtbegin*.o(.ctors))
105 SINGLE_LINK:    /* We don't want to include the .ctor section from
106 SINGLE_LINK:       from the crtend.o file until after the sorted ctors.
107 SINGLE_LINK:       The .ctor section from the crtend file contains the
108 SINGLE_LINK:       end of ctors marker and it must be last */
109 SINGLE_LINK:    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
110 SINGLE_LINK:    KEEP (*(SORT(.ctors.*)))
111                 KEEP (*(.ctors))
112                 LONG(0)
113                 __CTOR_END__ = .;
114                 __DTOR_LIST__ = .;
115                 LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
116 SINGLE_LINK:    KEEP (*crtbegin*.o(.dtors))
117 SINGLE_LINK:    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
118 SINGLE_LINK:    KEEP (*(SORT(.dtors.*)))
119                 KEEP (*(.dtors))
120                 LONG(0)
121                 __DTOR_END__ = .;
122
123                 PROVIDE (__preinit_array_start = .);
124                 KEEP (*(.preinit_array))
125                 PROVIDE (__preinit_array_end = .);
126
127                 PROVIDE (__init_array_start = .);
128                 KEEP (*(SORT(.init_array.*)))
129                 KEEP (*(.init_array))
130                 PROVIDE (__init_array_end = .);
131
132                 PROVIDE (__fini_array_start = .);
133                 KEEP (*(.fini_array))
134                 KEEP (*(SORT(.fini_array.*)))
135                 PROVIDE (__fini_array_end = .);
136
137                 . = ALIGN(0x10) ; 
138                 _edata = . ;
139         } > flatmem
140
141         .bss : {
142                 . = ALIGN(0x4) ;
143                 _sbss = ALIGN(0x4) ;
144                 __bss_start = . ;
145                 *(.dynsbss)
146                 *(.sbss)
147                 *(.sbss.*)
148                 *(.scommon)
149                 *(.dynbss)
150                 *(.bss)
151                 *(.bss.*)
152                 *(.bss*)
153                 *(.gnu.linkonce.b*)
154                 *(COMMON)
155                 . = ALIGN(0x10) ;
156                 _ebss = . ;
157                 _end = . ;
158                 end = . ;
159         } > flatmem
160
161         .stack : {
162                 . = ALIGN(0x4);
163                 __stack_start = .;
164         }
165
166         .junk 0 : { *(.rel*) *(.rela*) }
167         /* Stabs debugging sections.    */
168         .stab 0 : { *(.stab) }
169         .stabstr 0 : { *(.stabstr) }
170         .stab.excl 0 : { *(.stab.excl) }
171         .stab.exclstr 0 : { *(.stab.exclstr) }
172         .stab.index 0 : { *(.stab.index) }
173         .stab.indexstr 0 : { *(.stab.indexstr) }
174         .comment 0 : { *(.comment) }
175         .debug_abbrev 0 : { *(.debug_abbrev) }
176         .debug_info 0 : { *(.debug_info) }
177         .debug_line 0 : { *(.debug_line) }
178         .debug_pubnames 0 : { *(.debug_pubnames) }
179         .debug_aranges 0 : { *(.debug_aranges) }
180         .debug_frame    0 : { *(.debug_frame) }
181         .debug_str      0 : { *(.debug_str) }
182 }