From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 32C54210F475F for ; Thu, 7 Jun 2018 20:38:33 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 20:38:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,489,1520924400"; d="scan'208";a="235406196" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga005.fm.intel.com with ESMTP; 07 Jun 2018 20:38:33 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Jun 2018 20:38:33 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Jun 2018 20:38:33 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.87]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.70]) with mapi id 14.03.0319.002; Fri, 8 Jun 2018 11:38:31 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" Thread-Topic: [Patch] BaseTools: Check elf sections alignment with MAX_COFF_ALIGNMENT Thread-Index: AQHT/gOin/DbK5RpM0Gj5SeWtlbqpaRVuEcw Date: Fri, 8 Jun 2018 03:38:30 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E294A13@SHSMSX104.ccr.corp.intel.com> References: <1528336951-6212-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1528336951-6212-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2I5YTBmMzktMGVhOS00NmE0LThjOTgtODNiN2FkZGNhOTljIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiV3U3NnRFTlhsTEZ6SERcL1QzNGVmYlN1elF3RXc5cEtFZDhTeUlMdEttV3JEeE5ZNTU4Qm9YYlBtNlFpUUNURVQifQ== dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Check elf sections alignment with MAX_COFF_ALIGNMENT X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 03:38:34 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhu, Yonghong > Sent: Thursday, June 7, 2018 10:03 AM > To: edk2-devel@lists.01.org > Cc: Feng, YunhuaX ; Gao, Liming > Subject: [Patch] BaseTools: Check elf sections alignment with MAX_COFF_AL= IGNMENT >=20 > From: Yunhua Feng >=20 > Add the logic to check whether mCoffAlignment is larger than > MAX_COFF_ALIGNMENT, and report error for it. >=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Yunhua Feng > --- > BaseTools/Source/C/GenFw/Elf32Convert.c | 10 +++++++++- > BaseTools/Source/C/GenFw/Elf64Convert.c | 11 ++++++++++- > 2 files changed, 19 insertions(+), 2 deletions(-) >=20 > diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C= /GenFw/Elf32Convert.c > index 14fe4a2..e0f6491 100644 > --- a/BaseTools/Source/C/GenFw/Elf32Convert.c > +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c > @@ -1,9 +1,9 @@ > /** @file > Elf32 Convert solution >=20 > -Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> Portions copyright (c) 2013, ARM Ltd. All rights reserved.
>=20 > This program and the accompanying materials are licensed and made availa= ble > under the terms and conditions of the BSD License which accompanies this > distribution. The full text of the license may be found at > @@ -382,10 +382,18 @@ ScanSections32 ( > mCoffAlignment =3D (UINT32)shdr->sh_addralign; > } > } >=20 > // > + // Check if mCoffAlignment larger than MAX_COFF_ALIGNMENT > + // > + if (mCoffAlignment > MAX_COFF_ALIGNMENT) { > + Error (NULL, 0, 3000, "Invalid", "Section alignment larger than MAX_= COFF_ALIGNMENT."); > + assert (FALSE); > + } > + > + // > // Move the PE/COFF header right before the first section. This will h= elp us > // save space when converting to TE. > // > if (mCoffAlignment > mCoffOffset) { > mNtHdrOffset +=3D mCoffAlignment - mCoffOffset; > diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C= /GenFw/Elf64Convert.c > index c39bdff..9e68d22 100644 > --- a/BaseTools/Source/C/GenFw/Elf64Convert.c > +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c > @@ -1,9 +1,9 @@ > /** @file > Elf64 convert solution >=20 > -Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> Portions copyright (c) 2013-2014, ARM Ltd. All rights reserved.
>=20 > This program and the accompanying materials are licensed and made availa= ble > under the terms and conditions of the BSD License which accompanies this > distribution. The full text of the license may be found at > @@ -375,10 +375,19 @@ ScanSections64 ( > mCoffAlignment =3D (UINT32)shdr->sh_addralign; > } > } >=20 > // > + // Check if mCoffAlignment larger than MAX_COFF_ALIGNMENT > + // > + if (mCoffAlignment > MAX_COFF_ALIGNMENT) { > + Error (NULL, 0, 3000, "Invalid", "Section alignment larger than MAX_= COFF_ALIGNMENT."); > + assert (FALSE); > + } > + > + > + // > // Move the PE/COFF header right before the first section. This will h= elp us > // save space when converting to TE. > // > if (mCoffAlignment > mCoffOffset) { > mNtHdrOffset +=3D mCoffAlignment - mCoffOffset; > -- > 2.6.1.windows.1