by voidptr » Mon Mar 12, 2007 7:24 pm
Hi,
If you are using PPC you should check out some of the changes made by the PaX team in September 2006, and using a new feature offered by gcc-4. They allow you to use PPC without the use of emuplt. It does however require your entire system to be built with the newer gcc-4. This action is probably only really feasible on something like gentoo which makes rebuilding your toolchain a bit easier... but still a long wait time :)
The reason why to do it is, you'll get a serious performance increase... as in a less that 1% change from vanilla as shown by the following time outputs from kernel compiles under pax and under vanilla.
pax-2.6.18-test4
2099.90user 188.97system 37:24.76elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (31major+7986444minor)pagefaults 0swaps
2105.04user 190.85system 37:11.33elapsed 102%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (16major+7986081minor)pagefaults 0swaps
2103.76user 192.32system 37:11.06elapsed 102%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (16major+7986800minor)pagefaults 0swaps
2.6.18-vanilla
2086.58user 197.04system 37:19.54elapsed 101%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (60major+7975605minor)pagefaults 0swaps
2093.63user 197.42system 37:06.98elapsed 102%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+7975667minor)pagefaults 0swaps
2096.61user 195.19system 37:03.96elapsed 103%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+7975665minor)pagefaults 0swaps
The downside to this all is that you wont get PIE/SSP support from the hardened profile under gentoo, since you'll need gcc-4 which is not supported by hardened gentoo yet. If you can live without it, fine :)
A summary from emails I sent earlier over time to various people:
So as some of you know I've been working on building ppc with msecure-plt that comes with gcc4. This is to facilitate in making the plt non-writable.
What I did was edit toolchain.eclass and toolchain-binutils.eclass to add "--enable-secureplt" to the configure arguments. (I could have used EXTRA_ECONF)
Also I used ~arch of binutils, 2.17, which seems to be required.
After that I don't know exactly what I did, but it comes down to bootstrapping, and perhaps handmerging binutils/gcc in case of trouble. (most notably the "assembler doesn't support msecure-plt" error.)
After this I've added msecure-plt to cflags in make.conf.
Emerge -e system and be a happy man, apart from the new automake-wrapper changes kicking in on random software: coreutils, dev-libs/popt and sys-process/time.
I am using kernel pax-linux-2.6.18-test4 without emuplt.
sanity ~ # uname -a
Linux sanity 2.6.18 #3 SMP Fri Sep 22 01:25:56 CEST 2006 ppc 7400, altivec supported GNU/Linux
sanity ~ # cat /etc/make.conf
CFLAGS="-O2 -mcpu=7400 -mtune=7400 -maltivec -mabi=altivec -fno-strict-aliasing -pipe -msecure-plt"
CHOST="powerpc-unknown-linux-gnu"
CXXFLAGS="${CFLAGS}"
FEATURES="nostrip buildpkg"
MAKEOPTS="-j3"
USE="crypt hardened nls pam pic readline ssl tcpd userlocales zlib -gtk -fortran -ldap -X"
sanity ~ # cat /proc/self/maps
00100000-00103000 r-xp 00100000 00:00 0 [vdso]
10000000-10005000 r-xp 00000000 03:05 2334423 /bin/cat
10014000-10015000 rw-p 00004000 03:05 2334423 /bin/cat
10015000-1003b000 rw-p 10015000 00:00 0 [heap]
31ee1000-31efe000 r-xp 00000000 03:05 82719 /lib/ld-2.4.so
31efe000-31eff000 rw-p 31efe000 00:00 0
31f0d000-31f0e000 r--p 0001c000 03:05 82719 /lib/ld-2.4.so
31f0e000-31f0f000 rw-p 0001d000 03:05 82719 /lib/ld-2.4.so
31f0f000-31f10000 rw-p 31f0f000 00:00 0
31f13000-3204f000 r-xp 00000000 03:05 82720 /lib/libc-2.4.so
3204f000-3205e000 ---p 0013c000 03:05 82720 /lib/libc-2.4.so
3205e000-32063000 r--p 0013b000 03:05 82720 /lib/libc-2.4.so
32063000-32064000 rw-p 00140000 03:05 82720 /lib/libc-2.4.so
32064000-32067000 rw-p 32064000 00:00 0
7ddf8000-7de0d000 rw-p 7ddf8000 00:00 0 [stack]
Note: On hardened-2.6.17-r1 the stack showed up as rwx, which was a bit silly.
Readelf -ed reports:
LOAD 0x000000 0x10000000 0x10000000 0x04468 0x04468 R E 0x10000
LOAD 0x004468 0x10014468 0x10014468 0x001d8 0x00320 RW 0x10000
02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .text .fini .rodata .eh_frame_hdr .eh_frame
03 .ctors .dtors .jcr .got2 .dynamic .got .plt .data .sdata .sbss .bss
You might see here that .plt is in RW, however the pax author told me it was not the actual plt, but probably something remaining for compatibility reasons. Under my circumstances nothing executes from it atleast :) The actually plt was apparently embedded in .text.