qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] qemu-user: fix build with LLVM lld 10


From: Roger Pau Monne
Subject: [PATCH] qemu-user: fix build with LLVM lld 10
Date: Thu, 26 Mar 2020 14:43:16 +0100

lld 10.0.0 introduced a new linker option --image-base equivalent to
the GNU -Ttext-segment one, hence use it when available.

This fixes the build of QEMU on systems using lld 10 or greater.

Signed-off-by: Dimitry Andric <address@hidden>
Signed-off-by: Roger Pau Monné <address@hidden>
---
Cc: Laurent Vivier <address@hidden>
Cc: Richard Henderson <address@hidden>
Cc: "Philippe Mathieu-Daudé" <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Cc: "Daniel P. Berrangé" <address@hidden>
---
 configure | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/configure b/configure
index da09c35895..92d57d84fa 100755
--- a/configure
+++ b/configure
@@ -6514,27 +6514,31 @@ if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) 
&& [ "$pie" = no ]; then
     cat > $TMPC <<EOF
     int main(void) { return 0; }
 EOF
-    textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
+    # Test with image-base first, which appeared in lld 10.0.0
+    textseg_ldflags="-Wl,--image-base=$textseg_addr"
     if ! compile_prog "" "$textseg_ldflags"; then
-      # 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
+      textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
+      if ! compile_prog "" "$textseg_ldflags"; then
+        # 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 --image-base or -Ttext-segment" \
+              "options 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' \
-        -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + 
SIZEOF_HEADERS/" \
-        -e "s/__executable_start = [0-9a-fx]*/__executable_start = 
$textseg_addr/" > config-host.ld
-      textseg_ldflags="-Wl,-T../config-host.ld"
+        $ld --verbose | sed \
+          -e '1,/==================================================/d' \
+          -e '/==================================================/,$d' \
+          -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + 
SIZEOF_HEADERS/" \
+          -e "s/__executable_start = [0-9a-fx]*/__executable_start = 
$textseg_addr/" > config-host.ld
+        textseg_ldflags="-Wl,-T../config-host.ld"
+      fi
     fi
   fi
 fi
-- 
2.26.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]