[RFA/gdbserver] disable Elf32_auxv_t/Elf64_auxv_t AC_CHECK_TYPES check on Android

Message ID 1447092325-20362-1-git-send-email-brobecker@adacore.com
State New, archived
Headers

Commit Message

Joel Brobecker Nov. 9, 2015, 6:05 p.m. UTC
  Hello,

This patch fixes a GDBserver build failure on Android when using
NDK version 9 or later.

See the comment added in configure.ac for more details behind
this change.

gdb/gdbserver/ChangeLog:

        * configure.ac: Do not call AC_CHECK_TYPES for Elf32_auxv_t
        and Elf64_auxv_t if the target is Android.

Tested on arm-android. OK to commit?

Thanks!
  

Comments

Pedro Alves Nov. 20, 2015, 4:03 p.m. UTC | #1
On 11/09/2015 06:05 PM, Joel Brobecker wrote:
> Hello,
> 
> This patch fixes a GDBserver build failure on Android when using
> NDK version 9 or later.
> 
> See the comment added in configure.ac for more details behind
> this change.
> 
> gdb/gdbserver/ChangeLog:
> 
>         * configure.ac: Do not call AC_CHECK_TYPES for Elf32_auxv_t
>         and Elf64_auxv_t if the target is Android.
> 
> Tested on arm-android. OK to commit?
> 

LGTM.

Thanks,
Pedro Alves
  
Joel Brobecker Nov. 23, 2015, 5:49 p.m. UTC | #2
> > gdb/gdbserver/ChangeLog:
> > 
> >         * configure.ac: Do not call AC_CHECK_TYPES for Elf32_auxv_t
> >         and Elf64_auxv_t if the target is Android.
> > 
> > Tested on arm-android. OK to commit?
> > 
> 
> LGTM.

Thanks, Pedro. Now pushed.
  

Patch

diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 409f42b..f1b0e90 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -6444,7 +6444,20 @@  _ACEOF
 fi
 
 
-ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
+case "${target}" in
+  *-android*)
+    # Starting with NDK version 9, <elf.h> actually includes definitions
+    # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
+    # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
+    # leading to conflicts with the defintions from <linux/elf.h>.
+    # This makes it impossible for us to include both <elf.h> and
+    # <linux/elf.h>, which means that, in practice, we do not have
+    # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
+    # Therefore, do not try to auto-detect availability, as it would
+    # get it wrong on this platform.
+    ;;
+  *)
+    ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
 
 "
 if test "x$ac_cv_type_Elf32_auxv_t" = x""yes; then :
@@ -6467,6 +6480,7 @@  _ACEOF
 
 fi
 
+esac
 
 
 
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 0fe0a35..2a69db5 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -236,9 +236,23 @@  AC_CHECK_TYPES(socklen_t, [], [],
 #include <sys/socket.h>
 ])
 
-AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
-#include <elf.h>
-)
+case "${target}" in
+  *-android*)
+    # Starting with NDK version 9, <elf.h> actually includes definitions
+    # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
+    # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
+    # leading to conflicts with the defintions from <linux/elf.h>.
+    # This makes it impossible for us to include both <elf.h> and
+    # <linux/elf.h>, which means that, in practice, we do not have
+    # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
+    # Therefore, do not try to auto-detect availability, as it would
+    # get it wrong on this platform.
+    ;;
+  *)
+    AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
+    #include <elf.h>
+    )
+esac
 
 ACX_PKGVERSION([GDB])
 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])