mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Build with -fno-delete-null-pointer-checks
@ 2015-07-08 10:57 Sascha Hauer
  2015-07-08 16:14 ` Marc Kleine-Budde
  2015-07-13  7:19 ` Uwe Kleine-König
  0 siblings, 2 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-07-08 10:57 UTC (permalink / raw)
  To: Barebox List

This becomes important with gcc-4.9. Without this gcc assumes
that accessing NULL pointers traps and everything that happens
behind the access is not executed. This recently happened with
i.MX53 which has:

static int imx53_silicon_revision(void)
{
	void __iomem *rom = MX53_IROM_BASE_ADDR;

	rev = readl(rom + SI_REV);
	...
}

This resulted in object code in which the last instruction is
the readl, the reset of the function is missing because gcc assumes this
is never executed.

Disable this optimization with -fno-delete-null-pointer-checks since
in barebox NULL pointers can indeed be valid.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index e7db67a..0fe9274 100644
--- a/Makefile
+++ b/Makefile
@@ -301,7 +301,8 @@ CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffre
 
 CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                    -Werror-implicit-function-declaration \
-                   -fno-strict-aliasing -fno-common -Os -pipe
+                   -fno-strict-aliasing -fno-common -Os -pipe \
+                   -fno-delete-null-pointer-checks
 AFLAGS          := -D__ASSEMBLY__
 
 LDFLAGS_barebox	:= -Map barebox.map
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Build with -fno-delete-null-pointer-checks
  2015-07-08 10:57 [PATCH] Build with -fno-delete-null-pointer-checks Sascha Hauer
@ 2015-07-08 16:14 ` Marc Kleine-Budde
  2015-07-13  7:13   ` Sascha Hauer
  2015-07-13  7:19 ` Uwe Kleine-König
  1 sibling, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2015-07-08 16:14 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List


[-- Attachment #1.1: Type: text/plain, Size: 1825 bytes --]

On 07/08/2015 12:57 PM, Sascha Hauer wrote:
> This becomes important with gcc-4.9. Without this gcc assumes
> that accessing NULL pointers traps and everything that happens
> behind the access is not executed. This recently happened with
> i.MX53 which has:
> 
> static int imx53_silicon_revision(void)
> {
> 	void __iomem *rom = MX53_IROM_BASE_ADDR;
> 
> 	rev = readl(rom + SI_REV);
> 	...
> }
> 
> This resulted in object code in which the last instruction is
> the readl, the reset of the function is missing because gcc assumes this
> is never executed.
> 
> Disable this optimization with -fno-delete-null-pointer-checks since
> in barebox NULL pointers can indeed be valid.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index e7db67a..0fe9274 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -301,7 +301,8 @@ CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffre
>  
>  CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>                     -Werror-implicit-function-declaration \
> -                   -fno-strict-aliasing -fno-common -Os -pipe
> +                   -fno-strict-aliasing -fno-common -Os -pipe \
> +                   -fno-delete-null-pointer-checks
The kernel uses:
$(call cc-option,-fno-delete-null-pointer-checks,)

>  AFLAGS          := -D__ASSEMBLY__
>  
>  LDFLAGS_barebox	:= -Map barebox.map
> 
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Build with -fno-delete-null-pointer-checks
  2015-07-08 16:14 ` Marc Kleine-Budde
@ 2015-07-13  7:13   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2015-07-13  7:13 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Michael Olbrich, Barebox List

On Wed, Jul 08, 2015 at 06:14:33PM +0200, Marc Kleine-Budde wrote:
> On 07/08/2015 12:57 PM, Sascha Hauer wrote:
> > This becomes important with gcc-4.9. Without this gcc assumes
> > that accessing NULL pointers traps and everything that happens
> > behind the access is not executed. This recently happened with
> > i.MX53 which has:
> > 
> > static int imx53_silicon_revision(void)
> > {
> > 	void __iomem *rom = MX53_IROM_BASE_ADDR;
> > 
> > 	rev = readl(rom + SI_REV);
> > 	...
> > }
> > 
> > This resulted in object code in which the last instruction is
> > the readl, the reset of the function is missing because gcc assumes this
> > is never executed.
> > 
> > Disable this optimization with -fno-delete-null-pointer-checks since
> > in barebox NULL pointers can indeed be valid.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  Makefile | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index e7db67a..0fe9274 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -301,7 +301,8 @@ CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffre
> >  
> >  CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> >                     -Werror-implicit-function-declaration \
> > -                   -fno-strict-aliasing -fno-common -Os -pipe
> > +                   -fno-strict-aliasing -fno-common -Os -pipe \
> > +                   -fno-delete-null-pointer-checks
> The kernel uses:
> $(call cc-option,-fno-delete-null-pointer-checks,)

Changed it to do the same.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Build with -fno-delete-null-pointer-checks
  2015-07-08 10:57 [PATCH] Build with -fno-delete-null-pointer-checks Sascha Hauer
  2015-07-08 16:14 ` Marc Kleine-Budde
@ 2015-07-13  7:19 ` Uwe Kleine-König
  1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2015-07-13  7:19 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

On Wed, Jul 08, 2015 at 12:57:40PM +0200, Sascha Hauer wrote:
> This becomes important with gcc-4.9. Without this gcc assumes
> that accessing NULL pointers traps and everything that happens
> behind the access is not executed. This recently happened with
> i.MX53 which has:
> 
> static int imx53_silicon_revision(void)
> {
> 	void __iomem *rom = MX53_IROM_BASE_ADDR;
I assume MX53_IROM_BASE_ADDR is 0? Is this worth to be pointed out in
the commit log?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-07-13  7:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-08 10:57 [PATCH] Build with -fno-delete-null-pointer-checks Sascha Hauer
2015-07-08 16:14 ` Marc Kleine-Budde
2015-07-13  7:13   ` Sascha Hauer
2015-07-13  7:19 ` Uwe Kleine-König

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