1/*
2 * Linker script for ELF dynamic loaded modules.
3 * This simply mirrors the 32bit linker script with minimal x86_64 changes
4 */
5
6/* Script for --shared -z combreloc: shared library, combine & sort relocs */
7OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
8OUTPUT_ARCH(i386:x86-64)
9SECTIONS
10{
11  /* Read-only sections, merged into text segment: */
12  . = 0 + SIZEOF_HEADERS;
13  .note.gnu.build-id : { *(.note.gnu.build-id) }
14  .hash : { *(.hash) }
15  .gnu.hash  : { *(.gnu.hash) }
16  .dynsym  : { *(.dynsym) }
17  .dynstr  : { *(.dynstr) }
18  .gnu.version    : { *(.gnu.version) }
19  .gnu.version_d  : { *(.gnu.version_d) }
20  .gnu.version_r  : { *(.gnu.version_r) }
21/* mouli: introduce alignment for various segments */
22  .rel.dyn       :
23    {
24      *(.rel.init)
25      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
26      *(.rel.fini)
27      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
28      *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
29      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
30      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
31      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
32      *(.rel.ctors)
33      *(.rel.dtors)
34      *(.rel.got)
35      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
36    }
37  .rela.dyn  :
38    {
39      *(.rela.init)
40      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
41      *(.rela.fini)
42      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
43      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
44      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
45      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
46      *(.rela.ctors)
47      *(.rela.dtors)
48      *(.rela.got)
49      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
50    }
51  .rel.plt : { *(.rel.plt); }
52  .rela.plt : { *(.rela.plt) }
53  .init           :
54  {
55    KEEP (*(.init))
56  } =0x90909090
57  .plt : { *(.plt) }
58  .text :
59  {
60    *(.text .stub .text.* .gnu.linkonce.t.*)
61    KEEP (*(.text.*personality*))
62    /* .gnu.warning sections are handled specially by elf32.em.  */
63    *(.gnu.warning)
64  } =0x90909090
65  .fini           :
66  {
67    KEEP (*(.fini))
68  } =0x90909090
69  PROVIDE (__etext = .);
70  PROVIDE (_etext = .);
71  PROVIDE (etext = .);
72  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
73  .rodata1        : { *(.rodata1) }
74  . = ALIGN(4);
75  .preinit_array     :
76  {
77    KEEP (*(.preinit_array))
78  }
79  .ctors          :
80  {
81  	__ctors_start = .;
82    KEEP (*(SORT(.ctors.*)))
83    KEEP (*(.ctors))
84    KEEP (*(.ctors_modinit))
85    KEEP (*(.ctors_modmain))
86    KEEP (*(SORT(.init_array.*)))
87    KEEP (*(.init_array))
88	__ctors_end = .;
89  }
90
91  .dtors          :
92  {
93  	__dtors_start = .;
94    KEEP (*(SORT(.dtors.*)))
95    KEEP (*(.dtors))
96    KEEP (*(.dtors_modexit))
97    KEEP (*(.fini_array))
98    KEEP (*(SORT(.fini_array.*)))
99	__dtors_end = .;
100  }
101
102  .jcr            : { KEEP (*(.jcr)) }
103  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
104  .dynamic        : { *(.dynamic) }
105  .got            : { *(.got) }
106  /*. = DATA_SEGMENT_RELRO_END (12, .); -> This gives a "invalid assignment to location counter" error */
107  .got.plt        : { *(.got.plt) }
108  .data           :
109  {
110    *(.data .data.* .gnu.linkonce.d.*)
111    KEEP (*(.gnu.linkonce.d.*personality*))
112    SORT(CONSTRUCTORS)
113  }
114  .data1          : { *(.data1) }
115  PROVIDE (edata = .);
116  PROVIDE (_edata = .);
117  .bss            :
118  {
119   *(.dynbss)
120   *(.bss .bss.* .gnu.linkonce.b.*)
121   *(COMMON)
122   /* Align here to ensure that the .bss section occupies space up to
123      _end.  Align after .bss to ensure correct alignment even if the
124      .bss section disappears because there are no input sections.
125      FIXME: Why do we need it? When there is no .bss section, we don't
126      pad the .data section.  */
127   /*. = ALIGN(. != 0 ? 32 / 8 : 1);*/
128   . = ALIGN(. != 0 ? 64 / 8 : 1);
129  }
130  . = ALIGN(32 / 8);
131  . = ALIGN(32 / 8);
132  PROVIDE (_end = .);
133  PROVIDE (end = .);
134  /*. = DATA_SEGMENT_END (.); -> This gives a "invalid assignment to location counter" error */
135  /* Stabs debugging sections.  */
136  .stab          0 : { *(.stab) }
137  .stabstr       0 : { *(.stabstr) }
138  .stab.excl     0 : { *(.stab.excl) }
139  .stab.exclstr  0 : { *(.stab.exclstr) }
140  .stab.index    0 : { *(.stab.index) }
141  .stab.indexstr 0 : { *(.stab.indexstr) }
142  .comment       0 : { *(.comment) }
143  /* DWARF debug sections.
144     Symbols in the DWARF debugging sections are relative to the beginning
145     of the section so we begin them at 0.  */
146  /* DWARF 1 */
147  .debug          0 : { *(.debug) }
148  .line           0 : { *(.line) }
149  /* GNU DWARF 1 extensions */
150  .debug_srcinfo  0 : { *(.debug_srcinfo) }
151  .debug_sfnames  0 : { *(.debug_sfnames) }
152  /* DWARF 1.1 and DWARF 2 */
153  .debug_aranges  0 : { *(.debug_aranges) }
154  .debug_pubnames 0 : { *(.debug_pubnames) }
155  /* DWARF 2 */
156  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
157  .debug_abbrev   0 : { *(.debug_abbrev) }
158  .debug_line     0 : { *(.debug_line) }
159  .debug_frame    0 : { *(.debug_frame) }
160  .debug_str      0 : { *(.debug_str) }
161  .debug_loc      0 : { *(.debug_loc) }
162  .debug_macinfo  0 : { *(.debug_macinfo) }
163  /* SGI/MIPS DWARF 2 extensions */
164  .debug_weaknames 0 : { *(.debug_weaknames) }
165  .debug_funcnames 0 : { *(.debug_funcnames) }
166  .debug_typenames 0 : { *(.debug_typenames) }
167  .debug_varnames  0 : { *(.debug_varnames) }
168  /* DWARF 3 */
169  .debug_pubtypes 0 : { *(.debug_pubtypes) }
170  .debug_ranges   0 : { *(.debug_ranges) }
171  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
172  /DISCARD/ : { *(.eh_frame) }
173}
174