1/* Default linker script, for normal executables */
2/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
3   Copying and distribution of this script, with or without modification,
4   are permitted in any medium without royalty provided the copyright
5   notice and this notice are preserved.  */
6/* -*- Makefile -*- */
7OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
8              "elf32-littlearm")
9OUTPUT_ARCH(arm)
10ENTRY(_start)
11
12PHDRS
13{
14  phdr PT_PHDR PHDRS;
15  ro PT_LOAD FILEHDR PHDRS;
16  rw PT_LOAD;
17  tls PT_TLS;
18  L4_DEFINE_L4PHDRS
19}
20
21
22SECTIONS
23{
24  /* Read-only sections, merged into text segment: */
25  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x00010000)); . = SEGMENT_START("text-segment", 0x00010000) + SIZEOF_HEADERS;
26  .interp         : { *(.interp) } :ro
27  .note.gnu.build-id : { *(.note.gnu.build-id) }
28  .hash           : { *(.hash) }
29  .gnu.hash       : { *(.gnu.hash) }
30  .dynsym         : { *(.dynsym) }
31  .dynstr         : { *(.dynstr) }
32  .gnu.version    : { *(.gnu.version) }
33  .gnu.version_d  : { *(.gnu.version_d) }
34  .gnu.version_r  : { *(.gnu.version_r) }
35  .rel.init       : { *(.rel.init) }
36  .rela.init      : { *(.rela.init) }
37  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
38  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
39  .rel.fini       : { *(.rel.fini) }
40  .rela.fini      : { *(.rela.fini) }
41  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
42  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
43  .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
44  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
45  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
46  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
47  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
48  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
49  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
50  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
51  .rel.ctors      : { *(.rel.ctors) }
52  .rela.ctors     : { *(.rela.ctors) }
53  .rel.dtors      : { *(.rel.dtors) }
54  .rela.dtors     : { *(.rela.dtors) }
55  .rel.got        : { *(.rel.got) }
56  .rela.got       : { *(.rela.got) }
57  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
58  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
59  .rel.iplt       :
60    {
61      PROVIDE_HIDDEN (__rel_iplt_start = .);
62      *(.rel.iplt)
63      PROVIDE_HIDDEN (__rel_iplt_end = .);
64    }
65  .rela.iplt      :
66    {
67      PROVIDE_HIDDEN (__rela_iplt_start = .);
68      *(.rela.iplt)
69      PROVIDE_HIDDEN (__rela_iplt_end = .);
70    }
71  .rel.plt        :
72    {
73      *(.rel.plt)
74    }
75  .rela.plt       :
76    {
77      *(.rela.plt)
78    }
79  .init           :
80  {
81    _stext = .;
82    _prog_img_start = _stext;
83    KEEP (*(SORT_NONE(.init)))
84  }
85  .plt            : { *(.plt) }
86  .iplt           : { *(.iplt) }
87  .text           :
88  {
89    *(.text.unlikely .text.*_unlikely .text.unlikely.*)
90    *(.text.exit .text.exit.*)
91    *(.text.startup .text.startup.*)
92    *(.text.hot .text.hot.*)
93    *(.text .stub .text.* .gnu.linkonce.t.*)
94    /* .gnu.warning sections are handled specially by elf32.em.  */
95    *(.gnu.warning)
96    *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
97  }
98  .fini           :
99  {
100    KEEP (*(SORT_NONE(.fini)))
101  }
102  PROVIDE (__etext = .);
103  PROVIDE (_etext = .);
104  PROVIDE (etext = .);
105  .rol4re_elf_aux : {
106    KEEP (*(.rol4re_elf_aux))
107  } : ro : l4re_aux
108  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) } : ro
109  .rodata1        : { *(.rodata1) }
110  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
111   PROVIDE_HIDDEN (__exidx_start = .);
112  .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
113   PROVIDE_HIDDEN (__exidx_end = .);
114  .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
115  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
116  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table
117  .gcc_except_table.*) }
118  .gnu_extab   : ONLY_IF_RO { *(.gnu_extab*) }
119  /* These sections are generated by the Sun/Oracle C++ compiler.  */
120  .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
121  .exception_ranges*) }
122  /* Adjust the address for the data segment.  We want to adjust up to
123     the same address within the page on the next page up.  */
124  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
125  /* Exception handling  */
126  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rw
127  .gnu_extab      : ONLY_IF_RW { *(.gnu_extab) } :rw
128  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :rw
129  .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :rw
130  /* Thread Local Storage sections  */
131  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) } :rw : tls
132  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
133  .preinit_array     :
134  {
135    PROVIDE_HIDDEN (__preinit_array_start = .);
136    KEEP (*(.preinit_array))
137    PROVIDE_HIDDEN (__preinit_array_end = .);
138  } : rw
139  .init_array     :
140  {
141    PROVIDE_HIDDEN (__init_array_start = .);
142    KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
143    KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
144    PROVIDE_HIDDEN (__init_array_end = .);
145  }
146  .fini_array     :
147  {
148    PROVIDE_HIDDEN (__fini_array_start = .);
149    KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
150    KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
151    PROVIDE_HIDDEN (__fini_array_end = .);
152  }
153  .ctors          :
154  {
155    /* gcc uses crtbegin.o to find the start of
156       the constructors, so we make sure it is
157       first.  Because this is a wildcard, it
158       doesn't matter if the user does not
159       actually link against crtbegin.o; the
160       linker won't look for a file to match a
161       wildcard.  The wildcard also means that it
162       doesn't matter which directory crtbegin.o
163       is in.  */
164    KEEP (*crtbegin.o(.ctors))
165    KEEP (*crtbegin?.o(.ctors))
166    /* We don't want to include the .ctor section from
167       the crtend.o file until after the sorted ctors.
168       The .ctor section from the crtend file contains the
169       end of ctors marker and it must be last */
170    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
171    KEEP (*(SORT(.ctors.*)))
172    KEEP (*(.ctors))
173  }
174  .dtors          :
175  {
176    KEEP (*crtbegin.o(.dtors))
177    KEEP (*crtbegin?.o(.dtors))
178    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
179    KEEP (*(SORT(.dtors.*)))
180    KEEP (*(.dtors))
181  }
182  .jcr            : { KEEP (*(.jcr)) }
183  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
184  .dynamic        : { *(.dynamic) }
185  . = DATA_SEGMENT_RELRO_END (0, .);
186  .got            : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
187  .data           :
188  {
189    PROVIDE (__data_start = .);
190    *(.data .data.* .gnu.linkonce.d.*)
191    SORT(CONSTRUCTORS)
192  }
193  .data1          : { *(.data1) }
194  _edata = .; PROVIDE (edata = .);
195  . = .;
196  __bss_start = .;
197  __bss_start__ = .;
198  .bss            :
199  {
200   *(.dynbss)
201   *(.bss .bss.* .gnu.linkonce.b.*)
202   *(COMMON)
203   /* Align here to ensure that the .bss section occupies space up to
204      _end.  Align after .bss to ensure correct alignment even if the
205      .bss section disappears because there are no input sections.
206      FIXME: Why do we need it? When there is no .bss section, we don't
207      pad the .data section.  */
208   . = ALIGN(. != 0 ? 32 / 8 : 1);
209  }
210  _bss_end__ = . ; __bss_end__ = . ;
211  . = ALIGN(32 / 8);
212  . = SEGMENT_START("ldata-segment", .);
213  . = ALIGN(32 / 8);
214  __end__ = . ;
215  _end = .; PROVIDE (end = .);
216  . = DATA_SEGMENT_END (.);
217  /* Stabs debugging sections.  */
218  .stab          0 : { *(.stab) } :NONE
219  .stabstr       0 : { *(.stabstr) }
220  .stab.excl     0 : { *(.stab.excl) }
221  .stab.exclstr  0 : { *(.stab.exclstr) }
222  .stab.index    0 : { *(.stab.index) }
223  .stab.indexstr 0 : { *(.stab.indexstr) }
224  .comment       0 : { *(.comment) }
225  /* DWARF debug sections.
226     Symbols in the DWARF debugging sections are relative to the beginning
227     of the section so we begin them at 0.  */
228  /* DWARF 1 */
229  .debug          0 : { *(.debug) }
230  .line           0 : { *(.line) }
231  /* GNU DWARF 1 extensions */
232  .debug_srcinfo  0 : { *(.debug_srcinfo) }
233  .debug_sfnames  0 : { *(.debug_sfnames) }
234  /* DWARF 1.1 and DWARF 2 */
235  .debug_aranges  0 : { *(.debug_aranges) }
236  .debug_pubnames 0 : { *(.debug_pubnames) }
237  /* DWARF 2 */
238  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
239  .debug_abbrev   0 : { *(.debug_abbrev) }
240  .debug_line     0 : { *(.debug_line .debug_line.* .debug_line_end ) }
241  .debug_frame    0 : { *(.debug_frame) }
242  .debug_str      0 : { *(.debug_str) }
243  .debug_loc      0 : { *(.debug_loc) }
244  .debug_macinfo  0 : { *(.debug_macinfo) }
245  /* SGI/MIPS DWARF 2 extensions */
246  .debug_weaknames 0 : { *(.debug_weaknames) }
247  .debug_funcnames 0 : { *(.debug_funcnames) }
248  .debug_typenames 0 : { *(.debug_typenames) }
249  .debug_varnames  0 : { *(.debug_varnames) }
250  /* DWARF 3 */
251  .debug_pubtypes 0 : { *(.debug_pubtypes) }
252  .debug_ranges   0 : { *(.debug_ranges) }
253  /* DWARF Extension.  */
254  .debug_macro    0 : { *(.debug_macro) }
255  .debug_addr     0 : { *(.debug_addr) }
256  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
257  .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
258  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
259}
260