-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup-bingcc
executable file
·80 lines (61 loc) · 2.86 KB
/
setup-bingcc
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
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
if [ -f /etc/debian_version ] ; then
LIBCPATH="/lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libm.so.6 /lib/x86_64-linux-gnu/librt.so.1 /lib/x86_64-linux-gnu/libpthread.so.0 /lib/x86_64-linux-gnu/libdl.so.2"
LIBC32PATH="/lib/i386-linux-gnu/libc.so.6 /lib/i386-linux-gnu/libm.so.6 /lib/i386-linux-gnu/librt.so.1 /lib/i386-linux-gnu/libpthread.so.0 /lib/i386-linux-gnu/libdl.so.2"
elif [ -f /etc/fedora-release ] ; then
LIBCPATH="/lib64/libc.so.6 /lib64/libm.so.6 /lib64/librt.so.1 /lib64/libpthread.so.0 /lib64/libdl.so.2"
LIBC32PATH="/lib/libc.so.6 /lib/libm.so.6 /lib/librt.so.1 /lib/libpthread.so.0 /lib/libdl.so.2"
elif [ -f /etc/redhat-release ] ; then
# Red Hat / CentOS / Sci Linux are the same as fedora
LIBCPATH="/lib64/libc.so.6 /lib64/libm.so.6 /lib64/librt.so.1 /lib64/libphread.so.0 /lib64/libdl.so.2"
LIBC32PATH="/lib/libc.so.6 /lib/libm.so.6 /lib/librt.so.1 /lib/libpthread.so.0 /lib/libdl.so.2"
elif [ -f /etc/arch-release ] ; then
# Arch Linux
LIBCPATH="/lib/libc.so.6 /lib/libm.so.6 /lib/librt.so.1 /lib/libphread.so.0 /lib/libdl.so.2"
LIBC32PATH="/usr/lib32/libc.so.6 /usr/lib32/libm.so.6 /usr/lib32/librt.so.1 /usr/lib32/libphread.so.0 /usr/lib32/libdl.so.2"
elif [ -e /etc/os-release ] ; then
. /etc/os-release
if [[ "$ID_LIKE" = *"suse"* ]] ; then
LIBCPATH="/lib64/libc.so.6 /lib64/libm.so.6 /lib64/librt.so.1 /lib64/libpthread.so.0 /lib64/libdl.so.2"
LIBC32PATH="/lib/libc.so.6 /lib/libm.so.6 /lib/librt.so.1 /lib/libpthread.so.0 /lib/libdl.so.2"
else
echo "Could not find settings for your distro (${ID_LIKE})."
exit 1
fi
else
echo "Could not find settings for your distro!"
exit 1
fi
if [ -z $1 ]
then
libcver="2.14"
else
libcver=$1
fi
#if [ -z $2 ]
#then
# stdcppver="3.4.11"
#else
# stdcppver=$2
#fi
source ./common-options.sh
echo "Generating files for glibc $libcver (native) ..."
./gensymoverride GLIBC "$libcver" $LIBCPATH > glibc_ver.h
echo "Generating files for glibc $libcver (32-bit) ..."
./gensymoverride GLIBC "$libcver" $LIBC32PATH > glibc_ver32.h
# Generate the version and wrapper files for glibc 2.33+
echo "#!/bin/bash" > version-options.sh
echo "#!/bin/bash" > version-options32.sh
if objdump -p $LIBCPATH | grep "GLIBC_2.28" > /dev/null ; then
echo "glibc 2.28+ detected, wrapping fcntl64"
echo 'bingcc_veropts="-Wl,--wrap=fcntl64 "' >> version-options.sh
echo 'bingcc_veropts="-Wl,--wrap=fcntl64 "' >> version-options32.sh
fi
if objdump -p $LIBCPATH | grep "GLIBC_2.33" > /dev/null ; then
echo "glibc 2.33 detected, building wrappers..."
echo 'bingcc_veropts+="-Wl,$bingcc_incpath/glibc_wrapper.o"' >> version-options.sh
gcc $bingcc_options -fPIC -include "glibc_ver.h" -c -o glibc_wrapper.o glibc_wrapper.c
echo 'bingcc_veropts+="-m32 -Wl,$bingcc_incpath/glibc_wrapper32.o"' >> version-options32.sh
gcc $bingcc_options -fPIC -m32 -include "glibc_ver32.h" -c -o glibc_wrapper32.o glibc_wrapper.c
fi
echo "Done!"