diff options
| author | Cody P Schafer <dev@codyps.com> | 2017-06-07 16:36:44 -0400 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-29 16:50:53 +0100 |
| commit | 72084f751303405416938c776f6c1bf5b8842536 (patch) | |
| tree | 3f74568bc9f3bbe1efa7755344958bc3651b194b /meta | |
| parent | 5f7d84821f7c53ce2250861c5e08da9eac928993 (diff) | |
| download | poky-72084f751303405416938c776f6c1bf5b8842536.tar.gz | |
elfutils: fix building elfutils-native with GCC7
This is heavily based on the oe-core master commit with the same
subject, but includes a backport of upstream's fix for the fallthrough
warnings rebased to 0.166 (the oe-core patch which targeted 0.168 did
not apply), a rebase of the format-truncation patch, and a backport of
the upstream format-length patch.
Info from OE-Core master patch follows:
From OE-Core rev: aaf4c4f3d09ac3897205417eb15e19d54e0c0d05
From: Joshua Lock <joshua.g.lock@intel.com>
Backport a fix from upstream for a -Wformat-truncation=2 warning
and implement a simple fix for a -Wimplicit-fallthrough warning.
Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(From OE-Core rev: 3b91be97ae8c36cd6bad86fed992efc9800f4c9e)
Signed-off-by: Cody P Schafer <dev@codyps.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
5 files changed, 529 insertions, 0 deletions
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch b/meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch new file mode 100644 index 0000000000..a240323f33 --- /dev/null +++ b/meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch | |||
| @@ -0,0 +1,318 @@ | |||
| 1 | From 09949994e76eea3c1230a5c88ffa8fdf588b120f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Wielaard <mjw@redhat.com> | ||
| 3 | Date: Wed, 2 Nov 2016 13:29:26 +0100 | ||
| 4 | Subject: [PATCH] Add GCC7 -Wimplicit-fallthrough support/fixes. | ||
| 5 | |||
| 6 | GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one | ||
| 7 | small buglet in elflint option procession. So it seems useful to enable | ||
| 8 | to make sure all swatch case fallthroughs are deliberate. | ||
| 9 | |||
| 10 | Add configure check to detect whether gcc support -Wimplicit-fallthrough | ||
| 11 | and enable it. Add fixes and explicit fallthrough comments where necessary. | ||
| 12 | |||
| 13 | Signed-off-by: Mark Wielaard <mjw@redhat.com> | ||
| 14 | |||
| 15 | Upstream-Status: Backport | ||
| 16 | Upstream-Commit: a3cc8182b2ae05290b0eafa74b70746d7befc0e4 | ||
| 17 | --- | ||
| 18 | backends/alpha_retval.c | 4 +--- | ||
| 19 | backends/i386_regs.c | 1 + | ||
| 20 | backends/i386_retval.c | 3 +-- | ||
| 21 | backends/linux-core-note.c | 4 ++-- | ||
| 22 | backends/ppc_regs.c | 2 +- | ||
| 23 | backends/x86_64_regs.c | 1 + | ||
| 24 | config/eu.am | 8 +++++++- | ||
| 25 | configure.ac | 10 ++++++++++ | ||
| 26 | libcpu/i386_disasm.c | 2 +- | ||
| 27 | libdw/cfi.c | 2 ++ | ||
| 28 | libdw/encoded-value.h | 1 + | ||
| 29 | libdwfl/dwfl_report_elf.c | 2 +- | ||
| 30 | src/addr2line.c | 1 + | ||
| 31 | src/elfcompress.c | 3 ++- | ||
| 32 | src/elflint.c | 4 +++- | ||
| 33 | src/objdump.c | 4 +++- | ||
| 34 | tests/backtrace-data.c | 1 + | ||
| 35 | tests/backtrace.c | 2 +- | ||
| 36 | 18 files changed, 40 insertions(+), 15 deletions(-) | ||
| 37 | |||
| 38 | diff --git a/backends/alpha_retval.c b/backends/alpha_retval.c | ||
| 39 | index 53dbfa45..7232b462 100644 | ||
| 40 | --- a/backends/alpha_retval.c | ||
| 41 | +++ b/backends/alpha_retval.c | ||
| 42 | @@ -130,9 +130,7 @@ alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) | ||
| 43 | return nloc_intreg; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | - | ||
| 47 | - /* Else fall through. */ | ||
| 48 | - | ||
| 49 | + /* Fallthrough */ | ||
| 50 | case DW_TAG_structure_type: | ||
| 51 | case DW_TAG_class_type: | ||
| 52 | case DW_TAG_union_type: | ||
| 53 | diff --git a/backends/i386_regs.c b/backends/i386_regs.c | ||
| 54 | index fb8ded33..fd963a62 100644 | ||
| 55 | --- a/backends/i386_regs.c | ||
| 56 | +++ b/backends/i386_regs.c | ||
| 57 | @@ -92,6 +92,7 @@ i386_register_info (Ebl *ebl __attribute__ ((unused)), | ||
| 58 | case 5: | ||
| 59 | case 8: | ||
| 60 | *type = DW_ATE_address; | ||
| 61 | + /* Fallthrough */ | ||
| 62 | case 0 ... 3: | ||
| 63 | case 6 ... 7: | ||
| 64 | name[0] = 'e'; | ||
| 65 | diff --git a/backends/i386_retval.c b/backends/i386_retval.c | ||
| 66 | index 9da797d5..4aa646fe 100644 | ||
| 67 | --- a/backends/i386_retval.c | ||
| 68 | +++ b/backends/i386_retval.c | ||
| 69 | @@ -122,9 +122,8 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) | ||
| 70 | return nloc_intreg; | ||
| 71 | if (size <= 8) | ||
| 72 | return nloc_intregpair; | ||
| 73 | - | ||
| 74 | - /* Else fall through. */ | ||
| 75 | } | ||
| 76 | + /* Fallthrough */ | ||
| 77 | |||
| 78 | case DW_TAG_structure_type: | ||
| 79 | case DW_TAG_class_type: | ||
| 80 | diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c | ||
| 81 | index ff2b226f..321721f3 100644 | ||
| 82 | --- a/backends/linux-core-note.c | ||
| 83 | +++ b/backends/linux-core-note.c | ||
| 84 | @@ -219,8 +219,8 @@ EBLHOOK(core_note) (const GElf_Nhdr *nhdr, const char *name, | ||
| 85 | case sizeof "CORE": | ||
| 86 | if (memcmp (name, "CORE", nhdr->n_namesz) == 0) | ||
| 87 | break; | ||
| 88 | - /* Buggy old Linux kernels didn't terminate "LINUX". | ||
| 89 | - Fall through. */ | ||
| 90 | + /* Buggy old Linux kernels didn't terminate "LINUX". */ | ||
| 91 | + /* Fall through. */ | ||
| 92 | |||
| 93 | case sizeof "LINUX": | ||
| 94 | if (memcmp (name, "LINUX", nhdr->n_namesz) == 0) | ||
| 95 | diff --git a/backends/ppc_regs.c b/backends/ppc_regs.c | ||
| 96 | index 4b92a9aa..bcf4f7a3 100644 | ||
| 97 | --- a/backends/ppc_regs.c | ||
| 98 | +++ b/backends/ppc_regs.c | ||
| 99 | @@ -140,7 +140,7 @@ ppc_register_info (Ebl *ebl __attribute__ ((unused)), | ||
| 100 | case 100: | ||
| 101 | if (*bits == 32) | ||
| 102 | return stpcpy (name, "mq") + 1 - name; | ||
| 103 | - | ||
| 104 | + /* Fallthrough */ | ||
| 105 | case 102 ... 107: | ||
| 106 | name[0] = 's'; | ||
| 107 | name[1] = 'p'; | ||
| 108 | diff --git a/backends/x86_64_regs.c b/backends/x86_64_regs.c | ||
| 109 | index 2172d9f1..84304407 100644 | ||
| 110 | --- a/backends/x86_64_regs.c | ||
| 111 | +++ b/backends/x86_64_regs.c | ||
| 112 | @@ -87,6 +87,7 @@ x86_64_register_info (Ebl *ebl __attribute__ ((unused)), | ||
| 113 | |||
| 114 | case 6 ... 7: | ||
| 115 | *type = DW_ATE_address; | ||
| 116 | + /* Fallthrough */ | ||
| 117 | case 0 ... 5: | ||
| 118 | name[0] = 'r'; | ||
| 119 | name[1] = baseregs[regno][0]; | ||
| 120 | diff --git a/config/eu.am b/config/eu.am | ||
| 121 | index 4998771d..8fe1e259 100644 | ||
| 122 | --- a/config/eu.am | ||
| 123 | +++ b/config/eu.am | ||
| 124 | @@ -61,10 +61,16 @@ else | ||
| 125 | NULL_DEREFERENCE_WARNING= | ||
| 126 | endif | ||
| 127 | |||
| 128 | +if HAVE_IMPLICIT_FALLTHROUGH_WARNING | ||
| 129 | +IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough | ||
| 130 | +else | ||
| 131 | +IMPLICIT_FALLTHROUGH_WARNING= | ||
| 132 | +endif | ||
| 133 | + | ||
| 134 | AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ | ||
| 135 | -Wold-style-definition -Wstrict-prototypes \ | ||
| 136 | $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ | ||
| 137 | - $(NULL_DEREFERENCE_WARNING) \ | ||
| 138 | + $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ | ||
| 139 | $(if $($(*F)_no_Werror),,-Werror) \ | ||
| 140 | $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ | ||
| 141 | $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ | ||
| 142 | diff --git a/configure.ac b/configure.ac | ||
| 143 | index 86a69c66..35850c64 100644 | ||
| 144 | --- a/configure.ac | ||
| 145 | +++ b/configure.ac | ||
| 146 | @@ -336,6 +336,16 @@ CFLAGS="$old_CFLAGS"]) | ||
| 147 | AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING, | ||
| 148 | [test "x$ac_cv_null_dereference" != "xno"]) | ||
| 149 | |||
| 150 | +# -Wimplicit-fallthrough was added by GCC7 | ||
| 151 | +AC_CACHE_CHECK([whether gcc accepts -Wimplicit-fallthrough], ac_cv_implicit_fallthrough, [dnl | ||
| 152 | +old_CFLAGS="$CFLAGS" | ||
| 153 | +CFLAGS="$CFLAGS -Wimplicit-fallthrough -Werror" | ||
| 154 | +AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], | ||
| 155 | + ac_cv_implicit_fallthrough=yes, ac_cv_implicit_fallthrough=no) | ||
| 156 | +CFLAGS="$old_CFLAGS"]) | ||
| 157 | +AM_CONDITIONAL(HAVE_IMPLICIT_FALLTHROUGH_WARNING, | ||
| 158 | + [test "x$ac_cv_implicit_fallthrough" != "xno"]) | ||
| 159 | + | ||
| 160 | dnl Check if we have argp available from our libc | ||
| 161 | AC_LINK_IFELSE( | ||
| 162 | [AC_LANG_PROGRAM( | ||
| 163 | diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c | ||
| 164 | index 832241f2..1a584635 100644 | ||
| 165 | --- a/libcpu/i386_disasm.c | ||
| 166 | +++ b/libcpu/i386_disasm.c | ||
| 167 | @@ -819,7 +819,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, | ||
| 168 | ++param_start; | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | - | ||
| 172 | + /* Fallthrough */ | ||
| 173 | default: | ||
| 174 | assert (! "INVALID not handled"); | ||
| 175 | } | ||
| 176 | diff --git a/libdw/cfi.c b/libdw/cfi.c | ||
| 177 | index 1fd668d7..daa845f3 100644 | ||
| 178 | --- a/libdw/cfi.c | ||
| 179 | +++ b/libdw/cfi.c | ||
| 180 | @@ -138,6 +138,7 @@ execute_cfi (Dwarf_CFI *cache, | ||
| 181 | |||
| 182 | case DW_CFA_advance_loc1: | ||
| 183 | operand = *program++; | ||
| 184 | + /* Fallthrough */ | ||
| 185 | case DW_CFA_advance_loc + 0 ... DW_CFA_advance_loc + CFI_PRIMARY_MAX: | ||
| 186 | advance_loc: | ||
| 187 | loc += operand * cie->code_alignment_factor; | ||
| 188 | @@ -300,6 +301,7 @@ execute_cfi (Dwarf_CFI *cache, | ||
| 189 | |||
| 190 | case DW_CFA_restore_extended: | ||
| 191 | get_uleb128 (operand, program, end); | ||
| 192 | + /* Fallthrough */ | ||
| 193 | case DW_CFA_restore + 0 ... DW_CFA_restore + CFI_PRIMARY_MAX: | ||
| 194 | |||
| 195 | if (unlikely (abi_cfi) && likely (opcode == DW_CFA_restore)) | ||
| 196 | diff --git a/libdw/encoded-value.h b/libdw/encoded-value.h | ||
| 197 | index 48d868fb..f0df4cec 100644 | ||
| 198 | --- a/libdw/encoded-value.h | ||
| 199 | +++ b/libdw/encoded-value.h | ||
| 200 | @@ -64,6 +64,7 @@ encoded_value_size (const Elf_Data *data, const unsigned char e_ident[], | ||
| 201 | if (*end++ & 0x80u) | ||
| 202 | return end - p; | ||
| 203 | } | ||
| 204 | + return 0; | ||
| 205 | |||
| 206 | default: | ||
| 207 | return 0; | ||
| 208 | diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c | ||
| 209 | index 1c6e401d..73a5511a 100644 | ||
| 210 | --- a/libdwfl/dwfl_report_elf.c | ||
| 211 | +++ b/libdwfl/dwfl_report_elf.c | ||
| 212 | @@ -170,7 +170,7 @@ __libdwfl_elf_address_range (Elf *elf, GElf_Addr base, bool add_p_vaddr, | ||
| 213 | /* An assigned base address is meaningless for these. */ | ||
| 214 | base = 0; | ||
| 215 | add_p_vaddr = true; | ||
| 216 | - | ||
| 217 | + /* Fallthrough. */ | ||
| 218 | case ET_DYN: | ||
| 219 | default:; | ||
| 220 | size_t phnum; | ||
| 221 | diff --git a/src/addr2line.c b/src/addr2line.c | ||
| 222 | index 0ce854f6..bea24aea 100644 | ||
| 223 | --- a/src/addr2line.c | ||
| 224 | +++ b/src/addr2line.c | ||
| 225 | @@ -632,6 +632,7 @@ handle_address (const char *string, Dwfl *dwfl) | ||
| 226 | case 1: | ||
| 227 | addr = 0; | ||
| 228 | j = i; | ||
| 229 | + /* Fallthrough */ | ||
| 230 | case 2: | ||
| 231 | if (string[j] != '\0') | ||
| 232 | break; | ||
| 233 | diff --git a/src/elfcompress.c b/src/elfcompress.c | ||
| 234 | index d0ca469c..57afa116 100644 | ||
| 235 | --- a/src/elfcompress.c | ||
| 236 | +++ b/src/elfcompress.c | ||
| 237 | @@ -153,7 +153,8 @@ parse_opt (int key, char *arg __attribute__ ((unused)), | ||
| 238 | argp_error (state, | ||
| 239 | N_("Only one input file allowed together with '-o'")); | ||
| 240 | /* We only use this for checking the number of arguments, we don't | ||
| 241 | - actually want to consume them, so fallthrough. */ | ||
| 242 | + actually want to consume them. */ | ||
| 243 | + /* Fallthrough */ | ||
| 244 | default: | ||
| 245 | return ARGP_ERR_UNKNOWN; | ||
| 246 | } | ||
| 247 | diff --git a/src/elflint.c b/src/elflint.c | ||
| 248 | index 15b12f6f..2c45fcb8 100644 | ||
| 249 | --- a/src/elflint.c | ||
| 250 | +++ b/src/elflint.c | ||
| 251 | @@ -210,6 +210,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)), | ||
| 252 | |||
| 253 | case 'd': | ||
| 254 | is_debuginfo = true; | ||
| 255 | + break; | ||
| 256 | |||
| 257 | case ARGP_gnuld: | ||
| 258 | gnuld = true; | ||
| 259 | @@ -3963,6 +3964,7 @@ section [%2zu] '%s': merge flag set but entry size is zero\n"), | ||
| 260 | case SHT_NOBITS: | ||
| 261 | if (is_debuginfo) | ||
| 262 | break; | ||
| 263 | + /* Fallthrough */ | ||
| 264 | default: | ||
| 265 | ERROR (gettext ("\ | ||
| 266 | section [%2zu] '%s' has unexpected type %d for an executable section\n"), | ||
| 267 | @@ -4305,7 +4307,7 @@ section [%2d] '%s': unknown core file note type %" PRIu32 | ||
| 268 | if (nhdr.n_namesz == sizeof "Linux" | ||
| 269 | && !memcmp (data->d_buf + name_offset, "Linux", sizeof "Linux")) | ||
| 270 | break; | ||
| 271 | - | ||
| 272 | + /* Fallthrough */ | ||
| 273 | default: | ||
| 274 | if (shndx == 0) | ||
| 275 | ERROR (gettext ("\ | ||
| 276 | diff --git a/src/objdump.c b/src/objdump.c | ||
| 277 | index 0aa41e89..94e9e021 100644 | ||
| 278 | --- a/src/objdump.c | ||
| 279 | +++ b/src/objdump.c | ||
| 280 | @@ -234,7 +234,9 @@ parse_opt (int key, char *arg, | ||
| 281 | program_invocation_short_name); | ||
| 282 | exit (EXIT_FAILURE); | ||
| 283 | } | ||
| 284 | - | ||
| 285 | + /* We only use this for checking the number of arguments, we don't | ||
| 286 | + actually want to consume them. */ | ||
| 287 | + /* Fallthrough */ | ||
| 288 | default: | ||
| 289 | return ARGP_ERR_UNKNOWN; | ||
| 290 | } | ||
| 291 | diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c | ||
| 292 | index bc5ceba0..b7158dae 100644 | ||
| 293 | --- a/tests/backtrace-data.c | ||
| 294 | +++ b/tests/backtrace-data.c | ||
| 295 | @@ -250,6 +250,7 @@ thread_callback (Dwfl_Thread *thread, void *thread_arg __attribute__ ((unused))) | ||
| 296 | break; | ||
| 297 | case -1: | ||
| 298 | error (1, 0, "dwfl_thread_getframes: %s", dwfl_errmsg (-1)); | ||
| 299 | + break; | ||
| 300 | default: | ||
| 301 | abort (); | ||
| 302 | } | ||
| 303 | diff --git a/tests/backtrace.c b/tests/backtrace.c | ||
| 304 | index 12476430..bf5995b4 100644 | ||
| 305 | --- a/tests/backtrace.c | ||
| 306 | +++ b/tests/backtrace.c | ||
| 307 | @@ -123,7 +123,7 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, | ||
| 308 | assert (symname2 == NULL || strcmp (symname2, "jmp") != 0); | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | - /* PASSTHRU */ | ||
| 312 | + /* FALLTHRU */ | ||
| 313 | case 4: | ||
| 314 | assert (symname != NULL && strcmp (symname, "stdarg") == 0); | ||
| 315 | break; | ||
| 316 | -- | ||
| 317 | 2.13.0 | ||
| 318 | |||
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.166/0001-ar-Fix-GCC7-Wformat-length-issues.patch b/meta/recipes-devtools/elfutils/elfutils-0.166/0001-ar-Fix-GCC7-Wformat-length-issues.patch new file mode 100644 index 0000000000..3465476784 --- /dev/null +++ b/meta/recipes-devtools/elfutils/elfutils-0.166/0001-ar-Fix-GCC7-Wformat-length-issues.patch | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | From f090883ca61f0bf0f979c5b26d4e1a69e805156e Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Wielaard <mjw@redhat.com> | ||
| 3 | Date: Thu, 10 Nov 2016 18:45:02 +0100 | ||
| 4 | Subject: [PATCH] ar: Fix GCC7 -Wformat-length issues. | ||
| 5 | |||
| 6 | GCC7 adds warnings for snprintf formatting into too small buffers. | ||
| 7 | Fix the two issues pointed out by the new warning. The ar header | ||
| 8 | fields are fixed length containing left-justified strings without | ||
| 9 | zero terminator. snprintf always adds a '\0' char at the end (which | ||
| 10 | we then don't copy into the ar header field) and numbers are decimal | ||
| 11 | strings of fixed 10 chars (-Wformat-length thinks formatting | ||
| 12 | them as size_t might overflow the buffer on 64bit arches). | ||
| 13 | |||
| 14 | Signed-off-by: Mark Wielaard <mjw@redhat.com> | ||
| 15 | |||
| 16 | Upstream-Status: Backport | ||
| 17 | Upstream-Commit: d5afff85e22b38949f3e7936231c67de16e180e8 | ||
| 18 | --- | ||
| 19 | src/ar.c | 15 +++++++++++---- | ||
| 20 | src/arlib.c | 16 ++++++++++------ | ||
| 21 | 2 files changed, 21 insertions(+), 10 deletions(-) | ||
| 22 | |||
| 23 | diff --git a/src/ar.c b/src/ar.c | ||
| 24 | index 1320d07b..f2160d35 100644 | ||
| 25 | --- a/src/ar.c | ||
| 26 | +++ b/src/ar.c | ||
| 27 | @@ -1,5 +1,5 @@ | ||
| 28 | /* Create, modify, and extract from archives. | ||
| 29 | - Copyright (C) 2005-2012 Red Hat, Inc. | ||
| 30 | + Copyright (C) 2005-2012, 2016 Red Hat, Inc. | ||
| 31 | This file is part of elfutils. | ||
| 32 | Written by Ulrich Drepper <drepper@redhat.com>, 2005. | ||
| 33 | |||
| 34 | @@ -853,7 +853,10 @@ write_member (struct armem *memb, off_t *startp, off_t *lenp, Elf *elf, | ||
| 35 | off_t end_off, int newfd) | ||
| 36 | { | ||
| 37 | struct ar_hdr arhdr; | ||
| 38 | - char tmpbuf[sizeof (arhdr.ar_name) + 1]; | ||
| 39 | + /* The ar_name is not actually zero teminated, but we need that for | ||
| 40 | + snprintf. Also if the name is too long, then the string starts | ||
| 41 | + with '/' plus an index off number (decimal). */ | ||
| 42 | + char tmpbuf[sizeof (arhdr.ar_name) + 2]; | ||
| 43 | |||
| 44 | bool changed_header = memb->long_name_off != -1; | ||
| 45 | if (changed_header) | ||
| 46 | @@ -1455,7 +1458,11 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, | ||
| 47 | |||
| 48 | /* Create the header. */ | ||
| 49 | struct ar_hdr arhdr; | ||
| 50 | - char tmpbuf[sizeof (arhdr.ar_name) + 1]; | ||
| 51 | + /* The ar_name is not actually zero teminated, but we | ||
| 52 | + need that for snprintf. Also if the name is too | ||
| 53 | + long, then the string starts with '/' plus an index | ||
| 54 | + off number (decimal). */ | ||
| 55 | + char tmpbuf[sizeof (arhdr.ar_name) + 2]; | ||
| 56 | if (all->long_name_off == -1) | ||
| 57 | { | ||
| 58 | size_t namelen = strlen (all->name); | ||
| 59 | @@ -1465,7 +1472,7 @@ do_oper_insert (int oper, const char *arfname, char **argv, int argc, | ||
| 60 | } | ||
| 61 | else | ||
| 62 | { | ||
| 63 | - snprintf (tmpbuf, sizeof (arhdr.ar_name) + 1, "/%-*ld", | ||
| 64 | + snprintf (tmpbuf, sizeof (tmpbuf), "/%-*ld", | ||
| 65 | (int) sizeof (arhdr.ar_name), all->long_name_off); | ||
| 66 | memcpy (arhdr.ar_name, tmpbuf, sizeof (arhdr.ar_name)); | ||
| 67 | } | ||
| 68 | diff --git a/src/arlib.c b/src/arlib.c | ||
| 69 | index 43a9145b..0c2e4cde 100644 | ||
| 70 | --- a/src/arlib.c | ||
| 71 | +++ b/src/arlib.c | ||
| 72 | @@ -1,5 +1,5 @@ | ||
| 73 | /* Functions to handle creation of Linux archives. | ||
| 74 | - Copyright (C) 2007-2012 Red Hat, Inc. | ||
| 75 | + Copyright (C) 2007-2012, 2016 Red Hat, Inc. | ||
| 76 | This file is part of elfutils. | ||
| 77 | Written by Ulrich Drepper <drepper@redhat.com>, 2007. | ||
| 78 | |||
| 79 | @@ -23,6 +23,7 @@ | ||
| 80 | #include <assert.h> | ||
| 81 | #include <error.h> | ||
| 82 | #include <gelf.h> | ||
| 83 | +#include <inttypes.h> | ||
| 84 | #include <libintl.h> | ||
| 85 | #include <stdio.h> | ||
| 86 | #include <stdlib.h> | ||
| 87 | @@ -107,6 +108,9 @@ arlib_init (void) | ||
| 88 | void | ||
| 89 | arlib_finalize (void) | ||
| 90 | { | ||
| 91 | + /* Note that the size is stored as decimal string in 10 chars, | ||
| 92 | + without zero terminator (we add + 1 here only so snprintf can | ||
| 93 | + put it at the end, we then don't use it when we memcpy it). */ | ||
| 94 | char tmpbuf[sizeof (((struct ar_hdr *) NULL)->ar_size) + 1]; | ||
| 95 | |||
| 96 | symtab.longnameslen = obstack_object_size (&symtab.longnamesob); | ||
| 97 | @@ -121,9 +125,9 @@ arlib_finalize (void) | ||
| 98 | |||
| 99 | symtab.longnames = obstack_finish (&symtab.longnamesob); | ||
| 100 | |||
| 101 | - int s = snprintf (tmpbuf, sizeof (tmpbuf), "%-*zu", | ||
| 102 | + int s = snprintf (tmpbuf, sizeof (tmpbuf), "%-*" PRIu32 "", | ||
| 103 | (int) sizeof (((struct ar_hdr *) NULL)->ar_size), | ||
| 104 | - symtab.longnameslen - sizeof (struct ar_hdr)); | ||
| 105 | + (uint32_t) (symtab.longnameslen - sizeof (struct ar_hdr))); | ||
| 106 | memcpy (&((struct ar_hdr *) symtab.longnames)->ar_size, tmpbuf, s); | ||
| 107 | } | ||
| 108 | |||
| 109 | @@ -169,10 +173,10 @@ arlib_finalize (void) | ||
| 110 | |||
| 111 | /* See comment for ar_date above. */ | ||
| 112 | memcpy (&((struct ar_hdr *) symtab.symsoff)->ar_size, tmpbuf, | ||
| 113 | - snprintf (tmpbuf, sizeof (tmpbuf), "%-*zu", | ||
| 114 | + snprintf (tmpbuf, sizeof (tmpbuf), "%-*" PRIu32 "", | ||
| 115 | (int) sizeof (((struct ar_hdr *) NULL)->ar_size), | ||
| 116 | - symtab.symsofflen + symtab.symsnamelen | ||
| 117 | - - sizeof (struct ar_hdr))); | ||
| 118 | + (uint32_t) (symtab.symsofflen + symtab.symsnamelen | ||
| 119 | + - sizeof (struct ar_hdr)))); | ||
| 120 | } | ||
| 121 | |||
| 122 | |||
| 123 | -- | ||
| 124 | 2.13.0 | ||
| 125 | |||
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.166/Fix_one_GCC7_warning.patch b/meta/recipes-devtools/elfutils/elfutils-0.166/Fix_one_GCC7_warning.patch new file mode 100644 index 0000000000..25f5e14821 --- /dev/null +++ b/meta/recipes-devtools/elfutils/elfutils-0.166/Fix_one_GCC7_warning.patch | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | From 8e2ab18b874d1fda06243ad00209d44e2992928a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mark Wielaard <mark@klomp.org> | ||
| 3 | Date: Sun, 12 Feb 2017 21:51:34 +0100 | ||
| 4 | Subject: [PATCH 1/2] libasm: Fix one GCC7 -Wformat-truncation=2 warning. | ||
| 5 | |||
| 6 | Make sure that if we have really lots of labels the tempsym doesn't get | ||
| 7 | truncated because it is too small to hold the whole name. | ||
| 8 | |||
| 9 | This doesn't enable -Wformat-truncation=2 or fix other "issues" pointed | ||
| 10 | out by enabling this warning because there are currently some issues | ||
| 11 | with it. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79448 | ||
| 12 | |||
| 13 | Signed-off-by: Mark Wielaard <mark@klomp.org> | ||
| 14 | |||
| 15 | Upstream-Status: Backport (https://sourceware.org/git/?p=elfutils.git;a=commit;h=93c51144c3f664d4e9709da75a1d0fa00ea0fe95) | ||
| 16 | Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> | ||
| 17 | --- | ||
| 18 | libasm/asm_newsym.c | 6 ++++-- | ||
| 19 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/libasm/asm_newsym.c b/libasm/asm_newsym.c | ||
| 22 | index 7f522910..76482bb2 100644 | ||
| 23 | --- a/libasm/asm_newsym.c | ||
| 24 | +++ b/libasm/asm_newsym.c | ||
| 25 | @@ -1,5 +1,5 @@ | ||
| 26 | /* Define new symbol for current position in given section. | ||
| 27 | - Copyright (C) 2002, 2005 Red Hat, Inc. | ||
| 28 | + Copyright (C) 2002, 2005, 2017 Red Hat, Inc. | ||
| 29 | This file is part of elfutils. | ||
| 30 | Written by Ulrich Drepper <drepper@redhat.com>, 2002. | ||
| 31 | |||
| 32 | @@ -44,7 +44,9 @@ AsmSym_t * | ||
| 33 | asm_newsym (AsmScn_t *asmscn, const char *name, GElf_Xword size, | ||
| 34 | int type, int binding) | ||
| 35 | { | ||
| 36 | -#define TEMPSYMLEN 10 | ||
| 37 | +/* We don't really expect labels with many digits, but in theory it could | ||
| 38 | + be 10 digits (plus ".L" and a zero terminator). */ | ||
| 39 | +#define TEMPSYMLEN 13 | ||
| 40 | char tempsym[TEMPSYMLEN]; | ||
| 41 | AsmSym_t *result; | ||
| 42 | |||
| 43 | -- | ||
| 44 | 2.13.0 | ||
| 45 | |||
diff --git a/meta/recipes-devtools/elfutils/elfutils-0.166/fallthrough.patch b/meta/recipes-devtools/elfutils/elfutils-0.166/fallthrough.patch new file mode 100644 index 0000000000..b2623f9d2e --- /dev/null +++ b/meta/recipes-devtools/elfutils/elfutils-0.166/fallthrough.patch | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | GCC7 adds -Wimplicit-fallthrough to warn when a switch case falls through, | ||
| 2 | however this causes warnings (which are promoted to errors) with the elfutils | ||
| 3 | patches from Debian for mips and parisc, which use fallthrough's by design. | ||
| 4 | |||
| 5 | Explicitly mark the intentional fallthrough switch cases with a comment to | ||
| 6 | disable the warnings where the fallthrough behaviour is desired. | ||
| 7 | |||
| 8 | Upstream-Status: Pending [debian] | ||
| 9 | Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> | ||
| 10 | |||
| 11 | Index: elfutils-0.168/backends/parisc_retval.c | ||
| 12 | =================================================================== | ||
| 13 | --- elfutils-0.168.orig/backends/parisc_retval.c | ||
| 14 | +++ elfutils-0.168/backends/parisc_retval.c | ||
| 15 | @@ -166,7 +166,7 @@ parisc_return_value_location_ (Dwarf_Die | ||
| 16 | return nloc_intregpair; | ||
| 17 | |||
| 18 | /* Else fall through. */ | ||
| 19 | - } | ||
| 20 | + } // fallthrough | ||
| 21 | |||
| 22 | case DW_TAG_structure_type: | ||
| 23 | case DW_TAG_class_type: | ||
| 24 | Index: elfutils-0.168/backends/mips_retval.c | ||
| 25 | =================================================================== | ||
| 26 | --- elfutils-0.168.orig/backends/mips_retval.c | ||
| 27 | +++ elfutils-0.168/backends/mips_retval.c | ||
| 28 | @@ -387,7 +387,7 @@ mips_return_value_location (Dwarf_Die *f | ||
| 29 | else | ||
| 30 | return nloc_intregpair; | ||
| 31 | } | ||
| 32 | - } | ||
| 33 | + } // fallthrough | ||
| 34 | |||
| 35 | /* Fallthrough to handle large types */ | ||
| 36 | |||
diff --git a/meta/recipes-devtools/elfutils/elfutils_0.166.bb b/meta/recipes-devtools/elfutils/elfutils_0.166.bb index 5d934281b3..3593c1c1d3 100644 --- a/meta/recipes-devtools/elfutils/elfutils_0.166.bb +++ b/meta/recipes-devtools/elfutils/elfutils_0.166.bb | |||
| @@ -18,7 +18,10 @@ SRC_URI += "\ | |||
| 18 | file://0001-remove-the-unneed-checking.patch \ | 18 | file://0001-remove-the-unneed-checking.patch \ |
| 19 | file://0001-fix-a-stack-usage-warning.patch \ | 19 | file://0001-fix-a-stack-usage-warning.patch \ |
| 20 | file://aarch64_uio.patch \ | 20 | file://aarch64_uio.patch \ |
| 21 | file://Fix_one_GCC7_warning.patch \ | ||
| 22 | file://0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch \ | ||
| 21 | file://shadow.patch \ | 23 | file://shadow.patch \ |
| 24 | file://0001-ar-Fix-GCC7-Wformat-length-issues.patch \ | ||
| 22 | " | 25 | " |
| 23 | 26 | ||
| 24 | # pick the patch from debian | 27 | # pick the patch from debian |
| @@ -37,6 +40,8 @@ SRC_URI += "\ | |||
| 37 | file://uclibc-support.patch \ | 40 | file://uclibc-support.patch \ |
| 38 | file://elfcmp-fix-self-comparision.patch \ | 41 | file://elfcmp-fix-self-comparision.patch \ |
| 39 | " | 42 | " |
| 43 | # Fix the patches from Debian with GCC7 | ||
| 44 | SRC_URI += "file://fallthrough.patch" | ||
| 40 | SRC_URI_append_libc-musl = " file://0001-build-Provide-alternatives-for-glibc-assumptions-hel.patch " | 45 | SRC_URI_append_libc-musl = " file://0001-build-Provide-alternatives-for-glibc-assumptions-hel.patch " |
| 41 | 46 | ||
| 42 | # The buildsystem wants to generate 2 .h files from source using a binary it just built, | 47 | # The buildsystem wants to generate 2 .h files from source using a binary it just built, |
