From: Mark Wielaard Date: Wed, 10 Jun 2015 15:04:19 +0000 (+0200) Subject: Merge branch 'master' into portable X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1a21ea179628baca9aecca7f537ba1436973ec8;p=thirdparty%2Felfutils.git Merge branch 'master' into portable Fixup futimens issues. --- f1a21ea179628baca9aecca7f537ba1436973ec8 diff --cc config/eu.am index 6ca36a537,70d32deb4..65af085c3 --- a/config/eu.am +++ b/config/eu.am @@@ -29,26 -29,32 +29,40 @@@ ## not, see . ## +WEXTRA = @WEXTRA@ +LD_AS_NEEDED = @LD_AS_NEEDED@ + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"' AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. + + # Warn about stack usage of more than 256K = 262144 bytes. + if ADD_STACK_USAGE_WARNING + STACK_USAGE_WARNING=-Wstack-usage=262144 + else + STACK_USAGE_WARNING= + endif -AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ +AM_CFLAGS = -std=gnu99 -Wall -Wshadow \ $(if $($(*F)_no_Werror),,-Werror) \ - $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ + $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ + $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ + $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ $($(*F)_CFLAGS) +if BUILD_WERROR +AM_CFLAGS += $(if $($(*F)_no_Werror),,-Werror) +endif + COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE)) + DEFS.os = -DPIC -DSHARED + if SYMBOL_VERSIONING + DEFS.os += -DSYMBOL_VERSIONING + else + endif + %.os: %.c %.o if AMDEP - if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ + if $(COMPILE.os) -c -o $@ -fpic $(DEFS.os) -MT $@ -MD -MP \ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ rm -f "$(DEPDIR)/$*.Tpo"; \ diff --cc configure.ac index a1ad6dbe8,4a4b27e1b..eba4aa117 --- a/configure.ac +++ b/configure.ac @@@ -79,7 -73,16 +73,18 @@@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR] AC_CHECK_TOOL([READELF], [readelf]) AC_CHECK_TOOL([NM], [nm]) - AC_CACHE_CHECK([for gcc with C99 support], ac_cv_c99, [dnl ++AC_CHECK_FUNCS([futimens]) ++ + # We use -std=gnu99 but have explicit checks for some language constructs + # and GNU extensions since some compilers claim GNU99 support, but don't + # really support all language extensions. In particular we need + # Mixed Declarations and Code + # https://gcc.gnu.org/onlinedocs/gcc/Mixed-Declarations.html + # Nested Functions + # https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html + # Arrays of Variable Length + # https://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html + AC_CACHE_CHECK([for gcc with GNU99 support], ac_cv_c99, [dnl old_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -std=gnu99" AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl @@@ -87,56 -104,8 +106,56 @@@ void baz (int n ac_cv_c99=yes, ac_cv_c99=no) CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], - AC_MSG_ERROR([gcc with C99 support required])) + AC_MSG_ERROR([gcc with GNU99 support required])) +AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wextra" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([void foo (void) { }])], + ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no) +CFLAGS="$old_CFLAGS"]) +AC_SUBST(WEXTRA) +AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W]) + +AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fgnu89-inline -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +void foo (void) +{ + inline void bar (void) {} + bar (); +} +extern inline void baz (void) {} +])], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no) +CFLAGS="$old_CFLAGS"]) +AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes], + [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"]) + +AC_CACHE_CHECK([for --as-needed linker option], + ac_cv_as_needed, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD]) +then + ac_cv_as_needed=yes +else + ac_cv_as_needed=no +fi +rm -f conftest*]) +AS_IF([test "x$ac_cv_as_needed" = xyes], + [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=]) +AC_SUBST(LD_AS_NEEDED) + +AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])], + ac_cv_popcount=yes, ac_cv_popcount=no)]) +AS_IF([test "x$ac_cv_popcount" = xyes], + [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])]) + AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl # Use the same flags that we use for our DSOs, so the test is representative. # Some old compiler/linker/libc combinations fail some ways and not others. @@@ -358,8 -388,14 +446,14 @@@ case "$eu_version" i esac # Round up to the next release API (x.y) version. -eu_version=$(( (eu_version + 999) / 1000 )) +eu_version=`expr \( $eu_version + 999 \) / 1000` + dnl Unique ID for this build. + MODVERSION="Build for ${LIBEBL_SUBDIR} ${eu_version} ${ac_cv_build}" + AC_SUBST([MODVERSION]) + AC_DEFINE_UNQUOTED(MODVERSION, "$MODVERSION") + AH_TEMPLATE([MODVERSION], [Identifier for modules in the build.]) + AC_CHECK_SIZEOF(long) # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead diff --cc lib/eu-config.h index d89f3a8ae,400cdc6e7..88cac6703 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@@ -162,19 -163,8 +163,19 @@@ asm (".section predict_data, \"aw\"; .p /* This macro is used by the tests conditionalize for standalone building. */ #define ELFUTILS_HEADER(name) +#ifndef HAVE_BUILTIN_POPCOUNT +# define __builtin_popcount hakmem_popcount +static inline unsigned int __attribute__ ((unused)) +hakmem_popcount (unsigned int x) +{ + /* HAKMEM 169 */ + unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111); + return ((n + (n >> 3)) & 030707070707) % 63; +} +#endif /* HAVE_BUILTIN_POPCOUNT */ + - #ifdef SHARED + #ifdef SYMBOL_VERSIONING # define OLD_VERSION(name, version) \ asm (".globl _compat." #version "." #name "\n" \ "_compat." #version "." #name " = " #name "\n" \ diff --cc src/Makefile.am index e84c7a59a,cd2755b03..f72c3a84a --- a/src/Makefile.am +++ b/src/Makefile.am @@@ -88,18 -88,27 +88,32 @@@ endi # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes + ldgeneric_no_Wstack_usage = yes +# Buggy old compilers or libc headers. +readelf_no_Werror = yes +strings_no_Werror = yes +addr2line_no_Wformat = yes + - readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl - nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl \ + # Bad, bad stack usage... + readelf_no_Wstack_usage = yes + nm_no_Wstack_usage = yes + size_no_Wstack_usage = yes + strip_no_Wstack_usage = yes + elflint_no_Wstack_usage = yes + findtextrel_no_Wstack_usage = yes + elfcmp_no_Wstack_usage = yes + objdump_no_Wstack_usage = yes + ranlib_no_Wstack_usage = yes + ar_no_Wstack_usage = yes + unstrip_no_Wstack_usage = yes + + readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl + nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \ $(demanglelib) - size_LDADD = $(libelf) $(libeu) - strip_LDADD = $(libebl) $(libelf) $(libeu) -ldl - ld_LDADD = $(libebl) $(libelf) $(libeu) -ldl + size_LDADD = $(libelf) $(libeu) $(argp_LDADD) + strip_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl + ld_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl if NATIVE_LD # -ldl is always needed for libebl. ld_LDADD += libld_elf.a diff --cc src/ar.c index f51f0efdd,1320d07bc..f1f1533ed --- a/src/ar.c +++ b/src/ar.c @@@ -683,13 -679,13 +679,20 @@@ do_oper_extract (int oper, const char * if (preserve_dates) { - struct timeval tv[2]; + struct timespec tv[2]; tv[0].tv_sec = arhdr->ar_date; - tv[0].tv_usec = 0; + tv[0].tv_nsec = 0; tv[1].tv_sec = arhdr->ar_date; - tv[1].tv_usec = 0; - - if (unlikely (futimes (xfd, tv) != 0)) + tv[1].tv_nsec = 0; + ++#ifdef HAVE_FUTIMENS + if (unlikely (futimens (xfd, tv) != 0)) ++#else ++ struct timeval times[2]; ++ TIMESPEC_TO_TIMEVAL (×[0], &tv[0]); ++ TIMESPEC_TO_TIMEVAL (×[1], &tv[1]); ++ if (unlikely (futimes (xfd, times) != 0)) ++#endif { error (0, errno, gettext ("cannot change modification time of %s"), diff --cc src/strip.c index 1b34eeea9,5e69334bf..2028eb8b4 --- a/src/strip.c +++ b/src/strip.c @@@ -2107,7 -2191,7 +2191,14 @@@ while computing checksum for debug info /* If requested, preserve the timestamp. */ if (tvp != NULL) { - if (FUTIMES (fd, output_fname, tvp) != 0) ++#ifdef HAVE_FUTIMENS + if (futimens (fd, tvp) != 0) ++#else ++ struct timeval times[2]; ++ TIMESPEC_TO_TIMEVAL (×[0], &tvp[0]); ++ TIMESPEC_TO_TIMEVAL (×[1], &tvp[1]); ++ if (futimes (fd, times) != 0) ++#endif { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), @@@ -2164,7 -2263,7 +2270,14 @@@ handle_ar (int fd, Elf *elf, const cha if (tvp != NULL) { - if (unlikely (FUTIMES (fd, fname, tvp) != 0)) ++#ifdef HAVE_FUTIMENS + if (unlikely (futimens (fd, tvp) != 0)) ++#else ++ struct timeval times[2]; ++ TIMESPEC_TO_TIMEVAL (×[0], &tvp[0]); ++ TIMESPEC_TO_TIMEVAL (×[1], &tvp[1]); ++ if (unlikely (futimes (fd, times) != 0)) ++#endif { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), fname); diff --cc tests/Makefile.am index b6f471258,55241c7d1..43cb9bfe5 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@@ -365,13 -382,12 +382,13 @@@ get_lines_LDADD = $(libdw) $(libelf get_files_LDADD = $(libdw) $(libelf) get_aranges_LDADD = $(libdw) $(libelf) allfcts_LDADD = $(libdw) $(libelf) +line2addr_no_Wformat = yes - line2addr_LDADD = $(libdw) - addrscopes_LDADD = $(libdw) - funcscopes_LDADD = $(libdw) - funcretval_LDADD = $(libdw) - allregs_LDADD = $(libdw) - find_prologues_LDADD = $(libdw) + line2addr_LDADD = $(libdw) $(argp_LDADD) + addrscopes_LDADD = $(libdw) $(argp_LDADD) + funcscopes_LDADD = $(libdw) $(argp_LDADD) + funcretval_LDADD = $(libdw) $(argp_LDADD) + allregs_LDADD = $(libdw) $(argp_LDADD) + find_prologues_LDADD = $(libdw) $(argp_LDADD) #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) -ldl asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) -ldl