module.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_POWERPC_MODULE_H
  3. #define _ASM_POWERPC_MODULE_H
  4. #ifdef __KERNEL__
  5. #include <linux/list.h>
  6. #include <asm/bug.h>
  7. #include <asm-generic/module.h>
  8. #ifndef __powerpc64__
  9. /*
  10. * Thanks to Paul M for explaining this.
  11. *
  12. * PPC can only do rel jumps += 32MB, and often the kernel and other
  13. * modules are further away than this. So, we jump to a table of
  14. * trampolines attached to the module (the Procedure Linkage Table)
  15. * whenever that happens.
  16. */
  17. struct ppc_plt_entry {
  18. /* 16 byte jump instruction sequence (4 instructions) */
  19. unsigned int jump[4];
  20. };
  21. #endif /* __powerpc64__ */
  22. struct mod_arch_specific {
  23. #ifdef __powerpc64__
  24. unsigned int stubs_section; /* Index of stubs section in module */
  25. unsigned int toc_section; /* What section is the TOC? */
  26. bool toc_fixed; /* Have we fixed up .TOC.? */
  27. /* For module function descriptor dereference */
  28. unsigned long start_opd;
  29. unsigned long end_opd;
  30. #else /* powerpc64 */
  31. /* Indices of PLT sections within module. */
  32. unsigned int core_plt_section;
  33. unsigned int init_plt_section;
  34. #endif /* powerpc64 */
  35. #ifdef CONFIG_DYNAMIC_FTRACE
  36. unsigned long tramp;
  37. unsigned long tramp_regs;
  38. #endif
  39. /* List of BUG addresses, source line numbers and filenames */
  40. struct list_head bug_list;
  41. struct bug_entry *bug_table;
  42. unsigned int num_bugs;
  43. };
  44. /*
  45. * Select ELF headers.
  46. * Make empty section for module_frob_arch_sections to expand.
  47. */
  48. #ifdef __powerpc64__
  49. # ifdef MODULE
  50. asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
  51. # endif
  52. #else
  53. # ifdef MODULE
  54. asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
  55. asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
  56. # endif /* MODULE */
  57. #endif
  58. #ifdef CONFIG_DYNAMIC_FTRACE
  59. # ifdef MODULE
  60. asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
  61. # endif /* MODULE */
  62. int module_trampoline_target(struct module *mod, unsigned long trampoline,
  63. unsigned long *target);
  64. int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
  65. #else
  66. static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
  67. {
  68. return 0;
  69. }
  70. #endif
  71. #endif /* __KERNEL__ */
  72. #endif /* _ASM_POWERPC_MODULE_H */