LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
[external/binutils.git] / ld / scripttempl / pru.sc
1 cat <<EOF
2 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
3 OUTPUT_ARCH(${ARCH})
4
5 EOF
6
7 test -n "${RELOCATING}" && cat <<EOF
8 MEMORY
9 {
10   imem   (x)   : ORIGIN = $TEXT_ORIGIN, LENGTH = $TEXT_LENGTH
11   dmem   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
12 }
13
14 __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32;
15 __STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : 512;
16
17 PROVIDE (_stack_top = ORIGIN(dmem) + LENGTH(dmem));
18
19 ENTRY (_start)
20
21 EOF
22
23 cat <<EOF
24 SECTIONS
25 {
26   /* Read-only sections, merged into text segment: */
27   ${TEXT_DYNAMIC+${DYNAMIC}}
28   .hash        ${RELOCATING-0} : { *(.hash)             }
29   .dynsym      ${RELOCATING-0} : { *(.dynsym)           }
30   .dynstr      ${RELOCATING-0} : { *(.dynstr)           }
31   .gnu.version ${RELOCATING-0} : { *(.gnu.version)      }
32   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)  }
33   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)  }
34
35   .rel.init    ${RELOCATING-0} : { *(.rel.init)         }
36   .rela.init   ${RELOCATING-0} : { *(.rela.init)        }
37   .rel.text    ${RELOCATING-0} :
38     {
39       *(.rel.text)
40       ${RELOCATING+*(.rel.text.*)}
41       ${RELOCATING+*(.rel.text:*)}
42       ${RELOCATING+*(.rel.gnu.linkonce.t*)}
43     }
44   .rela.text   ${RELOCATING-0} :
45     {
46       *(.rela.text)
47       ${RELOCATING+*(.rela.text.*)}
48       ${RELOCATING+*(.rela.text:*)}
49       ${RELOCATING+*(.rela.gnu.linkonce.t*)}
50     }
51   .rel.fini    ${RELOCATING-0} : { *(.rel.fini)         }
52   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)        }
53   .rel.rodata  ${RELOCATING-0} :
54     {
55       *(.rel.rodata)
56       ${RELOCATING+*(.rel.rodata.*)}
57       ${RELOCATING+*(.rel.rodata:*)}
58       ${RELOCATING+*(.rel.gnu.linkonce.r*)}
59     }
60   .rela.rodata ${RELOCATING-0} :
61     {
62       *(.rela.rodata)
63       ${RELOCATING+*(.rela.rodata.*)}
64       ${RELOCATING+*(.rela.rodata:*)}
65       ${RELOCATING+*(.rela.gnu.linkonce.r*)}
66     }
67   .rel.data    ${RELOCATING-0} :
68     {
69       *(.rel.data)
70       ${RELOCATING+*(.rel.data.*)}
71       ${RELOCATING+*(.rel.data:*)}
72       ${RELOCATING+*(.rel.gnu.linkonce.d*)}
73     }
74   .rela.data   ${RELOCATING-0} :
75     {
76       *(.rela.data)
77       ${RELOCATING+*(.rela.data.*)}
78       ${RELOCATING+*(.rela.data:*)}
79       ${RELOCATING+*(.rela.gnu.linkonce.d*)}
80     }
81   .rel.init_array       ${RELOCATING-0} : { *(.rel.init_array)  }
82   .rela.init_array      ${RELOCATING-0} : { *(.rela.init_array) }
83   .rel.fini_array       ${RELOCATING-0} : { *(.rel.fini_array)  }
84   .rela.fini_array      ${RELOCATING-0} : { *(.rela.fini_array) }
85   .rel.got              ${RELOCATING-0} : { *(.rel.got)         }
86   .rela.got             ${RELOCATING-0} : { *(.rela.got)        }
87   .rel.bss              ${RELOCATING-0} : { *(.rel.bss)         }
88   .rela.bss             ${RELOCATING-0} : { *(.rela.bss)        }
89   .rel.plt              ${RELOCATING-0} : { *(.rel.plt)         }
90   .rela.plt             ${RELOCATING-0} : { *(.rela.plt)        }
91
92   /* Internal text space.  */
93   .text ${RELOCATING-0} :
94   {
95     ${RELOCATING+ _text_start = . ; }
96
97     ${RELOCATING+. = ALIGN(4);}
98
99     ${RELOCATING+*(.init0)  /* Start here after reset.  */}
100     ${RELOCATING+KEEP (*(.init0))}
101
102     ${RELOCATING+. = ALIGN(4);}
103     *(.text)
104     ${RELOCATING+. = ALIGN(4);}
105     ${RELOCATING+*(.text.*)}
106     ${RELOCATING+. = ALIGN(4);}
107     ${RELOCATING+*(.text:*)}
108     ${RELOCATING+. = ALIGN(4);}
109     ${RELOCATING+*(.gnu.linkonce.t*)}
110     ${RELOCATING+. = ALIGN(4);}
111
112     ${RELOCATING+ _text_end = . ; }
113   } ${RELOCATING+ > imem}
114
115   .data        ${RELOCATING-0} :
116   {
117     /* Optional variable that user is prepared to have NULL address.  */
118     ${RELOCATING+ *(.data.atzero*)}
119
120     /* CRT is prepared for constructor/destructor table to have
121        a "valid" NULL address.  */
122     ${CONSTRUCTING+ __init_array_start = . ; }
123     ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))}
124     ${CONSTRUCTING+ KEEP (*(.init_array))}
125     ${CONSTRUCTING+ __init_array_end = . ; }
126     ${CONSTRUCTING+ __fini_array_start = . ; }
127     ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))}
128     ${CONSTRUCTING+ KEEP (*(.fini_array))}
129     ${CONSTRUCTING+ __fini_array_end = . ; }
130
131     ${RELOCATING+/* DATA memory starts at address 0.  So to avoid placing a valid static
132        variable at the invalid NULL address, we introduce the .data.atzero
133        section.  If CRT can make some use of it - great.  Otherwise skip a
134        word.  In all cases .data/.bss sections must start at non-zero.  */
135     . += (. == 0 ? 4 : 0);}
136
137     ${RELOCATING+ PROVIDE (_data_start = .) ; }
138     *(.data)
139     ${RELOCATING+ *(.data*)}
140     ${RELOCATING+ *(.data:*)}
141     ${RELOCATING+ *(.rodata)  /* We need to include .rodata here if gcc is used.  */}
142     ${RELOCATING+ *(.rodata.*) /* with -fdata-sections.  */}
143     ${RELOCATING+ *(.rodata:*)}
144     ${RELOCATING+*(.gnu.linkonce.d*)}
145     ${RELOCATING+*(.gnu.linkonce.r*)}
146     ${RELOCATING+. = ALIGN(4);}
147     ${RELOCATING+ PROVIDE (_data_end = .) ; }
148   } ${RELOCATING+ > dmem }
149
150   .resource_table ${RELOCATING-0} :
151   {
152     KEEP (*(.resource_table))
153   } ${RELOCATING+ > dmem}
154
155   .bss ${RELOCATING-0} :
156   {
157     ${RELOCATING+ PROVIDE (_bss_start = .) ; }
158     *(.bss)
159     ${RELOCATING+ *(.bss.*)}
160     ${RELOCATING+ *(.bss:*)}
161     ${RELOCATING+*(.gnu.linkonce.b*)}
162     ${RELOCATING+*(COMMON)}
163     ${RELOCATING+ PROVIDE (_bss_end = .) ; }
164   } ${RELOCATING+ > dmem}
165
166   /* Global data not cleared after reset.  */
167   .noinit ${RELOCATING-0} :
168   {
169     ${RELOCATING+ PROVIDE (_noinit_start = .) ; }
170     *(.noinit)
171     ${RELOCATING+ PROVIDE (_noinit_end = .) ; }
172     ${RELOCATING+ PROVIDE (_heap_start = .) ; }
173     ${RELOCATING+ . += __HEAP_SIZE ; }
174     ${RELOCATING+/* Stack is not here really.  It will be put at the end of DMEM.
175        But we take into account its size here, in order to allow
176        for MEMORY overflow checking during link time.  */}
177     ${RELOCATING+ . += __STACK_SIZE ; }
178   } ${RELOCATING+ > dmem}
179
180   /* Stabs debugging sections.  */
181   .stab 0 : { *(.stab) }
182   .stabstr 0 : { *(.stabstr) }
183   .stab.excl 0 : { *(.stab.excl) }
184   .stab.exclstr 0 : { *(.stab.exclstr) }
185   .stab.index 0 : { *(.stab.index) }
186   .stab.indexstr 0 : { *(.stab.indexstr) }
187   .comment 0 : { *(.comment) }
188   .note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
189 EOF
190
191 . $srcdir/scripttempl/DWARF.sc
192
193 cat <<EOF
194 }
195 EOF