mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Detect invalid .o files created by objtool.
@ 2018-07-20 10:59 David Laight
  0 siblings, 0 replies; only message in thread
From: David Laight @ 2018-07-20 10:59 UTC (permalink / raw)
  To: 'Masahiro Yamada', 'Michal Marek'; +Cc: linux-kernel


The objtool code that generates to ORC unwind tables found a bug
in libelf that causes the section headers to not be rewritten.
The next access to the output file generates a ' File format not recognised'
error from objdump or ld.

Module compilation uses 'objdump ... | grep -q ...' and the objump
error is treated the same as the grep not finding the required line.
This means the build doesn't even stop.

Detect errors from objdump when building modules.

Verfify (with objdump -h) that the file modified by objtool is valid.
If invalid suggest updating libelf.so or disabling the ORC unwinder.

Signed-off-by: David Laight <david.laight@aculab.com>
---
 scripts/Makefile.build | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e7889f4..200b02c 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -193,7 +193,9 @@ else
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
 
 cmd_modversions_c =								\
-	if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then		\
+	if ! obj_headers=$$($(OBJDUMP) -h $(@D)/.tmp_$(@F)); then		\
+		false;								\
+	elif echo "$obj_headers" | grep -q __ksymtab; then			\
 		$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))	\
 		    > $(@D)/.tmp_$(@F:.o=.ver);					\
 										\
@@ -277,7 +279,14 @@ endif
 # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
 cmd_objtool = $(if $(patsubst y%,, \
 	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
-	$(__objtool_obj) $(objtool_args) "$(objtool_o)";)
+	$(__objtool_obj) $(objtool_args) "$(objtool_o)" && { \
+		$(OBJDUMP) -h "$(objtool_o)" >/dev/null 2>&1 || { \
+			echo >&2 "******* objtool generated the invalid file $(objtool_o)"; \
+			echo >&2 "******* Update libelf.so or disable the ORC unwinder"; \
+			/bin/false; \
+		}; \
+	};)
+
 objtool_obj = $(if $(patsubst y%,, \
 	$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
 	$(__objtool_obj))
-- 
1.8.1.2

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-20 10:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 10:59 [PATCH] Detect invalid .o files created by objtool David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome