[REFACTOR] create empty swap_uprobe module
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 7 Mar 2013 08:28:38 +0000 (12:28 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 7 Mar 2013 08:28:38 +0000 (12:28 +0400)
uprobe/Kbuild [new file with mode: 0644]
uprobe/Makefile.am [new file with mode: 0644]
uprobe/swap_uprobe.sh [new file with mode: 0755]
uprobe/swap_uprobes.c [new file with mode: 0644]

diff --git a/uprobe/Kbuild b/uprobe/Kbuild
new file mode 100644 (file)
index 0000000..d2f2fc8
--- /dev/null
@@ -0,0 +1,4 @@
+EXTRA_CFLAGS := $(extra_cflags)
+
+obj-m := swap_uprobe.o
+swap_uprobe-y := swap_uprobes.o
diff --git a/uprobe/Makefile.am b/uprobe/Makefile.am
new file mode 100644 (file)
index 0000000..f592a45
--- /dev/null
@@ -0,0 +1,26 @@
+board_opt = -DBOARD_@BOARD@
+target_kernel_src = @KERNEL@
+target_arch = @ARCH@
+uprobes_module_dir = $(realpath $(top_srcdir)/src/modules/uprobe)
+module_name = swap_uprobe
+cross_compiler = $(subst gcc,,$(CC))
+
+inlude_opt = -I$(realpath $(top_srcdir)/src/modules/ksyms)
+extra_cflags = "$(inlude_opt) $(android_opt) $(board_opt)"
+
+all-local:
+       rm -rf $(top_srcdir)/src/modules/uprobe/arch/asm && $(LN_S) asm-${target_arch} $(top_srcdir)/src/modules/uprobe/arch/asm
+       $(MAKE) CROSS_COMPILE=$(cross_compiler) ARCH=$(target_arch) extra_cflags=$(extra_cflags) \
+               $(AM_MAKEFLAGS) -C $(target_kernel_src) M=$(uprobes_module_dir) modules
+
+       echo "generate data for version patching <$(OBJDUMP)><$(READELF)>"
+       PATH=$(PATH) $(top_srcdir)/src/modules/driver/patchko.sh -g $(uprobes_module_dir)/$(module_name).ko $(OBJDUMP) $(READELF)
+
+clean-local:
+       $(MAKE) CROSS_COMPILE=$(cross_compiler) ARCH=$(target_arch) $(AM_MAKEFLAGS) -C $(target_kernel_src) M=$(uprobes_module_dir) clean
+
+install-exec-local:
+       install -m 644 $(uprobes_module_dir)/$(module_name).ko $(prefix)
+       install -m 644 $(uprobes_module_dir)/$(module_name).ko.addr $(prefix)
+
+       if [ "$(android)" != "yes" ] ; then install -m 755 $(uprobes_module_dir)/$(module_name).sh $(prefix) ; fi
diff --git a/uprobe/swap_uprobe.sh b/uprobe/swap_uprobe.sh
new file mode 100755 (executable)
index 0000000..5253ff8
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+SWAP_UPROBE=swap_uprobe
+
+# Check for running module in /proc/modules
+RUNNING=`sed "/${SWAP_UPROBE}/ ! d" /proc/modules`
+
+if [ "${RUNNING}" = "" ]; then
+    ./bin/insmod.sh ${SWAP_UPROBE}.ko
+    if [ $? -ne 0 ]; then
+            echo "Error: unable to load SWAP UProbe!"
+           exit 1
+    fi
+else
+       echo "SWAP Uprobe is already running!"
+       exit 1
+fi
diff --git a/uprobe/swap_uprobes.c b/uprobe/swap_uprobes.c
new file mode 100644 (file)
index 0000000..cd52983
--- /dev/null
@@ -0,0 +1,15 @@
+#include <linux/module.h>
+
+static int __init init_uprobes(void)
+{
+       return 0;
+}
+
+static void __exit exit_uprobes(void)
+{
+}
+
+module_init(init_uprobes);
+module_exit(exit_uprobes);
+
+MODULE_LICENSE ("GPL");