From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heinrich Schuchardt Date: Thu, 3 May 2018 09:22:39 +0200 Subject: [U-Boot] [PATCH] efi_loader: correctly apply relocations from the .reloc section In-Reply-To: <20180502233602.GA2557@intel.com> References: <20180502233602.GA2557@intel.com> Message-ID: <88607598-691c-4152-a985-70e736569a03@gmx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05/03/2018 01:36 AM, Ivan Gorinov wrote: > Instead of difference between preferred and actual image base, the > actual base is added to the fields specified in the .reloc section. > > Use ImageBase from PE optional header to compute the delta, > exit early if the image is loaded at the preferred address. > > Signed-off-by: Ivan Gorinov The PE spec has this sentence: "To apply a base relocation, the difference is calculated between the preferred base address and the base where the image is actually loaded." The spec further defines ImageBase as "The preferred address of the first byte of image when loaded into memory." EDK2 also calculates the relocations offset as: BaseAddress - OptionalHeader.ImageBase in MdePkg/Library/BasePeCoffLib/BasePeCoff.c and in DuetPkg/EfiLdr/PeLoader.c Reviewed-by: Heinrich Schuchardt