diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-02-17 13:17:49 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-02-17 13:17:49 +0100 |
commit | 09a87ae9712acb3725fb76d3f71215e168215611 (patch) | |
tree | 3bdbe689d0cf133477ec5b4d06369c4bfabb1615 /test | |
parent | 782d90f9187e290f4523efe04a6e0eacdeb68613 (diff) | |
download | strace-09a87ae9712acb3725fb76d3f71215e168215611.tar.gz strace-09a87ae9712acb3725fb76d3f71215e168215611.tar.bz2 strace-09a87ae9712acb3725fb76d3f71215e168215611.tar.xz |
Remove wrong x32-specific lseek
Testing confirmed what I suspected: x32 lseek uses kernel-sized
(i.e. wide) long for offset parameter.
* file.c: Delete sys_lseek32.
* linux/syscall.h: Likewise.
* linux/x32/syscallent1.h: Likewise.
* test/x32_lseek.c: New file.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/x32_lseek.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/x32_lseek.c b/test/x32_lseek.c new file mode 100644 index 0000000..6faa2fa --- /dev/null +++ b/test/x32_lseek.c @@ -0,0 +1,38 @@ +// Test program which explores whether lseek syscall (not llseek!) +// on x32 uses 64-bit offset argument. +// IOW: does _kernel_ truncate it on entry? +// The answer appears to be "no, full 64-bit offset is used". +// strace must show it correctly too - tricky if strace itself is x32 one! +// +// Build: x86_64-gcc -static -Wall -ox32_lseek x32_lseek.c +// Run: $ strace ./x32_lseek 2>&1 | grep lseek | grep 1250999896321 +// lseek(0, 1250999896321, SEEK_SET) = 1250999896321 +#define _GNU_SOURCE +#include <sys/types.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <sys/syscall.h> +// Ensure we are compiling to 64 bits +struct bug { int t[sizeof(long) > 4 ? 1 : -1]; }; +int main(int argc, char **argv) +{ + long ofs = 0x12345678901; + errno = 0; + close(0); + if (open("/etc/passwd", O_RDONLY)) + return 1; + long r = syscall( + (long) (__NR_lseek | 0x40000000), // make x32 call + (long) (0), + (long) (ofs), + (long) (SEEK_SET) + ); + printf("pos:%ld(0x%lx) errno:%m\n", r, r); + if (!errno) + printf((r == ofs) ? "64-bit offset used\n" : "Kernel truncated offset\n"); + return 0; +} |