1 --- elfutils/backends/Makefile.am
2 +++ elfutils/backends/Makefile.am
4 ## <http://www.openinventionnetwork.com>.
6 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
8 +LD_AS_NEEDED = @LD_AS_NEEDED@
14 -AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
15 +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \
17 INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
18 -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \
19 @@ -59,7 +61,6 @@ endif
21 textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
24 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c \
25 i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c
26 cpu_i386 = ../libcpu/libcpu_i386.a
27 --- elfutils/configure.ac
28 +++ elfutils/configure.ac
29 @@ -74,6 +74,34 @@ CFLAGS="$old_CFLAGS"])
30 AS_IF([test "x$ac_cv_c99" != xyes],
31 AC_MSG_ERROR([gcc with C99 support required]))
33 +AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
35 +CFLAGS="$CFLAGS -Wextra"
36 +AC_COMPILE_IFELSE([void foo (void) { }],
37 + ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
38 +CFLAGS="$old_CFLAGS"])
40 +AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
42 +AC_CACHE_CHECK([for --as-needed linker option],
43 + ac_cv_as_needed, [dnl
44 +cat > conftest.c <<EOF
45 +int main (void) { return 0; }
47 +if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
48 + -fPIC -shared -o conftest.so conftest.c
49 + -Wl,--as-needed 1>&AS_MESSAGE_LOG_FD])
56 +AS_IF([test "x$ac_cv_as_needed" = xyes],
57 + [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=])
58 +AC_SUBST(LD_AS_NEEDED)
63 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
64 --- elfutils/lib/Makefile.am
65 +++ elfutils/lib/Makefile.am
67 ## <http://www.openinventionnetwork.com>.
69 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
76 -AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra $($(*F)_CFLAGS)
77 +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) $($(*F)_CFLAGS)
78 INCLUDES = -I$(srcdir)/../libelf -I..
80 noinst_LIBRARIES = libeu.a
81 --- elfutils/libasm/Makefile.am
82 +++ elfutils/libasm/Makefile.am
84 ## <http://www.openinventionnetwork.com>.
86 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
93 -AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
94 +AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2
95 INCLUDES = -I. -I$(srcdir) -I.. \
96 -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\
98 --- elfutils/libcpu/Makefile.am
99 +++ elfutils/libcpu/Makefile.am
100 @@ -30,7 +30,8 @@ AM_CFLAGS = -fmudflap
104 -AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \
106 +AM_CFLAGS += -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fpic \
107 -fdollars-in-identifiers \
109 $(if $($(*F)_no_Werror),,-Werror)
110 --- elfutils/libdw/Makefile.am
111 +++ elfutils/libdw/Makefile.am
113 ## <http://www.openinventionnetwork.com>.
115 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW
118 AM_CFLAGS = -fmudflap
120 @@ -33,7 +34,7 @@ endif
124 -AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
125 +AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99
126 INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
129 --- elfutils/libdwfl/Makefile.am
130 +++ elfutils/libdwfl/Makefile.am
132 ## <http://www.openinventionnetwork.com>.
134 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
137 AM_CFLAGS = -fmudflap
141 -AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
142 +AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99
143 INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
144 -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
146 --- elfutils/libebl/Makefile.am
147 +++ elfutils/libebl/Makefile.am
149 ## <http://www.openinventionnetwork.com>.
151 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
154 AM_CFLAGS = -fmudflap
158 -AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
159 +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \
162 INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \
163 --- elfutils/libelf/common.h
164 +++ elfutils/libelf/common.h
165 @@ -160,7 +160,7 @@ libelf_release_all (Elf *elf)
166 (Var) = (sizeof (Var) == 1 \
167 ? (unsigned char) (Var) \
168 : (sizeof (Var) == 2 \
170 + ? (unsigned short int) bswap_16 (Var) \
171 : (sizeof (Var) == 4 \
174 @@ -169,7 +169,7 @@ libelf_release_all (Elf *elf)
175 (Dst) = (sizeof (Var) == 1 \
176 ? (unsigned char) (Var) \
177 : (sizeof (Var) == 2 \
179 + ? (unsigned short int) bswap_16 (Var) \
180 : (sizeof (Var) == 4 \
183 --- elfutils/libelf/Makefile.am
184 +++ elfutils/libelf/Makefile.am
186 ## <http://www.openinventionnetwork.com>.
188 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
191 AM_CFLAGS = -fmudflap
193 @@ -33,7 +34,7 @@ endif
197 -AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \
198 +AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \
200 INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I..
201 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
202 --- elfutils/src/findtextrel.c
203 +++ elfutils/src/findtextrel.c
204 @@ -488,7 +488,11 @@ ptrcompare (const void *p1, const void *
208 -check_rel (size_t nsegments, struct segments segments[nsegments],
209 +check_rel (size_t nsegments, struct segments segments[
214 GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
215 const char *fname, bool more_than_one, void **knownsrcs)
217 --- elfutils/src/Makefile.am
218 +++ elfutils/src/Makefile.am
221 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
222 -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
225 AM_CFLAGS = -fmudflap
227 @@ -33,7 +34,7 @@ AM_CFLAGS =
229 AM_CFLAGS += -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
230 $(if $($(*F)_no_Werror),,-Werror) \
231 - $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
232 + $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
233 $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F))
235 INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
236 @@ -111,6 +112,9 @@ strings_no_Wformat = yes
237 # XXX While the file is not finished, don't warn about this
238 ldgeneric_no_Wunused = yes
240 +# Buggy old compilers.
241 +readelf_no_Werror = yes
243 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
244 nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
245 size_LDADD = $(libelf) $(libeu) $(libmudflap)
246 --- elfutils/src/readelf.c
247 +++ elfutils/src/readelf.c
248 @@ -6419,7 +6419,7 @@ dump_archive_index (Elf *elf, const char
249 if (unlikely (elf_rand (elf, as_off) == 0)
250 || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
252 -#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
253 +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4
256 error (EXIT_FAILURE, 0,
257 --- elfutils/src/strings.c
258 +++ elfutils/src/strings.c
263 +#ifndef MAP_POPULATE
264 +# define MAP_POPULATE 0
268 /* Prototypes of local functions. */
269 static int read_fd (int fd, const char *fname, off64_t fdlen);
270 @@ -491,8 +495,13 @@ map_file (int fd, off64_t start_off, off
272 if (mem != MAP_FAILED)
274 +#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL
275 +# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
277 +#ifdef POSIX_MADV_SEQUENTIAL
278 /* We will go through the mapping sequentially. */
279 (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
283 if (errno != EINVAL && errno != ENOMEM)
284 --- elfutils/src/strip.c
285 +++ elfutils/src/strip.c
291 +# define FUTIMES(fd, fname, tvp) futimes (fd, tvp)
293 +# define FUTIMES(fd, fname, tvp) utimes (fname, tvp)
297 /* Name and version of program. */
298 static void print_version (FILE *stream, struct argp_state *state);
299 @@ -300,8 +306,18 @@ process_file (const char *fname)
301 /* If we have to preserve the timestamp, we need it in the
302 format utimes() understands. */
303 +#ifdef HAVE_STRUCT_STAT_ST_ATIM
304 TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim);
306 + tv[0].tv_sec = pre_st.st_atime;
309 +#ifdef HAVE_STRUCT_STAT_ST_MTIM
310 TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
312 + tv[1].tv_sec = pre_st.st_atime;
318 @@ -1745,7 +1761,7 @@ handle_elf (int fd, Elf *elf, const char
319 /* If requested, preserve the timestamp. */
322 - if (futimes (fd, tvp) != 0)
323 + if (FUTIMES (fd, output_fname, tvp) != 0)
325 error (0, errno, gettext ("\
326 cannot set access and modification date of '%s'"),
327 @@ -1802,7 +1818,7 @@ handle_ar (int fd, Elf *elf, const char
331 - if (unlikely (futimes (fd, tvp) != 0))
332 + if (unlikely (FUTIMES (fd, fname, tvp) != 0))
334 error (0, errno, gettext ("\
335 cannot set access and modification date of '%s'"), fname);
336 --- elfutils/tests/line2addr.c
337 +++ elfutils/tests/line2addr.c
338 @@ -132,7 +132,7 @@ main (int argc, char *argv[])
340 struct args a = { .arg = argv[cnt] };
342 - switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
343 + switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
347 --- elfutils/tests/Makefile.am
348 +++ elfutils/tests/Makefile.am
350 ## <http://www.openinventionnetwork.com>.
352 DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE
355 -AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\
356 +AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\
357 $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
358 BUILD_RPATH = \$$ORIGIN/../backends
360 -AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
361 +AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \
362 $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
363 BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf