miscthings.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "linux/threads.h"
  2. #include "linux/stddef.h" // for NULL
  3. #include "linux/elf.h" // for AT_NULL
  4. /* The following function nicked from arch/ppc/kernel/process.c and
  5. * adapted slightly */
  6. /*
  7. * XXX ld.so expects the auxiliary table to start on
  8. * a 16-byte boundary, so we have to find it and
  9. * move it up. :-(
  10. */
  11. void shove_aux_table(unsigned long sp)
  12. {
  13. int argc;
  14. char *p;
  15. unsigned long e;
  16. unsigned long aux_start, offset;
  17. argc = *(int *)sp;
  18. sp += sizeof(int) + (argc + 1) * sizeof(char *);
  19. /* skip over the environment pointers */
  20. do {
  21. p = *(char **)sp;
  22. sp += sizeof(char *);
  23. } while (p != NULL);
  24. aux_start = sp;
  25. /* skip to the end of the auxiliary table */
  26. do {
  27. e = *(unsigned long *)sp;
  28. sp += 2 * sizeof(unsigned long);
  29. } while (e != AT_NULL);
  30. offset = ((aux_start + 15) & ~15) - aux_start;
  31. if (offset != 0) {
  32. do {
  33. sp -= sizeof(unsigned long);
  34. e = *(unsigned long *)sp;
  35. *(unsigned long *)(sp + offset) = e;
  36. } while (sp > aux_start);
  37. }
  38. }
  39. /* END stuff taken from arch/ppc/kernel/process.c */
  40. /*
  41. * Overrides for Emacs so that we follow Linus's tabbing style.
  42. * Emacs will notice this stuff at the end of the file and automatically
  43. * adjust the settings for this buffer only. This must remain at the end
  44. * of the file.
  45. * ---------------------------------------------------------------------------
  46. * Local variables:
  47. * c-file-style: "linux"
  48. * End:
  49. */