0001-fix-prototype-generation.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Subject: Fix prototype generation for openat
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Date: 2021-12-30
  4. Bug-Debian: https://bugs.debian.org/995393
  5. Forwarded: Yes (implicitely)
  6. As jrtc27 pointed out in IRC, ppc64el is more strict than other
  7. architectures when it comes to va_arg handling:
  8. it's that ppc64le uses the elfv2 abi, and for variadic calls you
  9. must reserve space for a parameter save area
  10. So enhance wrapawk to create a proper prototype and argument
  11. handling although it's specific to the openat call. Also add the
  12. missing documentation for the sixth column to wrapfunc.inp.
  13. Signed-off-by: Joel Stanley <joel@jms.id.au>
  14. --- a/wrapawk
  15. +++ b/wrapawk
  16. @@ -37,7 +37,25 @@
  17. argtype=$3;
  18. argname=$4;
  19. MACRO=$5;
  20. - if(MACRO){
  21. + openat_extra=$6;
  22. + if(openat_extra){
  23. + print " {(void(*))&next_" name ", \"" name "\"}," > structfile;
  24. + print "extern " ret " (*next_" name ")" openat_extra ";" > headerfile;
  25. + print ret " (*next_" name ")" openat_extra "=tmp_" name ";"> deffile;
  26. +
  27. + print ret " tmp_" name, openat_extra "{" > tmpffile;
  28. + print " mode_t mode = 0;" > tmpffile;
  29. + print " if (flags & O_CREAT) {" > tmpffile;
  30. + print " va_list args;" > tmpffile;
  31. + print " va_start(args, flags);" > tmpffile;
  32. + print " mode = va_arg(args, int);" > tmpffile;
  33. + print " va_end(args);" > tmpffile;
  34. + print " }" > tmpffile;
  35. + print " load_library_symbols();" > tmpffile;
  36. + print " return next_" name, argname ";" > tmpffile;
  37. + print "}" > tmpffile;
  38. + print "" > tmpffile;
  39. + } else if(MACRO){
  40. print " {(void(*))&NEXT_" MACRO "_NOARG, " name "_QUOTE}," > structfile;
  41. print "extern " ret " (*NEXT_" MACRO "_NOARG)" argtype ";" > headerfile;
  42. print ret " (*NEXT_" MACRO "_NOARG)" argtype "=TMP_" MACRO ";"> deffile;
  43. --- a/wrapfunc.inp
  44. +++ b/wrapfunc.inp
  45. @@ -9,8 +9,10 @@
  46. /**/ */
  47. /* each line of this file lists 4 fields, seperated by a ";". */
  48. /* The first field is the name of the wrapped function, then it's return */
  49. -/* value. After that come the function arguments with types, and the last */
  50. +/* value. After that come the function arguments with types, and the fifth */
  51. /* field contains the function arguments without types. */
  52. +/* A sixth field is a special needed when wrapping the openat syscall. */
  53. +/* Otherwise it's like the third (function arguments with types). */
  54. /**/
  55. /* __*xstat are used on glibc systems instead of just *xstat. */