2 * linux/arch/sparc/mm/extable.c
5 #include <asm/uaccess.h>
7 void sort_extable(struct exception_table_entry
*start
,
8 struct exception_table_entry
*finish
)
12 /* Caller knows they are in a range if ret->fixup == 0 */
13 const struct exception_table_entry
*
14 search_extable(const struct exception_table_entry
*start
,
15 const struct exception_table_entry
*last
,
18 const struct exception_table_entry
*walk
;
20 /* Single insn entries are encoded as:
21 * word 1: insn address
22 * word 2: fixup code address
24 * Range entries are encoded as:
25 * word 1: first insn address
27 * word 3: last insn address + 4 bytes
28 * word 4: fixup code address
30 * Deleted entries are encoded as:
34 * See asm/uaccess.h for more details.
37 /* 1. Try to find an exact match. */
38 for (walk
= start
; walk
<= last
; walk
++) {
39 if (walk
->fixup
== 0) {
40 /* A range entry, skip both parts. */
45 /* A deleted entry; see trim_init_extable */
46 if (walk
->fixup
== -1)
49 if (walk
->insn
== value
)
53 /* 2. Try to find a range match. */
54 for (walk
= start
; walk
<= (last
- 1); walk
++) {
58 if (walk
[0].insn
<= value
&& walk
[1].insn
> value
)
68 /* We could memmove them around; easier to mark the trimmed ones. */
69 void trim_init_extable(struct module
*m
)
74 for (i
= 0; i
< m
->num_exentries
; i
+= range
? 2 : 1) {
75 range
= m
->extable
[i
].fixup
== 0;
77 if (within_module_init(m
->extable
[i
].insn
, m
)) {
78 m
->extable
[i
].fixup
= -1;
80 m
->extable
[i
+1].fixup
= -1;
86 #endif /* CONFIG_MODULES */
88 /* Special extable search, which handles ranges. Returns fixup */
89 unsigned long search_extables_range(unsigned long addr
, unsigned long *g2
)
91 const struct exception_table_entry
*entry
;
93 entry
= search_exception_tables(addr
);
97 /* Inside range? Fix g2 and return correct fixup */
99 *g2
= (addr
- entry
->insn
) / 4;
100 return (entry
+ 1)->fixup
;