All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugeniu Rosca <roscaeugeniu@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/8] UBSAN: run-time undefined behavior sanity checker
Date: Mon, 20 Aug 2018 23:00:01 +0200	[thread overview]
Message-ID: <20180820210001.GA11615@x230> (raw)
In-Reply-To: <DB7PR04MB4298FB3A6D3071BDDD59055D9A320@DB7PR04MB4298.eurprd04.prod.outlook.com>

On Mon, Aug 20, 2018 at 03:00:31PM +0000, York Sun wrote:
> On 08/19/2018 05:04 PM, Eugeniu Rosca wrote:
> <snip>
> > 
> > The size increase of sanbox U-Boot (gcc 8.1.0):
> > $ size u-boot.sandbox.*
> >    text	   data	    bss	    dec	    hex	filename
> > 1234958	  80048	 291472	1606478	 18834e	u-boot.sandbox.default
> > 1422710	 272240	 291472	1986422	 1e4f76	u-boot.sandbox.ubsan
> > +187752 +192192       0 +379944
> > 
> > The size increase of H3 Salvator-X U-Boot (aarch64-linux-gnu-gcc 7.2.1):
> > $ size u-boot.r8a7795-salvator-x.*
> >    text	   data	    bss	    dec	    hex	filename
> >  589954	  23504	 263984	 877442	  d6382	u-boot.r8a7795-salvator-x.default
> >  810968	 103304	 263984	1178256	 11fa90	u-boot.r8a7795-salvator-x.ubsan
> > +221014  +79800       0 +300814
> >
> I wonder if SPL can take advantage of this. Size is sensitive for SPL.

To build SPL, below fix is required (will be squashed into v2):

diff --git a/lib/Makefile b/lib/Makefile
index 099a49032a02..0ae2c121cacf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -18,9 +18,6 @@ obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
 obj-$(CONFIG_ARCH_AT91) += at91/
 obj-$(CONFIG_OPTEE) += optee/
 
-obj-$(CONFIG_UBSAN) += ubsan.o
-UBSAN_SANITIZE_ubsan.o := n
-
 obj-$(CONFIG_AES) += aes.o
 obj-y += charset.o
 obj-$(CONFIG_USB_TTY) += circbuf.o
@@ -54,6 +51,8 @@ endif
 obj-$(CONFIG_RSA) += rsa/
 obj-$(CONFIG_SHA1) += sha1.o
 obj-$(CONFIG_SHA256) += sha256.o
+obj-$(CONFIG_UBSAN) += ubsan.o
+UBSAN_SANITIZE_ubsan.o := n
 
 obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
 obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o

With respect to the ELF/BIN size, I get below numbers using
sandbox_spl_defconfig:

$ size u-boot-spl.default u-boot-spl.ubsan
   text	   data	    bss	    dec	    hex	filename
  58097	   5552	    672	  64321	   fb41	u-boot-spl.default
  74041	  25456	    672	 100169	  18749	u-boot-spl.ubsan

$ du -b u-boot-spl-nodtb.bin.default u-boot-spl-nodtb.bin.ubsan
2163064	u-boot-spl-nodtb.bin.default
2199352	u-boot-spl-nodtb.bin.ubsan

FWIW https://github.com/google/bloaty reports:

$ bloaty u-boot-spl.ubsan -- u-boot-spl.default
     VM SIZE                      FILE SIZE
 --------------                --------------
  [ = ]       0 .debug_info    +41.8Ki  +6.7%
  +727% +19.4Ki .data          +19.4Ki  +727%
  [ = ]       0 .debug_loc     +10.1Ki  +3.1%
   +32% +10.1Ki .text          +10.1Ki   +32%
  [ = ]       0 .debug_line    +7.38Ki  +4.9%
   +46% +3.78Ki .rodata        +3.78Ki   +46%
  [ = ]       0 .debug_abbrev  +2.25Ki  +2.6%
  [ = ]       0 .debug_str     +1.63Ki  +3.1%
   +15% +1.56Ki .eh_frame      +1.56Ki   +15%
  [ = ]       0 .debug_ranges     +880  +2.3%
  [ = ]       0 .symtab           +624  +4.2%
  [ = ]       0 .strtab           +548  +6.3%
  [ = ]       0 .debug_aranges    +416  +2.4%
  [ = ]       0 [Unmapped]        +416   +19%
  +6.7%    +152 .eh_frame_hdr     +152  +6.7%
   +37%     +16 [LOAD [RX]]        +16   +37%
   +55% +35.0Ki TOTAL           +101Ki  +7.3%

Except for some untreated UBs, I experienced no issues running
the sandbox SPL U-Boot.

> York

Best regards,
Eugeniu.

  reply	other threads:[~2018-08-20 21:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20  0:00 [U-Boot] [PATCH 0/8] Import Undefined Behavior Sanitizer Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 1/8] UBSAN: run-time undefined behavior sanity checker Eugeniu Rosca
2018-08-20  1:51   ` Tom Rini
2018-08-20 12:54     ` Eugeniu Rosca
2018-08-20 17:50       ` Tom Rini
2018-08-20 15:00   ` York Sun
2018-08-20 21:00     ` Eugeniu Rosca [this message]
2018-08-20  0:00 ` [U-Boot] [PATCH 2/8] mmc: Fix "left shift in type int" undefined behavior Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 3/8] armv8: mmu: " Eugeniu Rosca
2018-08-20  1:51   ` Tom Rini
2018-08-20 13:24     ` Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 4/8] pinctrl: renesas: " Eugeniu Rosca
2018-08-20  8:07   ` Marek Vasut
2018-08-20  8:07     ` Marek Vasut
2018-08-20 13:42     ` Eugeniu Rosca
2018-08-20 13:42       ` Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 5/8] net: phy: " Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 6/8] net: ravb: " Eugeniu Rosca
2018-08-20  8:05   ` Marek Vasut
2018-08-20  0:00 ` [U-Boot] [PATCH 7/8] mmc: Fix read-past-end-of-array " Eugeniu Rosca
2018-08-20  0:00 ` [U-Boot] [PATCH 8/8] hashtable: Fix zero-sized array " Eugeniu Rosca
2018-08-20  1:51   ` Tom Rini
2018-08-20  1:51 ` [U-Boot] [PATCH 0/8] Import Undefined Behavior Sanitizer Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180820210001.GA11615@x230 \
    --to=roscaeugeniu@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.