Fix code/rodata split
[glibc/nacl-glibc.git] / elf_i386.x
blob2fd7902f1da6539f74c821bdb8529ab2295726ef
1 /* Default linker script, for normal executables */
2 OUTPUT_FORMAT("elf32-nacl", "elf32-nacl",
3               "elf32-nacl")
4 /* OUTPUT_FORMAT("elf32-i386", "elf32-i386", */
5 /*            "elf32-i386") */
6 OUTPUT_ARCH(i386)
7 ENTRY(_start)
8 /* SEARCH_DIR("/usr/i486-linux-gnu/lib32"); SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32"); SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i486-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); */
9 PHDRS
11   headers PT_PHDR FILEHDR PHDRS ;  /* put the headers in a non-loadable seg */
12   segtext    PT_LOAD FLAGS(5) ;       /* read + execute */
13   segrodata  PT_LOAD FLAGS(4) ;       /* read */
14   segdata    PT_LOAD FLAGS(6) ;       /* read + write */
15   /* TODO: do we need a stack? */
17 SECTIONS
19   /* Read-only sections, merged into text segment: */
20   PROVIDE (__executable_start = 0x10000); . = 0x10000;
21   .interp         : { *(.interp) }
22   .note.gnu.build-id : { *(.note.gnu.build-id) }
23   .hash           : { *(.hash) }
24   .gnu.hash       : { *(.gnu.hash) }
25   .dynsym         : { *(.dynsym) }
26   .dynstr         : { *(.dynstr) }
27   .gnu.version    : { *(.gnu.version) }
28   .gnu.version_d  : { *(.gnu.version_d) }
29   .gnu.version_r  : { *(.gnu.version_r) }
30   .rel.init       : { *(.rel.init) }
31   .rela.init      : { *(.rela.init) }
32   .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
33   .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
34   .rel.fini       : { *(.rel.fini) }
35   .rela.fini      : { *(.rela.fini) }
36   .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
37   .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
38   .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
39   .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
40   .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
41   .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
42   .rel.tdata      : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
43   .rela.tdata     : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
44   .rel.tbss       : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
45   .rela.tbss      : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
46   .rel.ctors      : { *(.rel.ctors) }
47   .rela.ctors     : { *(.rela.ctors) }
48   .rel.dtors      : { *(.rel.dtors) }
49   .rela.dtors     : { *(.rela.dtors) }
50   .rel.got        : { *(.rel.got) }
51   .rela.got       : { *(.rela.got) }
52   .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
53   .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
54   .rel.plt        : { *(.rel.plt) }
55   .rela.plt       : { *(.rela.plt) }
56   .init           :
57   {
58     KEEP (*(.init))
59   } :segtext =0x90909090
60   .plt            : { *(.plt) }
61   .text           : SUBALIGN(32)
62   {
63     *(.text .stub .text.* .gnu.linkonce.t.*)
64     KEEP (*(.text.*personality*))
65     /* .gnu.warning sections are handled specially by elf32.em.  */
66     *(.gnu.warning)
67   } =0x90909090
68   .fini           : SUBALIGN(32)
69   {
70     KEEP (*(.fini))
71   } =0x90909090
72   PROVIDE (__etext = .);
73   PROVIDE (_etext = .);
74   PROVIDE (etext = .);
75   . = ALIGN(CONSTANT (MAXPAGESIZE)); /* nacl wants page alignment */
76   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) } :segrodata
77   .rodata1        : { *(.rodata1) }
78   .eh_frame_hdr : { *(.eh_frame_hdr) }
79   .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
80   .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
81   /* Adjust the address for the data segment.  We want to adjust up to
82      the same address within the page on the next page up.  */
83   . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
84   /* Exception handling  */
85   .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
86   .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
87   /* Thread Local Storage sections  */
88   .tdata          : {
89     PROVIDE (__tls_template_start = .);
90     *(.tdata .tdata.* .gnu.linkonce.td.*)
91     PROVIDE (__tls_template_tdata_end = .);
92   }
93   .tbss           : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
94   PROVIDE (__tls_template_end = .);
95   .preinit_array     :
96   {
97     PROVIDE_HIDDEN (__preinit_array_start = .);
98     KEEP (*(.preinit_array))
99     PROVIDE_HIDDEN (__preinit_array_end = .);
100   } :segdata
101   .init_array     :
102   {
103      PROVIDE_HIDDEN (__init_array_start = .);
104      KEEP (*(SORT(.init_array.*)))
105      KEEP (*(.init_array))
106      PROVIDE_HIDDEN (__init_array_end = .);
107   }
108   .fini_array     :
109   {
110     PROVIDE_HIDDEN (__fini_array_start = .);
111     KEEP (*(.fini_array))
112     KEEP (*(SORT(.fini_array.*)))
113     PROVIDE_HIDDEN (__fini_array_end = .);
114   }
115   .ctors          :
116   {
117     /* gcc uses crtbegin.o to find the start of
118        the constructors, so we make sure it is
119        first.  Because this is a wildcard, it
120        doesn't matter if the user does not
121        actually link against crtbegin.o; the
122        linker won't look for a file to match a
123        wildcard.  The wildcard also means that it
124        doesn't matter which directory crtbegin.o
125        is in.  */
126     KEEP (*crtbegin.o(.ctors))
127     KEEP (*crtbegin?.o(.ctors))
128     /* We don't want to include the .ctor section from
129        the crtend.o file until after the sorted ctors.
130        The .ctor section from the crtend file contains the
131        end of ctors marker and it must be last */
132     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
133     KEEP (*(SORT(.ctors.*)))
134     KEEP (*(.ctors))
135   }
136   .dtors          :
137   {
138     KEEP (*crtbegin.o(.dtors))
139     KEEP (*crtbegin?.o(.dtors))
140     KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
141     KEEP (*(SORT(.dtors.*)))
142     KEEP (*(.dtors))
143   }
144   .jcr            : { KEEP (*(.jcr)) }
145   .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
146   .dynamic        : { *(.dynamic) }
147   .got            : { *(.got) }
148   . = DATA_SEGMENT_RELRO_END (12, .);
149   .got.plt        : { *(.got.plt) }
150   . = ALIGN(CONSTANT (MAXPAGESIZE)); /* nacl wants page alignment */
151   .data           :
152   {
153     *(.data .data.* .gnu.linkonce.d.*)
154     KEEP (*(.gnu.linkonce.d.*personality*))
155     SORT(CONSTRUCTORS)
156   }
157   .data1          : { *(.data1) }
158   _edata = .; PROVIDE (edata = .);
159   __bss_start = .;
160   .bss            :
161   {
162    *(.dynbss)
163    *(.bss .bss.* .gnu.linkonce.b.*)
164    *(COMMON)
165    /* Align here to ensure that the .bss section occupies space up to
166       _end.  Align after .bss to ensure correct alignment even if the
167       .bss section disappears because there are no input sections.
168       FIXME: Why do we need it? When there is no .bss section, we don't
169       pad the .data section.  */
170    . = ALIGN(. != 0 ? 32 / 8 : 1);
171   }
172   . = ALIGN(32 / 8);
173   . = ALIGN(32 / 8);
174   _end = .; PROVIDE (end = .);
175   . = DATA_SEGMENT_END (.);
176   /* Stabs debugging sections.  */
177   .stab          0 : { *(.stab) }
178   .stabstr       0 : { *(.stabstr) }
179   .stab.excl     0 : { *(.stab.excl) }
180   .stab.exclstr  0 : { *(.stab.exclstr) }
181   .stab.index    0 : { *(.stab.index) }
182   .stab.indexstr 0 : { *(.stab.indexstr) }
183   .comment       0 : { *(.comment) }
184   /* DWARF debug sections.
185      Symbols in the DWARF debugging sections are relative to the beginning
186      of the section so we begin them at 0.  */
187   /* DWARF 1 */
188   .debug          0 : { *(.debug) }
189   .line           0 : { *(.line) }
190   /* GNU DWARF 1 extensions */
191   .debug_srcinfo  0 : { *(.debug_srcinfo) }
192   .debug_sfnames  0 : { *(.debug_sfnames) }
193   /* DWARF 1.1 and DWARF 2 */
194   .debug_aranges  0 : { *(.debug_aranges) }
195   .debug_pubnames 0 : { *(.debug_pubnames) }
196   /* DWARF 2 */
197   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
198   .debug_abbrev   0 : { *(.debug_abbrev) }
199   .debug_line     0 : { *(.debug_line) }
200   .debug_frame    0 : { *(.debug_frame) }
201   .debug_str      0 : { *(.debug_str) }
202   .debug_loc      0 : { *(.debug_loc) }
203   .debug_macinfo  0 : { *(.debug_macinfo) }
204   /* SGI/MIPS DWARF 2 extensions */
205   .debug_weaknames 0 : { *(.debug_weaknames) }
206   .debug_funcnames 0 : { *(.debug_funcnames) }
207   .debug_typenames 0 : { *(.debug_typenames) }
208   .debug_varnames  0 : { *(.debug_varnames) }
209   /* DWARF 3 */
210   .debug_pubtypes 0 : { *(.debug_pubtypes) }
211   .debug_ranges   0 : { *(.debug_ranges) }
212   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
213   /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
214   /DISCARD/ : { *(.note.ABI-tag) }