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