All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] u-boot: Alawys build with disabled PIE
@ 2018-10-18  5:49 Khem Raj
  2018-10-18 14:09 ` Tom Rini
  2018-10-19  0:27 ` Denys Dmytriyenko
  0 siblings, 2 replies; 4+ messages in thread
From: Khem Raj @ 2018-10-18  5:49 UTC (permalink / raw)
  To: meta-ti; +Cc: Tom Rini

some OE distros can default to hardened toolchains which means PIE is
added implicitly to compiler cmdline, here this options makes sure that
whattever the default toolchain are, u-boot is not impacted

Fixes errors e.g.

| arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
| arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Denys Dmytriyenko <denys@ti.com>
---
 .../0001-Always-build-with-fno-PIE.patch      | 35 +++++++++++++++++++
 .../u-boot/u-boot-ti-staging_2018.01.bb       |  2 ++
 2 files changed, 37 insertions(+)
 create mode 100644 recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch

diff --git a/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
new file mode 100644
index 00000000..dfd99c66
--- /dev/null
+++ b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
@@ -0,0 +1,35 @@
+From ec81bbe3ea7e077512f4b9d2b4aa87e7f1494bcc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Wed, 17 Oct 2018 22:32:57 -0700
+Subject: [PATCH] Always build with -fno-PIE
+
+GNU Toolchains can be configured to generate PIE by default
+while PIE could be ok, it is known that u-boot/SPL on ARM starts to
+generate bigger code and starts to overflow the SRAM size, therefore
+disabling PIE explcitly insulates against toolchain intrinsic defaults
+
+Fixes errors like
+| arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
+| arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Cc: Tom Rini <trini@konsulko.com>
+---
+ Makefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Makefile b/Makefile
+index 45cd751ba3..9eb8ac564e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -592,6 +592,7 @@ KBUILD_CFLAGS	+= -O2
+ endif
+ 
+ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
+ KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
+ 
+ KBUILD_CFLAGS	+= -g
+-- 
+2.19.1
+
diff --git a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
index cbb8857a..c9c97111 100644
--- a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
+++ b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
@@ -5,3 +5,5 @@ PR = "r24"
 BRANCH = "ti-u-boot-2018.01"
 
 SRCREV = "2cc52408bf1357f11b96548e78223a1df321c1ae"
+
+SRC_URI += "file://0001-Always-build-with-fno-PIE.patch"
-- 
2.19.1



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

* Re: [PATCH] u-boot: Alawys build with disabled PIE
  2018-10-18  5:49 [PATCH] u-boot: Alawys build with disabled PIE Khem Raj
@ 2018-10-18 14:09 ` Tom Rini
  2018-10-18 17:33   ` Khem Raj
  2018-10-19  0:27 ` Denys Dmytriyenko
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Rini @ 2018-10-18 14:09 UTC (permalink / raw)
  To: Khem Raj; +Cc: meta-ti

[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]

On Wed, Oct 17, 2018 at 10:49:46PM -0700, Khem Raj wrote:
> some OE distros can default to hardened toolchains which means PIE is
> added implicitly to compiler cmdline, here this options makes sure that
> whattever the default toolchain are, u-boot is not impacted
> 
> Fixes errors e.g.
> 
> | arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> | arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Denys Dmytriyenko <denys@ti.com>
> ---
>  .../0001-Always-build-with-fno-PIE.patch      | 35 +++++++++++++++++++
>  .../u-boot/u-boot-ti-staging_2018.01.bb       |  2 ++
>  2 files changed, 37 insertions(+)
>  create mode 100644 recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> 
> diff --git a/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> new file mode 100644
> index 00000000..dfd99c66
> --- /dev/null
> +++ b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> @@ -0,0 +1,35 @@
> +From ec81bbe3ea7e077512f4b9d2b4aa87e7f1494bcc Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Wed, 17 Oct 2018 22:32:57 -0700
> +Subject: [PATCH] Always build with -fno-PIE
> +
> +GNU Toolchains can be configured to generate PIE by default
> +while PIE could be ok, it is known that u-boot/SPL on ARM starts to
> +generate bigger code and starts to overflow the SRAM size, therefore
> +disabling PIE explcitly insulates against toolchain intrinsic defaults
> +
> +Fixes errors like
> +| arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> +| arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> +
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +Cc: Tom Rini <trini@konsulko.com>
> +---
> + Makefile | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/Makefile b/Makefile
> +index 45cd751ba3..9eb8ac564e 100644
> +--- a/Makefile
> ++++ b/Makefile
> +@@ -592,6 +592,7 @@ KBUILD_CFLAGS	+= -O2
> + endif
> + 
> + KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
> ++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
> + KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
> + 
> + KBUILD_CFLAGS	+= -g
> +-- 
> +2.19.1
> +
> diff --git a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> index cbb8857a..c9c97111 100644
> --- a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> +++ b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> @@ -5,3 +5,5 @@ PR = "r24"
>  BRANCH = "ti-u-boot-2018.01"
>  
>  SRCREV = "2cc52408bf1357f11b96548e78223a1df321c1ae"
> +
> +SRC_URI += "file://0001-Always-build-with-fno-PIE.patch"

So does this end up being something that is appropriate to push
upstream?  Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] u-boot: Alawys build with disabled PIE
  2018-10-18 14:09 ` Tom Rini
