Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

3544 save-args matcher could be considerably more robust

3545 save-args matcher should accept saves may be out-of-order
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Approved by: Gordon Ross <gwr@nexenta.com>
  • Loading branch information...
commit 702941cd97e30d600c2c1275823bc58231b2c361 1 parent 8cc2da6
@richlowe richlowe authored
Showing with 888 additions and 115 deletions.
  1. +8 −0 exception_lists/packaging
  2. +1 −10 usr/src/cmd/mdb/intel/amd64/Makefile.kmdb
  3. +1 −0  usr/src/cmd/mdb/intel/amd64/kmdb/Makefile
  4. +2 −10 usr/src/cmd/mdb/intel/amd64/mdb/Makefile
  5. +6 −3 usr/src/lib/Makefile
  6. +1 −2  usr/src/lib/libdisasm/common/libdisasm.h
  7. +1 −0  usr/src/lib/libdisasm/common/mapfile-vers
  8. +9 −2 usr/src/lib/libdisasm/i386/dis_i386.c
  9. +7 −3 usr/src/lib/libdisasm/sparc/dis_sparc.c
  10. +0 −7 usr/src/lib/libproc/Makefile.com
  11. +1 −2  usr/src/lib/libproc/amd64/Makefile
  12. +65 −0 usr/src/lib/libsaveargs/Makefile
  13. +99 −0 usr/src/lib/libsaveargs/Makefile.com
  14. +80 −0 usr/src/lib/libsaveargs/Makefile.targ
  15. +34 −0 usr/src/lib/libsaveargs/amd64/Makefile
  16. +154 −48 usr/src/{common/saveargs → lib/libsaveargs/amd64}/saveargs.c
  17. +18 −0 usr/src/lib/libsaveargs/common/linktest_stand.c
  18. +17 −0 usr/src/lib/libsaveargs/common/llib-lsaveargs
  19. +35 −0 usr/src/lib/libsaveargs/common/mapfile-vers
  20. 0  usr/src/{common/saveargs → lib/libsaveargs/common}/saveargs.h
  21. +5 −0 usr/src/{common/saveargs → lib/libsaveargs}/tests/README
  22. +39 −0 usr/src/lib/libsaveargs/tests/dump/Makefile
  23. +167 −0 usr/src/lib/libsaveargs/tests/dump/dump.c
  24. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/Makefile
  25. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/align.c
  26. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/basic.c
  27. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/big-struct-ret-and-spill.c
  28. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/big-struct-ret.c
  29. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/small-struct-ret-and-spill.c
  30. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/small-struct-ret.c
  31. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/stack-spill.c
  32. 0  usr/src/{common/saveargs → lib/libsaveargs}/tests/functional/test.sh
  33. +5 −6 usr/src/{common/saveargs → lib/libsaveargs}/tests/testmatch/Makefile
  34. +72 −0 usr/src/{common/saveargs → lib/libsaveargs}/tests/testmatch/data.s
  35. +59 −21 usr/src/{common/saveargs → lib/libsaveargs}/tests/testmatch/testmatch.c
  36. +1 −0  usr/src/pkg/manifests/system-library.mf
  37. +1 −1  usr/src/tools/findunref/exception_list.open
