module.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _ASM_POWERPC_MODULE_H
  2. #define _ASM_POWERPC_MODULE_H
  3. #ifdef __KERNEL__
  4. /*
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #include <linux/list.h>
  11. #include <asm/bug.h>
  12. #include <asm-generic/module.h>
  13. #ifdef CONFIG_MPROFILE_KERNEL
  14. #define MODULE_ARCH_VERMAGIC_FTRACE "mprofile-kernel "
  15. #else
  16. #define MODULE_ARCH_VERMAGIC_FTRACE ""
  17. #endif
  18. #ifdef CONFIG_RELOCATABLE
  19. #define MODULE_ARCH_VERMAGIC_RELOCATABLE "relocatable "
  20. #else
  21. #define MODULE_ARCH_VERMAGIC_RELOCATABLE ""
  22. #endif
  23. #define MODULE_ARCH_VERMAGIC MODULE_ARCH_VERMAGIC_FTRACE MODULE_ARCH_VERMAGIC_RELOCATABLE
  24. #ifndef __powerpc64__
  25. /*
  26. * Thanks to Paul M for explaining this.
  27. *
  28. * PPC can only do rel jumps += 32MB, and often the kernel and other
  29. * modules are further away than this. So, we jump to a table of
  30. * trampolines attached to the module (the Procedure Linkage Table)
  31. * whenever that happens.
  32. */
  33. struct ppc_plt_entry {
  34. /* 16 byte jump instruction sequence (4 instructions) */
  35. unsigned int jump[4];
  36. };
  37. #endif /* __powerpc64__ */
  38. struct mod_arch_specific {
  39. #ifdef __powerpc64__
  40. unsigned int stubs_section; /* Index of stubs section in module */
  41. unsigned int toc_section; /* What section is the TOC? */
  42. bool toc_fixed; /* Have we fixed up .TOC.? */
  43. /* For module function descriptor dereference */
  44. unsigned long start_opd;
  45. unsigned long end_opd;
  46. #else /* powerpc64 */
  47. /* Indices of PLT sections within module. */
  48. unsigned int core_plt_section;
  49. unsigned int init_plt_section;
  50. #endif /* powerpc64 */
  51. #ifdef CONFIG_DYNAMIC_FTRACE
  52. unsigned long tramp;
  53. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  54. unsigned long tramp_regs;
  55. #endif
  56. #endif
  57. /* List of BUG addresses, source line numbers and filenames */
  58. struct list_head bug_list;
  59. struct bug_entry *bug_table;
  60. unsigned int num_bugs;
  61. };
  62. /*
  63. * Select ELF headers.
  64. * Make empty section for module_frob_arch_sections to expand.
  65. */
  66. #ifdef __powerpc64__
  67. # ifdef MODULE
  68. asm(".section .stubs,\"ax\",@nobits; .align 3; .previous");
  69. # endif
  70. #else
  71. # ifdef MODULE
  72. asm(".section .plt,\"ax\",@nobits; .align 3; .previous");
  73. asm(".section .init.plt,\"ax\",@nobits; .align 3; .previous");
  74. # endif /* MODULE */
  75. #endif
  76. #ifdef CONFIG_DYNAMIC_FTRACE
  77. # ifdef MODULE
  78. asm(".section .ftrace.tramp,\"ax\",@nobits; .align 3; .previous");
  79. # endif /* MODULE */
  80. #endif
  81. int module_trampoline_target(struct module *mod, unsigned long trampoline,
  82. unsigned long *target);
  83. #ifdef CONFIG_DYNAMIC_FTRACE
  84. int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs);
  85. #else
  86. static inline int module_finalize_ftrace(struct module *mod, const Elf_Shdr *sechdrs)
  87. {
  88. return 0;
  89. }
  90. #endif
  91. #endif /* __KERNEL__ */
  92. #endif /* _ASM_POWERPC_MODULE_H */