[PATCH RFA] configure.in: HAVE_STRUCT_LINK_MAP32 fix

Kevin Buettner kevinb@cygnus.com
Sat Sep 9 13:20:00 GMT 2000


The patch below fix the problem in which HAVE_STRUCT_LINK_MAP32 gets
incorrectly defined for Linux.  The original test is as follows:

    [AC_TRY_RUN([#define _SYSCALL32
     #include <sys/link.h>
     int main()
     {
       if (sizeof (struct link_map32) > 0)
	 return 1;
       return 0;
     }],
     gdb_cv_have_struct_link_map32=no,
     gdb_cv_have_struct_link_map32=yes,
     gdb_cv_have_struct_link_map32=yes)]

The problem with this test is that gdb_cv_have_struct_link_map32 is
defined to be no if the program compiles successfully *and* returns
0 when run.  It will be defined to be yes otherwise.  So, on the
appropriate Solaris system, the test would compile, but the program
would exit with status code 1 (not 0), thus causing the autoconf
variable to be defined to yes.

On Linux, the compilation would simply fail because Linux lacks a
<sys/link.h> file.  This would also cause the autoconf variable to
be set to yes.  (Not what we want.)

I don't think it would ever be possible for the autoconf variable
to be set to no.  For this to happen, there would have to be a
struct link_map32 declared which is also of zero size.

In order for the above test to work, it would have to be written
as follows:

    [AC_TRY_RUN([#define _SYSCALL32
     #include <sys/link.h>
     int main()
     {
       if (sizeof (struct link_map32) > 0)
	 return 0;
       return 1;
     }],
     gdb_cv_have_struct_link_map32=yes,
     gdb_cv_have_struct_link_map32=no,
     gdb_cv_have_struct_link_map32=no)]

Note that the 0 and 1 were interchanged as were the yes/no values.

However, I don't think AC_TRY_RUN is really appropriate in this case
anyway because it effectively precludes the use of a cross compiler.
Instead, I think AC_TRY_COMPILE is sufficient for making the test
work properly.

This has been tested on Linux, but not on Solaris.

Please let me know if it's okay to commit this patch.

	* configure.in (HAVE_STRUCT_LINK_MAP32): Change test to use
	AC_TRY_COMPILE instead of AC_TRY_RUN.

Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.43
diff -u -p -r1.43 configure.in
--- configure.in	2000/08/30 00:58:58	1.43
+++ configure.in	2000/09/09 20:01:41
@@ -239,17 +239,10 @@ if test "$ac_cv_header_sys_procfs_h" = y
 
   AC_MSG_CHECKING(for struct link_map32 in sys/link.h)
   AC_CACHE_VAL(gdb_cv_have_struct_link_map32, 
-    [AC_TRY_RUN([#define _SYSCALL32
-     #include <sys/link.h>
-     int main()
-     {
-       if (sizeof (struct link_map32) > 0)
-	 return 1;
-       return 0;
-     }],
-     gdb_cv_have_struct_link_map32=no,
+    [AC_TRY_COMPILE([#define _SYSCALL32
+#include <sys/link.h>], [struct link_map32 l;],
      gdb_cv_have_struct_link_map32=yes,
-     gdb_cv_have_struct_link_map32=yes)])
+     gdb_cv_have_struct_link_map32=no)])
   AC_MSG_RESULT($gdb_cv_have_struct_link_map32)
   if test $gdb_cv_have_struct_link_map32 = yes; then
     AC_DEFINE(HAVE_STRUCT_LINK_MAP32)



More information about the Gdb-patches mailing list