View
8 exception_lists/packaging
@@ -973,3 +973,11 @@ usr/include/libbe_priv.h
# delivered on SPARC and used by the build.
#
usr/include/sys/ipmi.h sparc
+
+#
+# libsaveargs is private
+#
+usr/include/saveargs.h i386
+usr/lib/amd64/libsaveargs.so i386
+usr/lib/amd64/libstandsaveargs.so i386
+usr/lib/amd64/llib-lsaveargs.ln i386
View
11 usr/src/cmd/mdb/intel/amd64/Makefile.kmdb
@@ -29,15 +29,6 @@ KMDBML += \
KMDBSRCS += \
kmdb_makecontext.c \
- mdb_amd64util.c \
- saveargs.c
-
-%.o: $(SRC)/common/saveargs/%.c
- $(COMPILE.c) $<
- $(CTFCONVERT_O)
-
-%.ln: $(SRC)/common/saveargs/%.c
- $(LINT.c) -c $<
+ mdb_amd64util.c
SACPPFLAGS = -D__$(MACH64) -U__$(MACH)
-CPPFLAGS += -I$(SRC)/common/saveargs
View
1  usr/src/cmd/mdb/intel/amd64/kmdb/Makefile
@@ -62,6 +62,7 @@ include ../../Makefile.amd64
include ../../../Makefile.kmdb
STANDLIBS += $(ROOT)/usr/lib/amd64/libstanddisasm.so
+STANDLIBS += $(ROOT)/usr/lib/amd64/libstandsaveargs.so
INCDIRS += $(SRC)/uts/i86pc $(SRC)/common/dis/i386
View
12 usr/src/cmd/mdb/intel/amd64/mdb/Makefile
@@ -26,8 +26,7 @@
SRCS = kvm_amd64dep.c \
kvm_isadep.c \
mdb_amd64util.c \
- proc_amd64dep.c \
- saveargs.c
+ proc_amd64dep.c
%.o: %.c
$(COMPILE.c) $<
@@ -37,25 +36,18 @@ SRCS = kvm_amd64dep.c \
$(COMPILE.c) $<
$(CTFCONVERT_O)
-%.o: $(SRC)/common/saveargs/%.c
- $(COMPILE.c) $<
- $(CTFCONVERT_O)
-
%.ln: %.c
$(LINT.c) -c $<
%.ln: ../../mdb/%.c
$(LINT.c) -c $<
-%.ln: $(SRC)/common/saveargs/%.c
- $(LINT.c) -c $<
-
include ../../../../Makefile.cmd
include ../../../../Makefile.cmd.64
include ../../Makefile.amd64
include ../../../Makefile.mdb
CPPFLAGS += -I../../mdb
-CPPFLAGS += -I$(SRC)/common/saveargs
+LDLIBS += -lsaveargs
install: all $(ISAEXEC) $(ROOTPROG64) $(ROOTLINK64)
View
9 usr/src/lib/Makefile
@@ -271,7 +271,8 @@ SUBDIRS += \
i386_SUBDIRS= \
libntfs \
libparted \
- libfdisk
+ libfdisk \
+ libsaveargs
sparc_SUBDIRS= .WAIT \
efcode \
@@ -511,7 +512,8 @@ $(CLOSED_BUILD)HDRSUBDIRS += \
i386_HDRSUBDIRS= \
libparted \
- libfdisk
+ libfdisk \
+ libsaveargs
sparc_HDRSUBDIRS= \
libds \
@@ -623,7 +625,7 @@ libpool: libnvpair libexacct
libpp: libast
libzonecfg: libc libsocket libnsl libuuid libnvpair libsysevent libsec \
libbrand libpool libscf
-libproc: ../cmd/sgs/librtld_db ../cmd/sgs/libelf libctf
+libproc: ../cmd/sgs/librtld_db ../cmd/sgs/libelf libctf libsaveargs
libproject: libpool libproc libsecdb
libtermcap: libcurses
libtsnet: libnsl libtsol libsecdb
@@ -635,6 +637,7 @@ pam_modules: libproject passwdutil smbsrv
libscf: libuutil libmd libgen libsmbios libnsl
libinetsvc: libscf
librestart: libuutil libscf
+libsaveargs: libdisasm
../cmd/sgs/libdl: ../cmd/sgs/libconv
../cmd/sgs/libelf: ../cmd/sgs/libconv
pkcs11: libcryptoutil
View
3  usr/src/lib/libdisasm/common/libdisasm.h
@@ -27,8 +27,6 @@
#ifndef _LIBDISASM_H
#define _LIBDISASM_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#ifdef __cplusplus
@@ -67,6 +65,7 @@ extern void dis_set_data(dis_handle_t *, void *);
extern void dis_flags_set(dis_handle_t *, int f);
extern void dis_flags_clear(dis_handle_t *, int f);
extern int dis_max_instrlen(dis_handle_t *);
+extern int dis_instrlen(dis_handle_t *, uint64_t);
/* libdisasm errors */
#define E_DIS_NOMEM 1 /* Out of memory */
View
1  usr/src/lib/libdisasm/common/mapfile-vers
@@ -44,6 +44,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
dis_errno;
dis_handle_create;
dis_handle_destroy;
+ dis_instrlen;
dis_max_instrlen;
dis_previnstr;
dis_set_data;
View
11 usr/src/lib/libdisasm/i386/dis_i386.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <libdisasm.h>
#include <stdlib.h>
#include <stdio.h>
@@ -245,3 +243,12 @@ dis_previnstr(dis_handle_t *dhp, uint64_t pc, int n)
dis_free(hist, sizeof (uint64_t) * n);
return (res);
}
+
+int
+dis_instrlen(dis_handle_t *dhp, uint64_t pc)
+{
+ if (dis_disassemble(dhp, pc, NULL, 0) != 0)
+ return (-1);
+
+ return (dhp->dh_addr - pc);
+}
View
10 usr/src/lib/libdisasm/sparc/dis_sparc.c
@@ -29,9 +29,6 @@
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* The sparc disassembler is mostly straightforward, each instruction is
* represented by an inst_t structure. The inst_t definitions are organized
@@ -229,6 +226,13 @@ dis_previnstr(dis_handle_t *dhp, uint64_t pc, int n)
return (pc - n*4);
}
+/* ARGSUSED */
+int
+dis_instrlen(dis_handle_t *dhp, uint64_t pc)
+{
+ return (4);
+}
+
int
dis_disassemble(dis_handle_t *dhp, uint64_t addr, char *buf, size_t buflen)
{
View
7 usr/src/lib/libproc/Makefile.com
@@ -74,13 +74,6 @@ CMNOBJS = \
ISAOBJS = \
Pisadep.o
-amd64_SAVEOBJS = \
- saveargs.o
-
-amd64_CPPFLAGS = -I$(SRC)/common/saveargs
-
-SAVEOBJS = $($(MACH64)_SAVEOBJS)
-
OBJECTS = $(CMNOBJS) $(ISAOBJS) $(SAVEOBJS)
# include library definitions
View
3  usr/src/lib/libproc/amd64/Makefile
@@ -22,8 +22,6 @@
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
# This is a 64-bit build, and as such needs 64-bit ELF support
CMNOBJS64 = Psymtab_machelf64.o
@@ -32,5 +30,6 @@ include ../Makefile.com
include ../../Makefile.lib.64
CPPFLAGS += -D_SYSCALL32
+LDLIBS += -lsaveargs
install: all $(ROOTLIBS64) $(ROOTLINKS64)
View
65 usr/src/lib/libsaveargs/Makefile
@@ -0,0 +1,65 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+#
+
+include ../Makefile.lib
+
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+delete := TARGET= delete
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+package := TARGET= package
+
+LIBRARY= libsaveargs.a
+
+# definitions for install_h target
+HDRS= saveargs.h
+ROOTHDRDIR= $(ROOT)/usr/include
+ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
+CHECKHDRS= $(HDRS:%.h=common/%.check)
+
+$(ROOTHDRS) := FILEMODE= 644
+
+# install rule for install_h target
+$(ROOTHDRDIR)/%: common/%
+ $(INS.file)
+
+.KEEP_STATE:
+
+all clean clobber delete install lint package: $(SUBDIRS)
+
+install_h: $(ROOTHDRS)
+
+check: $(CHECKHDRS)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
View
99 usr/src/lib/libsaveargs/Makefile.com
@@ -0,0 +1,99 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# The build process for libsaveargs is sightly different from that used by other
+# libraries, because libsaveargs must be built in two flavors - as a standalone
+# for use by kmdb and as a normal library. We use $(CURTYPE) to indicate the
+# current flavor being built.
+#
+
+LIBRARY= libsaveargs.a
+STANDLIBRARY= libstandsaveargs.so
+VERS= .1
+
+# By default, we build the shared library. Construction of the standalone
+# is specifically requested by architecture-specific Makefiles.
+TYPES= library
+CURTYPE= library
+
+COMDIR= $(SRC)/lib/libsaveargs/common
+
+OBJECTS_common_amd64 = saveargs.o
+SRCS_common_amd64 = $(OBJECTS_common_amd64:%.o=../amd64/%.c)
+
+OBJECTS= $(OBJECTS_common_$(MACH)) $(OBJECTS_common_$(MACH64)) $(OBJECTS_common_common)
+
+include $(SRC)/lib/Makefile.lib
+
+SRCS= $(SRCS_common_$(MACH)) $(SRCS_common_$(MACH64)) $(SRC_common_common)
+
+#
+# Used to verify that the standalone doesn't have any unexpected external
+# dependencies.
+#
+LINKTEST_OBJ = objs/linktest_stand.o
+
+CLOBBERFILES_standalone = $(LINKTEST_OBJ)
+CLOBBERFILES += $(CLOBBERFILES_$(CURTYPE))
+
+LIBS_standalone = $(STANDLIBRARY)
+LIBS_library = $(DYNLIB) $(LINTLIB)
+LIBS = $(LIBS_$(CURTYPE))
+
+MAPFILES = $(COMDIR)/mapfile-vers
+
+LDLIBS += -lc -ldisasm
+
+LDFLAGS_standalone = $(ZNOVERSION) $(BREDUCE) -dy -r
+LDFLAGS = $(LDFLAGS_$(CURTYPE))
+
+ASFLAGS_standalone = -DDIS_STANDALONE
+ASFLAGS_library =
+ASFLAGS += -P $(ASFLAGS_$(CURTYPE)) -D_ASM
+
+$(LINTLIB) := SRCS = $(COMDIR)/$(LINTSRC)
+
+# We want the thread-specific errno in the library, but we don't want it in
+# the standalone. $(DTS_ERRNO) is designed to add -D_TS_ERRNO to $(CPPFLAGS),
+# in order to enable this feature. Conveniently, -D_REENTRANT does the same
+# thing. As such, we null out $(DTS_ERRNO) to ensure that the standalone
+# doesn't get it.
+DTS_ERRNO=
+
+CPPFLAGS_standalone = -DDIS_STANDALONE
+CPPFLAGS_library = -D_REENTRANT
+CPPFLAGS += -I$(COMDIR) $(CPPFLAGS_$(CURTYPE))
+
+CFLAGS_standalone = $(STAND_FLAGS_32)
+CFLAGS_common =
+CFLAGS += $(CFLAGS_$(CURTYPE)) $(CFLAGS_common)
+
+CFLAGS64_standalone = $(STAND_FLAGS_64)
+CFLAGS64 += $(CCVERBOSE) $(CFLAGS64_$(CURTYPE)) $(CFLAGS64_common)
+
+DYNFLAGS += $(ZINTERPOSE)
+
+.KEEP_STATE:
View
80 usr/src/lib/libsaveargs/Makefile.targ
@@ -0,0 +1,80 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# We build each flavor in a separate make invocation to improve clarity(!) in
+# Makefile.com. The subordinate makes have $(CURTYPE) set to indicate the
+# flavor they're supposed to build. This causes the correct set of source
+# files and compiler and linker flags to be selected.
+#
+
+install: $(TYPES:%=install.%)
+
+all: $(TYPES:%=all.%)
+
+$(TYPES:%=all.%):
+ @CURTYPE=$(@:all.%=%) $(MAKE) $@.targ
+
+$(TYPES:%=install.%):
+ @CURTYPE=$(@:install.%=%) $(MAKE) $@.targ
+
+install.library.targ: all.library $(INSTALL_DEPS_library)
+install.standalone.targ: all.standalone $(INSTALL_DEPS_standalone)
+
+all.library.targ: $(LIBS)
+all.standalone.targ: $(STANDLIBRARY)
+
+lint: $(TYPES:%=lint.%)
+
+$(TYPES:%=lint.%):
+ @CURTYPE=$(@:lint.%=%) $(MAKE) lintcheck
+
+$(STANDLIBRARY): $(OBJS) $(LINKTEST_OBJ)
+ $(LD) $(BREDUCE) $(ZDEFS) $(LDFLAGS) -o $@.linktest $(OBJS) $(LINKTEST_OBJ)
+ rm $@.linktest
+ $(LD) $(LDFLAGS) -o $@ $(OBJS)
+
+clobber: $(TYPES:%=clobber.%)
+
+$(TYPES:%=clobber.%):
+ @CURTYPE=$(@:clobber.%=%) $(MAKE) clobber.targ
+
+clobber.targ: clean
+ -$(RM) $(CLOBBERTARGFILES)
+
+# include library targets
+include $(SRC)/lib/Makefile.targ
+
+$(PICS): pics
+$(OBJS): objs
+
+objs/%.o pics/%.o: $(COMDIR)/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+# install rule for lint library target
+$(ROOTLINTDIR)/%: $(COMDIR)/%
+ $(INS.file)
+
View
34 usr/src/lib/libsaveargs/amd64/Makefile
@@ -0,0 +1,34 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+TYPES=library standalone
+
+INSTALL_DEPS_library = $(ROOTLINKS64) $(ROOTLINT64) $(ROOTLIBS64)
+INSTALL_DEPS_standalone = $(ROOTLIBS64)
+
+include ../Makefile.targ
View
202 usr/src/common/saveargs/saveargs.c → usr/src/lib/libsaveargs/amd64/saveargs.c
@@ -93,10 +93,7 @@
* function prolog already reserves.
*
* We loop through the first SAVEARGS_INSN_SEQ_LEN bytes of the function
- * looking for each argument saving instruction we would expect to see. We
- * loop byte-by-byte, rather than doing anything smart about insn lengths,
- * only deviating from this when we know we have our insn, and can skip the
- * rest of it.
+ * looking for each argument saving instruction we would expect to see.
*
* If there are odd number of arguments to a function, additional space is
* reserved on the stack to maintain 16-byte alignment. For example,
@@ -108,6 +105,9 @@
#include <sys/sysmacros.h>
#include <sys/types.h>
+#include <libdisasm.h>
+#include <string.h>
+
#include <saveargs.h>
/*
@@ -162,8 +162,8 @@ static const uint32_t save_instr_sr[INSTR_ARRAY_SIZE-1] = {
};
static const uint8_t save_fp_pushes[] = {
- 0x55, /* pushq %rbp */
- 0xcc /* int $0x3 */
+ 0x55, /* pushq %rbp */
+ 0xcc /* int $0x3 */
};
#define NUM_FP_PUSHES (sizeof (save_fp_pushes) / sizeof (save_fp_pushes[0]))
@@ -173,30 +173,80 @@ static const uint32_t save_fp_movs[] = {
};
#define NUM_FP_MOVS (sizeof (save_fp_movs) / sizeof (save_fp_movs[0]))
+typedef struct {
+ uint8_t *data;
+ size_t size;
+} text_t;
+
static int
-has_saved_fp(uint8_t *ins, int size)
+do_read(void *data, uint64_t addr, void *buf, size_t len)
{
- int i, j;
- uint32_t n;
- int found_push = 0;
+ text_t *t = data;
+
+ if (addr >= t->size)
+ return (-1);
+
+ len = MIN(len, t->size - addr);
+
+ (void) memcpy(buf, (char *)t->data + addr, len);
+
+ return (len);
+}
+
+/* ARGSUSED */
+int
+do_lookup(void *data, uint64_t addr, char *buf, size_t buflen, uint64_t *start,
+ size_t *symlen)
+{
+ /* We don't actually need lookup info */
+ return (-1);
+}
+
+static int
+instr_size(dis_handle_t *dhp, uint8_t *ins, unsigned int i, size_t size)
+{
+ text_t t;
+
+ t.data = ins;
+ t.size = size;
+
+ dis_set_data(dhp, &t);
+ return (dis_instrlen(dhp, i));
+}
+
+static boolean_t
+has_saved_fp(dis_handle_t *dhp, uint8_t *ins, int size)
+{
+ int i, j;
+ uint32_t n;
+ boolean_t found_push = B_FALSE;
+ ssize_t sz = 0;
+
+ for (i = 0; i < size; i += sz) {
+ if ((sz = instr_size(dhp, ins, i, size)) < 1)
+ return (B_FALSE);
+
+ if (found_push == B_FALSE) {
+ if (sz != 1)
+ continue;
- for (i = 0; i < size; i++) {
- if (found_push == 0) {
n = INSTR1(ins, i);
for (j = 0; j <= NUM_FP_PUSHES; j++)
if (save_fp_pushes[j] == n) {
- found_push = 1;
+ found_push = B_TRUE;
break;
}
} else {
+ if (sz != 3)
+ continue;
n = INSTR3(ins, i);
for (j = 0; j <= NUM_FP_MOVS; j++)
if (save_fp_movs[j] == n)
- return (1);
+ return (B_TRUE);
}
}
- return (0);
+ return (B_FALSE);
}
int
@@ -204,65 +254,121 @@ saveargs_has_args(uint8_t *ins, size_t size, uint_t argc, int start_index)
{
int i, j;
uint32_t n;
+ uint8_t found = 0;
+ ssize_t sz = 0;
+ dis_handle_t *dhp = NULL;
+ int ret = SAVEARGS_NO_ARGS;
argc = MIN((start_index + argc), INSTR_ARRAY_SIZE);
- if (!has_saved_fp(ins, size))
+ if ((dhp = dis_handle_create(DIS_X86_SIZE64, NULL, do_lookup,
+ do_read)) == NULL)
return (SAVEARGS_NO_ARGS);
+ if (!has_saved_fp(dhp, ins, size)) {
+ dis_handle_destroy(dhp);
+ return (SAVEARGS_NO_ARGS);
+ }
+
/*
- * Compare against Sun Studio implementation
+ * For each possible style of argument saving, walk the insn stream as
+ * we've been given it, and set bit N in 'found' if we find the
+ * instruction saving the Nth argument.
*/
- for (i = 4, j = 0; i <= size - 4; i++) {
- n = INSTR4(ins, i);
-
- if (n == save_instr[j]) {
- i += 3;
- if (++j >= argc)
- return (start_index ? SAVEARGS_STRUCT_ARGS :
- SAVEARGS_TRAD_ARGS);
- }
- }
/*
- * Compare against GCC implementation
+ * Compare against regular implementation
*/
- for (i = 4, j = argc - 1; i <= size - 4; i++) {
+ found = 0;
+ for (i = 0; i < size; i += sz) {
+ sz = instr_size(dhp, ins, i, size);
+
+ if (sz < 1)
+ break;
+ else if (sz != 4)
+ continue;
+
n = INSTR4(ins, i);
- if (n == save_instr[j]) {
- i += 3;
- if (--j < start_index)
- return (SAVEARGS_TRAD_ARGS);
+ for (j = 0; j < argc; j++) {
+ if (n == save_instr[j]) {
+ found |= (1 << j);
+
+ if (found == ((1 << argc) - 1)) {
+ ret = start_index ?
+ SAVEARGS_STRUCT_ARGS :
+ SAVEARGS_TRAD_ARGS;
+ goto done;
+ }
+
+ break;
+ }
}
}
/*
* Compare against GCC push-based implementation
*/
- for (i = 4, j = start_index; i <= size - 2; i += 1) {
- n = (i >= (8 - start_index)) ? INSTR2(ins, i) : INSTR1(ins, i);
-
- if (n == save_instr_push[j]) {
- if (i >= (8 - start_index))
- i += 1;
- if (++j >= argc)
- return (SAVEARGS_TRAD_ARGS);
+ found = 0;
+ for (i = 0; i < size; i += sz) {
+ if ((sz = instr_size(dhp, ins, i, size)) < 1)
+ break;
+
+ for (j = start_index; j < argc; j++) {
+ if (sz == 2) /* Two byte */
+ n = INSTR2(ins, i);
+ else if (sz == 1)
+ n = INSTR1(ins, i);
+ else
+ continue;
+
+ if (n == save_instr_push[j]) {
+ found |= (1 << (j - start_index));
+
+ if (found ==
+ ((1 << (argc - start_index)) - 1)) {
+ ret = SAVEARGS_TRAD_ARGS;
+ goto done;
+ }
+
+ break;
+ }
}
}
- /* Look for a GCC-style returned structure */
+ /*
+ * Look for a GCC-style returned structure.
+ */
+ found = 0;
if (start_index != 0) {
- for (i = 4, j = argc - 2; i <= size - 4; i++) {
+ for (i = 0; i < size; i += sz) {
+ sz = instr_size(dhp, ins, i, size);
+
+ if (sz < 1)
+ break;
+ else if (sz != 4)
+ continue;
+
n = INSTR4(ins, i);
- if (n == save_instr_sr[j]) {
- i += 3;
- if (--j >= (argc - 1))
- return (SAVEARGS_TRAD_ARGS);
+ /* argc is inclusive of start_index, allow for that */
+ for (j = 0; j < (argc - start_index); j++) {
+ if (n == save_instr_sr[j]) {
+ found |= (1 << j);
+
+ if (found ==
+ ((1 << (argc - start_index)) - 1)) {
+ ret = SAVEARGS_TRAD_ARGS;
+ goto done;
+ }
+
+ break;
+ }
}
}
}
- return (SAVEARGS_NO_ARGS);
+done:
+ dis_handle_destroy(dhp);
+ return (ret);
}
View
18 usr/src/lib/libsaveargs/common/linktest_stand.c
@@ -0,0 +1,18 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/* Copyright 2013, Richard Lowe */
+
+void memcpy(void) {}
+void dis_set_data(void) {}
+void dis_instrlen(void) {}
+void dis_handle_create(void) {}
+void dis_handle_destroy(void) {}
View
17 usr/src/lib/libsaveargs/common/llib-lsaveargs
@@ -0,0 +1,17 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/* Copyright 2013, Richard Lowe. */
+
+/* LINTLIBRARY */
+/* PROTOLIB1 */
+
+#include <saveargs.h>
View
35 usr/src/lib/libsaveargs/common/mapfile-vers
@@ -0,0 +1,35 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+# Copyright 2013, Richard Lowe.
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION ILLUMOSprivate {
+ global:
+ saveargs_has_args;
+ local:
+ *;
+};
View
0  usr/src/common/saveargs/saveargs.h → usr/src/lib/libsaveargs/common/saveargs.h
File renamed without changes
View
5 usr/src/common/saveargs/tests/README → usr/src/lib/libsaveargs/tests/README
@@ -7,3 +7,8 @@ functional:
Actually test the full chunk of the (libproc) side of the code, running
pstack on the range of test apps.
+
+dump:
+
+ Display each function in a given object we believe to have saved
+ arguments.
View
39 usr/src/lib/libsaveargs/tests/dump/Makefile
@@ -0,0 +1,39 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2012, Richard Lowe.
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/Makefile.master.64
+
+.KEEP_STATE:
+
+OBJECTS = dump.o
+PROG = dump
+
+CFLAGS += -m64
+
+LDLIBS64 += -lctf -lelf -lsaveargs
+
+C99MODE = $(C99_ENABLE)
+
+$(PROG): $(OBJECTS)
+ $(LINK.c) -o $@ $(OBJECTS) $(LDLIBS64)
+clean:
+ $(RM) $(OBJECTS) $(PROG)
+
+clobber: clean
+
+all: $(PROG)
+
+install: all
View
167 usr/src/lib/libsaveargs/tests/dump/dump.c
@@ -0,0 +1,167 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2011, Robert Mustacchi, Inc. All rights reserved.
+ * Copyright 2013, Richard Lowe.
+ */
+
+#include <err.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <libctf.h>
+#include <saveargs.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+
+extern const char *__progname;
+
+typedef struct symtab_sym {
+ GElf_Sym ss_sym;
+ char *ss_name;
+ ctf_funcinfo_t ss_finfo;
+ uint8_t *ss_data;
+ size_t ss_size;
+} symtab_sym_t;
+
+static void
+walk_symtab(Elf *elf, char *fname, ctf_file_t *fp,
+ void (*callback)(ctf_file_t *, symtab_sym_t *))
+{
+ Elf_Scn *stab = NULL;
+ Elf_Scn *text = NULL;
+ Elf_Data *stabdata = NULL;
+ Elf_Data *textdata = NULL;
+ GElf_Ehdr ehdr;
+ GElf_Shdr stabshdr;
+ GElf_Shdr textshdr;
+ int foundtext = 0, foundstab = 0;
+ symtab_sym_t ss;
+
+ if ((gelf_getehdr(elf, &ehdr)) == NULL)
+ errx(1, "could not read ELF header from %s\n",
+ fname);
+
+ while ((stab = elf_nextscn(elf, stab)) != NULL) {
+ (void) gelf_getshdr(stab, &stabshdr);
+
+ if (stabshdr.sh_type == SHT_SYMTAB) {
+ foundstab = 1;
+ break;
+ }
+ }
+
+ while ((text = elf_nextscn(elf, text)) != NULL) {
+ (void) gelf_getshdr(text, &textshdr);
+
+ if (strcmp(".text", elf_strptr(elf,
+ ehdr.e_shstrndx, (size_t)textshdr.sh_name)) == 0) {
+ foundtext = 1;
+ break;
+ }
+ }
+
+ if (!foundstab || !foundtext)
+ return;
+
+ stabdata = elf_getdata(stab, NULL);
+ textdata = elf_rawdata(text, NULL);
+ for (unsigned symdx = 0;
+ symdx < (stabshdr.sh_size / stabshdr.sh_entsize);
+ symdx++) {
+ (void) gelf_getsym(stabdata, symdx, &ss.ss_sym);
+
+ if ((GELF_ST_TYPE(ss.ss_sym.st_info) != STT_FUNC) ||
+ (ss.ss_sym.st_shndx == SHN_UNDEF))
+ continue;
+
+ ss.ss_name = elf_strptr(elf, stabshdr.sh_link,
+ ss.ss_sym.st_name);
+ ss.ss_data = ((uint8_t *)(textdata->d_buf)) +
+ (ss.ss_sym.st_value - textshdr.sh_addr);
+
+ if (ctf_func_info(fp, symdx, &ss.ss_finfo) == CTF_ERR) {
+ fprintf(stderr, "failed to get funcinfo for: %s\n",
+ ss.ss_name);
+ continue;
+ }
+
+ (void) callback(fp, &ss);
+ }
+}
+
+void
+check_sym(ctf_file_t *ctfp, symtab_sym_t *ss)
+{
+ int rettype = ctf_type_kind(ctfp, ss->ss_finfo.ctc_return);
+ int start_index = 0;
+
+ if (ss->ss_finfo.ctc_argc == 0) /* No arguments, no point */
+ return;
+
+ if (((rettype == CTF_K_STRUCT) || (rettype == CTF_K_UNION)) &&
+ ctf_type_size(ctfp, ss->ss_finfo.ctc_return) > 16)
+ start_index = 1;
+
+ if (saveargs_has_args(ss->ss_data, ss->ss_sym.st_size,
+ ss->ss_finfo.ctc_argc, start_index) != SAVEARGS_NO_ARGS)
+ printf("%s has %d saved args\n", ss->ss_name,
+ ss->ss_finfo.ctc_argc);
+}
+
+int
+main(int argc, char **argv)
+{
+ Elf *elf;
+ ctf_file_t *ctfp;
+ int errp, fd;
+
+ if (ctf_version(CTF_VERSION) == -1)
+ errx(1, "mismatched libctf versions\n");
+
+ if (elf_version(EV_CURRENT) == EV_NONE)
+ errx(1, "mismatched libelf versions\n");
+
+ if (argc != 2)
+ errx(2, "usage: %s <file>\n", __progname);
+
+ if ((ctfp = ctf_open(argv[1], &errp)) == NULL)
+ errx(1, "failed to ctf_open file: %s: %s\n", argv[1],
+ ctf_errmsg(errp));
+
+ if ((fd = open(argv[1], O_RDONLY)) == -1)
+ errx(1, "could not open %s\n", argv[1]);
+
+ if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL)
+ errx(1, "could not interpret ELF from %s\n",
+ argv[1]);
+
+ walk_symtab(elf, argv[1], ctfp, check_sym);
+
+ (void) elf_end(elf);
+ (void) close(fd);
+
+ return (0);
+}
View
0  usr/src/common/saveargs/tests/functional/Makefile → usr/src/lib/libsaveargs/tests/functional/Makefile
File renamed without changes
View
0  usr/src/common/saveargs/tests/functional/align.c → usr/src/lib/libsaveargs/tests/functional/align.c
File renamed without changes
View
0  usr/src/common/saveargs/tests/functional/basic.c → usr/src/lib/libsaveargs/tests/functional/basic.c
File renamed without changes
View
0  ...eargs/tests/functional/big-struct-ret-and-spill.c → ...eargs/tests/functional/big-struct-ret-and-spill.c
File renamed without changes
View
0  ...common/saveargs/tests/functional/big-struct-ret.c → ...lib/libsaveargs/tests/functional/big-struct-ret.c
File renamed without changes
View
0  ...rgs/tests/functional/small-struct-ret-and-spill.c → ...rgs/tests/functional/small-struct-ret-and-spill.c
File renamed without changes
View
0  ...mmon/saveargs/tests/functional/small-struct-ret.c → ...b/libsaveargs/tests/functional/small-struct-ret.c
File renamed without changes
View
0  ...rc/common/saveargs/tests/functional/stack-spill.c → ...rc/lib/libsaveargs/tests/functional/stack-spill.c
File renamed without changes
View
0  usr/src/common/saveargs/tests/functional/test.sh → usr/src/lib/libsaveargs/tests/functional/test.sh
File renamed without changes
View
11 usr/src/common/saveargs/tests/testmatch/Makefile → usr/src/lib/libsaveargs/tests/testmatch/Makefile
@@ -1,3 +1,4 @@
+
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
@@ -18,18 +19,16 @@ include $(SRC)/Makefile.master.64
.KEEP_STATE:
-OBJECTS = testmatch.o saveargs.o data.o
+OBJECTS = testmatch.o data.o
PROG = testmatch
-CPPFLAGS += -I$(SRC)/common/saveargs
+LDLIBS64 += -lsaveargs
+
ASFLAGS += -P
AS_CPPFLAGS += -D_ASM
-%.o: $(SRC)/common/saveargs/%.c
- $(COMPILE.c) -o $@ $<
-
$(PROG): $(OBJECTS)
- $(LINK.c) -o $@ $(OBJECTS) -lc
+ $(LINK.c) -o $@ $(OBJECTS) $(LDLIBS64)
clean:
$(RM) $(OBJECTS) $(PROG)
View
72 usr/src/common/saveargs/tests/testmatch/data.s → usr/src/lib/libsaveargs/tests/testmatch/data.s
@@ -64,6 +64,17 @@ movq %rdi,-0x8(%rbp)
subq $0x50,%rsp
SET_SIZE(gcc_mov_basic, gcc_mov_basic_end)
+FUNC(gcc_mov_noorder)
+pushq %rbp
+movq %rsp, %rbp
+movq %rcx,-0x20(%rbp)
+movq %rbx,-0x28(%rbp)
+movq %rdi,-0x8(%rbp)
+movq %rdx,-0x18(%rbp)
+movq %rsi,-0x10(%rbp)
+subq $0x50,%rsp
+SET_SIZE(gcc_mov_noorder, gcc_mov_noorder_end)
+
FUNC(gcc_mov_big_struct_ret)
pushq %rbp
movq %rsp,%rbp
@@ -75,6 +86,17 @@ movq %rsi,-0x8(%rbp)
subq $0x50,%rsp
SET_SIZE(gcc_mov_big_struct_ret, gcc_mov_big_struct_ret_end)
+FUNC(gcc_mov_struct_noorder)
+pushq %rbp
+movq %rsp,%rbp
+movq %rcx,-0x18(%rbp)
+movq %r8,-0x20(%rbp)
+movq %rsi,-0x8(%rbp)
+movq %rdx,-0x10(%rbp)
+movq %rbx,-0x28(%rbp)
+subq $0x50,%rsp
+SET_SIZE(gcc_mov_struct_noorder, gcc_mov_struct_noorder_end)
+
FUNC(gcc_mov_big_struct_ret_and_spill)
pushq %rbp
movq %rsp,%rbp
@@ -146,6 +168,16 @@ pushq %rcx
subq $0x20,%rsp
SET_SIZE(gcc_push_basic, gcc_push_basic_end)
+FUNC(gcc_push_noorder)
+pushq %rbp
+movq %rsp,%rbp
+pushq %rsi
+pushq %rdi
+pushq %rcx
+pushq %rdx
+subq $0x20,%rsp
+SET_SIZE(gcc_push_noorder, gcc_push_noorder_end)
+
FUNC(gcc_push_big_struct_ret)
pushq %rbp
movq %rsp,%rbp
@@ -156,6 +188,16 @@ pushq %r8
subq $0x30,%rsp
SET_SIZE(gcc_push_big_struct_ret, gcc_push_big_struct_ret_end)
+FUNC(gcc_push_struct_noorder)
+pushq %rbp
+movq %rsp,%rbp
+pushq %rdx
+pushq %rsi
+pushq %r8
+pushq %rcx
+subq $0x30,%rsp
+SET_SIZE(gcc_push_struct_noorder, gcc_push_struct_noorder_end)
+
FUNC(gcc_push_big_struct_ret_and_spill)
pushq %rbp
movq %rsp,%rbp
@@ -394,3 +436,33 @@ movq %rsi,-0x10(%rbp)
movq %rdi,-0x8(%rbp)
subq $0x50,%rsp
SET_SIZE(small_struct_arg_by_value, small_struct_arg_by_value_end)
+
+FUNC(interleaved_argument_saves)
+pushq %rbp
+movq %rdi,%rax
+shlq $0x21,%rax
+movq %rsp,%rbp
+shrq $0x29,%rax
+subq $0x30,%rsp
+movq %rdi,-0x8(%rbp)
+movq %rbx,-0x28(%rbp)
+movzbl %dil,%edi
+movq %rcx,-0x20(%rbp)
+movq %rdx,-0x18(%rbp)
+movq %rsi,-0x10(%rbp)
+movq 0x0(,%rax,8),%rax
+SET_SIZE(interleaved_argument_saves, interleaved_argument_saves_end)
+
+FUNC(jmp_table)
+pushq %rbp
+movq %rsp,%rbp
+.word 0x9afe
+.word 0xffff
+.word 0xffff
+.word 0xa8ff
+.word 0xffff
+.word 0xffff
+.word 0x7cff
+.word 0xffff
+.word 0xffff
+SET_SIZE(jmp_table, jmp_table_end)
View
80 usr/src/common/saveargs/tests/testmatch/testmatch.c → usr/src/lib/libsaveargs/tests/testmatch/testmatch.c
@@ -24,31 +24,55 @@
#define SIZE_OF(name) ((caddr_t)&name##_end - (caddr_t)&name)
#define TEST_GOOD(name, argc) \
- if (saveargs_has_args(name, SIZE_OF(name), argc, 0) != 0) \
- printf("Pass: %s\n", #name); \
- else \
- printf("FAIL: %s\n", #name);
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 0) == \
+ SAVEARGS_TRAD_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
#define TEST_GOOD_STRUCT(name, argc) \
- if (saveargs_has_args(name, SIZE_OF(name), argc, 1) != 0) \
- printf("Pass: %s\n", #name); \
- else \
- printf("FAIL: %s\n", #name);
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 1) == \
+ SAVEARGS_STRUCT_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
+
+/*
+ * GCC deals with structures differently, so TRAD args is actually correct for
+ * this
+ */
+#define TEST_GOOD_GSTRUCT(name, argc) \
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 1) == \
+ SAVEARGS_TRAD_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
#define TEST_BAD(name, argc) \
- if (saveargs_has_args(name, SIZE_OF(name), argc, 0) == 0) \
- printf("Pass: %s\n", #name); \
- else \
- printf("FAIL: %s\n", #name);
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 0) == \
+ SAVEARGS_NO_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
#define TEST_BAD_STRUCT(name, argc) \
- if (saveargs_has_args(name, SIZE_OF(name), argc, 1) == 0) \
- printf("Pass: %s\n", #name); \
- else \
- printf("FAIL: %s\n", #name);
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 1) == \
+ SAVEARGS_NO_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
+
+#define TEST_BAD_GSTRUCT(name, argc) \
+ if (saveargs_has_args(name, SIZE_OF(name), argc, 1) == \
+ SAVEARGS_NO_ARGS) \
+ printf("Pass: %s\n", #name); \
+ else \
+ printf("FAIL: %s\n", #name);
DEF_TEST(gcc_mov_align);
DEF_TEST(gcc_mov_basic);
+DEF_TEST(gcc_mov_noorder);
+DEF_TEST(gcc_mov_struct_noorder);
DEF_TEST(gcc_mov_big_struct_ret);
DEF_TEST(gcc_mov_big_struct_ret_and_spill);
DEF_TEST(gcc_mov_small_struct_ret);
@@ -57,6 +81,8 @@ DEF_TEST(gcc_mov_stack_spill);
DEF_TEST(gcc_push_align);
DEF_TEST(gcc_push_basic);
+DEF_TEST(gcc_push_noorder);
+DEF_TEST(gcc_push_struct_noorder);
DEF_TEST(gcc_push_big_struct_ret);
DEF_TEST(gcc_push_big_struct_ret_and_spill);
DEF_TEST(gcc_push_small_struct_ret);
@@ -79,6 +105,9 @@ DEF_TEST(av1394_ic_bitreverse);
DEF_TEST(small_struct_ret_w_float);
DEF_TEST(big_struct_ret_w_float);
+DEF_TEST(interleaved_argument_saves);
+DEF_TEST(jmp_table);
+
/*
* Functions which should not match
*
@@ -97,7 +126,7 @@ main(int argc, char **argv)
TEST_GOOD(uts_kill, 2);
TEST_GOOD(av1394_ic_bitreverse, 1);
TEST_GOOD(dtrace_instrumented, 4);
- TEST_GOOD_STRUCT(big_struct_ret_w_float, 1);
+ TEST_GOOD_GSTRUCT(big_struct_ret_w_float, 1);
TEST_BAD(no_fp, 5);
TEST_GOOD(gcc_mov_align, 5);
@@ -108,12 +137,18 @@ main(int argc, char **argv)
TEST_GOOD(gcc_push_basic, 4);
TEST_GOOD(ss_mov_basic, 4);
- TEST_GOOD_STRUCT(gcc_mov_big_struct_ret, 4);
- TEST_GOOD_STRUCT(gcc_push_big_struct_ret, 4);
+ TEST_GOOD(gcc_mov_noorder, 4);
+ TEST_GOOD(gcc_push_noorder, 4);
+
+ TEST_GOOD_GSTRUCT(gcc_mov_big_struct_ret, 4);
+ TEST_GOOD_GSTRUCT(gcc_push_big_struct_ret, 4);
TEST_GOOD_STRUCT(ss_mov_big_struct_ret, 4);
- TEST_GOOD_STRUCT(gcc_mov_big_struct_ret_and_spill, 8);
- TEST_GOOD_STRUCT(gcc_push_big_struct_ret_and_spill, 8);
+ TEST_GOOD_GSTRUCT(gcc_mov_struct_noorder, 4);
+ TEST_GOOD_GSTRUCT(gcc_push_struct_noorder, 4);
+
+ TEST_GOOD_GSTRUCT(gcc_mov_big_struct_ret_and_spill, 8);
+ TEST_GOOD_GSTRUCT(gcc_push_big_struct_ret_and_spill, 8);
TEST_GOOD_STRUCT(ss_mov_big_struct_ret_and_spill, 8);
TEST_GOOD(gcc_mov_small_struct_ret, 4);
@@ -133,5 +168,8 @@ main(int argc, char **argv)
TEST_BAD(small_struct_ret_w_float, 1);
+ TEST_GOOD(interleaved_argument_saves, 4);
+ TEST_BAD(jmp_table, 1);
+
return (0);
}
View
1  usr/src/pkg/manifests/system-library.mf
@@ -351,6 +351,7 @@ file path=usr/lib/$(ARCH64)/libpkcs11.so.1
file path=usr/lib/$(ARCH64)/libproject.so.1
file path=usr/lib/$(ARCH64)/libraidcfg.so.1
file path=usr/lib/$(ARCH64)/libreparse.so.1
+$(i386_ONLY)file path=usr/lib/$(ARCH64)/libsaveargs.so.1
file path=usr/lib/$(ARCH64)/libsched.so.1
file path=usr/lib/$(ARCH64)/libsctp.so.1
file path=usr/lib/$(ARCH64)/libshell.so.1
View
2  usr/src/tools/findunref/exception_list.open
@@ -132,7 +132,7 @@
./usr/src/lib/crypt_modules/sha256/test.c
./usr/src/lib/efcode/fcode_test
./usr/src/lib/libkvm/common/test.c
-./usr/src/common/saveargs/tests/
+./usr/src/lib/libsaveargs/tests/
#
# Ignore debugging code.
Please sign in to comment.
Something went wrong with that request. Please try again.