aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2016-11-27 20:42:26 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2016-12-04 21:02:25 -0500
commitff45000fcb56b5b0f1a14a865d3541746d838a0a (patch)
treecddec161a0d5b9df36a82a36575bf604edf585c5
parentc02e0349d7e9eec8a6414840dd34b8d26e0c047b (diff)
powerpc/boot: Request no dynamic linker for boot wrapper
The boot wrapper performs its own relocations and does not require PT_INTERP segment. However currently we don't tell the linker that. Prior to binutils 2.28 that works OK. But since binutils commit 1a9ccd70f9a7 ("Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix readelf to report such invalid binaries.") binutils tries to create a program header segment due to PT_INTERP, and the link fails because there is no space for it: ld: arch/powerpc/boot/zImage.pseries: Not enough room for program headers, try linking with -N ld: final link failed: Bad value So tell the linker not to do that, by passing --no-dynamic-linker. Cc: stable@vger.kernel.org Reported-by: Anton Blanchard <anton@samba.org> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> [mpe: Drop dependency on ld-version.sh and massage change log] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rwxr-xr-xarch/powerpc/boot/wrapper24
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 404b3aabdb4d..76fe3ccfd381 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -181,6 +181,28 @@ case "$elfformat" in
181 elf32-powerpc) format=elf32ppc ;; 181 elf32-powerpc) format=elf32ppc ;;
182esac 182esac
183 183
184ld_version()
185{
186 # Poached from scripts/ld-version.sh, but we don't want to call that because
187 # this script (wrapper) is distributed separately from the kernel source.
188 # Extract linker version number from stdin and turn into single number.
189 awk '{
190 gsub(".*\\)", "");
191 gsub(".*version ", "");
192 gsub("-.*", "");
193 split($1,a, ".");
194 print a[1]*100000000 + a[2]*1000000 + a[3]*10000;
195 exit
196 }'
197}
198
199# Do not include PT_INTERP segment when linking pie. Non-pie linking
200# just ignores this option.
201LD_VERSION=$(${CROSS}ld --version | ld_version)
202LD_NO_DL_MIN_VERSION=$(echo 2.26 | ld_version)
203if [ "$LD_VERSION" -ge "$LD_NO_DL_MIN_VERSION" ] ; then
204 nodl="--no-dynamic-linker"
205fi
184 206
185platformo=$object/"$platform".o 207platformo=$object/"$platform".o
186lds=$object/zImage.lds 208lds=$object/zImage.lds
@@ -446,7 +468,7 @@ if [ "$platform" != "miboot" ]; then
446 text_start="-Ttext $link_address" 468 text_start="-Ttext $link_address"
447 fi 469 fi
448#link everything 470#link everything
449 ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ 471 ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" \
450 $platformo $tmp $object/wrapper.a 472 $platformo $tmp $object/wrapper.a
451 rm $tmp 473 rm $tmp
452fi 474fi