forked from shellphish/how2heap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glibc_run.sh
executable file
·57 lines (47 loc) · 1.09 KB
/
glibc_run.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
#!/bin/bash
VERSION="./glibc_versions"
DIR_TCACHE='tcache'
DIR_HOST='x64'
GLIBC_VERSION=''
TARGET=''
# Handle arguments
function show_help {
echo "Usage: $0 <version> <target> [-h] [-disable-tcache] [-i686]"
}
if [[ $# < 2 ]]; then
show_help
exit 1
fi
GLIBC_VERSION=$1
TARGET=$2
while :; do
case $3 in
-h|-\?|--help)
show_help
exit
;;
-disable-tcache)
DIR_TCACHE='notcache'
;;
-i686)
DIR_HOST='i686'
;;
'')
break
;;
esac
shift
done
OUTPUT_DIR="$VERSION/$GLIBC_VERSION/${DIR_HOST}_${DIR_TCACHE}/lib"
# Get glibc source
if [ ! -e "$OUTPUT_DIR/libc-$GLIBC_VERSION.so" ]; then
echo "Error: Glibc-version wasn't build. Build it first:"
echo "./build_glibc $GLIBC_VERSION <#make-threads"
fi
curr_interp=$(readelf -l "$TARGET" | grep 'Requesting' | cut -d':' -f2 | tr -d ' ]')
target_interp="$OUTPUT_DIR/ld-$GLIBC_VERSION.so"
if [[ $curr_interp != $target_interp ]];
then
patchelf --set-interpreter "$target_interp" "$TARGET"
fi
"$TARGET"