diff mbox

[1/2] configure: Improve usermode relocation linker option probe

Message ID 1466287502-18730-2-git-send-email-pmaydell@chiark.greenend.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Maydell June 18, 2016, 10:05 p.m. UTC
From: Peter Maydell <peter.maydell@linaro.org>

The probe we do to determine what flags to use to make the usermode
executables use a non-default text address has some flaws:
 * we run it even if we're not building the user binaries
 * we don't expect "ld --verbose" to fail

The combination of these two results in a harmless but
ugly "ld: unknown option: --verbose" message when running
configure on OSX.

Improve the probe to only run when we need it and to fail
nicely when even the backstop 'ld --verbose' approach fails.

Reported-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 configure | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Stefan Weil June 19, 2016, 5:47 a.m. UTC | #1
Am 19.06.2016 um 00:05 schrieb Peter Maydell:
> From: Peter Maydell <peter.maydell@linaro.org>
> 
> The probe we do to determine what flags to use to make the usermode
> executables use a non-default text address has some flaws:
>  * we run it even if we're not building the user binaries
>  * we don't expect "ld --verbose" to fail
> 
> The combination of these two results in a harmless but
> ugly "ld: unknown option: --verbose" message when running
> configure on OSX.
> 
> Improve the probe to only run when we need it and to fail
> nicely when even the backstop 'ld --verbose' approach fails.
> 
> Reported-by: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  configure | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 10cb212..7beefcd 100755
> --- a/configure
> +++ b/configure
> @@ -4700,7 +4700,7 @@ if test "$cpu" = "s390x" ; then
>  fi
>  
>  # Probe for the need for relocating the user-only binary.
> -if test "$pie" = "no" ; then
> +if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
>    textseg_addr=
>    case "$cpu" in
>      arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
> @@ -4722,6 +4722,16 @@ EOF
>        # In case ld does not support -Ttext-segment, edit the default linker
>        # script via sed to set the .text start addr.  This is needed on FreeBSD
>        # at least.
> +      if ! $ld --verbose >/dev/null 2>&1; then
> +        error_exit \
> +            "We need to link the QEMU user mode binaries at a" \
> +            "specific text address. Unfortunately your linker" \
> +            "doesn't support either the -Ttext-segment option or" \
> +            "printing the default linker script with --verbose." \
> +            "If you don't want the user mode binaries, pass the" \
> +            "--disable-user option to configure."
> +      fi
> +
>        $ld --verbose | sed \
>          -e '1,/==================================================/d' \
>          -e '/==================================================/,$d' \
> 

Reviewed-by: Stefan Weil <sw@weilnetz.de>

Thanks.
diff mbox

Patch

diff --git a/configure b/configure
index 10cb212..7beefcd 100755
--- a/configure
+++ b/configure
@@ -4700,7 +4700,7 @@  if test "$cpu" = "s390x" ; then
 fi
 
 # Probe for the need for relocating the user-only binary.
-if test "$pie" = "no" ; then
+if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
   textseg_addr=
   case "$cpu" in
     arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
@@ -4722,6 +4722,16 @@  EOF
       # In case ld does not support -Ttext-segment, edit the default linker
       # script via sed to set the .text start addr.  This is needed on FreeBSD
       # at least.
+      if ! $ld --verbose >/dev/null 2>&1; then
+        error_exit \
+            "We need to link the QEMU user mode binaries at a" \
+            "specific text address. Unfortunately your linker" \
+            "doesn't support either the -Ttext-segment option or" \
+            "printing the default linker script with --verbose." \
+            "If you don't want the user mode binaries, pass the" \
+            "--disable-user option to configure."
+      fi
+
       $ld --verbose | sed \
         -e '1,/==================================================/d' \
         -e '/==================================================/,$d' \