If argument passing to register case (ex. -mregparam=3). This case set all parameters set to register from caller. But callee refer to stack. So can't get parameter.
Signed-off-by: Yoshinori Sato ysato@users.sourceforge.jp --- include/fcntl.h | 4 ++-- libc/sysdeps/linux/common/open.c | 4 ++-- libc/sysdeps/linux/common/openat.c | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/include/fcntl.h b/include/fcntl.h index adcd7ef..683f976 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -108,8 +108,8 @@ libc_hidden_proto(fcntl64) extern int open (const char *__file, int __oflag, ...) __nonnull ((1)); libc_hidden_proto(open) # ifdef _LIBC -extern int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden; -extern int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden; +extern int __open2_nocancel(const char *, int, ...) __nonnull ((1)) attribute_hidden; +extern int __open_nocancel(const char *, int, ...) __nonnull ((1)) attribute_hidden; # endif #else # ifdef __REDIRECT diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c index aab0fb5..909201a 100644 --- a/libc/sysdeps/linux/common/open.c +++ b/libc/sysdeps/linux/common/open.c @@ -21,8 +21,8 @@ strong_alias_untyped(__syscall_open,__NC(open)) # define __NR___open2_nocancel __NR_open _syscall2(int, __NC(open2), const char *, file, int, flags) #else -int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden; -int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden; +int __open2_nocancel(const char *, int, ...) __nonnull ((1)) attribute_hidden; +int __open_nocancel(const char *, int, ...) __nonnull ((1)) attribute_hidden; #endif
int open(const char *file, int oflag, ...) diff --git a/libc/sysdeps/linux/common/openat.c b/libc/sysdeps/linux/common/openat.c index f6032da..f71567c 100644 --- a/libc/sysdeps/linux/common/openat.c +++ b/libc/sysdeps/linux/common/openat.c @@ -8,11 +8,24 @@
#include <sys/syscall.h> #include <fcntl.h> +#include <stdarg.h>
#ifdef __NR_openat # define __NR___syscall_openat __NR_openat static __inline__ _syscall4(int, __syscall_openat, int, fd, const char *, file, int, oflag, mode_t, mode) -strong_alias_untyped(__syscall_openat,openat) + +int __openat(int fd, const char *file, int o_flag, ...) +{ + va_list ap; + mode_t mode; + + va_start(ap, o_flag); + mode = va_arg(ap, int); + va_end(ap); + return __syscall_openat(fd, file, o_flag, mode); +} + +strong_alias_untyped(__openat,openat) libc_hidden_def(openat) #else /* should add emulation with open() and /proc/self/fd/ ... */
Hi Yoshinori, Yoshinori Sato wrote,
If argument passing to register case (ex. -mregparam=3). This case set all parameters set to register from caller. But callee refer to stack. So can't get parameter.
The patch breaks toolchain building for alpha:
/home/wbx/embedded-test/openadk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/bin/alpha-openadk-linux-uclibc-gcc -c libc/sysdeps/linux/common/open.c -o libc/sysdeps/linux/common/open.os -Wall -Ws trict-prototypes -Wstrict-aliasing -funsigned-char -fno-builtin -fno-asm -fmerge-all-constants -std=gnu99 -fno-stack-protector -nostdinc -I./include -I./include -include libc-symbols.h -I./l ibc/sysdeps/linux/alpha -I./libc/sysdeps/linux -I./ldso/ldso/alpha -I./ldso/include -I. -DSTATIC -Os -fstrict-aliasing -fwrapv -fno-ident -fhonour-copts -static -Os -pipe -fomit-frame-pointe r -fno-unwind-tables -fno-asynchronous-unwind-tables -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux/alpha -I./libpthread/linuxthreads.old/sysdeps/alpha -I./libpthread/linuxthreads.o ld/sysdeps/unix/sysv/linux -I./libpthread/linuxthreads.old/sysdeps/pthread -I./libpthread/linuxthreads.old -I./libpthread -I./libc/sysdeps/linux/common -isystem /home/wbx/embedded-test/opena dk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/lib/gcc/alpha-openadk-linux-uclibc/5.3.0/include-fixed -isystem /home/wbx/embedded-test/openadk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/lib/gcc/a lpha-openadk-linux-uclibc/5.3.0/include -I/home/wbx/embedded-test/openadk/target_qemu-alpha_uclibc-ng_alpha/usr/include/ -DNDEBUG -DIN_LIB=libc -fPIC -MT libc/sysdeps/linux/common/open.os -MD -MP -MF libc/sysdeps/linux/common/.open.os.dep In file included from ./include/sys/syscall.h:34:0, from libc/sysdeps/linux/common/open.c:10: ./include/cancel.h:43:19: error: conflicting types for '__open2_nocancel' #define _NC(name) __##name##_nocancel ^ ./include/bits/syscalls-common.h:96:6: note: in definition of macro 'SYSCALL_FUNC' type name(C_DECL_ARGS_##nargs(args)) { \ ^ libc/sysdeps/linux/common/open.c:22:1: note: in expansion of macro '_syscall2' _syscall2(int, __NC(open2), const char *, file, int, flags) ^ ./include/cancel.h:42:20: note: in expansion of macro '_NC' #define __NC(name) _NC(name) ^ libc/sysdeps/linux/common/open.c:22:16: note: in expansion of macro '__NC' _syscall2(int, __NC(open2), const char *, file, int, flags) ^
Any idea?
best regards Waldemar
On Mon, 04 Jan 2016 05:59:15 +0900, Waldemar Brodkorb wrote:
Hi Yoshinori, Yoshinori Sato wrote,
If argument passing to register case (ex. -mregparam=3). This case set all parameters set to register from caller. But callee refer to stack. So can't get parameter.
The patch breaks toolchain building for alpha:
/home/wbx/embedded-test/openadk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/bin/alpha-openadk-linux-uclibc-gcc -c libc/sysdeps/linux/common/open.c -o libc/sysdeps/linux/common/open.os -Wall -Ws trict-prototypes -Wstrict-aliasing -funsigned-char -fno-builtin -fno-asm -fmerge-all-constants -std=gnu99 -fno-stack-protector -nostdinc -I./include -I./include -include libc-symbols.h -I./l ibc/sysdeps/linux/alpha -I./libc/sysdeps/linux -I./ldso/ldso/alpha -I./ldso/include -I. -DSTATIC -Os -fstrict-aliasing -fwrapv -fno-ident -fhonour-copts -static -Os -pipe -fomit-frame-pointe r -fno-unwind-tables -fno-asynchronous-unwind-tables -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux/alpha -I./libpthread/linuxthreads.old/sysdeps/alpha -I./libpthread/linuxthreads.o ld/sysdeps/unix/sysv/linux -I./libpthread/linuxthreads.old/sysdeps/pthread -I./libpthread/linuxthreads.old -I./libpthread -I./libc/sysdeps/linux/common -isystem /home/wbx/embedded-test/opena dk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/lib/gcc/alpha-openadk-linux-uclibc/5.3.0/include-fixed -isystem /home/wbx/embedded-test/openadk/toolchain_qemu-alpha_uclibc-ng_alpha/usr/lib/gcc/a lpha-openadk-linux-uclibc/5.3.0/include -I/home/wbx/embedded-test/openadk/target_qemu-alpha_uclibc-ng_alpha/usr/include/ -DNDEBUG -DIN_LIB=libc -fPIC -MT libc/sysdeps/linux/common/open.os -MD -MP -MF libc/sysdeps/linux/common/.open.os.dep In file included from ./include/sys/syscall.h:34:0, from libc/sysdeps/linux/common/open.c:10: ./include/cancel.h:43:19: error: conflicting types for '__open2_nocancel' #define _NC(name) __##name##_nocancel ^ ./include/bits/syscalls-common.h:96:6: note: in definition of macro 'SYSCALL_FUNC' type name(C_DECL_ARGS_##nargs(args)) { \ ^ libc/sysdeps/linux/common/open.c:22:1: note: in expansion of macro '_syscall2' _syscall2(int, __NC(open2), const char *, file, int, flags) ^ ./include/cancel.h:42:20: note: in expansion of macro '_NC' #define __NC(name) _NC(name) ^ libc/sysdeps/linux/common/open.c:22:16: note: in expansion of macro '__NC' _syscall2(int, __NC(open2), const char *, file, int, flags) ^
Any idea?
OK. It my mistake. I'll sent fixed patches.
best regards Waldemar