Re: same prog, different sizes
Jorge Almeida <[email protected]> Mon, 22 Sep 2014 08:54:30 +0100
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <CAKpSnp+zDqSGC94ntiXmd1QVehVEXYyo8nCnjrzMxMmrBhZmyg@mail.gmail.com> |
On Mon, Sep 22, 2014 at 2:12 AM, Bela Lubkin <[email protected]> wrote: > Jorge Almeida and Steven Honeyman wrote: > > Steven>>> On your Gentoo i3... am I right in thinking you have a hardened= /PaX > Steven>>> build environment? > > Jorge>> Nope. It's a standard profile, no fancy > Jorge>> stuff whatsoever (box is used to backups and compiling some stuff= , > Jorge>> used mainly via ssh, not even X installed) > > Steven> Oh well, worth a guess! I just noticed this strange program heade= r > Steven> entry (only in the i3 version), which google says has something t= o do > Steven> with PaX. They are both the same binary really, but the i3 has a = few > Steven> kb of padding on the end (just empty space). I have no idea why; = but > Steven> I'm sure someone will be able to help you. > > I think Steven's right. For instance, see: > > https://blogs.gentoo.org/mgorny/2014/06/23/inlining-marchnative-for-di= stcc/ > > which says (about flags being bandied about by `gcc`): > > " You may also notice -fstack-protector there. This is because nowadays > " Gentoo enables it by default. > > -- the 2nd sentence links to: > > http://sources.gentoo.org/gitweb/?p=3Dproj/gentoo-news.git;a=3Dblob;f= =3D2014/2014-06-15-gcc48_ssp/2014-06-15-gcc48_ssp.en.txt > > which certainly seems to support the claim. This looked promising. I tried it with -fno-stack-protector, but there is no difference. I also added -fno-pie, still no joy. > > The two binaries contain .comment sections with "GCC: (GNU) 4.8.2" and > "GCC: (Gentoo 4.8.3 p1.1, pie-0.5.9) 4.8.3"; in which I *think* the > "pie-0.5.9" is another hint about hardening. $ eselect profile list Available profile symlink targets: [1] default/linux/x86/13.0 * [2] default/linux/x86/13.0/selinux [3] default/linux/x86/13.0/desktop [4] default/linux/x86/13.0/desktop/gnome [5] default/linux/x86/13.0/desktop/gnome/systemd [6] default/linux/x86/13.0/desktop/kde [7] default/linux/x86/13.0/desktop/kde/systemd [8] default/linux/x86/13.0/developer [9] hardened/linux/x86 [10] hardened/linux/x86/selinux [11] hardened/linux/musl/x86 [12] default/linux/uclibc/x86 [13] hardened/linux/uclibc/x86 Maybe some hardening features are somehow pulled when compiling with -stati= c? Just in case this contains some usefull info: $ gcc -### -march=3Dnative -x c - Using built-in specs. COLLECT_GCC=3D/usr/i686-pc-linux-gnu/gcc-bin/4.8.3/gcc COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/lto-wrapper Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.8.3/work/gcc-4.8.3/configure --host=3Di686-pc-linux-gnu --build=3Di686-pc-linux-gnu --prefix=3D/usr --bindir=3D/usr/i686-pc-linux-gnu/gcc-bin/4.8.3 --includedir=3D/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include --datadir=3D/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3 --mandir=3D/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3/man --infodir=3D/usr/share/gcc-data/i686-pc-linux-gnu/4.8.3/info --with-gxx-include-dir=3D/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/include/g++-v= 4 --with-python-dir=3D/share/gcc-data/i686-pc-linux-gnu/4.8.3/python --enable-languages=3Dc,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --disable-nls --enable-checking=3Drelease --with-bugurl=3Dhttps://bugs.gentoo.org/ --with-pkgversion=3D'Gentoo 4.8.3 p1.1, pie-0.5.9' --enable-libstdcxx-time --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --disable-multilib --disable-altivec --disable-fixed-point --with-arch=3Di686 --enable-targets=3Dall --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --enable-lto --without-cloog Thread model: posix gcc version 4.8.3 (Gentoo 4.8.3 p1.1, pie-0.5.9) COLLECT_GCC_OPTIONS=3D'-march=3Dnative' /usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/cc1 -quiet - "-march=3Dcore-avx2" -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt --param "l1-cache-size=3D32" --param "l1-cache-line-size=3D64" --param "l2-cache-size=3D3072" "-mtune=3Dcore-avx2" -quiet -dumpbase - -auxbase - -fstack-protector -o /tmp/ccxOOjI3.s COLLECT_GCC_OPTIONS=3D'-march=3Dnative' /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../i686-pc-linux-gnu/bin/as --32 -o /tmp/ccm6d0Pe.o /tmp/ccxOOjI3.s COMPILER_PATH=3D/usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/:/usr/libexec/gcc/= i686-pc-linux-gnu/4.8.3/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i= 686-pc-linux-gnu/4.8.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-p= c-linux-gnu/4.8.3/../../../../i686-pc-linux-gnu/bin/ LIBRARY_PATH=3D/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/:/usr/lib/gcc/i686-pc-l= inux-gnu/4.8.3/../../../../i686-pc-linux-gnu/lib/../lib/:/usr/lib/gcc/i686-= pc-linux-gnu/4.8.3/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/= gcc/i686-pc-linux-gnu/4.8.3/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc= /i686-pc-linux-gnu/4.8.3/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS=3D'-march=3Dnative' /usr/libexec/gcc/i686-pc-linux-gnu/4.8.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../lib/crt1.o /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../lib/crti.o /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/4.8.3 -L/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../i686-pc-linux-gnu/lib/..= /lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../.. /tmp/ccm6d0Pe.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/4.8.3/../../../../lib/crtn.o Thanks, Jorge