diff options
author | Ian Lance Taylor <ian@airs.com> | 2009-03-02 02:45:29 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2009-03-02 02:45:29 +0000 |
commit | 15d5fa160781daaf2e5c2b1d130f996a502016ea (patch) | |
tree | b746bde2e4e7c6e1e2878ac6465ed2140d9185d7 | |
parent | 3c54f1401bfc577f557a2a482647b19612b324ff (diff) | |
download | gdb-15d5fa160781daaf2e5c2b1d130f996a502016ea.zip gdb-15d5fa160781daaf2e5c2b1d130f996a502016ea.tar.gz gdb-15d5fa160781daaf2e5c2b1d130f996a502016ea.tar.bz2 |
elfcpp:/
* elfcpp_swap.h: #include "config.h". Only #include <byteswap.h>
if HAVE_BYTESWAP_H is defined; if not, provide definitions for
bswap_{16,32,64}. For gcc 4.3 and later, use the builtin bswap
functions. Check WORDS_BIGENDIAN rather than __BYTE_ORDER.
gold:/
* configure.ac: Check for byteswap.h.
* configure: Rebuild.
* config.in: Rebuild.
-rw-r--r-- | elfcpp/ChangeLog | 7 | ||||
-rw-r--r-- | elfcpp/elfcpp_swap.h | 58 | ||||
-rw-r--r-- | gold/ChangeLog | 6 | ||||
-rw-r--r-- | gold/config.in | 3 | ||||
-rwxr-xr-x | gold/configure | 150 | ||||
-rw-r--r-- | gold/configure.ac | 1 |
6 files changed, 222 insertions, 3 deletions
diff --git a/elfcpp/ChangeLog b/elfcpp/ChangeLog index c4bd716..5674d15 100644 --- a/elfcpp/ChangeLog +++ b/elfcpp/ChangeLog @@ -1,3 +1,10 @@ +2009-03-01 Ian Lance Taylor <iant@google.com> + + * elfcpp_swap.h: #include "config.h". Only #include <byteswap.h> + if HAVE_BYTESWAP_H is defined; if not, provide definitions for + bswap_{16,32,64}. For gcc 4.3 and later, use the builtin bswap + functions. Check WORDS_BIGENDIAN rather than __BYTE_ORDER. + 2009-01-06 H.J. Lu <hongjiu.lu@intel.com> * elfcpp.h (enum STT): Remove STT_IFUNC. diff --git a/elfcpp/elfcpp_swap.h b/elfcpp/elfcpp_swap.h index 9f445dc..0685276 100644 --- a/elfcpp/elfcpp_swap.h +++ b/elfcpp/elfcpp_swap.h @@ -1,6 +1,6 @@ // elfcpp_swap.h -- Handle swapping for elfcpp -*- C++ -*- -// Copyright 2006, 2007, Free Software Foundation, Inc. +// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // Written by Ian Lance Taylor <iant@google.com>. // This file is part of elfcpp. @@ -37,8 +37,54 @@ #define ELFCPP_SWAP_H #include <stdint.h> -#include <endian.h> + +// We need an autoconf-generated config.h file for endianness and +// swapping. We check two macros: WORDS_BIGENDIAN and +// HAVE_BYTESWAP_H. + +#include "config.h" + +#ifdef HAVE_BYTESWAP_H #include <byteswap.h> +#else +// Provide our own versions of the byteswap functions. +inline uint16_t +bswap_16(uint16_t v) +{ + return ((v >> 8) & 0xff) | ((v & 0xff) << 8); +} + +inline uint32_t +bswap_32(uint32_t v) +{ + return ( ((v & 0xff000000) >> 24) + | ((v & 0x00ff0000) >> 8) + | ((v & 0x0000ff00) << 8) + | ((v & 0x000000ff) << 24)); +} + +inline uint64_t +bswap_64(uint64_t v) +{ + return ( ((v & 0xff00000000000000ULL) >> 56) + | ((v & 0x00ff000000000000ULL) >> 40) + | ((v & 0x0000ff0000000000ULL) >> 24) + | ((v & 0x000000ff00000000ULL) >> 8) + | ((v & 0x00000000ff000000ULL) << 8) + | ((v & 0x0000000000ff0000ULL) << 24) + | ((v & 0x000000000000ff00ULL) << 40) + | ((v & 0x00000000000000ffULL) << 56)); +} +#endif // !defined(HAVE_BYTESWAP_H) + +// gcc 4.3 and later provides __builtin_bswap32 and __builtin_bswap64. + +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +#undef bswap_32 +#define bswap_32 __builtin_bswap32 +#undef bswap_64 +#define bswap_64 __builtin_bswap64 +#endif namespace elfcpp { @@ -49,7 +95,13 @@ struct Endian { public: // Used for template specializations. - static const bool host_big_endian = __BYTE_ORDER == __BIG_ENDIAN; + static const bool host_big_endian = +#ifdef WORDS_BIGENDIAN + true +#else + false +#endif + ; }; // Valtype_base is a template based on size (8, 16, 32, 64) which diff --git a/gold/ChangeLog b/gold/ChangeLog index cbd3d4b..e351dba 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2009-03-01 Ian Lance Taylor <iant@google.com> + + * configure.ac: Check for byteswap.h. + * configure: Rebuild. + * config.in: Rebuild. + 2009-03-01 Mikolaj Zalewski <mikolajz@google.com> * layout.cc (Layout::find_or_add_kept_section): New function. diff --git a/gold/config.in b/gold/config.in index 309f84b6..01aac90 100644 --- a/gold/config.in +++ b/gold/config.in @@ -19,6 +19,9 @@ /* Default size (32 or 64) */ #undef GOLD_DEFAULT_SIZE +/* Define to 1 if you have the <byteswap.h> header file. */ +#undef HAVE_BYTESWAP_H + /* Define to 1 if you have the <ext/hash_map> header file. */ #undef HAVE_EXT_HASH_MAP diff --git a/gold/configure b/gold/configure index 140c562..50ebad4 100755 --- a/gold/configure +++ b/gold/configure @@ -6490,6 +6490,156 @@ fi done +for ac_header in byteswap.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------- ## +## Report this to the gold lists. ## +## ------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + for ac_func in mallinfo do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/gold/configure.ac b/gold/configure.ac index e19161c..c26c05d 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -317,6 +317,7 @@ AC_LANG_PUSH(C++) AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map) AC_CHECK_HEADERS(ext/hash_map ext/hash_set) +AC_CHECK_HEADERS(byteswap.h) AC_CHECK_FUNCS(mallinfo) # gcc 4.3.0 doesn't recognize the printf attribute on a template |