lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Sep 2017 01:09:46 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     linux-kernel@...r.kernel.org
Cc:     kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] lib/lz4: make arrays static const, reduces object code
 size

Le 22/09/2017 à 00:19, Colin King a écrit :
> From: Colin Ian King <colin.king@...onical.com>
>
> Don't populate the read-only arrays dec32table and dec64table on the
> stack, instead make them both static const.  Makes the object code
> smaller by over 10K bytes:
10k? Wouaouh! This is way much more than what you usually win with such 
patches.
I assume we must thanks FORCE_INLINE in this case.
Nice catch!

CJ

> Before:
>     text	   data	    bss	    dec	    hex	filename
>    31500	      0	      0	  31500	   7b0c	lib/lz4/lz4_decompress.o
>
> After:
>     text	   data	    bss	    dec	    hex	filename
>    20237	    176	      0	  20413	   4fbd	lib/lz4/lz4_decompress.o
>
> (gcc version 7.2.0 x86_64)
>
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
>   lib/lz4/lz4_decompress.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
> index bd3574312b82..141734d255e4 100644
> --- a/lib/lz4/lz4_decompress.c
> +++ b/lib/lz4/lz4_decompress.c
> @@ -85,8 +85,8 @@ static FORCE_INLINE int LZ4_decompress_generic(
>   	const BYTE * const lowLimit = lowPrefix - dictSize;
>   
>   	const BYTE * const dictEnd = (const BYTE *)dictStart + dictSize;
> -	const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
> -	const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
> +	static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 };
> +	static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 };
>   
>   	const int safeDecode = (endOnInput == endOnInputSize);
>   	const int checkOffset = ((safeDecode) && (dictSize < (int)(64 * KB)));



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