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 <ard.biesheuvel@arm.com>
---
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
--
2.26.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#60893): https://edk2.groups.io/g/devel/message/60893
Mute This Topic: https://groups.io/mt/74757210/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
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 <ard.biesheuvel@arm.com>
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
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#61096): https://edk2.groups.io/g/devel/message/61096
Mute This Topic: https://groups.io/mt/74757210/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Bob Feng<bob.c.feng@intel.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
Sent: Tuesday, June 9, 2020 1:34 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>; Ilias Apalodimas <ilias.apalodimas@linaro.org>; Julien Grall <julien@xen.org>; Yao, Jiewen <jiewen.yao@intel.com>
Subject: [edk2-devel] [PATCH 2/4] BaseTools/Scripts/GccBase.lds: export image base symbol
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 <ard.biesheuvel@arm.com>
---
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--
2.26.2
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#60893): https://edk2.groups.io/g/devel/message/60893
Mute This Topic: https://groups.io/mt/74757210/1768742
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [bob.c.feng@intel.com] -=-=-=-=-=-=
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#61200): https://edk2.groups.io/g/devel/message/61200
Mute This Topic: https://groups.io/mt/74757210/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.