[<prev] [next>] [day] [month] [year] [list]
Message-ID: <30f4d334645246ddb7175b601de2c502@AcuMS.aculab.com>
Date: Fri, 20 Jul 2018 10:59:25 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Masahiro Yamada' <yamada.masahiro@...ionext.com>,
'Michal Marek' <michal.lkml@...kovi.net>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] Detect invalid .o files created by objtool.
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@...lab.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)
Powered by blists - more mailing lists