Override elf_nacl.xr linker script so that libc_pic.os links correctly
[glibc/nacl-glibc.git] / ld / ldscripts / elf_nacl.xr
blobe8b0a713bffcddeecf03314eeb3012f53ba6b9c4
1 /* Script for ld -r: link without relocation */
2 OUTPUT_FORMAT("elf32-nacl", "elf32-nacl",
3               "elf32-nacl")
4 OUTPUT_ARCH(i386)
5  /* For some reason, the Solaris linker makes bad executables
6   if gld -r is used and the intermediate file has sections starting
7   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
8   bug.  But for now assigning the zero vmas works.  */
9 PHDRS
11   headers PT_PHDR FILEHDR PHDRS ;  /* put the headers in a non-loadable seg */
12   text    PT_LOAD FLAGS(5) ;       /* read + execute */
13   rodata  PT_LOAD FLAGS(4) ;       /* read */
14   data    PT_LOAD FLAGS(6) ;       /* read + write */
15   /* TODO(sehr): do we need a stack? */
17 SECTIONS
19   /* Read-only sections, merged into text segment: */
20   .interp       0 : { *(.interp) }
21   .note.gnu.build-id : { *(.note.gnu.build-id) }
22   .hash         0 : { *(.hash) }
23   .gnu.hash     0 : { *(.gnu.hash) }
24   .dynsym       0 : { *(.dynsym) }
25   .dynstr       0 : { *(.dynstr) }
26   .gnu.version  0 : { *(.gnu.version) }
27   .gnu.version_d 0: { *(.gnu.version_d) }
28   .gnu.version_r 0: { *(.gnu.version_r) }
29   .rel.init     0 : { *(.rel.init) }
30   .rel.text     0 : { *(.rel.text) }
31   .rel.fini     0 : { *(.rel.fini) }
32   .rel.rodata   0 : { *(.rel.rodata) }
33   .rel.data.rel.ro 0 : { *(.rel.data.rel.ro) }
34   .rel.data     0 : { *(.rel.data) }
35   .rel.tdata    0 : { *(.rel.tdata) }
36   .rel.tbss     0 : { *(.rel.tbss) }
37   .rel.ctors    0 : { *(.rel.ctors) }
38   .rel.dtors    0 : { *(.rel.dtors) }
39   .rel.got      0 : { *(.rel.got) }
40   .rel.bss      0 : { *(.rel.bss) }
41   .rel.ifunc      0 : { *(.rel.ifunc) }
42   .rel.plt      0 :
43     {
44       *(.rel.plt)
45       *(.rel.iplt)
46     }
47   .init         0 :
48   {
49     KEEP (*(.init))
50   } :text =0x90909090
51   .plt          0 : { *(.plt) *(.iplt)}
52   .text         0 :
53   {
54     *(.text .stub)
55     /* .gnu.warning sections are handled specially by elf32.em.  */
56     *(.gnu.warning)
57   } =0x90909090
58   .text.compat  0 : { *(.text.compat) } =0x90909090
59   __libc_freeres_fn  0 : { *(__libc_freeres_fn) } =0x90909090
60   __libc_thread_freeres_fn  0 : { *(__libc_thread_freeres_fn) } =0x90909090
61   .fini         0 :
62   {
63     KEEP (*(.fini))
64   } =0x90909090
65    /* nacl wants page alignment */
66   .rodata       0 : { *(.rodata) } :rodata
67   .rodata1      0 : { *(.rodata1) }
68   .nacl_rpc_methods : { *(.nacl_rpc_methods) }
69   .eh_frame_hdr : { *(.eh_frame_hdr) }
70   .eh_frame     0 : ONLY_IF_RO { KEEP (*(.eh_frame)) }
71   .gcc_except_table 0 : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
72   /* Adjust the address for the data segment.  We want to adjust up to
73      the same address within the page on the next page up.  */
74   /* Exception handling  */
75   .eh_frame     0 : ONLY_IF_RW { KEEP (*(.eh_frame)) }
76   .gcc_except_table 0 : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
77   /* Thread Local Storage sections  */
78   /* The total size of the TLS template area must be a multiple of 0x20,
79    * but it's size calculation is hardcoded in bfd_elf_final_link function
80    * so the only thing we can do is align segments here properly */
81   .tdata        0 : {
82     *(.tdata)
83   }
84   .tbss         0 : {
85     *(.tbss)
86   }
87   /* . does not advance for tbss because it is not loaded. */
88   .preinit_array   0 :
89   {
90     KEEP (*(.preinit_array))
91   }
92   .init_array   0 :
93   {
94      KEEP (*(SORT(.init_array.*)))
95      KEEP (*(.init_array))
96   }
97   .fini_array   0 :
98   {
99     KEEP (*(.fini_array))
100     KEEP (*(SORT(.fini_array.*)))
101   }
102   .jcr          0 : { KEEP (*(.jcr)) }
103   .dynamic      0 : { *(.dynamic) }
104   .got          0 : { *(.got) *(.igot) }
105   .got.plt      0 : { *(.got.plt)  *(.igot.plt) }
106    /* nacl wants page alignment */
107   .data         0 :
108   {
109     *(.data)
110   } :data
111   .data1        0 : { *(.data1) }
112   .bss          0 :
113   {
114    *(.dynbss)
115    *(.bss)
116    *(COMMON)
117    /* Align here to ensure that the .bss section occupies space up to
118       _end.  Align after .bss to ensure correct alignment even if the
119       .bss section disappears because there are no input sections.
120       FIXME: Why do we need it? When there is no .bss section, we don't
121       pad the .data section.  */
122   }
123   /* Stabs debugging sections.  */
124   .stab          0 : { *(.stab) }
125   .stabstr       0 : { *(.stabstr) }
126   .stab.excl     0 : { *(.stab.excl) }
127   .stab.exclstr  0 : { *(.stab.exclstr) }
128   .stab.index    0 : { *(.stab.index) }
129   .stab.indexstr 0 : { *(.stab.indexstr) }
130   .comment       0 : { *(.comment) }
131   /* DWARF debug sections.
132      Symbols in the DWARF debugging sections are relative to the beginning
133      of the section so we begin them at 0.  */
134   /* DWARF 1 */
135   .debug          0 : { *(.debug) }
136   .line           0 : { *(.line) }
137   /* GNU DWARF 1 extensions */
138   .debug_srcinfo  0 : { *(.debug_srcinfo) }
139   .debug_sfnames  0 : { *(.debug_sfnames) }
140   /* DWARF 1.1 and DWARF 2 */
141   .debug_aranges  0 : { *(.debug_aranges) }
142   .debug_pubnames 0 : { *(.debug_pubnames) }
143   /* DWARF 2 */
144   .debug_info     0 : { *(.debug_info) }
145   .debug_abbrev   0 : { *(.debug_abbrev) }
146   .debug_line     0 : { *(.debug_line) }
147   .debug_frame    0 : { *(.debug_frame) }
148   .debug_str      0 : { *(.debug_str) }
149   .debug_loc      0 : { *(.debug_loc) }
150   .debug_macinfo  0 : { *(.debug_macinfo) }
151   /* SGI/MIPS DWARF 2 extensions */
152   .debug_weaknames 0 : { *(.debug_weaknames) }
153   .debug_funcnames 0 : { *(.debug_funcnames) }
154   .debug_typenames 0 : { *(.debug_typenames) }
155   .debug_varnames  0 : { *(.debug_varnames) }
156   /* DWARF 3 */
157   .debug_pubtypes 0 : { *(.debug_pubtypes) }
158   .debug_ranges   0 : { *(.debug_ranges) }
159   .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }