-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmklibkernel.sh
More file actions
executable file
·46 lines (37 loc) · 1.47 KB
/
mklibkernel.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.47 KB
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
#!/bin/bash
VMLINUX=~/Symbi-OS/linux/vmlinux
KERNELASM=kernel.s
OBJ=libkernel.o
LIB=libkernel.a
tmpfile=/tmp/$$_null.s
cat > $tmpfile <<EOF
.section .note.GNU-stack
EOF
blacklisted_symbols=(
"malloc" "free" "calloc" "realloc"
"strcpy" "strncpy" "strcat" "strncat" "strcmp" "strncmp" "strlen" "strchr" "strrchr" "strstr" "strtok" "sprintf" "sscanf" "atoi" "atol" "atof" "snprintf"
"fopen" "fclose" "fread" "fwrite" "fprintf" "fscanf" "fgets" "fputs" "fseek" "ftell" "rewind" "ferror" "feof"
"fork" "exec" "wait" "exit" "getpid" "getppid" "signal" "kill"
"dlopen" "dlsym" "dlclose" "dlerror"
"pthread_create" "pthread_join" "pthread_mutex_lock" "pthread_mutex_unlock" "pthread_cond_wait" "pthread_cond_signal"
"socket" "connect" "bind" "listen" "accept" "send" "recv"
"time" "localtime" "gmtime" "mktime" "strftime" "sleep"
"mount" "umount" "dir_list" "__fentry__"
"memset" "memcpy" "memmove" "memcmp" "memchr"
"strerror" "strncpy" "strncat" "strcspn" "strspn" "strpbrk" "strtod" "strtol" "strtoul" "strxfrm"
"isalpha" "isdigit" "isalnum" "islower" "isupper" "isspace" "ispunct" "isxdigit" "tolower" "toupper"
)
syms=""
nm $VMLINUX | while read val info sym; do
for symbol in "${blacklisted_symbols[@]}"; do
if [[ $sym == $symbol ]]; then
continue 2
fi
done
echo ".global $sym"
echo ".set $sym,0x$val"
done > $KERNELASM
echo ".section .note.GNU-stack" >> $KERNELASM
gcc -static -c $KERNELASM -o $OBJ
ar rcs $LIB $OBJ
rm $KERNELASM