xref: /netbsd/sys/arch/ofppc/stand/ofwboot/ldscript (revision dc6a7fd2)
1/* $NetBSD: ldscript,v 1.1 2008/02/13 20:11:38 garbled Exp $ */
2
3/* This only differs from the stock one by the addition of the text name
4   and the addition of the PHDRS section.
5*/
6/* Script for -N: mix text and data on same page; don't align data */
7OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc",
8	      "elf32-powerpc")
9OUTPUT_ARCH(powerpc:common)
10ENTRY(_start)
11SEARCH_DIR("/usr/src/tools/ppc-hack/powerpc--netbsd/lib");
12/* Do we need any of these for elf?
13   __DYNAMIC = 0;    */
14PROVIDE (__stack = 0); PROVIDE (___stack = 0);
15PHDRS
16{
17/* headers PT_PHDR PHDRS ;*/
18 text PT_LOAD;
19 text PT_NOTE;
20}
21SECTIONS
22{
23  /* Read-only sections, merged into text segment: */
24  PROVIDE (__executable_start = 0x0); . = 0x0 + SIZEOF_HEADERS;
25  .interp         : { *(.interp) }
26  .hash           : { *(.hash) }
27  .dynsym         : { *(.dynsym) }
28  .dynstr         : { *(.dynstr) }
29  .gnu.version    : { *(.gnu.version) }
30  .gnu.version_d  : { *(.gnu.version_d) }
31  .gnu.version_r  : { *(.gnu.version_r) }
32  .rel.init       : { *(.rel.init) }
33  .rela.init      : { *(.rela.init) }
34  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
35  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
36  .rel.fini       : { *(.rel.fini) }
37  .rela.fini      : { *(.rela.fini) }
38  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
39  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
40  .rel.data.rel.ro   : { *(.rel.data.rel.ro*) }
41  .rela.data.rel.ro   : { *(.rel.data.rel.ro*) }
42  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
43  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
44  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
45  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
46  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
47  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
48  .rel.ctors      : { *(.rel.ctors) }
49  .rela.ctors     : { *(.rela.ctors) }
50  .rel.dtors      : { *(.rel.dtors) }
51  .rela.dtors     : { *(.rela.dtors) }
52  .rel.got        : { *(.rel.got) }
53  .rela.got       : { *(.rela.got) }
54  .rela.got1           : { *(.rela.got1) }
55  .rela.got2           : { *(.rela.got2) }
56  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
57  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
58  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
59  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
60  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
61  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
62  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
63  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
64  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
65  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
66  .rel.plt        : { *(.rel.plt) }
67  .rela.plt       : { *(.rela.plt) }
68  .init           :
69  {
70    KEEP (*(.init))
71  } =0
72  .text           :
73  {
74    *(.text .stub .text.* .gnu.linkonce.t.*)
75    KEEP (*(.text.*personality*))
76    /* .gnu.warning sections are handled specially by elf32.em.  */
77    *(.gnu.warning)
78  } :text
79  .fini           :
80  {
81    KEEP (*(.fini))
82  } =0
83  PROVIDE (__etext = .);
84  PROVIDE (_etext = .);
85  PROVIDE (etext = .);
86  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
87  .rodata1        : { *(.rodata1) }
88  .sdata2         : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
89  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
90  .eh_frame_hdr : { *(.eh_frame_hdr) }
91  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
92  .gcc_except_table   : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
93  /* Adjust the address for the data segment.  We want to adjust up to
94     the same address within the page on the next page up.  */
95  . = .;
96  /* Exception handling  */
97  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
98  .gcc_except_table   : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
99  /* Thread Local Storage sections  */
100  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
101  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
102  /* Ensure the __preinit_array_start label is properly aligned.  We
103     could instead move the label definition inside the section, but
104     the linker would then create the section even if it turns out to
105     be empty, which isn't pretty.  */
106  . = ALIGN(32 / 8);
107  PROVIDE (__preinit_array_start = .);
108  .preinit_array     : { KEEP (*(.preinit_array)) }
109  PROVIDE (__preinit_array_end = .);
110  PROVIDE (__init_array_start = .);
111  .init_array     : { KEEP (*(.init_array)) }
112  PROVIDE (__init_array_end = .);
113  PROVIDE (__fini_array_start = .);
114  .fini_array     : { KEEP (*(.fini_array)) }
115  PROVIDE (__fini_array_end = .);
116  .ctors          :
117  {
118    /* gcc uses crtbegin.o to find the start of
119       the constructors, so we make sure it is
120       first.  Because this is a wildcard, it
121       doesn't matter if the user does not
122       actually link against crtbegin.o; the
123       linker won't look for a file to match a
124       wildcard.  The wildcard also means that it
125       doesn't matter which directory crtbegin.o
126       is in.  */
127    KEEP (*crtbegin*.o(.ctors))
128    /* We don't want to include the .ctor section from
129       from 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 ) .ctors))
133    KEEP (*(SORT(.ctors.*)))
134    KEEP (*(.ctors))
135  }
136  .dtors          :
137  {
138    KEEP (*crtbegin*.o(.dtors))
139    KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
140    KEEP (*(SORT(.dtors.*)))
141    KEEP (*(.dtors))
142  }
143  .jcr            : { KEEP (*(.jcr)) }
144  .data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
145  .fixup          : { *(.fixup) }
146  .got1           : { *(.got1) }
147  .got2           : { *(.got2) }
148  .dynamic        : { *(.dynamic) }
149  .data           :
150  {
151    *(.data .data.* .gnu.linkonce.d.*)
152    KEEP (*(.gnu.linkonce.d.*personality*))
153    SORT(CONSTRUCTORS)
154  }
155  .data1          : { *(.data1) }
156  .got            : { *(.got.plt) *(.got) }
157  /* We want the small data sections together, so single-instruction offsets
158     can access them all, and initialized data all before uninitialized, so
159     we can shorten the on-disk segment size.  */
160  .sdata          :
161  {
162    *(.sdata .sdata.* .gnu.linkonce.s.*)
163  }
164  _edata = .;
165  PROVIDE (edata = .);
166  __bss_start = .;
167  .sbss           :
168  {
169    PROVIDE (__sbss_start = .);
170    PROVIDE (___sbss_start = .);
171    *(.dynsbss)
172    *(.sbss .sbss.* .gnu.linkonce.sb.*)
173    *(.scommon)
174    PROVIDE (__sbss_end = .);
175    PROVIDE (___sbss_end = .);
176  }
177  .plt            : { *(.plt) }
178  .bss            :
179  {
180   *(.dynbss)
181   *(.bss .bss.* .gnu.linkonce.b.*)
182   *(COMMON)
183   /* Align here to ensure that the .bss section occupies space up to
184      _end.  Align after .bss to ensure correct alignment even if the
185      .bss section disappears because there are no input sections.  */
186   . = ALIGN(32 / 8);
187  }
188  . = ALIGN(32 / 8);
189  _end = .;
190  __end = .;
191  PROVIDE (end = .);
192  /* Stabs debugging sections.  */
193  .stab          0 : { *(.stab) }
194  .stabstr       0 : { *(.stabstr) }
195  .stab.excl     0 : { *(.stab.excl) }
196  .stab.exclstr  0 : { *(.stab.exclstr) }
197  .stab.index    0 : { *(.stab.index) }
198  .stab.indexstr 0 : { *(.stab.indexstr) }
199  .comment       0 : { *(.comment) }
200  /* DWARF debug sections.
201     Symbols in the DWARF debugging sections are relative to the beginning
202     of the section so we begin them at 0.  */
203  /* DWARF 1 */
204  .debug          0 : { *(.debug) }
205  .line           0 : { *(.line) }
206  /* GNU DWARF 1 extensions */
207  .debug_srcinfo  0 : { *(.debug_srcinfo) }
208  .debug_sfnames  0 : { *(.debug_sfnames) }
209  /* DWARF 1.1 and DWARF 2 */
210  .debug_aranges  0 : { *(.debug_aranges) }
211  .debug_pubnames 0 : { *(.debug_pubnames) }
212  /* DWARF 2 */
213  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
214  .debug_abbrev   0 : { *(.debug_abbrev) }
215  .debug_line     0 : { *(.debug_line) }
216  .debug_frame    0 : { *(.debug_frame) }
217  .debug_str      0 : { *(.debug_str) }
218  .debug_loc      0 : { *(.debug_loc) }
219  .debug_macinfo  0 : { *(.debug_macinfo) }
220  /* SGI/MIPS DWARF 2 extensions */
221  .debug_weaknames 0 : { *(.debug_weaknames) }
222  .debug_funcnames 0 : { *(.debug_funcnames) }
223  .debug_typenames 0 : { *(.debug_typenames) }
224  .debug_varnames  0 : { *(.debug_varnames) }
225  /DISCARD/ : { *(.note.GNU-stack) }
226}
227