1/***********************license start***************
2 * Copyright (c) 2003-2010  Cavium Inc. (support@cavium.com). All rights 
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 *   * Redistributions of source code must retain the above copyright
11 *     notice, this list of conditions and the following disclaimer.
12 *
13 *   * Redistributions in binary form must reproduce the above
14 *     copyright notice, this list of conditions and the following
15 *     disclaimer in the documentation and/or other materials provided
16 *     with the distribution.
17
18 *   * Neither the name of Cavium Inc. nor the names of
19 *     its contributors may be used to endorse or promote products
20 *     derived from this software without specific prior written
21 *     permission.  
22
23 * This Software, including technical data, may be subject to U.S. export  control
24 * laws, including the U.S. Export Administration Act and its  associated
25 * regulations, and may be subject to export or import  regulations in other
26 * countries. 
27
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
39
40
41
42
43
44
45/*
46 * This was created from a template supplied by GNU binutils.
47 * Copyright (C) 2004 Cavium Inc.
48 */
49 
50/**
51 * @file
52 * This linker script for use in building simple executive application to run
53 * under Linux in userspace. The important difference from a standard Linux 
54 * binary is the addition of the ".cvmx_shared" memory section. This script 
55 * adds two symbols __cvmx_shared_start and __cvmx_sahred_end before and after
56 * the CVMX_SHARED data. These are used by cvmx-app-init-linux.c to create a
57 * shared region across all application processes.
58 *
59 * The original template for this files was:
60 * ${OCTEON_ROOT}/tools/mips64-octeon-linux-gnu/lib/ldscripts/elf64btsmip.x
61 */
62OUTPUT_FORMAT("elf64-tradbigmips", "elf64-tradbigmips",
63	      "elf64-tradlittlemips")
64OUTPUT_ARCH(mips)
65ENTRY(__start)
66SEARCH_DIR("${OCTEON_ROOT}/tools/mips64-octeon-linux-gnu/lib");
67SECTIONS
68{
69  /* Read-only sections, merged into text segment: */
70  PROVIDE (__executable_start = 0x120000000); . = 0x120000000 + SIZEOF_HEADERS;
71  .MIPS.options : { *(.MIPS.options) }
72  .note.gnu.build-id : { *(.note.gnu.build-id) }
73  .dynamic        : { *(.dynamic) }
74  .hash           : { *(.hash) }
75  .gnu.hash       : { *(.gnu.hash) }
76  .dynsym         : { *(.dynsym) }
77  .dynstr         : { *(.dynstr) }
78  .gnu.version    : { *(.gnu.version) }
79  .gnu.version_d  : { *(.gnu.version_d) }
80  .gnu.version_r  : { *(.gnu.version_r) }
81  .rel.init       : { *(.rel.init) }
82  .rela.init      : { *(.rela.init) }
83  .rel.text       : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
84  .rela.text      : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
85  .rel.fini       : { *(.rel.fini) }
86  .rela.fini      : { *(.rela.fini) }
87  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
88  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
89  .rel.data.rel.ro   : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
90  .rela.data.rel.ro   : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
91  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
92  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
93  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
94  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
95  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
96  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
97  .rel.ctors      : { *(.rel.ctors) }
98  .rela.ctors     : { *(.rela.ctors) }
99  .rel.dtors      : { *(.rel.dtors) }
100  .rela.dtors     : { *(.rela.dtors) }
101  .rel.got        : { *(.rel.got) }
102  .rela.got       : { *(.rela.got) }
103  .rel.dyn        : { *(.rel.dyn) }
104  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
105  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
106  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
107  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
108  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
109  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
110  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
111  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
112  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
113  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
114  .rel.plt        : { *(.rel.plt) }
115  .rela.plt       : { *(.rela.plt) }
116  .init           :
117  {
118    KEEP (*(.init))
119  } =0
120  .plt            : { *(.plt) }
121  .text           :
122  {
123    _ftext = . ;
124    *(.text .stub .text.* .gnu.linkonce.t.*)
125    /* .gnu.warning sections are handled specially by elf32.em.  */
126    *(.gnu.warning)
127    *(.mips16.fn.*) *(.mips16.call.*)
128  } =0
129  .fini           :
130  {
131    KEEP (*(.fini))
132  } =0
133  PROVIDE (__etext = .);
134  PROVIDE (_etext = .);
135  PROVIDE (etext = .);
136  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
137  .rodata1        : { *(.rodata1) }
138  .sdata2         :
139  {
140    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
141  }
142  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
143  .eh_frame_hdr : { *(.eh_frame_hdr) }
144  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
145  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
146  /* Adjust the address for the data segment.  We want to adjust up to
147     the same address within the page on the next page up.  */
148  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
149  /* Exception handling  */
150  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
151  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
152  /* Thread Local Storage sections  */
153  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
154  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
155  .preinit_array     :
156  {
157    PROVIDE_HIDDEN (__preinit_array_start = .);
158    KEEP (*(.preinit_array))
159    PROVIDE_HIDDEN (__preinit_array_end = .);
160  }
161  .init_array     :
162  {
163     PROVIDE_HIDDEN (__init_array_start = .);
164     KEEP (*(SORT(.init_array.*)))
165     KEEP (*(.init_array))
166     PROVIDE_HIDDEN (__init_array_end = .);
167  }
168  .fini_array     :
169  {
170    PROVIDE_HIDDEN (__fini_array_start = .);
171    KEEP (*(.fini_array))
172    KEEP (*(SORT(.fini_array.*)))
173    PROVIDE_HIDDEN (__fini_array_end = .);
174  }
175  .ctors          :
176  {
177    /* gcc uses crtbegin.o to find the start of
178       the constructors, so we make sure it is
179       first.  Because this is a wildcard, it
180       doesn't matter if the user does not
181       actually link against crtbegin.o; the
182       linker won't look for a file to match a
183       wildcard.  The wildcard also means that it
184       doesn't matter which directory crtbegin.o
185       is in.  */
186    KEEP (*crtbegin.o(.ctors))
187    KEEP (*crtbegin?.o(.ctors))
188    /* We don't want to include the .ctor section from
189       the crtend.o file until after the sorted ctors.
190       The .ctor section from the crtend file contains the
191       end of ctors marker and it must be last */
192    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
193    KEEP (*(SORT(.ctors.*)))
194    KEEP (*(.ctors))
195  }
196  .dtors          :
197  {
198    KEEP (*crtbegin.o(.dtors))
199    KEEP (*crtbegin?.o(.dtors))
200    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
201    KEEP (*(SORT(.dtors.*)))
202    KEEP (*(.dtors))
203  }
204  .jcr            : { KEEP (*(.jcr)) }
205  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
206  . = DATA_SEGMENT_RELRO_END (0, .);
207  .data           :
208  {
209    _fdata = . ;
210    *(.data .data.* .gnu.linkonce.d.*)
211    SORT(CONSTRUCTORS)
212  }
213  .data1          : { *(.data1) }
214  .got.plt        : { *(.got.plt) }
215  . = .;
216  _gp = ALIGN(16) + 0x7ff0;
217  .got            : { *(.got) }
218  /* We want the small data sections together, so single-instruction offsets
219     can access them all, and initialized data all before uninitialized, so
220     we can shorten the on-disk segment size.  */
221  .sdata          :
222  {
223    *(.sdata .sdata.* .gnu.linkonce.s.*)
224  }
225  .lit8           : { *(.lit8) }
226  .lit4           : { *(.lit4) }
227  .srdata         : { *(.srdata) }
228  
229  . = ALIGN (0x10000); 
230  __cvmx_shared_start = .;
231  .cvmx_shared : {*(.cvmx_shared .cvmx_shared.linkonce.*)}
232  .cvmx_shared_bss : { *(.cvmx_shared_bss .cvmx_shared_bss.linkonce.*) }
233  . = ALIGN (0x10000);
234  __cvmx_shared_end = .;
235  
236  _edata = .; PROVIDE (edata = .);
237  __bss_start = .;
238  _fbss = .;
239  .sbss           :
240  {
241    PROVIDE (__sbss_start = .);
242    PROVIDE (___sbss_start = .);
243    *(.dynsbss)
244    *(.sbss .sbss.* .gnu.linkonce.sb.*)
245    *(.scommon)
246    PROVIDE (__sbss_end = .);
247    PROVIDE (___sbss_end = .);
248  }
249  .bss            :
250  {
251   *(.dynbss)
252   *(.bss .bss.* .gnu.linkonce.b.*)
253   *(COMMON)
254   /* Align here to ensure that the .bss section occupies space up to
255      _end.  Align after .bss to ensure correct alignment even if the
256      .bss section disappears because there are no input sections.
257      FIXME: Why do we need it? When there is no .bss section, we don't
258      pad the .data section.  */
259   . = ALIGN(. != 0 ? 64 / 8 : 1);
260  }
261  . = ALIGN(64 / 8);
262  . = ALIGN(32M);    /* RBF added alignment of data */
263  .cvmx_shared : { *(.cvmx_shared) }
264  _end = .; PROVIDE (end = .);
265  . = DATA_SEGMENT_END (.);
266  /* Stabs debugging sections.  */
267  .stab          0 : { *(.stab) }
268  .stabstr       0 : { *(.stabstr) }
269  .stab.excl     0 : { *(.stab.excl) }
270  .stab.exclstr  0 : { *(.stab.exclstr) }
271  .stab.index    0 : { *(.stab.index) }
272  .stab.indexstr 0 : { *(.stab.indexstr) }
273  .comment       0 : { *(.comment) }
274  /* DWARF debug sections.
275     Symbols in the DWARF debugging sections are relative to the beginning
276     of the section so we begin them at 0.  */
277  /* DWARF 1 */
278  .debug          0 : { *(.debug) }
279  .line           0 : { *(.line) }
280  /* GNU DWARF 1 extensions */
281  .debug_srcinfo  0 : { *(.debug_srcinfo) }
282  .debug_sfnames  0 : { *(.debug_sfnames) }
283  /* DWARF 1.1 and DWARF 2 */
284  .debug_aranges  0 : { *(.debug_aranges) }
285  .debug_pubnames 0 : { *(.debug_pubnames) }
286  /* DWARF 2 */
287  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
288  .debug_abbrev   0 : { *(.debug_abbrev) }
289  .debug_line     0 : { *(.debug_line) }
290  .debug_frame    0 : { *(.debug_frame) }
291  .debug_str      0 : { *(.debug_str) }
292  .debug_loc      0 : { *(.debug_loc) }
293  .debug_macinfo  0 : { *(.debug_macinfo) }
294  /* SGI/MIPS DWARF 2 extensions */
295  .debug_weaknames 0 : { *(.debug_weaknames) }
296  .debug_funcnames 0 : { *(.debug_funcnames) }
297  .debug_typenames 0 : { *(.debug_typenames) }
298  .debug_varnames  0 : { *(.debug_varnames) }
299  /* DWARF 3 */
300  .debug_pubtypes 0 : { *(.debug_pubtypes) }
301  .debug_ranges   0 : { *(.debug_ranges) }
302  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
303  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
304  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
305  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
306}
307