summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2007-07-28 23:15:04 +0000
committermarcel <marcel@FreeBSD.org>2007-07-28 23:15:04 +0000
commitaa233d32b1e7dc57144bc67c340f3c52c982328b (patch)
tree321b250e205daf0306e621989b97304217f90226 /usr.bin
parent03338701312c15220e1e66fcb969bd95cdfeb54c (diff)
downloadFreeBSD-src-aa233d32b1e7dc57144bc67c340f3c52c982328b.zip
FreeBSD-src-aa233d32b1e7dc57144bc67c340f3c52c982328b.tar.gz
Fix handling of Quad-type arguments. Previously, syscalls
containing 64-bit arguments would have explicit padding. On 64-bit platforms there was no padding, so the dummy argument was not covering anything. On 32-bit platforms with weak alignment (i.e. i386) the 64-bit argument did not need to be aligned, so there too an aditional argument was introduced. On 32-bit platforms with strong alignment (i.e. PowerPC) the dummy argument in fact cover the padding. By elimininating the dummy argument, 64-bit platforms now have 1 argument less. This also applies to 32-bit platforms with weak alignment. On PowerPC this doesn't matter, because the padding is still there. We just don't "name" it. Deal with those 3 cases. Approved by: re (kensmith)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/truss/amd64-fbsd32.c2
-rw-r--r--usr.bin/truss/i386-fbsd.c2
-rw-r--r--usr.bin/truss/powerpc-fbsd.c3
-rw-r--r--usr.bin/truss/syscalls.c28
4 files changed, 23 insertions, 12 deletions
diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c
index 6abd99f..4f0eabb 100644
--- a/usr.bin/truss/amd64-fbsd32.c
+++ b/usr.bin/truss/amd64-fbsd32.c
@@ -167,7 +167,7 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) {
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = (void *)parm_offset;
iorequest.piod_addr = fsc.args;
- iorequest.piod_len = nargs * sizeof(unsigned long);
+ iorequest.piod_len = (1+nargs) * sizeof(unsigned long);
ptrace(PT_IO, cpid, (caddr_t)&iorequest, 0);
if (iorequest.piod_len == 0)
return;
diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c
index 6abd99f..4f0eabb 100644
--- a/usr.bin/truss/i386-fbsd.c
+++ b/usr.bin/truss/i386-fbsd.c
@@ -167,7 +167,7 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) {
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = (void *)parm_offset;
iorequest.piod_addr = fsc.args;
- iorequest.piod_len = nargs * sizeof(unsigned long);
+ iorequest.piod_len = (1+nargs) * sizeof(unsigned long);
ptrace(PT_IO, cpid, (caddr_t)&iorequest, 0);
if (iorequest.piod_len == 0)
return;
diff --git a/usr.bin/truss/powerpc-fbsd.c b/usr.bin/truss/powerpc-fbsd.c
index aad4b87..7b4cfb5 100644
--- a/usr.bin/truss/powerpc-fbsd.c
+++ b/usr.bin/truss/powerpc-fbsd.c
@@ -118,6 +118,9 @@ powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs) {
unsigned int regargs;
struct syscall *sc;
+ /* Account for a 64-bit argument with corresponding alignment. */
+ nargs += 2;
+
cpid = trussinfo->curthread->tid;
clear_fsc();
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 5eff8d6..0a8ac6b 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -72,6 +72,20 @@ static const char rcsid[] =
#include "extern.h"
#include "syscall.h"
+/* 64-bit alignment on 32-bit platforms. */
+#ifdef __powerpc__
+#define QUAD_ALIGN 1
+#else
+#define QUAD_ALIGN 0
+#endif
+
+/* Number of slots needed for a 64-bit argument. */
+#ifdef __LP64__
+#define QUAD_SLOTS 1
+#else
+#define QUAD_SLOTS 2
+#endif
+
/*
* This should probably be in its own file, sorted alphabetically.
*/
@@ -82,19 +96,13 @@ struct syscall syscalls[] = {
{ "readlink", 1, 3,
{ { Name, 0 } , { Readlinkres | OUT, 1 }, { Int, 2 }}},
{ "lseek", 2, 3,
-#ifdef __LP64__
- { { Int, 0 }, {Quad, 2 }, { Whence, 3 }}},
-#else
- { { Int, 0 }, {Quad, 2 }, { Whence, 4 }}},
-#endif
+ { {Int, 0}, {Quad, 1 + QUAD_ALIGN},
+ {Whence, 1 + QUAD_SLOTS + QUAD_ALIGN}}},
{ "linux_lseek", 2, 3,
{ { Int, 0 }, {Int, 1 }, { Whence, 2 }}},
{ "mmap", 2, 6,
-#ifdef __LP64__
- { { Ptr, 0 }, {Int, 1}, {Mprot, 2}, {Mmapflags, 3}, {Int, 4}, {Quad, 5}}},
-#else
- { { Ptr, 0 }, {Int, 1}, {Mprot, 2}, {Mmapflags, 3}, {Int, 4}, {Quad, 6}}},
-#endif
+ { {Ptr, 0}, {Int, 1}, {Mprot, 2}, {Mmapflags, 3}, {Int, 4},
+ {Quad, 5 + QUAD_ALIGN}}},
{ "mprotect", 1, 3,
{ { Ptr, 0 }, {Int, 1}, {Mprot, 2}}},
{ "open", 1, 3,
OpenPOWER on IntegriCloud