From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5502.1591825756746355326 for ; Wed, 10 Jun 2020 14:49:17 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) 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 755081FB; Wed, 10 Jun 2020 14:49:15 -0700 (PDT) Received: from [192.168.1.69] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2CD3A3F6CF; Wed, 10 Jun 2020 14:49:14 -0700 (PDT) Subject: Re: [PATCH 2/4] BaseTools/Scripts/GccBase.lds: export image base symbol To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Julien Grall , Jiewen Yao References: <20200608173413.1100679-1-ard.biesheuvel@arm.com> <20200608173413.1100679-3-ard.biesheuvel@arm.com> From: "Ard Biesheuvel" Message-ID: <8f5cd985-c47e-b500-fca9-4ab449515a64@arm.com> Date: Wed, 10 Jun 2020 23:48:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200608173413.1100679-3-ard.biesheuvel@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 6/8/20 7:34 PM, Ard Biesheuvel wrote: > To help converted ELF images perform self-relocation, export a symbol > 'ElfImageBase' that can be used in the code to discover the start of > the image in memory. > > Note the use of PROVIDE() - this ensures that the symbol is only emitted > if a reference to it exists in the code being linked, but no definition. > This means the symbol is never emitted in a way that can conflict with > existing code. > > Signed-off-by: Ard Biesheuvel Bob, Liming, any objections? > --- > BaseTools/Scripts/GccBase.lds | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds > index a9dd2138d4b5..e73c1206a2e2 100644 > --- a/BaseTools/Scripts/GccBase.lds > +++ b/BaseTools/Scripts/GccBase.lds > @@ -12,6 +12,8 @@ > > SECTIONS { > > + PROVIDE(ElfImageBase = .); > + > /* > * The PE/COFF binary consists of DOS and PE/COFF headers, and a sequence of > * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs >