gen-offsets.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <stdio.h>
  2. #include <stddef.h>
  3. #include <ucontext.h>
  4. #include <asm/sigcontext.h>
  5. #define UC(N,X) \
  6. printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X))
  7. #define SC(N,X) \
  8. printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X))
  9. int
  10. main (void)
  11. {
  12. printf (
  13. "/* Linux-specific definitions: */\n\n"
  14. "/* Define various structure offsets to simplify cross-compilation. */\n\n"
  15. "/* Offsets for ARM Linux \"ucontext_t\": */\n\n");
  16. UC ("FLAGS", uc_flags);
  17. UC ("LINK", uc_link);
  18. UC ("STACK", uc_stack);
  19. UC ("MCONTEXT", uc_mcontext);
  20. UC ("SIGMASK", uc_sigmask);
  21. UC ("REGSPACE", uc_regspace);
  22. printf ("\n/* Offsets for ARM Linux \"struct sigcontext\": */\n\n");
  23. SC ("TRAPNO", trap_no);
  24. SC ("ERRORCODE", error_code);
  25. SC ("OLDMASK", oldmask);
  26. SC ("R0", arm_r0);
  27. SC ("R1", arm_r1);
  28. SC ("R2", arm_r2);
  29. SC ("R3", arm_r3);
  30. SC ("R4", arm_r4);
  31. SC ("R5", arm_r5);
  32. SC ("R6", arm_r6);
  33. SC ("R7", arm_r7);
  34. SC ("R8", arm_r8);
  35. SC ("R9", arm_r9);
  36. SC ("R10", arm_r10);
  37. SC ("FP", arm_fp);
  38. SC ("IP", arm_ip);
  39. SC ("SP", arm_sp);
  40. SC ("LR", arm_lr);
  41. SC ("PC", arm_pc);
  42. SC ("CPSR", arm_cpsr);
  43. SC ("FAULTADDR", fault_address);
  44. return 0;
  45. }