[PATCH] Build with -fno-delete-null-pointer-checks

Marc Kleine-Budde mkl at pengutronix.de
Wed Jul 8 09:14:33 PDT 2015


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 at 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   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20150708/853c2f89/attachment.sig>


More information about the barebox mailing list