From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.xenproject.org (mail.xenproject.org [104.130.215.37]) by mx.groups.io with SMTP id smtpd.web11.4265.1591698585477101186 for ; Tue, 09 Jun 2020 03:29:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@xen.org header.s=20200302mail header.b=nQHBErTB; spf=pass (domain: xen.org, ip: 104.130.215.37, mailfrom: julien@xen.org) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Scr+LchPVkfVD3Etic85jU1o3rWMQF8BYeXInmsPbDk=; b=nQHBErTBUtvMiGsJeCJqxbauH9 +qG39gli3luVCnq8bKxltj0GQWmG4EzXq31Jbk0k11eSiEYlFaG9HYOi60k4twMjHMOwY2qScw7rm kHVuhrlk3CL4sZG5PfYNwHXQolxE0pfLOaN/xdygVzb9HvPXFmZ8SMMl/yneq/jnrZfw=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jibVg-0003qD-50; Tue, 09 Jun 2020 10:29:36 +0000 Received: from [54.239.6.188] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jibVf-00030Y-UM; Tue, 09 Jun 2020 10:29:36 +0000 Subject: Re: [PATCH 0/4] ArmVirtPkg: use PE/COFF metadata for self relocation To: Ard Biesheuvel , devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Jiewen Yao References: <20200608173413.1100679-1-ard.biesheuvel@arm.com> From: Julien Grall Message-ID: Date: Tue, 9 Jun 2020 11:29:33 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200608173413.1100679-1-ard.biesheuvel@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi Ard, On 08/06/2020 18:34, Ard Biesheuvel wrote: > As suggested by Jiewen in response to Ilias RFC [0], it is better to use > the PE/COFF metadata for self-relocating executables than to rely on ELF > metadata, given how the latter is only available when using ELF based > toolchains. Also, we have had some maintenance issues with this code in > the past, as PIE linking of non-position independent objects is not a well > tested code path in toolchains in general. > > So implement this for the self-relocating PrePi in ArmVirtPkg first. > > First, we need to ensure that the module in question is emitted with its > PE/COFF relocation metadata preserved, by creating a special FDF rule. > > We also need to provide a way for the code to refer to the start of the > image directly, by adding it to the linker script. > > Then, it is simply a matter of swapping out the two assembly routines, > and adding the C code that serves the same purpose but based on PE/COFF > base relocations. > > Note that PE/COFF relocations are considerably more compact than ELF RELA > relocations, so this does not impact the memory footprint of the resulting > image adversely. I have tested the change in a Xen guest. No issues reported. Tested-by: Julien Grall Cheers, -- Julien Grall