]> git.pld-linux.org Git - packages/elfutils.git/blob - elfutils-portability.patch
- up for 0.141
[packages/elfutils.git] / elfutils-portability.patch
1 --- elfutils/backends/Makefile.am
2 +++ elfutils/backends/Makefile.am
3 @@ -25,12 +25,14 @@
4  ## <http://www.openinventionnetwork.com>.
5  ##
6  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
7 +WEXTRA = @WEXTRA@
8 +LD_AS_NEEDED = @LD_AS_NEEDED@
9  if MUDFLAP
10  AM_CFLAGS = -fmudflap
11  else
12  AM_CFLAGS =
13  endif
14 -AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
15 +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \
16              -std=gnu99
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
20  
21  textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
22  
23 -
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]))
32  
33 +AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
34 +old_CFLAGS="$CFLAGS"
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"])
39 +AC_SUBST(WEXTRA)
40 +AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
41 +
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; }
46 +EOF
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])
50 +then
51 +  ac_cv_as_needed=yes
52 +else
53 +  ac_cv_as_needed=no
54 +fi
55 +rm -f conftest*])
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)
59 +
60 +
61  LOCALEDIR=$datadir
62  AC_SUBST(LOCALEDIR)
63  AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
64 --- elfutils/lib/Makefile.am
65 +++ elfutils/lib/Makefile.am
66 @@ -25,12 +25,13 @@
67  ## <http://www.openinventionnetwork.com>.
68  ##
69  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
70 +WEXTRA = @WEXTRA@
71  if MUDFLAP
72  AM_CFLAGS = -fmudflap
73  else
74  AM_CFLAGS =
75  endif
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..
79  
80  noinst_LIBRARIES = libeu.a
81 --- elfutils/libasm/Makefile.am
82 +++ elfutils/libasm/Makefile.am
83 @@ -25,12 +25,13 @@
84  ## <http://www.openinventionnetwork.com>.
85  ##
86  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
87 +WEXTRA = @WEXTRA@
88  if MUDFLAP
89  AM_CFLAGS = -fmudflap
90  else
91  AM_CFLAGS =
92  endif
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\
97            -I$(top_srcdir)/lib
98 --- elfutils/libcpu/Makefile.am
99 +++ elfutils/libcpu/Makefile.am
100 @@ -30,7 +30,8 @@ AM_CFLAGS = -fmudflap
101  else
102  AM_CFLAGS =
103  endif
104 -AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \
105 +WEXTRA = @WEXTRA@
106 +AM_CFLAGS += -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fpic \
107              -fdollars-in-identifiers \
108              $($(*F)_CFLAGS) \
109              $(if $($(*F)_no_Werror),,-Werror)
110 --- elfutils/libdw/Makefile.am
111 +++ elfutils/libdw/Makefile.am
112 @@ -25,6 +25,7 @@
113  ## <http://www.openinventionnetwork.com>.
114  ##
115  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW
116 +WEXTRA = @WEXTRA@
117  if MUDFLAP
118  AM_CFLAGS = -fmudflap
119  else
120 @@ -33,7 +34,7 @@ endif
121  if BUILD_STATIC
122  AM_CFLAGS += -fpic
123  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
127  VERSION = 1
128  
129 --- elfutils/libdwfl/Makefile.am
130 +++ elfutils/libdwfl/Makefile.am
131 @@ -27,12 +27,13 @@
132  ## <http://www.openinventionnetwork.com>.
133  ##
134  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
135 +WEXTRA = @WEXTRA@
136  if MUDFLAP
137  AM_CFLAGS = -fmudflap
138  else
139  AM_CFLAGS =
140  endif
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
145  VERSION = 1
146 --- elfutils/libebl/Makefile.am
147 +++ elfutils/libebl/Makefile.am
148 @@ -25,12 +25,13 @@
149  ## <http://www.openinventionnetwork.com>.
150  ##
151  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
152 +WEXTRA = @WEXTRA@
153  if MUDFLAP
154  AM_CFLAGS = -fmudflap
155  else
156  AM_CFLAGS =
157  endif
158 -AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
159 +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \
160              -std=gnu99
161  
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                                               \
169 -             ? bswap_16 (Var)                                                \
170 +             ? (unsigned short int) bswap_16 (Var)                           \
171               : (sizeof (Var) == 4                                            \
172                  ? bswap_32 (Var)                                             \
173                  : bswap_64 (Var))))
174 @@ -169,7 +169,7 @@ libelf_release_all (Elf *elf)
175    (Dst) = (sizeof (Var) == 1                                                 \
176            ? (unsigned char) (Var)                                            \
177            : (sizeof (Var) == 2                                               \
178 -             ? bswap_16 (Var)                                                \
179 +             ? (unsigned short int) bswap_16 (Var)                           \
180               : (sizeof (Var) == 4                                            \
181                  ? bswap_32 (Var)                                             \
182                  : bswap_64 (Var))))
183 --- elfutils/libelf/Makefile.am
184 +++ elfutils/libelf/Makefile.am
185 @@ -25,6 +25,7 @@
186  ## <http://www.openinventionnetwork.com>.
187  ##
188  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
189 +WEXTRA = @WEXTRA@
190  if MUDFLAP
191  AM_CFLAGS = -fmudflap
192  else
193 @@ -33,7 +34,7 @@ endif
194  if BUILD_STATIC
195  AM_CFLAGS += -fpic
196  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 \
199              $($(*F)_CFLAGS)
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 *
205  
206  
207  static void
208 -check_rel (size_t nsegments, struct segments segments[nsegments],
209 +check_rel (size_t nsegments, struct segments segments[
210 +#if __GNUC__ >= 4
211 +                                                     nsegments
212 +#endif
213 +          ],
214            GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
215            const char *fname, bool more_than_one, void **knownsrcs)
216  {
217 --- elfutils/src/Makefile.am
218 +++ elfutils/src/Makefile.am
219 @@ -26,6 +26,7 @@
220  ##
221  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
222         -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
223 +WEXTRA = @WEXTRA@
224  if MUDFLAP
225  AM_CFLAGS = -fmudflap
226  else
227 @@ -33,7 +34,7 @@ AM_CFLAGS =
228  endif
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))
234  
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
239  
240 +# Buggy old compilers.
241 +readelf_no_Werror = yes
242 +
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))
251                            == NULL))
252 -#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
253 +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4
254             while (1)
255  #endif
256               error (EXIT_FAILURE, 0,
257 --- elfutils/src/strings.c
258 +++ elfutils/src/strings.c
259 @@ -51,6 +51,10 @@
260  
261  #include <system.h>
262  
263 +#ifndef MAP_POPULATE
264 +# define MAP_POPULATE 0
265 +#endif
266 +
267  
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
271                     fd, start_off);
272        if (mem != MAP_FAILED)
273         {
274 +#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL
275 +# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
276 +#endif
277 +#ifdef POSIX_MADV_SEQUENTIAL
278           /* We will go through the mapping sequentially.  */
279           (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
280 +#endif
281           break;
282         }
283        if (errno != EINVAL && errno != ENOMEM)
284 --- elfutils/src/strip.c
285 +++ elfutils/src/strip.c
286 @@ -52,6 +52,12 @@
287  #include <libebl.h>
288  #include <system.h>
289  
290 +#ifdef HAVE_FUTIMES
291 +# define FUTIMES(fd, fname, tvp) futimes (fd, tvp)
292 +#else
293 +# define FUTIMES(fd, fname, tvp) utimes (fname, tvp)
294 +#endif
295 +
296  
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)
300  
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);
305 +#else
306 +      tv[0].tv_sec = pre_st.st_atime;
307 +      tv[0].tv_usec = 0;
308 +#endif
309 +#ifdef HAVE_STRUCT_STAT_ST_MTIM
310        TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim);
311 +#else
312 +      tv[1].tv_sec = pre_st.st_atime;
313 +      tv[1].tv_usec = 0;
314 +#endif
315      }
316  
317    /* Open the file.  */
318 @@ -1745,7 +1761,7 @@ handle_elf (int fd, Elf *elf, const char
319    /* If requested, preserve the timestamp.  */
320    if (tvp != NULL)
321      {
322 -      if (futimes (fd, tvp) != 0)
323 +      if (FUTIMES (fd, output_fname, tvp) != 0)
324         {
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 
328  
329    if (tvp != NULL)
330      {
331 -      if (unlikely (futimes (fd, tvp) != 0))
332 +      if (unlikely (FUTIMES (fd, fname, tvp) != 0))
333         {
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[])
339      {
340        struct args a = { .arg = argv[cnt] };
341  
342 -      switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
343 +      switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
344         {
345         default:
346         case 0:
347 --- elfutils/tests/Makefile.am
348 +++ elfutils/tests/Makefile.am
349 @@ -25,12 +25,13 @@
350  ## <http://www.openinventionnetwork.com>.
351  ##
352  DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE
353 +WEXTRA = @WEXTRA@
354  if MUDFLAP
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
359  else
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
364  endif
This page took 0.052059 seconds and 3 git commands to generate.