EXTRA_CFLAGS := $(extra_cflags)
obj-m := swap_ksyms.o
+swap_ksyms-y := ksyms_module.o
ifeq ($(CONFIG_KALLSYMS),y)
- swap_ksyms-y := ksyms.o
+ swap_ksyms-y += ksyms.o
else
- swap_ksyms-y := no_ksyms.o
+ swap_ksyms-y += no_ksyms.o
endif
#include "ksyms.h"
+#include "ksyms_init.h"
#include <linux/kallsyms.h>
#include <linux/module.h>
#include <linux/percpu.h>
return sym_data.addr;
}
EXPORT_SYMBOL_GPL(swap_ksyms_substr);
-
-int __init swap_ksyms_init(void)
-{
- printk("SWAP_KSYMS: Module initialized\n");
-
- return 0;
-}
-
-void __exit swap_ksyms_exit(void)
-{
- printk("SWAP_KSYMS: Module uninitialized\n");
-}
-
-module_init(swap_ksyms_init);
-module_exit(swap_ksyms_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("SWAP ksyms module");
-MODULE_AUTHOR("Vyacheslav Cherkashin <v.cherkashin@samaung.com>");
-
--- /dev/null
+/*
+ * Dynamic Binary Instrumentation Module based on KProbes
+ * modules/ksyms/ksyms_init.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Alexander Aksenov <a.aksenov@samsung.com>
+ *
+ */
+
+#ifndef __KSYMS_INIT_H__
+#define __KSYMS_INIT_H__
+
+#ifdef CONFIG_KALLSYMS
+
+static inline int ksyms_init(void)
+{
+ return 0;
+}
+
+static inline void ksyms_exit(void)
+{
+}
+
+#else /* CONFIG_KALLSYMS */
+
+int ksyms_init(void);
+void ksyms_exit(void);
+
+#endif /* CONFIG_KALLSYMS */
+
+#endif /* __KSYMS_INIT_H__ */
--- /dev/null
+/*
+ * Dynamic Binary Instrumentation Module based on KProbes
+ * modules/ksyms/ksyms_module.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2014
+ *
+ * 2014 Alexander Aksenov <a.aksenov@samsung.com>
+ *
+ */
+
+#include "ksyms_init.h"
+
+#include <linux/module.h>
+
+int __init swap_ksyms_init(void)
+{
+ int ret = ksyms_init();
+
+ printk("SWAP_KSYMS: Module initialized\n");
+
+ return ret;
+}
+
+void __exit swap_ksyms_exit(void)
+{
+ ksyms_exit();
+
+ printk("SWAP_KSYMS: Module uninitialized\n");
+}
+
+module_init(swap_ksyms_init);
+module_exit(swap_ksyms_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("SWAP ksyms module");
+MODULE_AUTHOR("Vyacheslav Cherkashin <v.cherkashin@samaung.com>");
*/
#include "ksyms.h"
-#include <linux/module.h>
+#include "ksyms_init.h"
#include <linux/types.h>
#include <linux/vmalloc.h>
#include <linux/semaphore.h>
}
EXPORT_SYMBOL_GPL(swap_ksyms_substr);
-int __init swap_ksyms_init(void)
+int ksyms_init(void)
{
int ret = 0;
return 0;
}
-void __exit swap_ksyms_exit(void)
+void ksyms_exit(void)
{
down(&cnt_init_sm_lock);
up(&cnt_init_sm_lock);
}
-
-module_init(swap_ksyms_init);
-module_exit(swap_ksyms_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("SWAP ksyms module");
-MODULE_AUTHOR("Vyacheslav Cherkashin <v.cherkashin@samaung.com>");