[PATCH] pread_write on powerpc

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue Aug 19 10:17:50 UTC 2008


On Mon, Aug 18, 2008 at 04:26:25PM -0600, Wade Berrier wrote:
>Hi,
>
>I mailed previously about this issue:
>
>  LD libuClibc-0.9.29.so
>libc/libc_so.a(pread_write.os):(.text+0x14): undefined reference to
>`__illegally_sized_syscall_arg4'
>make[2]: *** [lib/libc.so] Error 1
>make[1]: *** [lib/libc.so.0] Error 2
>
>As said here
>( http://www.busybox.net/lists/uclibc/2007-March/017682.html ) this is a
>linking error that uncovers source code bugs.
>
>The error is because pread/write wants to send an 8 byte value in the
>system call, where only 4 bytes are allowed.
>
>I looked at what some other architectures are doing, as well as glibc,
>and found that the offset needs to be split up into a 4 byte pair.
>
>It works for the minimal pread tests I've done.
>
>I haven't tested without LFS support, but no patching would be necessary
>in that case since the offset would only be 4 bytes.

Can you please verify this with LFS turned off nevertheless?
TIA,
>
>Attached is a patch against trunk.
>
>Thanks,
>
>Wade

>Index: uClibc/libc/sysdeps/linux/powerpc/pread_write.c
>===================================================================
>--- uClibc/libc/sysdeps/linux/powerpc/pread_write.c	(revision 23102)
>+++ uClibc/libc/sysdeps/linux/powerpc/pread_write.c	(working copy)
>@@ -14,6 +14,7 @@
> 
> #include <sys/syscall.h>
> #include <unistd.h>
>+#include <endian.h>
> 
> #ifndef __UCLIBC_HAS_LFS__
> # define off64_t off_t
>@@ -22,12 +23,12 @@
> #ifdef __NR_pread
> extern __typeof(pread) __libc_pread;
> # define __NR___syscall_pread __NR_pread
>-static __inline__ _syscall4(ssize_t, __syscall_pread, int, fd,
>-		void *, buf, size_t, count, off64_t, offset);
>+static __inline__ _syscall6(ssize_t, __syscall_pread, int, fd,
>+		void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
> 
> ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
> {
>-	return(__syscall_pread(fd, buf, count, (off64_t)offset));
>+	return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
> }
> weak_alias(__libc_pread,pread)
> 
>@@ -35,7 +36,7 @@
> extern __typeof(pread64) __libc_pread64;
> ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
> {
>-	return(__syscall_pread(fd, buf, count, offset));
>+	return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
> }
> weak_alias(__libc_pread64,pread64)
> # endif /* __UCLIBC_HAS_LFS__  */
>@@ -45,12 +46,12 @@
> #ifdef __NR_pwrite
> extern __typeof(pwrite) __libc_pwrite;
> # define __NR___syscall_pwrite __NR_pwrite
>-static __inline__ _syscall4(ssize_t, __syscall_pwrite, int, fd,
>-		const void *, buf, size_t, count, off64_t, offset);
>+static __inline__ _syscall6(ssize_t, __syscall_pwrite, int, fd,
>+		const void *, buf, size_t, count, int, dummy, off_t, offset_hi, off_t, offset_lo);
> 
> ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
> {
>-	return(__syscall_pwrite(fd, buf, count, (off64_t)offset));
>+	return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 31, offset)));
> }
> weak_alias(__libc_pwrite,pwrite)
> 
>@@ -58,7 +59,7 @@
> extern __typeof(pwrite64) __libc_pwrite64;
> ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
> {
>-	return(__syscall_pwrite(fd, buf, count, offset));
>+	return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR(offset >> 32, offset)));
> }
> weak_alias(__libc_pwrite64,pwrite64)
> # endif /* __UCLIBC_HAS_LFS__  */

>_______________________________________________
>uClibc mailing list
>uClibc at uclibc.org
>http://busybox.net/cgi-bin/mailman/listinfo/uclibc



More information about the uClibc mailing list