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