aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-12-11 16:02:35 +1030
committerAlan Modra <amodra@gmail.com>2014-12-11 17:07:46 +1030
commit4c219c2e69bb66a5535645e2c83fafda1362acea (patch)
tree10dd7e49bfa50e1c721ee6b938330e0c9884960e
parent1b43a4392f2c979e77a9fef16877ec99b9cf26a3 (diff)
downloadfsf-binutils-gdb-4c219c2e69bb66a5535645e2c83fafda1362acea.zip
fsf-binutils-gdb-4c219c2e69bb66a5535645e2c83fafda1362acea.tar.gz
fsf-binutils-gdb-4c219c2e69bb66a5535645e2c83fafda1362acea.tar.bz2
Use autoconf check for long long in binutils
Also fix a place where %lld was wrongly used to print a dwarf_vma. * configure.ac: Check for long long and sizes of long long and long. * elfcomm.h (HOST_WIDEST_INT): Test HAVE_LONG_LONG in place of __STDC_VERSION__ and __GNUC__. * strings.c (print_strings): Likewise. * dwarf.c (DWARF_VMA_FMT, DWARF_VMA_FMT_LONG): Likewise. (read_debug_line_header): Use dwarf_vmatoa to print warning. * configure: Regenerate. * config.in: Regenerate.
-rw-r--r--binutils/ChangeLog11
-rw-r--r--binutils/config.in9
-rwxr-xr-xbinutils/configure314
-rw-r--r--binutils/configure.ac3
-rw-r--r--binutils/dwarf.c23
-rw-r--r--binutils/elfcomm.h2
-rw-r--r--binutils/strings.c24
7 files changed, 360 insertions, 26 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 3428a29..e8c0037 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2014-12-11 Alan Modra <amodra@gmail.com>
+
+ * configure.ac: Check for long long and sizes of long long and long.
+ * elfcomm.h (HOST_WIDEST_INT): Test HAVE_LONG_LONG in place of
+ __STDC_VERSION__ and __GNUC__.
+ * strings.c (print_strings): Likewise.
+ * dwarf.c (DWARF_VMA_FMT, DWARF_VMA_FMT_LONG): Likewise.
+ (read_debug_line_header): Use dwarf_vmatoa to print warning.
+ * configure: Regenerate.
+ * config.in: Regenerate.
+
2014-12-10 Alan Modra <amodra@gmail.com>
* objdump.c: #include "coff-bfd.h".
diff --git a/binutils/config.in b/binutils/config.in
index 076f514..a0ed034 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -108,6 +108,9 @@
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
+/* Define to 1 if the system has the type `long long'. */
+#undef HAVE_LONG_LONG
+
/* Define if mbstate_t exists in wchar.h. */
#undef HAVE_MBSTATE_T
@@ -208,6 +211,12 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
diff --git a/binutils/configure b/binutils/configure
index 78ad874..b960c19 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -1887,6 +1887,238 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_func
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid; break
+else
+ as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=$ac_mid; break
+else
+ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid
+else
+ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (($2) < 0)
+ {
+ long int i = longval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%lu", i);
+ }
+ /* Do not output a trailing newline, as this causes \r\n confusion
+ on some platforms. */
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+ ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+ fi
+ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ return $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
# ac_fn_c_check_decl LINENO SYMBOL VAR
# ------------------------------------
# Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
@@ -10987,7 +11219,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10990 "configure"
+#line 11222 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11093,7 +11325,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11096 "configure"
+#line 11328 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12567,6 +12799,84 @@ case "${host}" in
esac
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_long" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+ else
+ ac_cv_sizeof_long=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+ac_fn_c_check_type "$LINENO" "long long" "ac_cv_type_long_long" "$ac_includes_default"
+if test "x$ac_cv_type_long_long" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_LONG_LONG 1
+_ACEOF
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
+$as_echo_n "checking size of long long... " >&6; }
+if test "${ac_cv_sizeof_long_long+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_long_long" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+ else
+ ac_cv_sizeof_long_long=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
+$as_echo "$ac_cv_sizeof_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
+fi
+
+
for ac_header in string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h limits.h locale.h sys/param.h wchar.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 84c287c..b85a9d2 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -124,6 +124,9 @@ case "${host}" in
esac
AC_SUBST(DEMANGLER_NAME)
+AC_CHECK_SIZEOF([long])
+AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
+
AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h limits.h locale.h sys/param.h wchar.h)
AC_HEADER_SYS_WAIT
ACX_HEADER_STRING
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 4e37038..02b7668 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -162,17 +162,17 @@ get_encoded_value (unsigned char **pdata,
return val;
}
-#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
-#ifndef __MINGW32__
-#define DWARF_VMA_FMT "ll"
-#define DWARF_VMA_FMT_LONG "%16.16llx"
+#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
+# ifndef __MINGW32__
+# define DWARF_VMA_FMT "ll"
+# define DWARF_VMA_FMT_LONG "%16.16llx"
+# else
+# define DWARF_VMA_FMT "I64"
+# define DWARF_VMA_FMT_LONG "%016I64x"
+# endif
#else
-#define DWARF_VMA_FMT "I64"
-#define DWARF_VMA_FMT_LONG "%016I64x"
-#endif
-#else
-#define DWARF_VMA_FMT "l"
-#define DWARF_VMA_FMT_LONG "%16.16lx"
+# define DWARF_VMA_FMT "l"
+# define DWARF_VMA_FMT_LONG "%16.16lx"
#endif
/* Convert a dwarf vma value into a string. Returns a pointer to a static
@@ -2757,7 +2757,8 @@ read_debug_line_header (struct dwarf_section * section,
/* PR 17512: file:002-117414-0.004. */
if (* end_of_sequence > end)
{
- warn (_("Line length %lld extends beyond end of section\n"), linfo->li_length);
+ warn (_("Line length %s extends beyond end of section\n"),
+ dwarf_vmatoa ("u", linfo->li_length));
* end_of_sequence = end;
return NULL;
}
diff --git a/binutils/elfcomm.h b/binutils/elfcomm.h
index 4fd2d6c..f7f7544 100644
--- a/binutils/elfcomm.h
+++ b/binutils/elfcomm.h
@@ -29,7 +29,7 @@
void error (const char *, ...) ATTRIBUTE_PRINTF_1;
void warn (const char *, ...) ATTRIBUTE_PRINTF_1;
-#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+#if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
/* We can't use any bfd types here since readelf may define BFD64 and
objdump may not. */
#define HOST_WIDEST_INT long long
diff --git a/binutils/strings.c b/binutils/strings.c
index 2cf046f..7346f55 100644
--- a/binutils/strings.c
+++ b/binutils/strings.c
@@ -578,14 +578,14 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
switch (address_radix)
{
case 8:
-#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+#ifdef HAVE_LONG_LONG
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+# ifndef __MSVCRT__
printf ("%7llo ", (unsigned long long) start);
-#else
+# else
printf ("%7I64o ", (unsigned long long) start);
-#endif
+# endif
}
else
#elif !BFD_HOST_64BIT_LONG
@@ -597,14 +597,14 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
break;
case 10:
-#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+#ifdef HAVE_LONG_LONG
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+# ifndef __MSVCRT__
printf ("%7lld ", (unsigned long long) start);
-#else
+# else
printf ("%7I64d ", (unsigned long long) start);
-#endif
+# endif
}
else
#elif !BFD_HOST_64BIT_LONG
@@ -616,14 +616,14 @@ print_strings (const char *filename, FILE *stream, file_ptr address,
break;
case 16:
-#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
+#ifdef HAVE_LONG_LONG
if (sizeof (start) > sizeof (long))
{
-#ifndef __MSVCRT__
+# ifndef __MSVCRT__
printf ("%7llx ", (unsigned long long) start);
-#else
+# else
printf ("%7I64x ", (unsigned long long) start);
-#endif
+# endif
}
else
#elif !BFD_HOST_64BIT_LONG