2 * linux/arch/sparc/mm/extable.c
5 #include <linux/module.h>
6 #include <linux/extable.h>
7 #include <linux/uaccess.h>
9 void sort_extable(struct exception_table_entry *start,
10 struct exception_table_entry *finish)
14 /* Caller knows they are in a range if ret->fixup == 0 */
15 const struct exception_table_entry *
16 search_extable(const struct exception_table_entry *start,
17 const struct exception_table_entry *last,
20 const struct exception_table_entry *walk;
22 /* Single insn entries are encoded as:
23 * word 1: insn address
24 * word 2: fixup code address
26 * Range entries are encoded as:
27 * word 1: first insn address
29 * word 3: last insn address + 4 bytes
30 * word 4: fixup code address
32 * Deleted entries are encoded as:
36 * See asm/uaccess.h for more details.
39 /* 1. Try to find an exact match. */
40 for (walk = start; walk <= last; walk++) {
41 if (walk->fixup == 0) {
42 /* A range entry, skip both parts. */
47 /* A deleted entry; see trim_init_extable */
48 if (walk->fixup == -1)
51 if (walk->insn == value)
55 /* 2. Try to find a range match. */
56 for (walk = start; walk <= (last - 1); walk++) {
60 if (walk[0].insn <= value && walk[1].insn > value)
70 /* We could memmove them around; easier to mark the trimmed ones. */
71 void trim_init_extable(struct module *m)
76 for (i = 0; i < m->num_exentries; i += range ? 2 : 1) {
77 range = m->extable[i].fixup == 0;
79 if (within_module_init(m->extable[i].insn, m)) {
80 m->extable[i].fixup = -1;
82 m->extable[i+1].fixup = -1;
88 #endif /* CONFIG_MODULES */
90 /* Special extable search, which handles ranges. Returns fixup */
91 unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
93 const struct exception_table_entry *entry;
95 entry = search_exception_tables(addr);
99 /* Inside range? Fix g2 and return correct fixup */
101 *g2 = (addr - entry->insn) / 4;
102 return (entry + 1)->fixup;