Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Zachary T Welch <zwelch@codesourcery.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>,
	<gdb-patches@sourceware.org>
Cc: Zachary T Welch <zwelch@codesourcery.com>
Subject: [PATCH v2] Fix gdbserver build with x86_64-w64-mingw32 -m32
Date: Mon, 12 Jan 2015 17:46:00 -0000	[thread overview]
Message-ID: <1421084758-2096-1-git-send-email-zwelch@codesourcery.com> (raw)
In-Reply-To: <874mrzu3cd.fsf@redhat.com>

This patch allows a x86_64-w64-mingw32 toolchain to build a 32-bit
gdbserver.  Without it, gdbserver attempts to link to the 64-bit
register files, resulting in undefined references.

This version was regenerated with correct version of aclocal and rebased to the
current HEAD.

	* configure.ac: Add check for -m32 on x86_64-*-mingw*.
	* configure.srv: If using -m32 on x86_64-*-mingw*, use i386
	instead of amd64 registers.
	* configure: Regenerated.

Signed-off-by: Zachary T Welch <zwelch@codesourcery.com>
---
 gdb/gdbserver/ChangeLog     |  7 +++++++
 gdb/gdbserver/configure     | 29 +++++++++++++++++++++++++++++
 gdb/gdbserver/configure.ac  | 12 ++++++++++++
 gdb/gdbserver/configure.srv |  3 +++
 4 files changed, 51 insertions(+)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index d126748..09912e1 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-12  Zachary T Welch  <zwelch@codesourcery.com>
+
+	* configure.ac: Add check for -m32 on x86_64-*-mingw*.
+	* configure.srv: If using -m32 on x86_64-*-mingw*, use i386
+	instead of amd64 registers.
+	* configure: Regenerated.
+
 2015-01-10  Joel Brobecker  <brobecker@adacore.com>
 
 	* i387-fp.c (i387_cache_to_xsave): In look over
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 45efc51..f9cc792 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -5535,6 +5535,35 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_m68k_is_coldfire" >&5
 $as_echo "$gdb_cv_m68k_is_coldfire" >&6; }
     ;;
+  x86_64-*-mingw*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if building with -m32" >&5
+$as_echo_n "checking if building with -m32... " >&6; }
+if test "${gdb_cv_x86_64_is_i386+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  save_CPPFLAGS="$CPPFLAGS"
+		    CPPFLAGS="$CPPFLAGS $CFLAGS"
+                    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#if ! __x86_64__
+got it
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "got it" >/dev/null 2>&1; then :
+  gdb_cv_w64_x86_64_is_i386=yes
+else
+  gdb_cv_w64_x86_64_is_i386=no
+fi
+rm -f conftest*
+
+                    CPPFLAGS="$save_CPPFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_x86_64_is_i386" >&5
+$as_echo "$gdb_cv_x86_64_is_i386" >&6; }
+    ;;
 esac
 
 . ${srcdir}/configure.srv
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 02082cc..ff9e272 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -238,6 +238,18 @@ got it
                     [gdb_cv_m68k_is_coldfire=no])
                     CPPFLAGS="$save_CPPFLAGS"])
     ;;
+  x86_64-*-mingw*)
+    AC_CACHE_CHECK([if building with -m32], [gdb_cv_x86_64_is_i386],
+		   [save_CPPFLAGS="$CPPFLAGS"
+		    CPPFLAGS="$CPPFLAGS $CFLAGS"
+                    AC_EGREP_CPP([got it], [
+#if ! __x86_64__
+got it
+#endif
+                 ], [gdb_cv_w64_x86_64_is_i386=yes],
+                    [gdb_cv_w64_x86_64_is_i386=no])
+                    CPPFLAGS="$save_CPPFLAGS"])
+    ;;
 esac
 
 . ${srcdir}/configure.srv
diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
index 679fc9f..e0d5413 100644
--- a/gdb/gdbserver/configure.srv
+++ b/gdb/gdbserver/configure.srv
@@ -325,6 +325,9 @@ case "${target}" in
 			ipa_obj="${ipa_amd64_linux_regobj} linux-amd64-ipa.o"
 			;;
   x86_64-*-mingw*)	srv_regobj="$srv_amd64_regobj"
+			if test "$gdb_cv_w64_x86_64_is_i386" = yes ; then
+			  srv_regobj="$srv_i386_regobj"
+			fi
 			srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o"
 			srv_xmlfiles="$srv_i386_xmlfiles $srv_amd64_xmlfiles"
 			srv_mingw=yes
-- 
1.8.1.1


  reply	other threads:[~2015-01-12 17:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 17:49 [PATCH] " Zachary T Welch
2015-01-09 20:05 ` Sergio Durigan Junior
2015-01-12 17:46   ` Zachary T Welch [this message]
2015-01-13  9:21     ` [PATCH v2] " Joel Brobecker
2015-01-10  4:17 ` [PATCH] " Joel Brobecker
2015-01-12 17:54   ` Zach Welch
2015-01-13  9:17     ` Joel Brobecker
2015-01-13 16:59       ` Zach Welch
2015-01-15  4:46         ` Joel Brobecker
2015-01-13 17:42     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421084758-2096-1-git-send-email-zwelch@codesourcery.com \
    --to=zwelch@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox