From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E614EECDFB8 for ; Fri, 20 Jul 2018 10:59:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A83FC2084A for ; Fri, 20 Jul 2018 10:59:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A83FC2084A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728830AbeGTLqn convert rfc822-to-8bit (ORCPT ); Fri, 20 Jul 2018 07:46:43 -0400 Received: from eu-smtp-delivery-211.mimecast.com ([207.82.80.211]:53213 "EHLO eu-smtp-delivery-211.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727289AbeGTLqm (ORCPT ); Fri, 20 Jul 2018 07:46:42 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-115-F7fa8LnjOrWsLpX9wEOGfQ-1; Fri, 20 Jul 2018 11:57:45 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 20 Jul 2018 11:59:25 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Fri, 20 Jul 2018 11:59:25 +0100 From: David Laight To: 'Masahiro Yamada' , 'Michal Marek' CC: "linux-kernel@vger.kernel.org" Subject: [PATCH] Detect invalid .o files created by objtool. Thread-Topic: [PATCH] Detect invalid .o files created by objtool. Thread-Index: AdQgGLh7PYZxMOlYSQi/8LvLaBR9Jg== Date: Fri, 20 Jul 2018 10:59:25 +0000 Message-ID: <30f4d334645246ddb7175b601de2c502@AcuMS.aculab.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] MIME-Version: 1.0 X-MC-Unique: F7fa8LnjOrWsLpX9wEOGfQ-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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)