extable.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Rewritten by Rusty Russell, on the backs of many others...
  2. Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <asm/uaccess.h>
  18. #include <asm/sections.h>
  19. extern struct exception_table_entry __start___ex_table[];
  20. extern struct exception_table_entry __stop___ex_table[];
  21. /* Sort the kernel's built-in exception table */
  22. void __init sort_main_extable(void)
  23. {
  24. sort_extable(__start___ex_table, __stop___ex_table);
  25. }
  26. /* Given an address, look for it in the exception tables. */
  27. const struct exception_table_entry *search_exception_tables(unsigned long addr)
  28. {
  29. const struct exception_table_entry *e;
  30. e = search_extable(__start___ex_table, __stop___ex_table-1, addr);
  31. if (!e)
  32. e = search_module_extables(addr);
  33. return e;
  34. }
  35. int core_kernel_text(unsigned long addr)
  36. {
  37. if (addr >= (unsigned long)_stext &&
  38. addr <= (unsigned long)_etext)
  39. return 1;
  40. if (addr >= (unsigned long)_sinittext &&
  41. addr <= (unsigned long)_einittext)
  42. return 1;
  43. return 0;
  44. }
  45. int __kernel_text_address(unsigned long addr)
  46. {
  47. if (core_kernel_text(addr))
  48. return 1;
  49. return __module_text_address(addr) != NULL;
  50. }
  51. int kernel_text_address(unsigned long addr)
  52. {
  53. if (core_kernel_text(addr))
  54. return 1;
  55. return module_text_address(addr) != NULL;
  56. }