asm-offsets.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Generate definitions needed by assembly language modules.
  3. * This code generates raw asm output which is post-processed
  4. * to extract and format the required data.
  5. */
  6. #include <linux/crypto.h>
  7. #include <linux/sched.h>
  8. #include <linux/signal.h>
  9. #include <linux/personality.h>
  10. #include <linux/suspend.h>
  11. #include <asm/ucontext.h>
  12. #include "sigframe.h"
  13. #include <asm/fixmap.h>
  14. #include <asm/processor.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/elf.h>
  17. #define DEFINE(sym, val) \
  18. asm volatile("\n->" #sym " %0 " #val : : "i" (val))
  19. #define BLANK() asm volatile("\n->" : : )
  20. #define OFFSET(sym, str, mem) \
  21. DEFINE(sym, offsetof(struct str, mem));
  22. void foo(void)
  23. {
  24. OFFSET(SIGCONTEXT_eax, sigcontext, eax);
  25. OFFSET(SIGCONTEXT_ebx, sigcontext, ebx);
  26. OFFSET(SIGCONTEXT_ecx, sigcontext, ecx);
  27. OFFSET(SIGCONTEXT_edx, sigcontext, edx);
  28. OFFSET(SIGCONTEXT_esi, sigcontext, esi);
  29. OFFSET(SIGCONTEXT_edi, sigcontext, edi);
  30. OFFSET(SIGCONTEXT_ebp, sigcontext, ebp);
  31. OFFSET(SIGCONTEXT_esp, sigcontext, esp);
  32. OFFSET(SIGCONTEXT_eip, sigcontext, eip);
  33. BLANK();
  34. OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
  35. OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
  36. OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
  37. OFFSET(CPUINFO_x86_mask, cpuinfo_x86, x86_mask);
  38. OFFSET(CPUINFO_hard_math, cpuinfo_x86, hard_math);
  39. OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
  40. OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
  41. OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
  42. BLANK();
  43. OFFSET(TI_task, thread_info, task);
  44. OFFSET(TI_exec_domain, thread_info, exec_domain);
  45. OFFSET(TI_flags, thread_info, flags);
  46. OFFSET(TI_status, thread_info, status);
  47. OFFSET(TI_cpu, thread_info, cpu);
  48. OFFSET(TI_preempt_count, thread_info, preempt_count);
  49. OFFSET(TI_addr_limit, thread_info, addr_limit);
  50. OFFSET(TI_restart_block, thread_info, restart_block);
  51. OFFSET(TI_sysenter_return, thread_info, sysenter_return);
  52. BLANK();
  53. OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
  54. OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
  55. BLANK();
  56. OFFSET(pbe_address, pbe, address);
  57. OFFSET(pbe_orig_address, pbe, orig_address);
  58. OFFSET(pbe_next, pbe, next);
  59. /* Offset from the sysenter stack to tss.esp0 */
  60. DEFINE(TSS_sysenter_esp0, offsetof(struct tss_struct, esp0) -
  61. sizeof(struct tss_struct));
  62. DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
  63. DEFINE(VDSO_PRELINK, VDSO_PRELINK);
  64. OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
  65. }