@ 2018-10-18 17:33   ` Khem Raj
  0 siblings, 0 replies; 4+ messages in thread
From: Khem Raj @ 2018-10-18 17:33 UTC (permalink / raw)
  To: Tom Rini; +Cc: meta-ti

Hi Tom

I think, it does for now. Eventually, it might be interesting to see if
u-boot could be compiled as static PIE, looking  at the code generated
by gcc for arm/beaglebone, there is additional penalty since arm gcc
is reloading pc-relative addresses, putting an extra slot in the
constant pool each time which can be significant if we use small
functions as seems to be the case in u-boot.

Thanks
-KhemOn Thu, Oct 18, 2018 at 7:09 AM Tom Rini <trini@konsulko.com> wrote:
>
> On Wed, Oct 17, 2018 at 10:49:46PM -0700, Khem Raj wrote:
> > some OE distros can default to hardened toolchains which means PIE is
> > added implicitly to compiler cmdline, here this options makes sure that
> > whattever the default toolchain are, u-boot is not impacted
> >
> > Fixes errors e.g.
> >
> > | arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> > | arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > Cc: Tom Rini <trini@konsulko.com>
> > Cc: Denys Dmytriyenko <denys@ti.com>
> > ---
> >  .../0001-Always-build-with-fno-PIE.patch      | 35 +++++++++++++++++++
> >  .../u-boot/u-boot-ti-staging_2018.01.bb       |  2 ++
> >  2 files changed, 37 insertions(+)
> >  create mode 100644 recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> >
> > diff --git a/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> > new file mode 100644
> > index 00000000..dfd99c66
> > --- /dev/null
> > +++ b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> > @@ -0,0 +1,35 @@
> > +From ec81bbe3ea7e077512f4b9d2b4aa87e7f1494bcc Mon Sep 17 00:00:00 2001
> > +From: Khem Raj <raj.khem@gmail.com>
> > +Date: Wed, 17 Oct 2018 22:32:57 -0700
> > +Subject: [PATCH] Always build with -fno-PIE
> > +
> > +GNU Toolchains can be configured to generate PIE by default
> > +while PIE could be ok, it is known that u-boot/SPL on ARM starts to
> > +generate bigger code and starts to overflow the SRAM size, therefore
> > +disabling PIE explcitly insulates against toolchain intrinsic defaults
> > +
> > +Fixes errors like
> > +| arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> > +| arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> > +
> > +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > +Cc: Tom Rini <trini@konsulko.com>
> > +---
> > + Makefile | 1 +
> > + 1 file changed, 1 insertion(+)
> > +
> > +diff --git a/Makefile b/Makefile
> > +index 45cd751ba3..9eb8ac564e 100644
> > +--- a/Makefile
> > ++++ b/Makefile
> > +@@ -592,6 +592,7 @@ KBUILD_CFLAGS    += -O2
> > + endif
> > +
> > + KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
> > ++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
> > + KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
> > +
> > + KBUILD_CFLAGS       += -g
> > +--
> > +2.19.1
> > +
> > diff --git a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> > index cbb8857a..c9c97111 100644
> > --- a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> > +++ b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> > @@ -5,3 +5,5 @@ PR = "r24"
> >  BRANCH = "ti-u-boot-2018.01"
> >
> >  SRCREV = "2cc52408bf1357f11b96548e78223a1df321c1ae"
> > +
> > +SRC_URI += "file://0001-Always-build-with-fno-PIE.patch"
>
> So does this end up being something that is appropriate to push
> upstream?  Thanks!
>
> --
> Tom


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

* Re: [PATCH] u-boot: Alawys build with disabled PIE
  2018-10-18  5:49 [PATCH] u-boot: Alawys build with disabled PIE Khem Raj
  2018-10-18 14:09 ` Tom Rini
