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.web11.145.1591637668433236023 for ; Mon, 08 Jun 2020 10:34:28 -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 1C8021FB; Mon, 8 Jun 2020 10:34:28 -0700 (PDT) Received: from localhost.localdomain (unknown [10.37.8.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 33B093F73D; Mon, 8 Jun 2020 10:34:26 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Bob Feng , Liming Gao , Laszlo Ersek , Leif Lindholm , Ilias Apalodimas , Julien Grall , Jiewen Yao Subject: [PATCH 2/4] BaseTools/Scripts/GccBase.lds: export image base symbol Date: Mon, 8 Jun 2020 19:34:11 +0200 Message-Id: <20200608173413.1100679-3-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200608173413.1100679-1-ard.biesheuvel@arm.com> References: <20200608173413.1100679-1-ard.biesheuvel@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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 @@ =0D SECTIONS {=0D =0D + PROVIDE(ElfImageBase =3D .);=0D +=0D /*=0D * The PE/COFF binary consists of DOS and PE/COFF headers, and a sequenc= e of=0D * section headers adding up to PECOFF_HEADER_SIZE bytes (which differs= =0D --=20 2.26.2