-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_symbols.c
58 lines (51 loc) · 1.43 KB
/
export_symbols.c
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
47
48
49
50
51
52
53
54
55
56
57
58
/*
* @file export_symbols.c
* @details Simple Linux device driver all what he do is to
* share some symbols (EXPORT_SYMBOL)
* @author smalinux
*
* insert the module then use:
* cat /proc/kallsyms | grep sohaib_
*
* In a programming language, a symbol is either a variable or
* a function. Or more generally, we can say, a symbol is a name representing
* space in the memory, which stores data (variable,
* for reading and writing) or instructions (function, for executing).
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
/**
* Declarations
*****************************************************/
int SOHAIB_CONUT = 0;
EXPORT_SYMBOL(SOHAIB_CONUT);
void sohaib_shared_func(void)
{
printk(KERN_INFO "Shared function been called!!!\n");
SOHAIB_CONUT++;
}
EXPORT_SYMBOL(sohaib_shared_func);
static int __init smalinux_driver_init(void)
{
printk("export_symbols: module loaded!!");
return 0;
}
static void __exit smalinux_driver_exit(void)
{
pr_info("export_symbols: module unloaded!!");
}
/**
* Definitions
*****************************************************/
module_init(smalinux_driver_init);
module_exit(smalinux_driver_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("smalinux <[email protected]>");
MODULE_DESCRIPTION("EXPORT_SYMBOL Driver - share some symbols");
MODULE_VERSION("1.2");