Re: [PATCH] constify static arrays of strings

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



On 30 Sep 2021 20:10, Thorsten Glaser wrote:
> On Thu, 30 Sep 2021, Mike Frysinger wrote:
> > By marking these static & the array itself as const, the data is moved
> 
> > -	static const char *rhosts_files[] = {".shosts", ".rhosts", NULL};
> > +	static const char * const rhosts_files[] = {".shosts", ".rhosts", NULL};
> 
> Is this really true nowadays? I thought with PIC/PIE, these are
> relocations and therefore neither constant nor shared/shareable,
> at least for some architectures (i386?).

i assume `size` doesn't lie to me ;).  on my current Linux build:

### sftp-server.o
function                                             old     new   delta
static.status_messages                                 -      80     +80
send_status                                          600     627     +27
status_to_message                                    278       -    -278
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 107/-278)         Total: -171 bytes

### sshconnect2.o
function                                             old     new   delta
static.suffixes                                        -      24     +24
sign_and_send_pubkey                                3838    3758     -80
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 24/-80)            Total: -56 bytes

### ssh-keygen.o
function                                             old     new   delta
static.suffixes                                        -      24     +24
main                                               14558   14522     -36
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 24/-36)            Total: -12 bytes

### utf8.o
function                                             old     new   delta
static.vars                                            -      32     +32
msetlocale                                           401     324     -77
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 32/-77)            Total: -45 bytes

you can see it shifting between writable sections to read-only sections too.

Gentoo gcc has PIE enabled by default.
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-11.2.0/work/gcc-11.2.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/11.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include/g++-v11 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/python --enable-languages=c,c++,go,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.2.0 p1' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=mx32,m32,m64 --disable-fixed-point --with-abi=m64 --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (Gentoo 11.2.0 p1) 
-mike

Attachment: signature.asc
Description: PGP signature

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux