GNU Binutils with patches for OS216
リビジョン | 85dd6069e6baac2596d6e9f200d4761eea2169de (tree) |
---|---|
日時 | 2016-06-08 21:07:29 |
作者 | Marcin Kościelnicki <koriakin@0x04...> |
コミッター | Marcin Kościelnicki |
ld: Enable using separate linker script for -z relro
This will be used for s390 relro got support.
ld/ChangeLog:
* emultempl/elf32.em: Use .xo, .xso, .xdo scripts if
GENERATE_RELRO_SCRIPT is set.
* genscripts.sh: Create .xo, .xso, .xdo scripts if
GENERATE_RELRO_SCRIPT is set.
@@ -2074,6 +2074,12 @@ echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | ||
2074 | 2074 | echo ' && link_info.relro' >> e${EMULATION_NAME}.c |
2075 | 2075 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
2076 | 2076 | sed $sc ldscripts/${EMULATION_NAME}.xdw >> e${EMULATION_NAME}.c |
2077 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2078 | +echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c | |
2079 | +echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
2080 | +echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
2081 | +sed $sc ldscripts/${EMULATION_NAME}.xdo >> e${EMULATION_NAME}.c | |
2082 | +fi | |
2077 | 2083 | echo ' ; else if (bfd_link_pie (&link_info)' >> e${EMULATION_NAME}.c |
2078 | 2084 | echo ' && link_info.combreloc) return' >> e${EMULATION_NAME}.c |
2079 | 2085 | sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c |
@@ -2087,6 +2093,12 @@ echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc' >> e${EMULA | ||
2087 | 2093 | echo ' && link_info.relro' >> e${EMULATION_NAME}.c |
2088 | 2094 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
2089 | 2095 | sed $sc ldscripts/${EMULATION_NAME}.xsw >> e${EMULATION_NAME}.c |
2096 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2097 | +echo ' ; else if (bfd_link_dll (&link_info)' >> e${EMULATION_NAME}.c | |
2098 | +echo ' && link_info.combreloc' >> e${EMULATION_NAME}.c | |
2099 | +echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
2100 | +sed $sc ldscripts/${EMULATION_NAME}.xso >> e${EMULATION_NAME}.c | |
2101 | +fi | |
2090 | 2102 | echo ' ; else if (bfd_link_dll (&link_info) && link_info.combreloc) return' >> e${EMULATION_NAME}.c |
2091 | 2103 | sed $sc ldscripts/${EMULATION_NAME}.xsc >> e${EMULATION_NAME}.c |
2092 | 2104 | fi |
@@ -2097,6 +2109,11 @@ if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then | ||
2097 | 2109 | echo ' ; else if (link_info.combreloc && link_info.relro' >> e${EMULATION_NAME}.c |
2098 | 2110 | echo ' && (link_info.flags & DF_BIND_NOW)) return' >> e${EMULATION_NAME}.c |
2099 | 2111 | sed $sc ldscripts/${EMULATION_NAME}.xw >> e${EMULATION_NAME}.c |
2112 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2113 | +echo ' ; else if (link_info.combreloc' >> e${EMULATION_NAME}.c | |
2114 | +echo ' && link_info.relro) return' >> e${EMULATION_NAME}.c | |
2115 | +sed $sc ldscripts/${EMULATION_NAME}.xo >> e${EMULATION_NAME}.c | |
2116 | +fi | |
2100 | 2117 | echo ' ; else if (link_info.combreloc) return' >> e${EMULATION_NAME}.c |
2101 | 2118 | sed $sc ldscripts/${EMULATION_NAME}.xc >> e${EMULATION_NAME}.c |
2102 | 2119 | fi |
@@ -2133,6 +2150,16 @@ fragment <<EOF | ||
2133 | 2150 | && link_info.relro |
2134 | 2151 | && (link_info.flags & DF_BIND_NOW)) |
2135 | 2152 | return "ldscripts/${EMULATION_NAME}.xdw"; |
2153 | +EOF | |
2154 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2155 | +fragment <<EOF | |
2156 | + else if (bfd_link_pie (&link_info) | |
2157 | + && link_info.combreloc | |
2158 | + && link_info.relro) | |
2159 | + return "ldscripts/${EMULATION_NAME}.xdo"; | |
2160 | +EOF | |
2161 | +fi | |
2162 | +fragment <<EOF | |
2136 | 2163 | else if (bfd_link_pie (&link_info) |
2137 | 2164 | && link_info.combreloc) |
2138 | 2165 | return "ldscripts/${EMULATION_NAME}.xdc"; |
@@ -2149,6 +2176,15 @@ fragment <<EOF | ||
2149 | 2176 | else if (bfd_link_dll (&link_info) && link_info.combreloc |
2150 | 2177 | && link_info.relro && (link_info.flags & DF_BIND_NOW)) |
2151 | 2178 | return "ldscripts/${EMULATION_NAME}.xsw"; |
2179 | +EOF | |
2180 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2181 | +fragment <<EOF | |
2182 | + else if (bfd_link_dll (&link_info) && link_info.combreloc | |
2183 | + && link_info.relro) | |
2184 | + return "ldscripts/${EMULATION_NAME}.xso"; | |
2185 | +EOF | |
2186 | +fi | |
2187 | +fragment <<EOF | |
2152 | 2188 | else if (bfd_link_dll (&link_info) && link_info.combreloc) |
2153 | 2189 | return "ldscripts/${EMULATION_NAME}.xsc"; |
2154 | 2190 | EOF |
@@ -2163,6 +2199,14 @@ fragment <<EOF | ||
2163 | 2199 | else if (link_info.combreloc && link_info.relro |
2164 | 2200 | && (link_info.flags & DF_BIND_NOW)) |
2165 | 2201 | return "ldscripts/${EMULATION_NAME}.xw"; |
2202 | +EOF | |
2203 | +if test -n "$GENERATE_RELRO_SCRIPT" ; then | |
2204 | +fragment <<EOF | |
2205 | + else if (link_info.combreloc && link_info.relro) | |
2206 | + return "ldscripts/${EMULATION_NAME}.xo"; | |
2207 | +EOF | |
2208 | +fi | |
2209 | +fragment <<EOF | |
2166 | 2210 | else if (link_info.combreloc) |
2167 | 2211 | return "ldscripts/${EMULATION_NAME}.xc"; |
2168 | 2212 | EOF |
@@ -321,6 +321,20 @@ if test -n "$GENERATE_COMBRELOC_SCRIPT"; then | ||
321 | 321 | . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc |
322 | 322 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xc |
323 | 323 | rm -f ${COMBRELOC} |
324 | + | |
325 | + if test -n "$GENERATE_RELRO_SCRIPT"; then | |
326 | + LD_FLAG=o | |
327 | + RELRO=" " | |
328 | + COMBRELOC=ldscripts/${EMULATION_NAME}.xo.tmp | |
329 | + ( echo "/* Script for -z combreloc -z relro: combine and sort reloc sections */" | |
330 | + . ${CUSTOMIZER_SCRIPT} | |
331 | + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc | |
332 | + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xo | |
333 | + rm -f ${COMBRELOC} | |
334 | + COMBRELOC= | |
335 | + unset RELRO | |
336 | + fi | |
337 | + | |
324 | 338 | LD_FLAG=w |
325 | 339 | RELRO_NOW=" " |
326 | 340 | COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp |
@@ -351,6 +365,20 @@ if test -n "$GENERATE_SHLIB_SCRIPT"; then | ||
351 | 365 | . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc |
352 | 366 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc |
353 | 367 | rm -f ${COMBRELOC} |
368 | + | |
369 | + if test -n "$GENERATE_RELRO_SCRIPT"; then | |
370 | + LD_FLAG=oshared | |
371 | + RELRO=" " | |
372 | + COMBRELOC=ldscripts/${EMULATION_NAME}.xso.tmp | |
373 | + ( echo "/* Script for --shared -z combreloc -z relro: shared library, combine & sort relocs */" | |
374 | + . ${CUSTOMIZER_SCRIPT} | |
375 | + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc | |
376 | + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xso | |
377 | + rm -f ${COMBRELOC} | |
378 | + COMBRELOC= | |
379 | + unset RELRO | |
380 | + fi | |
381 | + | |
354 | 382 | LD_FLAG=wshared |
355 | 383 | RELRO_NOW=" " |
356 | 384 | COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp |
@@ -383,6 +411,20 @@ if test -n "$GENERATE_PIE_SCRIPT"; then | ||
383 | 411 | . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc |
384 | 412 | ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc |
385 | 413 | rm -f ${COMBRELOC} |
414 | + | |
415 | + if test -n "$GENERATE_RELRO_SCRIPT"; then | |
416 | + LD_FLAG=opie | |
417 | + RELRO=" " | |
418 | + COMBRELOC=ldscripts/${EMULATION_NAME}.xdo.tmp | |
419 | + ( echo "/* Script for -pie -z combreloc -z relro: position independent executable, combine & sort relocs */" | |
420 | + . ${CUSTOMIZER_SCRIPT} | |
421 | + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc | |
422 | + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdo | |
423 | + rm -f ${COMBRELOC} | |
424 | + COMBRELOC= | |
425 | + unset RELRO | |
426 | + fi | |
427 | + | |
386 | 428 | LD_FLAG=wpie |
387 | 429 | RELRO_NOW=" " |
388 | 430 | COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp |