ANDROID: mnt: Propagate remount correctly
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / scripts / kaslr_patch.sh
1 #!/bin/sh
2 # Based on the relocatable vmlinux file and offset create the
3 # new vmlinux and System.map file. New vmlinux and System.map is
4 # intend to be used by debugging tools to retrieve the actual
5 # addresses of symbols in the kernel.
6 #
7 # Usage
8 # mksysmap vmlinux-old offset
9
10 # Author : Jia Ma (jia.ma@samsung.com)
11 # Created on : 21 Sep 2015
12 # Copyright (c) Samsung Electronics 2015
13
14 if test $# -ne 2; then
15 echo "Usage: $0 vmlinux offset"
16 exit 1
17 fi
18
19
20 vmlinux=$1
21 offset=$2
22
23 if [[ -z "$offset" || -z "$vmlinux" ]]; then
24 echo "$0 : variable not set"
25 exit 1
26 fi
27
28 if [[ ! -f $vmlinux ]]; then
29 echo "$vmlinux file not exist!"
30 exit 1
31 fi
32
33 NM=$ARM_TOOLCHAIN-nm
34 OBJCOPY=$ARM_TOOLCHAIN-objcopy
35
36 if [[ -z "$ARM_TOOLCHAIN" ]]; then
37 echo "Please specify ARM toolchain"
38 exit 1
39 fi
40
41 echo "+Patching System.map --> System.map.patched"
42 ### generate runtime System.map file¡¡###
43 $OBJCOPY --adjust-vma $offset $vmlinux vmlinux.tmp 2>/dev/null
44 $NM -n vmlinux.tmp | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > System.map.patched
45 rm -f vmlinux.tmp
46
47 echo "+Patching $vmlinux -->vmlinux.patched"
48 # following simply change the vmlinux from DYN type to EXEC type
49 # to avoid the JTag load the dyn symbol into the system: e.g. there will be 2 start_kernel in the JTag symbol list, 1 from SYMBOL table, 1 from RELO section
50 if [[ ! -f "elfedit" ]]; then
51 echo "Can find elfedit"
52 exit 1
53 fi
54
55 cp vmlinux vmlinux.patched
56 elfedit --output-type exec vmlinux.patched
57
58 echo "+Done"
59
60
61
62
63
64