linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "'yamada.masahiro@socionext.com'" <yamada.masahiro@socionext.com>,
	"'michal.lkml@markovi.net'" <michal.lkml@markovi.net>
Subject: [PATCH v2] scripts: Detect invalid .o files created by objtool.
Date: Thu, 26 Jul 2018 09:53:01 +0000	[thread overview]
Message-ID: <b44a52ad2f5d4e939a52e750f776582f@AcuMS.aculab.com> (raw)

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.

Verify (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>
---

v2: Add missing $ escaping $$obj_headers

 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)


                 reply	other threads:[~2018-07-26  9:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b44a52ad2f5d4e939a52e750f776582f@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).