@ 2018-10-19  0:27 ` Denys Dmytriyenko
  1 sibling, 0 replies; 4+ messages in thread
From: Denys Dmytriyenko @ 2018-10-19  0:27 UTC (permalink / raw)
  To: Khem Raj; +Cc: meta-ti, Tom Rini

On Wed, Oct 17, 2018 at 10:49:46PM -0700, Khem Raj wrote:
> some OE distros can default to hardened toolchains which means PIE is
> added implicitly to compiler cmdline, here this options makes sure that
> whattever the default toolchain are, u-boot is not impacted
> 
> Fixes errors e.g.
> 
> | arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> | arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Denys Dmytriyenko <denys@ti.com>

Thanks, merged!


> ---
>  .../0001-Always-build-with-fno-PIE.patch      | 35 +++++++++++++++++++
>  .../u-boot/u-boot-ti-staging_2018.01.bb       |  2 ++
>  2 files changed, 37 insertions(+)
>  create mode 100644 recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> 
> diff --git a/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> new file mode 100644
> index 00000000..dfd99c66
> --- /dev/null
> +++ b/recipes-bsp/u-boot/files/0001-Always-build-with-fno-PIE.patch
> @@ -0,0 +1,35 @@
> +From ec81bbe3ea7e077512f4b9d2b4aa87e7f1494bcc Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Wed, 17 Oct 2018 22:32:57 -0700
> +Subject: [PATCH] Always build with -fno-PIE
> +
> +GNU Toolchains can be configured to generate PIE by default
> +while PIE could be ok, it is known that u-boot/SPL on ARM starts to
> +generate bigger code and starts to overflow the SRAM size, therefore
> +disabling PIE explcitly insulates against toolchain intrinsic defaults
> +
> +Fixes errors like
> +| arm-yoe-linux-gnueabi-ld.bfd: u-boot-spl section `.rodata' will not fit in region `.sram'
> +| arm-yoe-linux-gnueabi-ld.bfd: region `.sram' overflowed by 5772 bytes
> +
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +Cc: Tom Rini <trini@konsulko.com>
> +---
> + Makefile | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/Makefile b/Makefile
> +index 45cd751ba3..9eb8ac564e 100644
> +--- a/Makefile
> ++++ b/Makefile
> +@@ -592,6 +592,7 @@ KBUILD_CFLAGS	+= -O2
> + endif
> + 
> + KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
> ++KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
> + KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
> + 
> + KBUILD_CFLAGS	+= -g
> +-- 
> +2.19.1
> +
> diff --git a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> index cbb8857a..c9c97111 100644
> --- a/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> +++ b/recipes-bsp/u-boot/u-boot-ti-staging_2018.01.bb
> @@ -5,3 +5,5 @@ PR = "r24"
>  BRANCH = "ti-u-boot-2018.01"
>  
>  SRCREV = "2cc52408bf1357f11b96548e78223a1df321c1ae"
> +
> +SRC_URI += "file://0001-Always-build-with-fno-PIE.patch"
> -- 
> 2.19.1
> 


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

end of thread, other threads:[~2018-10-19  0:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-18  5:49 [PATCH] u-boot: Alawys build with disabled PIE Khem Raj
2018-10-18 14:09 ` Tom Rini
2018-10-18 17:33   ` Khem Raj
2018-10-19  0:27 ` Denys Dmytriyenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.