1From e3d8ca89514ce7bb26b5b01b6a0fc232a27bac7e Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
3Date: Tue, 11 Nov 2014 03:24:19 +0100
4Subject: [PATCH 1/8] Add Haiku to the list of supported OSes
5
6---
7 build | 17 ++++++++++-------
8 1 file changed, 10 insertions(+), 7 deletions(-)
9
10diff --git a/build b/build
11index 8b5da45..8685601 100755
12--- a/build
13+++ b/build
14@@ -156,14 +156,17 @@ SYSNAME=`uname -s 2>/dev/null`
15 
16 test "$SYSNAME" = "" && SYSNAME="unknown"
17 
18-if [ ! "$SYSNAME" = "Linux" ]; then
19-  echo "$SYSNAME is not supported!"
20-  echo "[-] I do not support your OS yet. Please consult documentation."
21-  echo
22-  exit 1
23-fi
24+case "$SYSNAME" in
25+  Linux|Haiku) ;;
26+  *)
27+    echo "$SYSNAME is not supported!"
28+    echo "[-] I do not support your OS yet. Please consult documentation."
29+    echo
30+    exit 1
31+    ;;
32+esac
33 
34-echo "Linux (supported)"
35+echo "$SYSNAME (supported)"
36 
37 echo -n "[+] Processor check: "
38 
39-- 
401.8.3.4
41
42
43From 099cc965989d04b239bc8141d5ee31016c7be243 Mon Sep 17 00:00:00 2001
44From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
45Date: Tue, 11 Nov 2014 03:28:01 +0100
46Subject: [PATCH 2/8] Make BePC recognized as i586
47
48---
49 build | 1 +
50 1 file changed, 1 insertion(+)
51
52diff --git a/build b/build
53index 8685601..d7a4045 100755
54--- a/build
55+++ b/build
56@@ -172,6 +172,7 @@ echo -n "[+] Processor check: "
57 
58 PROC=`uname -m 2>/dev/null`
59 test "$PROC" = "" && PROC="unknown"
60+test "$PROC" = "BePC" && PROC="i586"
61 PROCOK=`echo $PROC|grep ^i.86\$ 2>/dev/null`
62 
63 if [ "$PROCOK" = "" ]; then
64-- 
651.8.3.4
66
67
68From ce9115de76f20f7529f8861f829c67384ed19ae5 Mon Sep 17 00:00:00 2001
69From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
70Date: Tue, 11 Nov 2014 03:36:31 +0100
71Subject: [PATCH 3/8] Force glibc version detection on Haiku
72
73Haiku has a mix of glibc versions anyway...
74---
75 build | 7 ++++++-
76 1 file changed, 6 insertions(+), 1 deletion(-)
77
78diff --git a/build b/build
79index d7a4045..e5af03c 100755
80--- a/build
81+++ b/build
82@@ -186,7 +186,12 @@ echo "$PROC (supported)"
83 
84 echo -n "[+] GNU C library version: "
85 
86-LIBCVER=`/lib/libc.so.6|awk -F'version ' '{print $2}'|awk -F, '{print $1}'|head -1`
87+LIBCVER=`/lib/libc.so.6 2>/dev/null|awk -F'version ' '{print $2}'|awk -F, '{print $1}'|head -1`
88+
89+if [ "$LIBCVER" = "" -a "$SYSNAME" = "Haiku" ]; then
90+	# currently Haiku uses a mix of several glibc versions inside libroot...
91+	LIBCVER="2.3.2"
92+fi
93 
94 if [ "$LIBCVER" = "" ]; then
95   echo "cannot determine libc version!"
96-- 
971.8.3.4
98
99
100From eea4d5c68ee699a7b13bc6c96b2b7bca0370eb68 Mon Sep 17 00:00:00 2001
101From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
102Date: Tue, 11 Nov 2014 03:45:04 +0100
103Subject: [PATCH 4/8] Test for several candidates for libc
104
105Including libroot for Haiku.
106We also test for 64 or 32bit versions on Linux.
107---
108 build | 16 ++++++++++++----
109 1 file changed, 12 insertions(+), 4 deletions(-)
110
111diff --git a/build b/build
112index e5af03c..a1785ef 100755
113--- a/build
114+++ b/build
115@@ -186,7 +186,15 @@ echo "$PROC (supported)"
116 
117 echo -n "[+] GNU C library version: "
118 
119-LIBCVER=`/lib/libc.so.6 2>/dev/null|awk -F'version ' '{print $2}'|awk -F, '{print $1}'|head -1`
120+LIBCS="/lib/libc.so.6
121+/lib/x86_64-linux-gnu/libc.so.6
122+/lib64/libc.so.6
123+/lib32/libc.so.6
124+/system/develop/lib/libroot.so"
125+for f in $LIBCS; do test -f "$f" && LIBCPATH="$f"; done
126+test "$LIBCPATH" = "" && LIBCPATH="unknown"
127+
128+LIBCVER=`$LIBCPATH 2>/dev/null|awk -F'version ' '{print $2}'|awk -F, '{print $1}'|head -1`
129 
130 if [ "$LIBCVER" = "" -a "$SYSNAME" = "Haiku" ]; then
131 	# currently Haiku uses a mix of several glibc versions inside libroot...
132@@ -241,12 +249,12 @@ fi
133 
134 echo -n "[+] GNU libc binary test: "
135 
136-STRILI=`file -L /lib/libc.so.6 2>/dev/null|grep 'not strip'`
137-GENLI=`file -L /lib/libc.so.6 2>/dev/null|grep 'strip'`
138+STRILI=`file -L $LIBCPATH 2>/dev/null|grep 'not strip'`
139+GENLI=`file -L $LIBCPATH 2>/dev/null|grep 'strip'`
140 
141 if [ "$GENLI" = "" ]; then
142   echo "failed!"
143-  echo "[-] I cannot read your /lib/libc.so.6 (or your 'file' utility"
144+  echo "[-] I cannot read your $LIBCPATH (or your 'file' utility"
145   echo "    is broken). Please fix it. Yes, you need libc6, yes, I need"
146   echo "    to be able to read it. Thanks =)"
147   echo
148-- 
1491.8.3.4
150
151
152From a3195adb5f862452d542fba34f4af021e6c93028 Mon Sep 17 00:00:00 2001
153From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
154Date: Tue, 11 Nov 2014 03:59:57 +0100
155Subject: [PATCH 5/8] Test for several candidates for crt file
156
157---
158 build | 14 +++++++++++---
159 1 file changed, 11 insertions(+), 3 deletions(-)
160
161diff --git a/build b/build
162index a1785ef..4f70ddd 100755
163--- a/build
164+++ b/build
165@@ -283,12 +283,20 @@ fi
166 
167 echo -n "[+] GCC crt code binary test: "
168 
169-STRILI=`file -L /usr/lib/crt1.o 2>/dev/null|grep 'not strip'`
170-GENLI=`file -L /usr/lib/crt1.o 2>/dev/null|grep 'strip'`
171+CRTS="/usr/lib/crt1.o
172+/usr/lib/x86_64-linux-gnu/crt1.o
173+/usr/lib64/crt1.o
174+/usr/lib32/crt1.o
175+/system/develop/lib/crti.o"
176+for f in $CRTS; do test -f "$f" && CRTPATH="$f"; done
177+test "$CRTPATH" = "" && CRTPATH="unknown"
178+
179+STRILI=`file -L $CRTPATH 2>/dev/null|grep 'not strip'`
180+GENLI=`file -L $CRTPATH 2>/dev/null|grep 'strip'`
181 
182 if [ "$GENLI" = "" ]; then
183   echo "failed!"
184-  echo "[-] I cannot read your /usr/lib/crt1.o (or your 'file' utility"
185+  echo "[-] I cannot read your $CRTPATH (or your 'file' utility"
186   echo "    is broken). Please fix it. Thanks =)"
187   echo
188   exit 1
189-- 
1901.8.3.4
191
192
193From 15bff0261495f62ec165fddc60c362e8d1f80c9b Mon Sep 17 00:00:00 2001
194From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
195Date: Tue, 11 Nov 2014 04:05:06 +0100
196Subject: [PATCH 6/8] Test for several candidates for runtime loader
197
198---
199 build | 13 ++++++++++---
200 1 file changed, 10 insertions(+), 3 deletions(-)
201
202diff --git a/build b/build
203index 4f70ddd..a462889 100755
204--- a/build
205+++ b/build
206@@ -324,12 +324,19 @@ fi
207 
208 echo -n "[+] GNU libc linker test: "
209 
210-STRILI=`file -L /lib/ld-linux.so.2 2>/dev/null|grep 'not strip'`
211-GENLI=`file -L /lib/ld-linux.so.2 2>/dev/null|grep 'strip'`
212+LDRS="/lib/ld-linux.so.2
213+/lib/ld-linux.so.2
214+/lib32/ld-linux.so.2
215+/system/runtime_loader"
216+for f in $LDRS; do test -f "$f" && LDRPATH="$f"; done
217+test "$LDRPATH" = "" && LDRPATH="unknown"
218+
219+STRILI=`file -L $LDRPATH 2>/dev/null|grep 'not strip'`
220+GENLI=`file -L $LDRPATH 2>/dev/null|grep 'strip'`
221 
222 if [ "$GENLI" = "" ]; then
223   echo "failed!"
224-  echo "[-] I cannot read your /lib/ld-linux.so.2 (or your 'file' utility"
225+  echo "[-] I cannot read your $LDRPATH (or your 'file' utility"
226   echo "    is broken). Please fix it. Yes, you need libc6, yes, I need"
227   echo "    to be able to read it. Thanks =)"
228   echo
229-- 
2301.8.3.4
231
232
233From d3d7280f6eda2fb0a81aac8d14ec0cb29d90df0e Mon Sep 17 00:00:00 2001
234From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
235Date: Tue, 11 Nov 2014 04:32:09 +0100
236Subject: [PATCH 7/8] Force running until breakpoint to force loading shared
237 libs
238
239Else gdb can't read memory on Haiku
240---
241 build | 1 +
242 1 file changed, 1 insertion(+)
243
244diff --git a/build b/build
245index a462889..cbe8e79 100755
246--- a/build
247+++ b/build
248@@ -416,6 +416,7 @@ fi
249 echo -n "[+] Library mapping address: "
250 
251 echo "break main" >.testerr 2>/dev/null
252+echo "run" >>.testerr 2>/dev/null
253 echo "x/2w getuid" >>.testerr 2>/dev/null
254 echo "x/10w __do_global_ctors_aux" >>.testerr 2>/dev/null
255 echo "x/10w __do_global_ctors_aux+1" >>.testerr 2>/dev/null
256-- 
2571.8.3.4
258
259
260From 037748ff2cb8320358a7a8381c254fdfdd5a9e26 Mon Sep 17 00:00:00 2001
261From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
262Date: Tue, 11 Nov 2014 04:42:45 +0100
263Subject: [PATCH 8/8] Add breakpoint and run when dumping PLT report
264
265So we do get the wanted disass.
266---
267 build | 4 +++-
268 1 file changed, 3 insertions(+), 1 deletion(-)
269
270diff --git a/build b/build
271index cbe8e79..43473da 100755
272--- a/build
273+++ b/build
274@@ -585,7 +585,9 @@ else
275     echo >>PLT.txt 2>/dev/null
276     gcc -v >>PLT.txt 2>&1
277     echo >>PLT.txt 2>/dev/null   
278-    echo "disass getuid" >.testerr 2>/dev/null
279+    echo "break main" >.testerr 2>/dev/null
280+    echo "run" >.testerr 2>/dev/null
281+    echo "disass getuid" >>.testerr 2>/dev/null
282     gdb -batch -x .testerr ./.testme >>PLT.txt 2>&1
283     rm -f .testerr .testme .testme.c
284     ls -l PLT.txt
285-- 
2861.8.3.4
287
288