From patchwork Thu Aug 31 15:36:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Shimizu X-Patchwork-Id: 9932387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BFB3360362 for ; Thu, 31 Aug 2017 15:36:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A594D289C7 for ; Thu, 31 Aug 2017 15:36:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9926A289D5; Thu, 31 Aug 2017 15:36:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D2EA289C7 for ; Thu, 31 Aug 2017 15:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751746AbdHaPg6 (ORCPT ); Thu, 31 Aug 2017 11:36:58 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35869 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbdHaPg5 (ORCPT ); Thu, 31 Aug 2017 11:36:57 -0400 Received: by mail-pg0-f66.google.com with SMTP id 83so696186pgb.3 for ; Thu, 31 Aug 2017 08:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=c8ti48Cb50xDabzeH44sJ9NQ5sT9mEWYpRDhhepZX0g=; b=mi2o1EIHKbVdooExmYL5YA4X44oq8UAuxIH+qM6EaQR5LHkQertbePak95ieprrtLv jU1nQs2mNSL31IYX5bkOT1ufUGI0ez3YHaAOQGfXbweWGoO3GzqsKytSJLm/dKaNgARd yEF6AGP0Yz0n4KW066Nr1YrlYPAHfs1uZTxcIszj/fGJ305fnBNogOEeoQhVegvRovEA gvKHH9Lvcvd7UN19S4qx4L8ME38B+UvqSbJ9zVcW4xOvvhfu6l9wpT9gmJfamN4557vL rr86p9URadhPsaINuG7E7X4gu7kc67vTcB+yZB1hB9oLp56Z+pQkGANNakVXg6cC8Xx1 YVDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c8ti48Cb50xDabzeH44sJ9NQ5sT9mEWYpRDhhepZX0g=; b=aT15PSr/iGoaGjzJWLJbOmoaS0BnbcH2zernPeGMLMPguuWEFY5tn69ZdfxRnZG2Fy lY93BoJtKSu962IgGIOeEt1qHEShFdxO+DgE7OZPqn3Po6TIZRJ0XCqrdb+DwBDkQMW+ CnIPhe4LeM3/BMaodZcoF6T7vHx2MXVfXwjq7lUHoNdewF8mRzhk1IFkHdDnFaVa9bYx D/mxwuk+TnA0xD4cpXuFNFKrzGyPFOSJFhVSnkMvIDYHBnti2sZ5uVYyzZDkeUBV5SIv bK4Yl6IWPp3SrUPq21Vg2FxwLaeTg6tBnHDeb2K+kpe1EIlo3tS64vsej9MA/s3hw8pR b5ig== X-Gm-Message-State: AHYfb5gxdgmycddh7HFbKDhOjEBkeJmFtUvgMSFpht6gtjeD6sZ8oC8J Wc7rX6EAZhsgkw== X-Google-Smtp-Source: ADKCNb6BFMwPXD9B6TmV4s/ieM6rcp5o64+EvtXiWj5J/PzS49IMHeG9LhYxzTkur4joBvCPCmR/Hg== X-Received: by 10.101.77.66 with SMTP id j2mr2983910pgt.314.1504193816015; Thu, 31 Aug 2017 08:36:56 -0700 (PDT) Received: from localhost ([2400:7800:4df7:4300:8e29:37ff:feee:1c9e]) by smtp.gmail.com with ESMTPSA id w64sm38231pfi.75.2017.08.31.08.36.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2017 08:36:55 -0700 (PDT) From: Roger Shimizu To: Michal Marek , Masahiro Yamada , Russell King Cc: Roger Shimizu , Corentin Chary , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org Subject: [PATCH] scripts: make extract-vmlinux support armel/armhf Date: Fri, 1 Sep 2017 00:36:31 +0900 Message-Id: <20170831153631.31026-1-rogershimizu@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP vmlinux/zImage on armel/armhf seems not an ELF, so update the script scripts/extract-vmlinux to support such case. This fix is tested on Debian amd64, armel, and armhf platform, with Debian kernels. Fixes: 09d481270d44 ("scripts: add extract-vmlinux") Cc: Corentin Chary Cc: Michal Marek Cc: Masahiro Yamada Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kbuild@vger.kernel.org Signed-off-by: Roger Shimizu --- Dear Michal, Masahiro-san, and Russell, I posted this patch before [0] but didn't get positive response. Recently when I trace a Debian kernel issue, I still find this patch useful to locate the root cause [1]. Besides, it's a well known bug confuses other developers [2][3]. So I decide to submit the patch again. [0]: https://patchwork.kernel.org/patch/8120831/ [1]: https://bugs.debian.org/870185#50 [2]: https://bugs.launchpad.net/linaro-ubuntu/+bug/1050453 [3]: https://bugs.linaro.org/show_bug.cgi?id=461 Please kindly help to review. Thank you! Cheers, Roger Shimizu, GMT +9 Tokyo PGP/GPG: 4096R/6C6ACD6417B3ACB1 scripts/extract-vmlinux | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux index 5061abcc2540..0c72ecd24969 100755 --- a/scripts/extract-vmlinux +++ b/scripts/extract-vmlinux @@ -6,6 +6,7 @@ # (c) 2009,2010 Dick Streefland # # (c) 2011 Corentin Chary +# (c) 2016 Roger Shimizu # # Licensed under the GNU General Public License, version 2 (GPLv2). # ---------------------------------------------------------------------- @@ -15,7 +16,14 @@ check_vmlinux() # Use readelf to check if it's a valid ELF # TODO: find a better to way to check that it's really vmlinux # and not just an elf - readelf -h $1 > /dev/null 2>&1 || return 1 + case "$2" in + 0|"") + readelf -h $1 > /dev/null 2>&1 || return 1 + ;; + 1) + # For ARCH like armel/armhf, vmlinux is not ELF, so we skip the check + ;; + esac cat $1 exit 0 @@ -31,7 +39,7 @@ try_decompress() do pos=${pos%%:*} tail -c+$pos "$img" | $3 > $tmp 2> /dev/null - check_vmlinux $tmp + test $? -eq 0 && check_vmlinux $tmp 1 done } @@ -53,7 +61,7 @@ check_vmlinux $img # That didn't work, so retry after decompression. try_decompress '\037\213\010' xy gunzip -try_decompress '\3757zXZ\000' abcde unxz +try_decompress '\3757zXZ\000' abcde "unxz --single-stream" try_decompress 'BZh' xy bunzip2 try_decompress '\135\0\0\0' xxx unlzma try_decompress '\211\114\132' xy 'lzop -d'