This source file includes following definitions.
- sort_extable
- search_extable
- trim_init_extable
- search_extables_range
1
2
3
4
5
6 #include <linux/module.h>
7 #include <linux/extable.h>
8 #include <linux/uaccess.h>
9
10 void sort_extable(struct exception_table_entry *start,
11 struct exception_table_entry *finish)
12 {
13 }
14
15
16 const struct exception_table_entry *
17 search_extable(const struct exception_table_entry *base,
18 const size_t num,
19 unsigned long value)
20 {
21 int i;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 for (i = 0; i < num; i++) {
42 if (base[i].fixup == 0) {
43
44 i++;
45 continue;
46 }
47
48
49 if (base[i].fixup == -1)
50 continue;
51
52 if (base[i].insn == value)
53 return &base[i];
54 }
55
56
57 for (i = 0; i < (num - 1); i++) {
58 if (base[i].fixup)
59 continue;
60
61 if (base[i].insn <= value && base[i + 1].insn > value)
62 return &base[i];
63
64 i++;
65 }
66
67 return NULL;
68 }
69
70 #ifdef CONFIG_MODULES
71
72 void trim_init_extable(struct module *m)
73 {
74 unsigned int i;
75 bool range;
76
77 for (i = 0; i < m->num_exentries; i += range ? 2 : 1) {
78 range = m->extable[i].fixup == 0;
79
80 if (within_module_init(m->extable[i].insn, m)) {
81 m->extable[i].fixup = -1;
82 if (range)
83 m->extable[i+1].fixup = -1;
84 }
85 if (range)
86 i++;
87 }
88 }
89 #endif
90
91
92 unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
93 {
94 const struct exception_table_entry *entry;
95
96 entry = search_exception_tables(addr);
97 if (!entry)
98 return 0;
99
100
101 if (!entry->fixup) {
102 *g2 = (addr - entry->insn) / 4;
103 return (entry + 1)->fixup;
104 }
105
106 return entry->fixup;
107 }