summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch')
-rw-r--r--meta/recipes-devtools/elfutils/elfutils-0.166/0001-Add-GCC7-Wimplicit-fallthrough-support-fixes.patch318
1 files changed, 318 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 @@
1From 09949994e76eea3c1230a5c88ffa8fdf588b120f Mon Sep 17 00:00:00 2001
2From: Mark Wielaard <mjw@redhat.com>
3Date: Wed, 2 Nov 2016 13:29:26 +0100
4Subject: [PATCH] Add GCC7 -Wimplicit-fallthrough support/fixes.
5
6GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one
7small buglet in elflint option procession. So it seems useful to enable
8to make sure all swatch case fallthroughs are deliberate.
9
10Add configure check to detect whether gcc support -Wimplicit-fallthrough
11and enable it. Add fixes and explicit fallthrough comments where necessary.
12
13Signed-off-by: Mark Wielaard <mjw@redhat.com>
14
15Upstream-Status: Backport
16Upstream-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
38diff --git a/backends/alpha_retval.c b/backends/alpha_retval.c
39index 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:
53diff --git a/backends/i386_regs.c b/backends/i386_regs.c
54index 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';
65diff --git a/backends/i386_retval.c b/backends/i386_retval.c
66index 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:
80diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c
81index 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)
95diff --git a/backends/ppc_regs.c b/backends/ppc_regs.c
96index 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';
108diff --git a/backends/x86_64_regs.c b/backends/x86_64_regs.c
109index 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];
120diff --git a/config/eu.am b/config/eu.am
121index 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)) \
142diff --git a/configure.ac b/configure.ac
143index 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(
163diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
164index 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 }
176diff --git a/libdw/cfi.c b/libdw/cfi.c
177index 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))
196diff --git a/libdw/encoded-value.h b/libdw/encoded-value.h
197index 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;
208diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c
209index 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;
221diff --git a/src/addr2line.c b/src/addr2line.c
222index 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;
233diff --git a/src/elfcompress.c b/src/elfcompress.c
234index 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 }
247diff --git a/src/elflint.c b/src/elflint.c
248index 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 ("\
276diff --git a/src/objdump.c b/src/objdump.c
277index 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 }
291diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
292index 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 }
303diff --git a/tests/backtrace.c b/tests/backtrace.c
304index 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--
3172.13.0
318