]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Merge branch 'master' into portable
authorMark Wielaard <mjw@redhat.com>
Wed, 10 Jun 2015 15:04:19 +0000 (17:04 +0200)
committerMark Wielaard <mjw@redhat.com>
Wed, 10 Jun 2015 15:04:19 +0000 (17:04 +0200)
Fixup futimens issues.

24 files changed:
1  2 
ChangeLog
backends/ChangeLog
backends/Makefile.am
config/ChangeLog
config/eu.am
configure.ac
lib/ChangeLog
lib/eu-config.h
libdw/ChangeLog
libdw/dwarf_begin_elf.c
libdw/libdw.h
libdwfl/ChangeLog
libebl/ChangeLog
libelf/ChangeLog
src/ChangeLog
src/Makefile.am
src/addr2line.c
src/ar.c
src/readelf.c
src/strings.c
src/strip.c
tests/ChangeLog
tests/Makefile.am
tests/backtrace.c

diff --cc ChangeLog
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc config/eu.am
index 6ca36a537b36cb2140e14302bf4194406c6d3e98,70d32deb4f83d29bce2996505c1896aa46c4c7cb..65af085c30182841d346bf0bdef39833c847c809
  ## not, see <http://www.gnu.org/licenses/>.
  ##
  
 +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..
 -AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
+ # 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 \
            $(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 a1ad6dbe88662f59dfd3854dc7a6bbe2504a3aed,4a4b27e1b65a6f0be4dcbee89dd646c74dd9bb1a..eba4aa1178db4a9156a3a2dd6d095847b68fcaad
@@@ -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 <<EOF
 +int main (void) { return 0; }
 +EOF
 +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
 +                          -fPIC -shared -o conftest.so conftest.c
 +                          -Wl,--as-needed 1>&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/ChangeLog
Simple merge
diff --cc lib/eu-config.h
index d89f3a8ae736582b512cb44fd79bd32cac6d36e5,400cdc6e77c227a9d1a5373a33e580ee54f843ae..88cac6703371a590012def6047aac37da7de3bd3
@@@ -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) <lib##name.h>
  
 +#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 libdw/ChangeLog
Simple merge
Simple merge
diff --cc libdw/libdw.h
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc src/ChangeLog
Simple merge
diff --cc src/Makefile.am
index e84c7a59a47bac5ed0fa630ccb6b078ea922dd43,cd2755b03db6f50756a322bab59d3590bd828edf..f72c3a84a04e0378b255201791f950b16b410dd6
@@@ -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
  
- readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl
- nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) -ldl \
 +# Buggy old compilers or libc headers.
 +readelf_no_Werror = yes
 +strings_no_Werror = yes
 +addr2line_no_Wformat = yes
 +
+ # 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/addr2line.c
Simple merge
diff --cc src/ar.c
index f51f0efdd7170fec4d11a24360a4d782a609ad3d,1320d07bc9a843bfca439bb047355a7336e95b6b..f1f1533ed88a2dd685d3c1ab6fab315526c41d88
+++ 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 (&times[0], &tv[0]);
++                TIMESPEC_TO_TIMEVAL (&times[1], &tv[1]);
++                if (unlikely (futimes (xfd, times) != 0))
++#endif
                    {
                      error (0, errno,
                             gettext ("cannot change modification time of %s"),
diff --cc src/readelf.c
Simple merge
diff --cc src/strings.c
Simple merge
diff --cc src/strip.c
index 1b34eeea9224053a4c380fecfe643b6ecda2880a,5e69334bf0e92422ecf8577bbdf7775d821bb26a..2028eb8b484719a1743c04588776132ac2a7f8d1
@@@ -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 (&times[0], &tvp[0]);
++      TIMESPEC_TO_TIMEVAL (&times[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 (&times[0], &tvp[0]);
++      TIMESPEC_TO_TIMEVAL (&times[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/ChangeLog
Simple merge
index b6f471258409609bdb3bc172db19cdd9873d64be,55241c7d18ac3075373fa3bb994a578069819215..43cb9bfe55cb3760164dc812ee2fb8aa00e2ee66
@@@ -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_LDADD = $(libdw)
- addrscopes_LDADD = $(libdw)
- funcscopes_LDADD = $(libdw)
- funcretval_LDADD = $(libdw)
- allregs_LDADD = $(libdw)
- find_prologues_LDADD = $(libdw)
 +line2addr_no_Wformat = yes
+ 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
Simple merge