From patchwork Thu Sep 6 13:45:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146093 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp534462ljw; Thu, 6 Sep 2018 06:45:55 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/6AUZIok2sPKA83BihB2Xt7D8kKX168iA0M5FpKCVvk4X93xxkbWNg+F10hq2XQgTBELj X-Received: by 2002:a62:ac12:: with SMTP id v18-v6mr2927573pfe.126.1536241555679; Thu, 06 Sep 2018 06:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536241555; cv=none; d=google.com; s=arc-20160816; b=LlwVMh0DseRIw1ncMEvnONeTT6HjzLeMooyak7l2KJr4wzI4wFhW6UlqV1U21ipGWl F1GID3Xk6vsykNDIEtqOB1CoIqlt4yCuZsfcuv99Xp+QGF/5U1933KfrtWfZoIh61RDH nBap37PwV+OaUPfTzPtmMlyy/fEsS7QaXQUI027w7w0Rhd/OOd2NIjPi3HrX9ZeZq+tF QMXbWZdvIiOlqId9wh2EQAfktYQ2MVQ59NTihrb1HU4uCw8u52ikVpq+39xvuDxkaQ9H 5VHs14n2ggco6OczmQXUO63z735DrrJ5n3WXlTmAV2+KfzcN/RHbI2h4i3dA/GrmUGY7 eqOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=/RPfb6bomLO26AztY9ronz8W4GH5E/RKwLo+i9KgxHY=; b=I0HK8CogyR9f7ZeS6CUvroNax7H/5i+f5W2BQS3/4LPFCyoUuLiWU+y/MdGoe1SOvi 6oJe2R7mStwREy3ZvBJrTdpSQATl71pW1g6bfD3geyPvx4SZdsaRwUANeBPzSXTaomMy f+9bY4WhzkNh6UN1X0KYg7h9srl8M+qXSdCmr77ogFMzbJI/WtvOLZqBsN3Y6cRSnRJF qQkvSH4MqCpQLXGWy7uVLTZdKVvh9i076W296tEjpBuMw4V+0haBqJVdRu1Krcq0Kgo1 Mwl2YPfUBbdqTloeoQ9omrfhxnl+VUjn5ane+GiRBV6MO2CB1heWrIO3wZ3vaEllwbJC eU2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NkcftrmI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 93-v6si5247909plf.113.2018.09.06.06.45.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NkcftrmI; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3B8F921122958; Thu, 6 Sep 2018 06:45:48 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::544; helo=mail-ed1-x544.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AD2BF2111FE66 for ; Thu, 6 Sep 2018 06:45:46 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id a20-v6so8937125edd.4 for ; Thu, 06 Sep 2018 06:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KZSjs/tdQyoWjZtOYk8Hkp7VwR0pq0KLvwhoiiN3nVU=; b=NkcftrmI1CnXOPaV8fbgbzvuUG8JCC1nBryN9fGw/BaRtKI35N+z04zHwunEjw+JZ8 NlH4fo4F7PjZxIkjA3GJ2obTgRdM561ZaKVGEM7/8n9FIPOmsAXz36jKu7InRTzOZKSF K6tJw2TeGVqGpzPOKA3XZHDwdDUg4foBUxMnI= 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:in-reply-to :references; bh=KZSjs/tdQyoWjZtOYk8Hkp7VwR0pq0KLvwhoiiN3nVU=; b=D+bge4SsWF3/B8S8nn4euwViyv7HZvNfMVaulOYcgV+CCOYFtp5IoUfxobRz/qRII/ Pysrc3bRpvYaw1yGmS8v7LWIPU1wKTBblICBaPUfnBV8DeTP2p4ZEpwAH/fJ+GBF4Cti HrmQpUVrN27GOULl4upseX2KJSzWV49QBjcLmP6Qhz25N+1IeI4XIrzDM8DoamZ50GlG 29T80CBm8Xl53pCkiaVZccJ078g9Ou5k7KDbwYJgBg7uw1PNZlAZV3oK7FlTSK1ZRu+r J7Pfq2rsidRJCHYlGNFuIhDIO7dS9/DVlwbb0iKFF79VD0MOBOxpCi/ZPNTMq/NynInu sYcg== X-Gm-Message-State: APzg51AQ3agMdW0d+zMTMHqO7cKvA2eP2KmwfJ9OET7sU3eHi3IsrlEo ngQrEsNaLKlLulmbsi33gz/VfeFHrFEix87k X-Received: by 2002:a50:ad0f:: with SMTP id y15-v6mr3679122edc.78.1536241545028; Thu, 06 Sep 2018 06:45:45 -0700 (PDT) Received: from rev02.home ([2a02:a212:9283:9800:24b9:e2d6:9acc:50dd]) by smtp.gmail.com with ESMTPSA id l48-v6sm2818764eda.94.2018.09.06.06.45.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Sep 2018 06:45:43 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 6 Sep 2018 15:45:23 +0200 Message-Id: <20180906134523.2036-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180906134523.2036-1-ard.biesheuvel@linaro.org> References: <20180906134523.2036-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/4] EdkCompatibilityPkg: remove PE/COFF header workaround for ELILO on IPF X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao , Jiewen Yao , Star Zeng , Michael D Kinney , Laszlo Ersek , Chao Zhang MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Now that Itanium support has been dropped, we can remove the various occurrences of the ELILO on Itanium PE/COFF header workaround. Link: https://bugzilla.tianocore.org/show_bug.cgi?id=816 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c | 60 +++----------------- 1 file changed, 8 insertions(+), 52 deletions(-) -- 2.18.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c index f99c23e5ee4c..28d39b342afd 100644 --- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c @@ -22,36 +22,6 @@ Abstract: #include "BasePeCoffLibInternals.h" -/** - Retrieves the magic value from the PE/COFF header. - - @param Hdr The buffer in which to return the PE32, PE32+, or TE header. - - @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32 - @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+ - -**/ -UINT16 -PeCoffLoaderGetPeHeaderMagicValue ( - IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr - ) -{ - // - // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value - // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the - // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - // - if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { - return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC; - } - // - // Return the magic value from the PC/COFF Optional Header - // - return Hdr.Pe32->OptionalHeader.Magic; -} - - /** Retrieves the PE or TE Header from a PE/COFF or TE image. @@ -71,7 +41,6 @@ GluePeCoffLoaderGetPeHeader ( RETURN_STATUS Status; EFI_IMAGE_DOS_HEADER DosHdr; UINTN Size; - UINT16 Magic; // // Read the DOS image header to check for it's existance @@ -130,9 +99,7 @@ GluePeCoffLoaderGetPeHeader ( ImageContext->IsTeImage = FALSE; ImageContext->Machine = Hdr.Pe32->FileHeader.Machine; - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -141,7 +108,7 @@ GluePeCoffLoaderGetPeHeader ( ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment; ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders; - } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) { // // Use PE32+ offset // @@ -209,7 +176,6 @@ GluePeCoffLoaderGetImageInfo ( EFI_IMAGE_SECTION_HEADER SectionHeader; EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; if (NULL == ImageContext) { return RETURN_INVALID_PARAMETER; @@ -225,13 +191,11 @@ GluePeCoffLoaderGetImageInfo ( return Status; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - // // Retrieve the base address of the image // if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -276,7 +240,7 @@ GluePeCoffLoaderGetImageInfo ( } if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -520,7 +484,6 @@ GluePeCoffLoaderRelocateImage ( CHAR8 *FixupData; PHYSICAL_ADDRESS BaseAddress; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; ASSERT (ImageContext != NULL); @@ -552,9 +515,7 @@ GluePeCoffLoaderRelocateImage ( if (!(ImageContext->IsTeImage)) { Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset); - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -777,7 +738,6 @@ GluePeCoffLoaderLoadImage ( UINTN Size; UINT32 TempDebugEntryRva; UINT32 NumberOfRvaAndSizes; - UINT16 Magic; ASSERT (ImageContext != NULL); @@ -965,12 +925,11 @@ GluePeCoffLoaderLoadImage ( // // Get image's entry point // - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); if (!(ImageContext->IsTeImage)) { // // Sizes of AddressOfEntryPoint are different so we need to do this safely // - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1004,7 +963,7 @@ GluePeCoffLoaderLoadImage ( // the optional header to verify a desired directory entry is there. // if (!(ImageContext->IsTeImage)) { - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset // @@ -1172,7 +1131,6 @@ PeCoffLoaderRelocateImageForRuntime ( CHAR8 *FixupData; UINTN Adjust; RETURN_STATUS Status; - UINT16 Magic; OldBase = (CHAR8 *)((UINTN)ImageBase); NewBase = (CHAR8 *)((UINTN)VirtImageBase); @@ -1201,9 +1159,7 @@ PeCoffLoaderRelocateImageForRuntime ( return ; } - Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr); - - if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) { // // Use PE32 offset //