From patchwork Fri Jul 3 09:40:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 50614 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C78B4214B3 for ; Fri, 3 Jul 2015 09:40:49 +0000 (UTC) Received: by lagx9 with SMTP id x9sf26793343lag.2 for ; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=Cpj5ROrPa5caxYd2WeFOWLDdP4h3WN9Ctcw+UCVfI8A=; b=XyarEsSlqDtewI6WQSoEy+G69kXQ/Ooodc49nluOOjniY9jt7Fwozb/ak0dZNtMiAK UCK4e+IFel349Q0tpffrFnDRxxx3gG2r28/mR2Ob/oPIrOsVzgDM61CVO15J3DVpgpdS itIukc/lJCopXYiZ5QbxhVg/FEQmnZC8gJA7cd2g2tAjuZOxwtzGrlL1p+zblnIimQMZ B/lWESYMGdjVULXfrl/HxZ/f8Ld/4iKAEwAVhCIWYvksAKpGL8cBBL4TZQYKV163M2YH PjAa5VlckTb0/0GXR7SGUGDOgzlWXa3OEeGYDeKXy8+v4/bSrSPWZ6H9FDmSxgGLhg0N X6lg== X-Gm-Message-State: ALoCoQkjaZ1Km9UAsuoWYUAYryxb9uQc+pIF+DvHePi1PpJt2Q2tWCEEL3Pm96Pk2fpaEiU0eTvW X-Received: by 10.194.175.36 with SMTP id bx4mr22270037wjc.1.1435916448728; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.168 with SMTP id ev8ls442153lac.44.gmail; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) X-Received: by 10.152.27.74 with SMTP id r10mr35529515lag.31.1435916448406; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id s8si6750858lbr.137.2015.07.03.02.40.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2015 02:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagx9 with SMTP id x9so78675056lag.1 for ; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr34971495lag.86.1435916448278; Fri, 03 Jul 2015 02:40:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1046256lbb; Fri, 3 Jul 2015 02:40:47 -0700 (PDT) X-Received: by 10.50.90.179 with SMTP id bx19mr48884599igb.43.1435916446513; Fri, 03 Jul 2015 02:40:46 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id l12si8337542ioe.23.2015.07.03.02.40.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Jul 2015 02:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAxSU-0000lK-2O; Fri, 03 Jul 2015 09:40:34 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ZAxST-0000lE-Gr for edk2-devel@lists.sourceforge.net; Fri, 03 Jul 2015 09:40:33 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.171 as permitted sender) client-ip=209.85.212.171; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f171.google.com; Received: from mail-wi0-f171.google.com ([209.85.212.171]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ZAxSS-0003gj-4M for edk2-devel@lists.sourceforge.net; Fri, 03 Jul 2015 09:40:33 +0000 Received: by widjy10 with SMTP id jy10so105392047wid.1 for ; Fri, 03 Jul 2015 02:40:26 -0700 (PDT) X-Received: by 10.194.205.101 with SMTP id lf5mr72121070wjc.37.1435916426049; Fri, 03 Jul 2015 02:40:26 -0700 (PDT) Received: from localhost.localdomain ([185.13.106.72]) by mx.google.com with ESMTPSA id fa8sm12986803wib.14.2015.07.03.02.40.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jul 2015 02:40:25 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, michael.d.kinney@intel.com, Jiewen.Yao@intel.com, liming.gao@intel.com, jordan.l.justen@intel.com Date: Fri, 3 Jul 2015 11:40:02 +0200 Message-Id: <1435916407-29683-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435916407-29683-1-git-send-email-ard.biesheuvel@linaro.org> References: <1435916407-29683-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1ZAxSS-0003gj-4M Subject: [edk2] [PATCH 1/6] MdePkg/BasePeCoffLib: remove redundant PeCoffLoaderEx.c for AARCH64 X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The AARCH64 specific implementations of PeCoffLoaderRelocateImageEx and PeHotRelocateImageEx only handle EFI_IMAGE_REL_BASED_DIR64 relocations. Since these are already handled by the respective callers, this is essentially dead code and can be removed. So add IMAGE_FILE_MACHINE_ARM64 support to the list of supported machines of the generic version, and use it for AARCH64 as well. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdePkg/Library/BasePeCoffLib/AArch64/PeCoffLoaderEx.c | 127 -------------------- MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf | 5 +- MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c | 4 +- 3 files changed, 3 insertions(+), 133 deletions(-) diff --git a/MdePkg/Library/BasePeCoffLib/AArch64/PeCoffLoaderEx.c b/MdePkg/Library/BasePeCoffLib/AArch64/PeCoffLoaderEx.c deleted file mode 100644 index 7e4b4db45328..000000000000 --- a/MdePkg/Library/BasePeCoffLib/AArch64/PeCoffLoaderEx.c +++ /dev/null @@ -1,127 +0,0 @@ -/** @file - Specific relocation fixups for ARM architecture. - - Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
- Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
- Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
- - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "BasePeCoffLibInternals.h" -#include - -// Note: Currently only large memory model is supported by UEFI relocation code. - -/** - Performs an AARCH64-based specific relocation fixup and is a no-op on other - instruction sets. - - @param Reloc The pointer to the relocation record. - @param Fixup The pointer to the address to fix up. - @param FixupData The pointer to a buffer to log the fixups. - @param Adjust The offset to adjust the fixup. - - @return Status code. - -**/ -RETURN_STATUS -PeCoffLoaderRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -{ - UINT64 *Fixup64; - - switch ((*Reloc) >> 12) { - - case EFI_IMAGE_REL_BASED_DIR64: - Fixup64 = (UINT64 *) Fixup; - *Fixup64 = *Fixup64 + (UINT64) Adjust; - if (*FixupData != NULL) { - *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64)); - *(UINT64 *)(*FixupData) = *Fixup64; - *FixupData = *FixupData + sizeof(UINT64); - } - break; - - default: - return RETURN_UNSUPPORTED; - } - - return RETURN_SUCCESS; -} - -/** - Returns TRUE if the machine type of PE/COFF image is supported. Supported - does not mean the image can be executed it means the PE/COFF loader supports - loading and relocating of the image type. It's up to the caller to support - the entry point. - - @param Machine Machine type from the PE Header. - - @return TRUE if this PE/COFF loader can load the image - -**/ -BOOLEAN -PeCoffLoaderImageFormatSupported ( - IN UINT16 Machine - ) -{ - if ((Machine == IMAGE_FILE_MACHINE_ARM64) || (Machine == IMAGE_FILE_MACHINE_EBC)) { - return TRUE; - } - - return FALSE; -} - -/** - Performs an ARM-based specific re-relocation fixup and is a no-op on other - instruction sets. This is used to re-relocated the image into the EFI virtual - space for runtime calls. - - @param Reloc The pointer to the relocation record. - @param Fixup The pointer to the address to fix up. - @param FixupData The pointer to a buffer to log the fixups. - @param Adjust The offset to adjust the fixup. - - @return Status code. - -**/ -RETURN_STATUS -PeHotRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -{ - UINT64 *Fixup64; - - switch ((*Reloc) >> 12) { - case EFI_IMAGE_REL_BASED_DIR64: - Fixup64 = (UINT64 *) Fixup; - *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); - if (*(UINT64 *) (*FixupData) == *Fixup64) { - *Fixup64 = *Fixup64 + (UINT64) Adjust; - } - - *FixupData = *FixupData + sizeof (UINT64); - break; - - default: - DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n")); - return RETURN_UNSUPPORTED; - } - - return RETURN_SUCCESS; -} diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf index 576d72826c32..ff0580fbdf56 100644 --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf @@ -40,7 +40,7 @@ [Sources] BasePeCoffLibInternals.h BasePeCoff.c -[Sources.IA32, Sources.X64, Sources.EBC] +[Sources.IA32, Sources.X64, Sources.EBC, Sources.AARCH64] PeCoffLoaderEx.c [Sources.IPF] @@ -49,9 +49,6 @@ [Sources.IPF] [Sources.ARM] Arm/PeCoffLoaderEx.c -[Sources.AARCH64] - AArch64/PeCoffLoaderEx.c - [Packages] MdePkg/MdePkg.dec diff --git a/MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c b/MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c index 2ed58844d5d4..01825c85392b 100644 --- a/MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c +++ b/MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c @@ -44,7 +44,7 @@ PeCoffLoaderRelocateImageEx ( loading and relocating of the image type. It's up to the caller to support the entry point. - The IA32/X64 version PE/COFF loader/relocater both support IA32, X64 and EBC images. + The generic version PE/COFF loader/relocater supports IA32, X64, AARCH64 and EBC images. @param Machine The machine type from the PE Header. @@ -57,7 +57,7 @@ PeCoffLoaderImageFormatSupported ( ) { if ((Machine == IMAGE_FILE_MACHINE_I386) || (Machine == IMAGE_FILE_MACHINE_X64) || - (Machine == IMAGE_FILE_MACHINE_EBC)) { + (Machine == IMAGE_FILE_MACHINE_ARM64) || (Machine == IMAGE_FILE_MACHINE_EBC)) { return TRUE; }