Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
#* Checking the C compiler fortify default value (only affects >= gcc-4.5) */ |
3 |
|
4 |
cflags= |
5 |
|
6 |
#*---------------------------------------------------------------------*/ |
7 |
#* We parse the arguments */ |
8 |
#*---------------------------------------------------------------------*/ |
9 |
while : ; do |
10 |
case $1 in |
11 |
"") |
12 |
break;; |
13 |
|
14 |
--cflags=*|-cflags=*) |
15 |
cflags="`echo $1 | sed 's/^[-a-z]*=//'`";; |
16 |
|
17 |
-*) |
18 |
echo "Unknown option \"$1\", ignored" >&2;; |
19 |
esac |
20 |
shift |
21 |
done |
22 |
|
23 |
file=$TMP/actest$USER |
24 |
aout=$TMP/Xactest$USER |
25 |
|
26 |
#*---------------------------------------------------------------------*/ |
27 |
#* compile */ |
28 |
#*---------------------------------------------------------------------*/ |
29 |
compile="$CC $cflags $file.c -o $aout >/dev/null" |
30 |
|
31 |
#*---------------------------------------------------------------------*/ |
32 |
#* The test C file */ |
33 |
#*---------------------------------------------------------------------*/ |
34 |
if( test -f $file.c ); then |
35 |
rm -f $file.c || exit $? |
36 |
fi |
37 |
|
38 |
#*---------------------------------------------------------------------*/ |
39 |
#* Test */ |
40 |
#*---------------------------------------------------------------------*/ |
41 |
cat > $file.c <<EOF |
42 |
#include <stdlib.h> |
43 |
#include <stdio.h> |
44 |
|
45 |
#ifndef _FORTIFY_SOURCE |
46 |
#define _FORTIFY_SOURCE 0 |
47 |
#endif |
48 |
|
49 |
int main (void) |
50 |
{ |
51 |
printf( "%d\n", _FORTIFY_SOURCE); |
52 |
return EXIT_SUCCESS; |
53 |
} |
54 |
EOF |
55 |
|
56 |
if eval "$BUILDSH $compile"; then |
57 |
\rm -f $file.* |
58 |
eval "$HOSTSH $aout" |
59 |
ret_code=$? |
60 |
\rm -f $aout |
61 |
exit $ret_code |
62 |
fi |
63 |
|
64 |
echo "0" |
65 |
exit 0 |