-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpts-tcc-0.9.25-compile.sh
executable file
·69 lines (63 loc) · 2.98 KB
/
pts-tcc-0.9.25-compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/bash --
#
# Build pts-tcc using uClibc.
# by pts@fazekas.hu at Sun Nov 1 12:12:16 CET 2009
#
# To create the patch:
# for F in tcc-0.9.25/*.{c,h}.orig; do diff -u -U10 "$F" "${F%.orig}"; done >tccb/pts-tcc-0.9.25.patch
# Using uClibc 0.9.30.1.
#
set -ex
UCLIBC_USR="${UCLIBC_USR:-/usr/i386-linux-uclibc/usr}"
test -f "$UCLIBC_USR/lib/crt1.o"
test -f "$UCLIBC_USR/lib/crti.o"
test -f "$UCLIBC_USR/lib/crtn.o"
test -f "$UCLIBC_USR/lib/libc.a"
test -f "$UCLIBC_USR/lib/libm.a"
test -f "$UCLIBC_USR/lib/libcrypt.a"
test -f "$UCLIBC_USR/lib/libutil.a"
type -p upx.pts || type -p upx
type -p gcc
type -p ld
type -p perl
# Original download URL: http://download.savannah.nongnu.org/releases/tinycc/tcc-0.9.25.tar.bz2
test -f tcc-0.9.25.tar.bz2 || wget https://github.com/pts/pts-tcc/releases/download/tcc/tcc-0.9.25.tar.bz2
test -f tcc-0.9.25.tar.bz2
test -f pts-tcc-0.9.25.patch || wget http://pts-mini-gpl.googlecode.com/svn/trunk/pts-tcc/pts-tcc-0.9.25.patch
test pts-tcc-0.9.25.patch
bash ./i386-uclibc-gcc.c # create i386-uclibc-gcc
CC="$PWD/i386-uclibc-gcc"
rm -rf tcc-0.9.25
tar xjf tcc-0.9.25.tar.bz2
patch -p0 <pts-tcc-0.9.25.patch
(cd tcc-0.9.25 && ./configure --cc="$CC -static" --extra-cflags='-DCONFIG_TCC_STATIC') || exit "?"
echo "CONFIG_NOLDL=yes" >>tcc-0.9.25/config.mak
(cd tcc-0.9.25 && make libtcc1.a) || exit "$?"
rm -rf tcclibc
mkdir tcclibc
#-rw-r--r-- 1 pts eng 1233128 Nov 27 2010 libc.a
#-rw-r--r-- 1 pts eng 214376 Nov 27 2010 libm.a
#-rw-r--r-- 1 pts eng 16386 Nov 27 2010 libcrypt.a
#-rw-r--r-- 1 pts eng 12024 Nov 27 2010 librt.a
#-rw-r--r-- 1 pts eng 7668 Nov 27 2010 libutil.a
# c,m: 329484 compressed
# c,m,crypt,util: 336732 compressed
for F in "$UCLIBC_USR"/lib/lib{c,m,crypt,util}.a; do
ls -l "$F"
(cd tcclibc && ar x "$F") || exit "$?"
done
(cd tcclibc && ar x ../tcc-0.9.25/libtcc1.a) || exit "$?"
rm -f tcclibc.a # ar cr doesn't remove the file.
(cd tcclibc && ar cr ../tcclibc.a *.o)
ls -l tcclibc.a
for F in tcclibc.a "$UCLIBC_USR"/lib/{crt1.o,crti.o,crtn.o}; do
G="${F##*/}"
export NAME="data_${G%.*}"
perl -e '$_=join("",<STDIN>); my$L=length; s@([^-+/\w])@sprintf"\\%03o",ord$1@ge; print".globl $ENV{NAME}\n.section .data\n.align 4\n.size $ENV{NAME},$L\n$ENV{NAME}:\n.string \"$_\\001\"\n"' <"$F"
done >tcc-0.9.25/libcdata.s
# make tcc does: /tmp/tccb/i386-uclibc-gcc -static -o tcc tcc.c -DTCC_TARGET_I386 -DCONFIG_TCC_STATIC -g -Wall -fno-strict-aliasing -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0 -Wno-pointer-sign -Wno-sign-compare -D_FORTIFY_SOURCE=0 -lm
(cd tcc-0.9.25 && $CC -static -o ../pts-tcc.uncompressed tcc.c libcdata.s -DTCC_TARGET_I386 -O2 -s -Wall -fno-strict-aliasing -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0 -Wno-pointer-sign -Wno-sign-compare -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -lm -DCONFIG_TCC_STATIC -Wno-unused-but-set-variable -Wno-array-bounds) || exit "$?"
ls -l pts-tcc.uncompressed
cp -f pts-tcc.uncompressed pts-tcc
upx.pts --best pts-tcc || upx --best pts-tcc
./elfosfix.pl pts-tcc pts-tcc.uncompressed