extable.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * linux/arch/sparc/mm/extable.c
  3. */
  4. #include <linux/module.h>
  5. #include <asm/uaccess.h>
  6. void sort_extable(struct exception_table_entry *start,
  7. struct exception_table_entry *finish)
  8. {
  9. }
  10. /* Caller knows they are in a range if ret->fixup == 0 */
  11. const struct exception_table_entry *
  12. search_extable(const struct exception_table_entry *start,
  13. const struct exception_table_entry *last,
  14. unsigned long value)
  15. {
  16. const struct exception_table_entry *walk;
  17. /* Single insn entries are encoded as:
  18. * word 1: insn address
  19. * word 2: fixup code address
  20. *
  21. * Range entries are encoded as:
  22. * word 1: first insn address
  23. * word 2: 0
  24. * word 3: last insn address + 4 bytes
  25. * word 4: fixup code address
  26. *
  27. * See asm/uaccess.h for more details.
  28. */
  29. /* 1. Try to find an exact match. */
  30. for (walk = start; walk <= last; walk++) {
  31. if (walk->fixup == 0) {
  32. /* A range entry, skip both parts. */
  33. walk++;
  34. continue;
  35. }
  36. if (walk->insn == value)
  37. return walk;
  38. }
  39. /* 2. Try to find a range match. */
  40. for (walk = start; walk <= (last - 1); walk++) {
  41. if (walk->fixup)
  42. continue;
  43. if (walk[0].insn <= value && walk[1].insn > value)
  44. return walk;
  45. walk++;
  46. }
  47. return NULL;
  48. }
  49. /* Special extable search, which handles ranges. Returns fixup */
  50. unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
  51. {
  52. const struct exception_table_entry *entry;
  53. entry = search_exception_tables(addr);
  54. if (!entry)
  55. return 0;
  56. /* Inside range? Fix g2 and return correct fixup */
  57. if (!entry->fixup) {
  58. *g2 = (addr - entry->insn) / 4;
  59. return (entry + 1)->fixup;
  60. }
  61. return entry->fixup;
  62. }