public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools/tools_def ARM: emit PIC veneers
@ 2018-12-12 12:19 Ard Biesheuvel
  2018-12-12 12:36 ` Leif Lindholm
  2018-12-12 13:56 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2018-12-12 12:19 UTC (permalink / raw)
  To: edk2-devel; +Cc: leif.lindholm, liming.gao, Ard Biesheuvel

The ARM linker may emit veneers, i.e., trampolines, when ordinary
direct relative branches cannot be used, e.g., for Thumb interworking
or branch targets that are out of range.

Usually, such veneers carry an absolute reference to the branch
target, which is problematic for us, since these absolute references
are not covered by annotations that are visible to GenFw in the
PE/COFF conversion, and so these absolute references are not fixed
up by the PE/COFF loader at runtime.

So switch to all ARM GNU ld toolchains to position independent veneers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 BaseTools/Conf/tools_def.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 2ba833e1fb06..902680c24c85 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -4150,7 +4150,7 @@ DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
 DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
 DEFINE GCC_IA32_X64_DLINK_COMMON   = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
 DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
-DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
+DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -Wl,--pic-veneer
 DEFINE GCC_AARCH64_DLINK_FLAGS     = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
 DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20
 DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
-- 
2.19.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] BaseTools/tools_def ARM: emit PIC veneers
  2018-12-12 12:19 [PATCH] BaseTools/tools_def ARM: emit PIC veneers Ard Biesheuvel
@ 2018-12-12 12:36 ` Leif Lindholm
  2018-12-19 20:11   ` Ard Biesheuvel
  2018-12-12 13:56 ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 4+ messages in thread
From: Leif Lindholm @ 2018-12-12 12:36 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel, liming.gao

On Wed, Dec 12, 2018 at 01:19:31PM +0100, Ard Biesheuvel wrote:
> The ARM linker may emit veneers, i.e., trampolines, when ordinary
> direct relative branches cannot be used, e.g., for Thumb interworking
> or branch targets that are out of range.
> 
> Usually, such veneers carry an absolute reference to the branch
> target, which is problematic for us, since these absolute references
> are not covered by annotations that are visible to GenFw in the
> PE/COFF conversion, and so these absolute references are not fixed
> up by the PE/COFF loader at runtime.
> 
> So switch to all ARM GNU ld toolchains to position independent veneers.

Do we know how ling that flag has been around for? I find a post from
2009 referring to as "new", so I guess we're safe for anything we care
about.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 2ba833e1fb06..902680c24c85 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4150,7 +4150,7 @@ DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>  DEFINE GCC_IA32_X64_DLINK_COMMON   = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
>  DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
> -DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> +DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -Wl,--pic-veneer
>  DEFINE GCC_AARCH64_DLINK_FLAGS     = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
>  DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20
>  DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
> -- 
> 2.19.2
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] BaseTools/tools_def ARM: emit PIC veneers
  2018-12-12 12:19 [PATCH] BaseTools/tools_def ARM: emit PIC veneers Ard Biesheuvel
  2018-12-12 12:36 ` Leif Lindholm
@ 2018-12-12 13:56 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-12-12 13:56 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel; +Cc: liming.gao

On 12/12/18 1:19 PM, Ard Biesheuvel wrote:
> The ARM linker may emit veneers, i.e., trampolines, when ordinary
> direct relative branches cannot be used, e.g., for Thumb interworking
> or branch targets that are out of range.
> 
> Usually, such veneers carry an absolute reference to the branch
> target, which is problematic for us, since these absolute references
> are not covered by annotations that are visible to GenFw in the
> PE/COFF conversion, and so these absolute references are not fixed
> up by the PE/COFF loader at runtime.
> 
> So switch to all ARM GNU ld toolchains to position independent veneers.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 2ba833e1fb06..902680c24c85 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -4150,7 +4150,7 @@ DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
>  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
>  DEFINE GCC_IA32_X64_DLINK_COMMON   = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
>  DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
> -DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> +DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -Wl,--pic-veneer
>  DEFINE GCC_AARCH64_DLINK_FLAGS     = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
>  DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20
>  DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] BaseTools/tools_def ARM: emit PIC veneers
  2018-12-12 12:36 ` Leif Lindholm
@ 2018-12-19 20:11   ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2018-12-19 20:11 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: edk2-devel@lists.01.org, Gao, Liming

On Wed, 12 Dec 2018 at 13:36, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> On Wed, Dec 12, 2018 at 01:19:31PM +0100, Ard Biesheuvel wrote:
> > The ARM linker may emit veneers, i.e., trampolines, when ordinary
> > direct relative branches cannot be used, e.g., for Thumb interworking
> > or branch targets that are out of range.
> >
> > Usually, such veneers carry an absolute reference to the branch
> > target, which is problematic for us, since these absolute references
> > are not covered by annotations that are visible to GenFw in the
> > PE/COFF conversion, and so these absolute references are not fixed
> > up by the PE/COFF loader at runtime.
> >
> > So switch to all ARM GNU ld toolchains to position independent veneers.
>
> Do we know how ling that flag has been around for? I find a post from
> 2009 referring to as "new", so I guess we're safe for anything we care
> about.
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>

I accidentally pushed this, and failed to add the tags as well.

Given that this only affects 32-bit ARM, I guess few people are going
to mind, so I am going to leave this as-is unless anyone complains.

> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  BaseTools/Conf/tools_def.template | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> > index 2ba833e1fb06..902680c24c85 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -4150,7 +4150,7 @@ DEFINE GCC_DLINK_FLAGS_COMMON      = -nostdlib --pie
> >  DEFINE GCC_DLINK2_FLAGS_COMMON     = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds
> >  DEFINE GCC_IA32_X64_DLINK_COMMON   = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
> >  DEFINE GCC_ARM_AARCH64_DLINK_COMMON= -Wl,--emit-relocs -nostdlib -Wl,--gc-sections -u $(IMAGE_ENTRY_POINT) -Wl,-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
> > -DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> > +DEFINE GCC_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20 -Wl,--pic-veneer
> >  DEFINE GCC_AARCH64_DLINK_FLAGS     = DEF(GCC_ARM_AARCH64_DLINK_COMMON) -z common-page-size=0x20
> >  DEFINE GCC_ARM_AARCH64_ASLDLINK_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(GCC_DLINK2_FLAGS_COMMON) -z common-page-size=0x20
> >  DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
> > --
> > 2.19.2
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-19 20:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12 12:19 [PATCH] BaseTools/tools_def ARM: emit PIC veneers Ard Biesheuvel
2018-12-12 12:36 ` Leif Lindholm
2018-12-19 20:11   ` Ard Biesheuvel
2018-12-12 13:56 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox