1# Copyright (C) 2014-2016 Free Software Foundation, Inc.
2#
3# Copying and distribution of this file, with or without modification,
4# are permitted in any medium without royalty provided the copyright
5# notice and this notice are preserved.
6
7# MMO is not a relocateable format, and we don't want to require an
8# explicit (e.g.) "-m elf64mmix" when -r is used.
9
10test -z $RELOCATEABLE_OUTPUT_FORMAT && RELOCATEABLE_OUTPUT_FORMAT=$OUTPUT_FORMAT
11test -z ${RELOCATING+0} && OUTPUT_FORMAT=$RELOCATEABLE_OUTPUT_FORMAT
12
13cat <<EOF
14/* Copyright (C) 2014-2016 Free Software Foundation, Inc.
15
16   Copying and distribution of this script, with or without modification,
17   are permitted in any medium without royalty provided the copyright
18   notice and this notice are preserved.  */
19
20OUTPUT_FORMAT("$OUTPUT_FORMAT")
21OUTPUT_ARCH(mmix)
22${RELOCATING+ENTRY(Main)}
23SECTIONS
24{
25  .text ${RELOCATING+ ${TEXT_START_ADDR}}:
26  {
27    *(.text)
28    ${RELOCATING+*(.text.*)}
29    ${RELOCATING+*(.gnu.linkonce.t*)}
30    ${RELOCATING+*(.rodata)}
31    ${RELOCATING+*(.rodata.*)}
32    ${RELOCATING+*(.gnu.linkonce.r*)}
33
34    /* FIXME: Move .init, .fini, .ctors and .dtors to their own sections.  */
35    ${RELOCATING+ PROVIDE (_init_start = .);}
36    ${RELOCATING+ PROVIDE (_init = .);}
37    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
38    ${RELOCATING+ PROVIDE (_init_end = .);}
39
40    ${RELOCATING+ PROVIDE (_fini_start = .);}
41    ${RELOCATING+ PROVIDE (_fini = .);}
42    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
43    ${RELOCATING+ PROVIDE (_fini_end = .);}
44
45    /* FIXME: Align ctors, dtors, ehframe.  */
46    ${RELOCATING+ PROVIDE (_ctors_start = .);}
47    ${RELOCATING+ PROVIDE (__ctors_start = .);}
48    ${RELOCATING+ PROVIDE (_ctors = .);}
49    ${RELOCATING+ PROVIDE (__ctors = .);}
50    ${RELOCATING+ KEEP (*crtbegin.o(.ctors))}
51    ${RELOCATING+ KEEP (*crtbegin?.o(.ctors))}
52    ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))}
53    ${RELOCATING+ KEEP (*(SORT(.ctors.*)))}
54    ${RELOCATING+ KEEP (*(.ctors))}
55    ${RELOCATING+ PROVIDE (_ctors_end = .);}
56    ${RELOCATING+ PROVIDE (__ctors_end = .);}
57
58    ${RELOCATING+ PROVIDE (_dtors_start = .);}
59    ${RELOCATING+ PROVIDE (__dtors_start = .);}
60    ${RELOCATING+ PROVIDE (_dtors = .);}
61    ${RELOCATING+ PROVIDE (__dtors = .);}
62    ${RELOCATING+ KEEP (*crtbegin.o(.dtors))}
63    ${RELOCATING+ KEEP (*crtbegin?.o(.dtors))}
64    ${RELOCATING+ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))}
65    ${RELOCATING+ KEEP (*(SORT(.dtors.*)))}
66    ${RELOCATING+ KEEP (*(.dtors))}
67    ${RELOCATING+ PROVIDE (_dtors_end = .);}
68    ${RELOCATING+ PROVIDE (__dtors_end = .);}
69
70    ${RELOCATING+KEEP (*(.jcr))}
71    ${RELOCATING+KEEP (*(.eh_frame))}
72    ${RELOCATING+*(.gcc_except_table)}
73
74    ${RELOCATING+Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : ADDR (.text));}
75  }
76
77  /* The following NOP assignment and those after .data and .bss, are
78     necessary to get orphan sections adopted by the .text inserted before
79     the following end-section symbols.  An output section would also serve
80     this purpose, but we can't do that.  */
81  . = .;
82  ${RELOCATING+ PROVIDE(etext = .);}
83  ${RELOCATING+ PROVIDE(_etext = .);}
84  ${RELOCATING+ PROVIDE(__etext = .);}
85
86  .data ${RELOCATING+ ${DATA_ADDR}}:
87  {
88    ${RELOCATING+ PROVIDE(__Sdata = .);}
89
90    *(.data);
91    ${RELOCATING+*(.data.*)}
92    ${RELOCATING+*(.gnu.linkonce.d*)}
93  }
94  . = .;
95  ${RELOCATING+ PROVIDE(__Edata = .);}
96  /* Deprecated, use __Edata.  */
97  ${RELOCATING+ PROVIDE(edata = .);}
98  ${RELOCATING+ PROVIDE(_edata = .);}
99  ${RELOCATING+ PROVIDE(__edata = .);}
100
101  /* At the moment, although perhaps we should, we can't map sections
102     without contents to sections *with* contents due to FIXME: a BFD bug.
103     Anyway, the mmo back-end ignores sections without contents when
104     writing out sections, so this works fine.   */
105  .bss :
106  {
107    ${RELOCATING+ PROVIDE(__Sbss = .);}
108    ${RELOCATING+ PROVIDE(__bss_start = .);}
109    ${RELOCATING+ *(.sbss);}
110    ${RELOCATING+ *(.bss);}
111    ${RELOCATING+*(.bss.*)}
112    ${RELOCATING+ *(COMMON);}
113  }
114  . = .;
115  ${RELOCATING+ PROVIDE(__Ebss = .);}
116
117  /* Deprecated, use __Ebss or __Eall as appropriate.  */
118  ${RELOCATING+ PROVIDE(end = .);}
119  ${RELOCATING+ PROVIDE(_end = .);}
120  ${RELOCATING+ PROVIDE(__end = .);}
121  ${RELOCATING+ PROVIDE(__Eall = .);}
122
123  .stab 0 : { *(.stab) }
124  .stabstr 0 : { *(.stabstr) }
125  .stab.excl 0 : { *(.stab.excl) }
126  .stab.exclstr 0 : { *(.stab.exclstr) }
127  .stab.index 0 : { *(.stab.index) }
128  .stab.indexstr 0 : { *(.stab.indexstr) }
129EOF
130
131. $srcdir/scripttempl/DWARF.sc
132
133cat <<EOF
134  .MMIX.reg_contents :
135  {
136    /* Note that this section always has a fixed VMA - that of its
137       first register * 8.  */
138    *(.MMIX.reg_contents.linker_allocated);
139    *(.MMIX.reg_contents);
140  }
141
142  /* By default, put the high end of the stack where the register stack
143     begins.  They grow in opposite directions.  */
144  PROVIDE (__Stack_start = 0x6000000000000000);
145
146  /* Unfortunately, stabs are not mappable from ELF to MMO.
147     It can probably be fixed with some amount of work.  */
148  /DISCARD/ :
149  { ${RELOCATING+ *(.gnu.warning.*);} }
150
151  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
152}
153EOF
154