From nobody Sun May 5 07:48:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61141+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61141+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1591879958; cv=none; d=zohomail.com; s=zohoarc; b=dp8Nq5SdncolypjOlwTVRFn2bwDXsz6xK2IQUhNMmAJExaPDAN1TClSU9FgK5eLhVVEyV0dzILmsQyjDt+cGJEUBuAGBzuIogBNz0/r/xj82yC+irBu2IyfxyHlfIzYo24T0URC6fC6CGtOxjaWJpbeAPrD14q6cG++wtyUyj28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591879958; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=1ZWKrK+VGBCeHiH4DdxP3wF1NAwQYbvKSrRHx43SJGc=; b=UZImY7NXcC6yJf5/xlTehVzt2slQLbQHgl57h39ZYjrASvy86PQzvx5OzJvlIQqpiCW9jFjVliMmygQZ5J71LqBryjkJwN9CeYpS2knXKKLdAiSdGEJTeLLX4gZB+cE5eBeh0A23569sYT5zQ5f0bYSYLMIGHYlH2CrTf/OqxsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61141+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591879958179677.4090381002582; Thu, 11 Jun 2020 05:52:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UYHZYY1788612xdjuhS7H19q; Thu, 11 Jun 2020 05:52:37 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.6607.1591879957272585429 for ; Thu, 11 Jun 2020 05:52:37 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CDBEA1FB; Thu, 11 Jun 2020 05:52:36 -0700 (PDT) X-Received: from localhost.localdomain (unknown [10.37.8.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7AB0D3F66F; Thu, 11 Jun 2020 05:52:34 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Julien Grall , Jiewen Yao , Sami Mujawar , Jiewen Yao Subject: [edk2-devel] [PATCH v2 1/3] ArmVirtPkg: add FDF rule for self-relocating PrePi Date: Thu, 11 Jun 2020 14:52:26 +0200 Message-Id: <20200611125228.252500-2-ard.biesheuvel@arm.com> In-Reply-To: <20200611125228.252500-1-ard.biesheuvel@arm.com> References: <20200611125228.252500-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: b9uU2bPH3rCRGAfNkZvor3j1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591879957; bh=VrOitRY2EFNZNHglRdU30cnO3v0ZMjNBWMtyfAlqk2E=; h=Cc:Date:From:Reply-To:Subject:To; b=LiFoIRRqR07wHgElh6RwoM2VTZqP4w5M93t5WhStrpRTbC3HO5kul70643vovC3P2yk AGqRCzKvwVqiYz6sJviueUpvzxIcqBBbEgmbkz2VUOEel8VHrvT3zwopsrMP/V4XHJrXQ 1va2VmeDwvUOpaWh1ZH5NWelBVHjmGbvpGI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In preparation for making the self-relocating PrePi use the ordinary BasePeCoffLib routines for relocating the image in place in memory at start, add a special FDF rule that builds SEC modules as PE32 images with the relocation metadata preserved. Signed-off-by: Ard Biesheuvel Acked-by: Jiewen Yao Reviewed-by: Laszlo Ersek Acked-by: Sami Mujawar --- ArmVirtPkg/ArmVirtQemuKernel.fdf | 2 +- ArmVirtPkg/ArmVirtXen.fdf | 2 +- ArmVirtPkg/ArmVirtRules.fdf.inc | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemuKernel.fdf b/ArmVirtPkg/ArmVirtQemuKerne= l.fdf index 72fc8dd698f8..55e33aba0d55 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.fdf +++ b/ArmVirtPkg/ArmVirtQemuKernel.fdf @@ -136,7 +136,7 @@ [FV.FVMAIN_COMPACT] READ_LOCK_CAP =3D TRUE READ_LOCK_STATUS =3D TRUE =20 - INF ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf + INF RuleOverride =3D SELF_RELOC ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelo= catable.inf =20 FILE FV_IMAGE =3D 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRE= D =3D TRUE { diff --git a/ArmVirtPkg/ArmVirtXen.fdf b/ArmVirtPkg/ArmVirtXen.fdf index 6a97bceeacbc..f708878f4965 100644 --- a/ArmVirtPkg/ArmVirtXen.fdf +++ b/ArmVirtPkg/ArmVirtXen.fdf @@ -233,7 +233,7 @@ [FV.FVMAIN_COMPACT] READ_LOCK_CAP =3D TRUE READ_LOCK_STATUS =3D TRUE =20 - INF ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf + INF RuleOverride =3D SELF_RELOC ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelo= catable.inf =20 FILE FV_IMAGE =3D 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRE= D =3D TRUE { diff --git a/ArmVirtPkg/ArmVirtRules.fdf.inc b/ArmVirtPkg/ArmVirtRules.fdf.= inc index 63de26abe056..b8ec040d2330 100644 --- a/ArmVirtPkg/ArmVirtRules.fdf.inc +++ b/ArmVirtPkg/ArmVirtRules.fdf.inc @@ -39,6 +39,11 @@ [Rule.Common.SEC] TE TE Align =3D Auto $(INF_OUTPUT)/$(MODULE_NAME).efi } =20 +[Rule.Common.SEC.SELF_RELOC] + FILE SEC =3D $(NAMED_GUID) { + TE TE Align =3D Auto $(INF_OUTPUT)/$(MODULE_NAME).efi + } + [Rule.Common.PEI_CORE] FILE PEI_CORE =3D $(NAMED_GUID) FIXED { TE TE Align =3D Auto $(INF_OUTPUT)/$(MODULE_NAME).efi --=20 2.26.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61141): https://edk2.groups.io/g/devel/message/61141 Mute This Topic: https://groups.io/mt/74817464/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 5 07:48:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61142+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61142+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1591879960; cv=none; d=zohomail.com; s=zohoarc; b=jFvaGU5N83E1EKi3XsgUDCq4PqmHMzuRYHviSn3gk3H804zZSvOEyZG4I0+LfSnf8kLaAZkyBofBrgjsj1Z/7LwY5HGQesVldzkZvut/UQe0T4v5EsECWBjoMGl8zBboO+ubGJtqBLgtVAVGr0nOZ9YYXJDaOGm4CoYKplaJQSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591879960; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=WaWCf4JgyyH6rUGEESU3ftHYrjnZxO5ZQRc6T1OtjVc=; b=oK3GO7Rkz2AZg5PFvj/R4eafhlMupbo+gVa8u1WTdKOtGHxfe6r5+1W2d09a79XsjjydKRBpJ1tVC/mcKRNR+gAztSOUxzcp07F4CTVCZqxrAcxJ6lmw33AnpCas7mnPBy7Mn8Pi3RkM05TBLP06SEJ0hHMX4OXwCAjKH1r40nk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61142+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591879960329650.1827421111558; Thu, 11 Jun 2020 05:52:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9NOlYY1788612xp15sqhcfl0; Thu, 11 Jun 2020 05:52:39 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.6566.1591879959395660424 for ; Thu, 11 Jun 2020 05:52:39 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21BA031B; Thu, 11 Jun 2020 05:52:39 -0700 (PDT) X-Received: from localhost.localdomain (unknown [10.37.8.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2EA333F66F; Thu, 11 Jun 2020 05:52:37 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Julien Grall , Jiewen Yao , Sami Mujawar , Jiewen Yao Subject: [edk2-devel] [PATCH v2 2/3] ArmVirtPkg/PrePi: use standard PeCoff routines for self-relocation Date: Thu, 11 Jun 2020 14:52:27 +0200 Message-Id: <20200611125228.252500-3-ard.biesheuvel@arm.com> In-Reply-To: <20200611125228.252500-1-ard.biesheuvel@arm.com> References: <20200611125228.252500-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: JViR5FW7XMBlnWehAjr9Jnfvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591879959; bh=Tiedrku7uCsErN7sZWf+IiYltZx2etpJi3DoyyMdhYI=; h=Cc:Date:From:Reply-To:Subject:To; b=nZA/VT5GsLcW2BoGODhXwCrJWI2Z2N5806+kyLZoCaf6OyyuWHtn9PvQcbuRBoB5NJK S+xVBRDIvohNMqDiP36/DLNkUuqR4mYaSXdQeudHMAEgBisSnXVekZA+JgkEbY0ee2gGI 4gMeMn1/0Ccnf/0ILDz689qFTsLfSUBwokU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Instead of having a GCC specific routine to perform self-relocation based on ELF metadata, use the PE/COFF metadata and the existing PeCoff library routines. This reduces the amount of bespoke assembler code that is a burden to maintain, and is not portable across the set of toolchains we support. This does require some special care, as we have no control over how the C code references global symbols, so we need to emit these references from the calling assembler code. Otherwise, they may be emitted as absolute references, in which case they need to be fixed up themselves, leading to a circular dependency. Signed-off-by: Ard Biesheuvel Acked-by: Jiewen Yao Acked-by: Laszlo Ersek Acked-by: Sami Mujawar --- ArmVirtPkg/ArmVirtQemuKernel.dsc | 10 ++-- ArmVirtPkg/ArmVirtXen.dsc | 10 ++-- ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 4 +- ArmVirtPkg/PrePi/PrePi.c | 35 ++++++++++++++ ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S | 49 +++++------------= --- ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S | 47 +++++------------= -- 6 files changed, 68 insertions(+), 87 deletions(-) diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index 2a6fd6bc06be..9449a01d6e40 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -83,14 +83,12 @@ [LibraryClasses.common.DXE_DRIVER] [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf =20 -[BuildOptions.common.EDKII.SEC, BuildOptions.common.EDKII.BASE] +[BuildOptions] # - # CLANG38 with LTO support enabled uses the GNU GOLD linker, which insis= ts - # on emitting GOT based symbol references when running in shared mode, u= nless - # we override visibility to 'hidden' in all modules that make up the Pre= Pi - # build. + # We need to avoid jump tables in SEC modules, so that the PE/COFF + # self-relocation code itself is guaranteed to be position independent. # - GCC:*_CLANG38_*_CC_FLAGS =3D -include $(WORKSPACE)/ArmVirtPkg/Include/Pl= atform/Hidden.h + GCC:*_*_*_CC_FLAGS =3D -fno-jump-tables =20 ##########################################################################= ###### # diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index 8a489b253684..278f5d3828ce 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -52,14 +52,12 @@ [LibraryClasses] [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf =20 -[BuildOptions.common.EDKII.SEC, BuildOptions.common.EDKII.BASE] +[BuildOptions] # - # CLANG38 with LTO support enabled uses the GNU GOLD linker, which insis= ts - # on emitting GOT based symbol references when running in shared mode, u= nless - # we override visibility to 'hidden' in all modules that make up the Pre= Pi - # build. + # We need to avoid jump tables in SEC modules, so that the PE/COFF + # self-relocation code itself is guaranteed to be position independent. # - GCC:*_CLANG38_*_CC_FLAGS =3D -include $(WORKSPACE)/ArmVirtPkg/Include/Pl= atform/Hidden.h + GCC:*_*_*_CC_FLAGS =3D -fno-jump-tables =20 ##########################################################################= ###### # diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtP= kg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf index 9e58e56fce09..7edf5018089d 100755 --- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf +++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf @@ -46,6 +46,7 @@ [LibraryClasses] SerialPortLib ExtractGuidedSectionLib LzmaDecompressLib + PeCoffLib PrePiLib MemoryAllocationLib HobLib @@ -95,6 +96,3 @@ [Pcd] gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress gArmTokenSpaceGuid.PcdFdBaseAddress gArmTokenSpaceGuid.PcdFvBaseAddress - -[BuildOptions] - GCC:*_*_*_DLINK_FLAGS =3D -Wl,-Bsymbolic,-pie,-T,$(MODULE_DIR)/Scripts/P= rePi-PIE.lds diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c index 72e35028c5bb..4f0c3f98bad6 100755 --- a/ArmVirtPkg/PrePi/PrePi.c +++ b/ArmVirtPkg/PrePi/PrePi.c @@ -9,6 +9,7 @@ #include #include =20 +#include #include #include #include @@ -128,3 +129,37 @@ CEntryPoint ( // DXE Core should always load and never return ASSERT (FALSE); } + +VOID +RelocatePeCoffImage ( + IN EFI_PEI_FV_HANDLE FwVolHeader, + IN PE_COFF_LOADER_READ_FILE ImageRead + ) +{ + EFI_PEI_FILE_HANDLE FileHandle; + VOID *SectionData; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_STATUS Status; + + FileHandle =3D NULL; + Status =3D FfsFindNextFile (EFI_FV_FILETYPE_SECURITY_CORE, FwVolHeader, + &FileHandle); + ASSERT_EFI_ERROR (Status); + + Status =3D FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &SectionDat= a); + if (EFI_ERROR (Status)) { + Status =3D FfsFindSectionData (EFI_SECTION_TE, FileHandle, &SectionDat= a); + } + ASSERT_EFI_ERROR (Status); + + ZeroMem (&ImageContext, sizeof ImageContext); + + ImageContext.Handle =3D (EFI_HANDLE)SectionData; + ImageContext.ImageRead =3D ImageRead; + PeCoffLoaderGetImageInfo (&ImageContext); + + if (ImageContext.ImageAddress !=3D (UINTN)SectionData) { + ImageContext.ImageAddress =3D (UINTN)SectionData; + PeCoffLoaderRelocateImage (&ImageContext); + } +} diff --git a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S b/ArmVirtPkg/PrePi= /AArch64/ModuleEntryPoint.S index 34d6abecb0ac..01623b6b3591 100644 --- a/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S +++ b/ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S @@ -9,40 +9,6 @@ #include =20 ASM_FUNC(_ModuleEntryPoint) - // - // We are built as a ET_DYN PIE executable, so we need to process all - // relative relocations regardless of whether or not we are executing fr= om - // the same offset we were linked at. This is only possible if we are - // running from RAM. - // - adr x8, __reloc_base - adr x9, __reloc_start - adr x10, __reloc_end - -.Lreloc_loop: - cmp x9, x10 - bhs .Lreloc_done - - // - // AArch64 uses the ELF64 RELA format, which means each entry in the - // relocation table consists of - // - // UINT64 offset : the relative offset of the value that need= s to - // be relocated - // UINT64 info : relocation type and symbol index (the latt= er is - // not used for R_AARCH64_RELATIVE relocation= s) - // UINT64 addend : value to be added to the value being reloc= ated - // - ldp x11, x12, [x9], #24 // read offset into x11 and info into x12 - cmp x12, #0x403 // check info =3D=3D R_AARCH64_RELATIVE? - bne .Lreloc_loop // not a relative relocation? then skip - - ldr x12, [x9, #-8] // read addend into x12 - add x12, x12, x8 // add reloc base to addend to get relocated= value - str x12, [x11, x8] // write relocated value at offset - b .Lreloc_loop -.Lreloc_done: - bl ASM_PFX(DiscoverDramFromDt) =20 // Get ID of this CPU in Multicore system @@ -170,15 +136,24 @@ ASM_PFX(DiscoverDramFromDt): str x1, [x8] str x7, [x9] =20 + // + // The runtime address may be different from the link time address so fix + // up the PE/COFF relocations. Since we are calling a C function, use the + // window at the beginning of the FD image as a temp stack. + // + mov x0, x7 + adr x1, PeCoffLoaderImageReadFromMemory + mov sp, x7 + bl RelocatePeCoffImage + // // Discover the memory size and offset from the DTB, and record in the // respective PCDs. This will also return false if a corrupt DTB is - // encountered. Since we are calling a C function, use the window at the - // beginning of the FD image as a temp stack. + // encountered. // + mov x0, x28 adr x1, PcdGet64 (PcdSystemMemoryBase) adr x2, PcdGet64 (PcdSystemMemorySize) - mov sp, x7 bl FindMemnode cbz x0, .Lout =20 diff --git a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmVirtPkg/PrePi/Arm= /ModuleEntryPoint.S index 72d756fdb571..f0536c65eb52 100644 --- a/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S +++ b/ArmVirtPkg/PrePi/Arm/ModuleEntryPoint.S @@ -9,38 +9,6 @@ #include =20 ASM_FUNC(_ModuleEntryPoint) - // - // We are built as a ET_DYN PIE executable, so we need to process all - // relative relocations if we are executing from a different offset than= we - // were linked at. This is only possible if we are running from RAM. - // - ADRL (r4, __reloc_base) - ADRL (r5, __reloc_start) - ADRL (r6, __reloc_end) - -.Lreloc_loop: - cmp r5, r6 - bhs .Lreloc_done - - // - // AArch32 uses the ELF32 REL format, which means each entry in the - // relocation table consists of - // - // UINT32 offset : the relative offset of the value that need= s to - // be relocated - // UINT32 info : relocation type and symbol index (the latt= er is - // not used for R_ARM_RELATIVE relocations) - // - ldrd r8, r9, [r5], #8 // read offset into r8 and info into r9 - cmp r9, #23 // check info =3D=3D R_ARM_RELATIVE? - bne .Lreloc_loop // not a relative relocation? then skip - - ldr r9, [r8, r4] // read addend into r9 - add r9, r9, r1 // add image base to addend to get relocated= value - str r9, [r8, r4] // write relocated value at offset - b .Lreloc_loop -.Lreloc_done: - // Do early platform specific actions bl ASM_PFX(ArmPlatformPeiBootAction) =20 @@ -172,15 +140,24 @@ ASM_PFX(ArmPlatformPeiBootAction): str r1, [r8] str r5, [r7] =20 + // + // The runtime address may be different from the link time address so fix + // up the PE/COFF relocations. Since we are calling a C function, use the + // window at the beginning of the FD image as a temp stack. + // + mov r0, r5 + ADRL (r1, PeCoffLoaderImageReadFromMemory) + mov sp, r5 + bl RelocatePeCoffImage + // // Discover the memory size and offset from the DTB, and record in the // respective PCDs. This will also return false if a corrupt DTB is - // encountered. Since we are calling a C function, use the window at the - // beginning of the FD image as a temp stack. + // encountered. // + mov r0, r10 ADRL (r1, PcdGet64 (PcdSystemMemoryBase)) ADRL (r2, PcdGet64 (PcdSystemMemorySize)) - mov sp, r5 bl FindMemnode teq r0, #0 beq .Lout --=20 2.26.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61142): https://edk2.groups.io/g/devel/message/61142 Mute This Topic: https://groups.io/mt/74817471/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 5 07:48:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+61143+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61143+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1591879965; cv=none; d=zohomail.com; s=zohoarc; b=Kmcnh2MhbWhywWtZqnDoo8xH25VUO7+ZdfkH4quIMcS6S5Ix2b25J+H8S6ZoaDHQTVow6OvSliD4x/EswKnz1w96ELbh39fl3RplPcAZdXwu4baJUAPcD5LnR98ZSZ8IoDhzbrr3W8fx+QR9N/TusJRdTx70tPvuszTzdwQcfhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591879965; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=X0iDUOr3pqLVg4ZikjnVbQgvmlYnpTSaCc6z5SppUzQ=; b=PALXEcEaGR5PXiroLCg+PJRIRLOlq7sfHW860xqompX20G62DdEPn5YXvRUoZJelzkDWRXmeq5PGQD2Qqj8kfDH0x12ph+Nn6SucP1ENFuGcQOjBD3EPxgEakVpkPhpTsahp0BzhZo3ncQ/+1zu9p8Igp0YtI6zlbZmQaM/hVBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+61143+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591879965116352.6582480256741; Thu, 11 Jun 2020 05:52:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tCXUYY1788612x5nr4rFriPb; Thu, 11 Jun 2020 05:52:44 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.6611.1591879961816595444 for ; Thu, 11 Jun 2020 05:52:41 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 693F755D; Thu, 11 Jun 2020 05:52:41 -0700 (PDT) X-Received: from localhost.localdomain (unknown [10.37.8.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 76BFF3F66F; Thu, 11 Jun 2020 05:52:39 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Julien Grall , Jiewen Yao , Sami Mujawar , Jiewen Yao Subject: [edk2-devel] [PATCH v2 3/3] ArmVirtPkg: remove unused files Date: Thu, 11 Jun 2020 14:52:28 +0200 Message-Id: <20200611125228.252500-4-ard.biesheuvel@arm.com> In-Reply-To: <20200611125228.252500-1-ard.biesheuvel@arm.com> References: <20200611125228.252500-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ard.biesheuvel@arm.com X-Gm-Message-State: keCXGu4b2UgnmDOtCajJjcGsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591879964; bh=jh1dQqq9VxONTIZx/PGtu/u5S9twsQoJ/h/nmvd433U=; h=Cc:Date:From:Reply-To:Subject:To; b=RDPZRW7OC3TXs8U/FXHWH77P1U7KFoKt3h64yLHixGkgtxIDsgK88F9O6FQX9aVuclb V5P2+kZzs/47TkJn/bJgfp/JeV1Pq+2h7ZJxpwqrPtn/w/e/XREWdaU3FLNIaYlJaY1VA exXfbyG2ZdEfAThznXGhDJU33udrVZfrUIU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" We no longer use ELF PIE executables to implement the self-relocating PrePi so drop the custom linker script and visibility override header file. Signed-off-by: Ard Biesheuvel Acked-by: Jiewen Yao Reviewed-by: Laszlo Ersek Acked-by: Sami Mujawar --- ArmVirtPkg/Include/Platform/Hidden.h | 22 ----------- ArmVirtPkg/PrePi/Scripts/PrePi-PIE.lds | 41 -------------------- 2 files changed, 63 deletions(-) diff --git a/ArmVirtPkg/Include/Platform/Hidden.h b/ArmVirtPkg/Include/Plat= form/Hidden.h deleted file mode 100644 index 7a7bdb42b8bd..000000000000 --- a/ArmVirtPkg/Include/Platform/Hidden.h +++ /dev/null @@ -1,22 +0,0 @@ -/** @file - - Copyright (c) 2018, Linaro Limited. All rights reserved. - - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef __PLATFORM_HIDDEN_H -#define __PLATFORM_HIDDEN_H - -// -// Setting the GCC -fvisibility=3Dhidden command line option is not quite = the same -// as setting the pragma below: the former only affects definitions, where= as the -// pragma affects extern declarations as well. So if we want to ensure tha= t no -// GOT indirected symbol references are emitted, we need to use the pragma= , or -// GOT based cross object references could be emitted, e.g., in libraries,= and -// these cannot be relaxed to ordinary symbol references at link time. -// -#pragma GCC visibility push (hidden) - -#endif diff --git a/ArmVirtPkg/PrePi/Scripts/PrePi-PIE.lds b/ArmVirtPkg/PrePi/Scri= pts/PrePi-PIE.lds deleted file mode 100644 index c9a15ca3493a..000000000000 --- a/ArmVirtPkg/PrePi/Scripts/PrePi-PIE.lds +++ /dev/null @@ -1,41 +0,0 @@ -/** @file - - Copyright (c) 2015, Linaro Ltd. All rights reserved.
- - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -SECTIONS -{ - PROVIDE(__reloc_base =3D .); - - . =3D PECOFF_HEADER_SIZE; - .text : ALIGN(CONSTANT(COMMONPAGESIZE)) { - *(.text .text*) - *(.got .got*) - *(.rodata .rodata*) - *(.data .data*) - *(.bss .bss*) - - . =3D ALIGN(0x20); - PROVIDE(__reloc_start =3D .); - *(.rel .rel.*) - *(.rela .rela.*) - PROVIDE(__reloc_end =3D .); - } - - .note (INFO) : { *(.note.gnu.build-id) } - - /DISCARD/ : { - *(.note.GNU-stack) - *(.gnu.hash) - *(.gnu_debuglink) - *(.interp) - *(.dynamic) - *(.dynsym) - *(.dynstr) - *(.hash) - *(.comment) - } -} --=20 2.26.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#61143): https://edk2.groups.io/g/devel/message/61143 Mute This Topic: https://groups.io/mt/74817473/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-