module: trim exception table on init free.
[sfrench/cifs-2.6.git] / arch / ia64 / mm / extable.c
index 71c50dd8f8706da65a0362dc2ee8e15888c42060..e95d5ad9285dab575aa10f70e398c1c8368e0316 100644 (file)
@@ -53,6 +53,32 @@ void sort_extable (struct exception_table_entry *start,
             cmp_ex, swap_ex);
 }
 
+static inline unsigned long ex_to_addr(const struct exception_table_entry *x)
+{
+       return (unsigned long)&x->insn + x->insn;
+}
+
+#ifdef CONFIG_MODULES
+/*
+ * Any entry referring to the module init will be at the beginning or
+ * the end.
+ */
+void trim_init_extable(struct module *m)
+{
+       /*trim the beginning*/
+       while (m->num_exentries &&
+              within_module_init(ex_to_addr(&m->extable[0]), m)) {
+               m->extable++;
+               m->num_exentries--;
+       }
+       /*trim the end*/
+       while (m->num_exentries &&
+              within_module_init(ex_to_addr(&m->extable[m->num_exentries-1]),
+                                 m))
+               m->num_exentries--;
+}
+#endif /* CONFIG_MODULES */
+
 const struct exception_table_entry *
 search_extable (const struct exception_table_entry *first,
                const struct exception_table_entry *last,