This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / mips / kernel / module.c
1 #include <linux/module.h>
2 #include <linux/spinlock.h>
3
4 static LIST_HEAD(dbe_list);
5 static spinlock_t dbe_lock = SPIN_LOCK_UNLOCKED;
6
7 /* Given an address, look for it in the module exception tables. */
8 const struct exception_table_entry *search_module_dbetables(unsigned long addr)
9 {
10         unsigned long flags;
11         const struct exception_table_entry *e = NULL;
12         struct mod_arch_specific *dbe;
13
14         spin_lock_irqsave(&dbe_lock, flags);
15         list_for_each_entry(dbe, &dbe_list, dbe_list) {
16                 e = search_extable(dbe->dbe_start, dbe->dbe_end - 1, addr);
17                 if (e)
18                         break;
19         }
20         spin_unlock_irqrestore(&dbe_lock, flags);
21
22         /* Now, if we found one, we are running inside it now, hence
23            we cannot unload the module, hence no refcnt needed. */
24         return e;
25 }
26
27 /* Put in dbe list if neccessary. */
28 int module_finalize(const Elf_Ehdr *hdr,
29                     const Elf_Shdr *sechdrs,
30                     struct module *me)
31 {
32         const Elf_Shdr *s;
33         char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
34
35         INIT_LIST_HEAD(&me->arch.dbe_list);
36         for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
37                 if (strcmp("__dbe_table", secstrings + s->sh_name) != 0)
38                         continue;
39                 me->arch.dbe_start = (void *)s->sh_addr;
40                 me->arch.dbe_end = (void *)s->sh_addr + s->sh_size;
41                 spin_lock_irq(&dbe_lock);
42                 list_add(&me->arch.dbe_list, &dbe_list);
43                 spin_unlock_irq(&dbe_lock);
44         }
45         return 0;
46 }
47
48 void module_arch_cleanup(struct module *mod)
49 {
50         spin_lock_irq(&dbe_lock);
51         list_del(&mod->arch.dbe_list);
52         spin_unlock_irq(&dbe_lock);
53 }