]> git.sesse.net Git - betaftpd/blob - strip-exec
Fixed a security problem where the custom snprintf() would always be used. Thanks...
[betaftpd] / strip-exec
1 #
2 # strip-exec: Try to build the smallest executable possible from the current
3 # source.
4 #
5
6 #
7 # Slack 3.4 standard gcc -- change if you need to, but gcc 2.7.2.3 typically
8 # generates much smaller code than egcs/pgcc
9 #
10 CC="gcc -V2.7.2.3 -bi486-unknown-linux-gnulibc1"
11 CFLAGS="-O2 -D__OPTIMIZE_SIZE__ -m486"
12 SECTIONS=".note.ABI-tag .gnu.version .rel.got .dtors .comment .note"
13 EXEC=betaftpd
14
15 rm -f *.s
16
17 #
18 # Warning
19 #
20 echo "***"
21 echo "*** WARNING: This script is intended for advanced users only, and"
22 echo "*** is highly experimental. It will most likely fail -- please do"
23 echo "*** not complain if it does."
24 echo "***"
25
26 #
27 # Compile
28 #
29 make distclean
30 CC="$CC" CFLAGS="$CFLAGS" ./configure --enable-dcache
31 make assembly-files
32
33 #
34 # -malign-* doesn't remove _all_ .align occurrences :-)
35 #
36 for FILE in *.s; do
37         echo "Removing alignment from $FILE..."
38         grep -v .align < $FILE > `basename $FILE .s`2.s
39         mv `basename $FILE .s`2.s $FILE
40 done
41
42 make betaftpd-from-assembly-files
43 strip --strip-all $EXEC
44
45 for SECTION in $SECTIONS; do
46         echo Stripping $SECTION...
47         strip --remove-section=$SECTION $EXEC
48 done
49
50 upx --best betaftpd
51 ls -l betaftpd
52