From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbcGDNzO (ORCPT ); Mon, 4 Jul 2016 09:55:14 -0400 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:52794 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753828AbcGDNzJ convert rfc822-to-8bit (ORCPT ); Mon, 4 Jul 2016 09:55:09 -0400 X-IronPort-AV: E=Sophos;i="5.26,574,1459814400"; d="scan'208";a="543763046" From: "Tautschnig, Michael" To: "linux-kbuild@vger.kernel.org" , "kexec@lists.infradead.org" , "linux-kernel@vger.kernel.org" CC: Michal Marek , Vivek Goyal Subject: [PATCH] scripts: Fix size mismatch of kexec_purgatory_size Thread-Topic: [PATCH] scripts: Fix size mismatch of kexec_purgatory_size Thread-Index: AQHR1fuq4VOZzVozC0+0gk9YgAAwdw== Date: Mon, 4 Jul 2016 13:55:04 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.43.166.131] Content-Type: text/plain; charset="us-ascii" Content-ID: <4D79288BAE707244A17A0CCC53700D7D@ant.amazon.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bin2c is used to create a valid C file out of a binary file where two symbols will be globally defined: and _size. is passed as the first parameter of the host binary. Building using goto-cc reported that the purgatory binary code (the only current user of this utility) declares kexec_purgatory_size as 'size_t' where bin2c generate _size to be 'int' so in a 64-bit host where sizeof(size_t) > sizeof(int) this type mismatch will always yield the wrong value for big-endian architectures while for little-endian it will be wrong if the object laid in memory directly after kexec_purgatory_size contains non-zero value at the time of reading. This commit changes _size to be size_t instead. Note: Another way to fix the problem is to change the type of kexec_purgatory_size to be 'int' as there's this check in code: (kexec_purgatory_size <= 0) Signed-off-by: Michael Tautschnig Cc: Michal Marek Cc: Vivek Goyal --- scripts/basic/bin2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/basic/bin2c.c b/scripts/basic/bin2c.c index af187e6..c3d7eef 100644 --- a/scripts/basic/bin2c.c +++ b/scripts/basic/bin2c.c @@ -29,7 +29,8 @@ int main(int argc, char *argv[]) } while (ch != EOF); if (argc > 1) - printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total); + printf("\t;\n\n#include \n\nconst size_t %s_size = %d;\n", + argv[1], total); return 0; } -- 2.7.3.AMZN