summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lowe <richlowe@richlowe.net>2013-02-09 17:21:16 -0500
committerRichard Lowe <richlowe@richlowe.net>2013-03-17 18:53:58 -0400
commit702941cd97e30d600c2c1275823bc58231b2c361 (patch)
tree2241e87e78f1f9bd2888920010c1739a4309256d
parent8cc2da61b2209ea79a015eead3f390ecf885fcfb (diff)
downloadillumos-joyent-702941cd97e30d600c2c1275823bc58231b2c361.tar.gz
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>
-rw-r--r--exception_lists/packaging8
-rw-r--r--usr/src/cmd/mdb/intel/amd64/Makefile.kmdb11
-rw-r--r--usr/src/cmd/mdb/intel/amd64/kmdb/Makefile1
-rw-r--r--usr/src/cmd/mdb/intel/amd64/mdb/Makefile12
-rw-r--r--usr/src/lib/Makefile9
-rw-r--r--usr/src/lib/libdisasm/common/libdisasm.h3
-rw-r--r--usr/src/lib/libdisasm/common/mapfile-vers1
-rw-r--r--usr/src/lib/libdisasm/i386/dis_i386.c11
-rw-r--r--usr/src/lib/libdisasm/sparc/dis_sparc.c10
-rw-r--r--usr/src/lib/libproc/Makefile.com7
-rw-r--r--usr/src/lib/libproc/amd64/Makefile3
-rw-r--r--usr/src/lib/libsaveargs/Makefile65
-rw-r--r--usr/src/lib/libsaveargs/Makefile.com99
-rw-r--r--usr/src/lib/libsaveargs/Makefile.targ80
-rw-r--r--usr/src/lib/libsaveargs/amd64/Makefile34
-rw-r--r--usr/src/lib/libsaveargs/amd64/saveargs.c (renamed from usr/src/common/saveargs/saveargs.c)202
-rw-r--r--usr/src/lib/libsaveargs/common/linktest_stand.c18
-rw-r--r--usr/src/lib/libsaveargs/common/llib-lsaveargs17
-rw-r--r--usr/src/lib/libsaveargs/common/mapfile-vers35
-rw-r--r--usr/src/lib/libsaveargs/common/saveargs.h (renamed from usr/src/common/saveargs/saveargs.h)0
-rw-r--r--usr/src/lib/libsaveargs/tests/README (renamed from usr/src/common/saveargs/tests/README)5
-rw-r--r--usr/src/lib/libsaveargs/tests/dump/Makefile39
-rw-r--r--usr/src/lib/libsaveargs/tests/dump/dump.c167
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/Makefile (renamed from usr/src/common/saveargs/tests/functional/Makefile)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/align.c (renamed from usr/src/common/saveargs/tests/functional/align.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/basic.c (renamed from usr/src/common/saveargs/tests/functional/basic.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/big-struct-ret-and-spill.c (renamed from usr/src/common/saveargs/tests/functional/big-struct-ret-and-spill.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/big-struct-ret.c (renamed from usr/src/common/saveargs/tests/functional/big-struct-ret.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/small-struct-ret-and-spill.c (renamed from usr/src/common/saveargs/tests/functional/small-struct-ret-and-spill.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/small-struct-ret.c (renamed from usr/src/common/saveargs/tests/functional/small-struct-ret.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/stack-spill.c (renamed from usr/src/common/saveargs/tests/functional/stack-spill.c)0
-rw-r--r--usr/src/lib/libsaveargs/tests/functional/test.sh (renamed from usr/src/common/saveargs/tests/functional/test.sh)0
-rw-r--r--usr/src/lib/libsaveargs/tests/testmatch/Makefile (renamed from usr/src/common/saveargs/tests/testmatch/Makefile)11
-rw-r--r--usr/src/lib/libsaveargs/tests/testmatch/data.s (renamed from usr/src/common/saveargs/tests/testmatch/data.s)72
-rw-r--r--usr/src/lib/libsaveargs/tests/testmatch/testmatch.c (renamed from usr/src/common/saveargs/tests/testmatch/testmatch.c)80
-rw-r--r--usr/src/pkg/manifests/system-library.mf1
-rw-r--r--usr/src/tools/findunref/exception_list.open2
37 files changed, 888 insertions, 115 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging
index ebd5918bcb..16e0efd34d 100644
--- a/exception_lists/packaging
+++ b/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
diff --git a/usr/src/cmd/mdb/intel/amd64/Makefile.kmdb b/usr/src/cmd/mdb/intel/amd64/Makefile.kmdb
index 278724bb74..61cf1541a2 100644
--- a/usr/src/cmd/mdb/intel/amd64/Makefile.kmdb
+++ b/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
diff --git a/usr/src/cmd/mdb/intel/amd64/kmdb/Makefile b/usr/src/cmd/mdb/intel/amd64/kmdb/Makefile
index 59edd9bec0..bfd7b9489a 100644
--- a/usr/src/cmd/mdb/intel/amd64/kmdb/Makefile
+++ b/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
diff --git a/usr/src/cmd/mdb/intel/amd64/mdb/Makefile b/usr/src/cmd/mdb/intel/amd64/mdb/Makefile
index 6542718c6b..3dfa7a34d5 100644
--- a/usr/src/cmd/mdb/intel/amd64/mdb/Makefile
+++ b/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)
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 5cee920575..6835c29fea 100644
--- a/usr/src/lib/Makefile
+++ b/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
diff --git a/usr/src/lib/libdisasm/common/libdisasm.h b/usr/src/lib/libdisasm/common/libdisasm.h
index bcd7318cd1..3329d565f5 100644
--- a/usr/src/lib/libdisasm/common/libdisasm.h
+++ b/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 */
diff --git a/usr/src/lib/libdisasm/common/mapfile-vers b/usr/src/lib/libdisasm/common/mapfile-vers
index 2363cf5175..8261e04067 100644
--- a/usr/src/lib/libdisasm/common/mapfile-vers
+++ b/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;
diff --git a/usr/src/lib/libdisasm/i386/dis_i386.c b/usr/src/lib/libdisasm/i386/dis_i386.c
index a940d69f75..a970cc76fb 100644
--- a/usr/src/lib/libdisasm/i386/dis_i386.c
+++ b/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 @@ done:
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);
+}
diff --git a/usr/src/lib/libdisasm/sparc/dis_sparc.c b/usr/src/lib/libdisasm/sparc/dis_sparc.c
index b9821a304c..70f4ee549b 100644
--- a/usr/src/lib/libdisasm/sparc/dis_sparc.c
+++ b/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)
{
diff --git a/usr/src/lib/libproc/Makefile.com b/usr/src/lib/libproc/Makefile.com
index 794c54f3eb..cca3c3255f 100644
--- a/usr/src/lib/libproc/Makefile.com
+++ b/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
diff --git a/usr/src/lib/libproc/amd64/Makefile b/usr/src/lib/libproc/amd64/Makefile
index 1e20da114e..01b08012b0 100644
--- a/usr/src/lib/libproc/amd64/Makefile
+++ b/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)
diff --git a/usr/src/lib/libsaveargs/Makefile b/usr/src/lib/libsaveargs/Makefile
new file mode 100644
index 0000000000..bbc26c7e7f
--- /dev/null
+++ b/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:
diff --git a/usr/src/lib/libsaveargs/Makefile.com b/usr/src/lib/libsaveargs/Makefile.com
new file mode 100644
index 0000000000..6db07cb87c
--- /dev/null
+++ b/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:
diff --git a/usr/src/lib/libsaveargs/Makefile.targ b/usr/src/lib/libsaveargs/Makefile.targ
new file mode 100644
index 0000000000..fac60a013e
--- /dev/null
+++ b/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)
+
diff --git a/usr/src/lib/libsaveargs/amd64/Makefile b/usr/src/lib/libsaveargs/amd64/Makefile
new file mode 100644
index 0000000000..de0c2793f7
--- /dev/null
+++ b/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
diff --git a/usr/src/common/saveargs/saveargs.c b/usr/src/lib/libsaveargs/amd64/saveargs.c
index c75d07e5b9..f07ef354c1 100644
--- a/usr/src/common/saveargs/saveargs.c
+++ b/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);
}
diff --git a/usr/src/lib/libsaveargs/common/linktest_stand.c b/usr/src/lib/libsaveargs/common/linktest_stand.c
new file mode 100644
index 0000000000..10b74e15ef
--- /dev/null
+++ b/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) {}
diff --git a/usr/src/lib/libsaveargs/common/llib-lsaveargs b/usr/src/lib/libsaveargs/common/llib-lsaveargs
new file mode 100644
index 0000000000..ef08c73ed8
--- /dev/null
+++ b/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>
diff --git a/usr/src/lib/libsaveargs/common/mapfile-vers b/usr/src/lib/libsaveargs/common/mapfile-vers
new file mode 100644
index 0000000000..f2a61065e5
--- /dev/null
+++ b/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:
+ *;
+};
diff --git a/usr/src/common/saveargs/saveargs.h b/usr/src/lib/libsaveargs/common/saveargs.h
index c20707d615..c20707d615 100644
--- a/usr/src/common/saveargs/saveargs.h
+++ b/usr/src/lib/libsaveargs/common/saveargs.h
diff --git a/usr/src/common/saveargs/tests/README b/usr/src/lib/libsaveargs/tests/README
index d97be601f6..b3d833faa1 100644
--- a/usr/src/common/saveargs/tests/README
+++ b/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.
diff --git a/usr/src/lib/libsaveargs/tests/dump/Makefile b/usr/src/lib/libsaveargs/tests/dump/Makefile
new file mode 100644
index 0000000000..41c2f51cd9
--- /dev/null
+++ b/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
diff --git a/usr/src/lib/libsaveargs/tests/dump/dump.c b/usr/src/lib/libsaveargs/tests/dump/dump.c
new file mode 100644
index 0000000000..7b4a628d4a
--- /dev/null
+++ b/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);
+}
diff --git a/usr/src/common/saveargs/tests/functional/Makefile b/usr/src/lib/libsaveargs/tests/functional/Makefile
index d8810eb49a..d8810eb49a 100644
--- a/usr/src/common/saveargs/tests/functional/Makefile
+++ b/usr/src/lib/libsaveargs/tests/functional/Makefile
diff --git a/usr/src/common/saveargs/tests/functional/align.c b/usr/src/lib/libsaveargs/tests/functional/align.c
index 731ca5eccb..731ca5eccb 100644
--- a/usr/src/common/saveargs/tests/functional/align.c
+++ b/usr/src/lib/libsaveargs/tests/functional/align.c
diff --git a/usr/src/common/saveargs/tests/functional/basic.c b/usr/src/lib/libsaveargs/tests/functional/basic.c
index 4a6a3819a6..4a6a3819a6 100644
--- a/usr/src/common/saveargs/tests/functional/basic.c
+++ b/usr/src/lib/libsaveargs/tests/functional/basic.c
diff --git a/usr/src/common/saveargs/tests/functional/big-struct-ret-and-spill.c b/usr/src/lib/libsaveargs/tests/functional/big-struct-ret-and-spill.c
index 4823346299..4823346299 100644
--- a/usr/src/common/saveargs/tests/functional/big-struct-ret-and-spill.c
+++ b/usr/src/lib/libsaveargs/tests/functional/big-struct-ret-and-spill.c
diff --git a/usr/src/common/saveargs/tests/functional/big-struct-ret.c b/usr/src/lib/libsaveargs/tests/functional/big-struct-ret.c
index 0953622f0d..0953622f0d 100644
--- a/usr/src/common/saveargs/tests/functional/big-struct-ret.c
+++ b/usr/src/lib/libsaveargs/tests/functional/big-struct-ret.c
diff --git a/usr/src/common/saveargs/tests/functional/small-struct-ret-and-spill.c b/usr/src/lib/libsaveargs/tests/functional/small-struct-ret-and-spill.c
index 6cbc0cde47..6cbc0cde47 100644
--- a/usr/src/common/saveargs/tests/functional/small-struct-ret-and-spill.c
+++ b/usr/src/lib/libsaveargs/tests/functional/small-struct-ret-and-spill.c
diff --git a/usr/src/common/saveargs/tests/functional/small-struct-ret.c b/usr/src/lib/libsaveargs/tests/functional/small-struct-ret.c
index 3731365f11..3731365f11 100644
--- a/usr/src/common/saveargs/tests/functional/small-struct-ret.c
+++ b/usr/src/lib/libsaveargs/tests/functional/small-struct-ret.c
diff --git a/usr/src/common/saveargs/tests/functional/stack-spill.c b/usr/src/lib/libsaveargs/tests/functional/stack-spill.c
index 4324d60c27..4324d60c27 100644
--- a/usr/src/common/saveargs/tests/functional/stack-spill.c
+++ b/usr/src/lib/libsaveargs/tests/functional/stack-spill.c
diff --git a/usr/src/common/saveargs/tests/functional/test.sh b/usr/src/lib/libsaveargs/tests/functional/test.sh
index dea1059b2c..dea1059b2c 100644
--- a/usr/src/common/saveargs/tests/functional/test.sh
+++ b/usr/src/lib/libsaveargs/tests/functional/test.sh
diff --git a/usr/src/common/saveargs/tests/testmatch/Makefile b/usr/src/lib/libsaveargs/tests/testmatch/Makefile
index 2277b64c60..0bea0f4d87 100644
--- a/usr/src/common/saveargs/tests/testmatch/Makefile
+++ b/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)
diff --git a/usr/src/common/saveargs/tests/testmatch/data.s b/usr/src/lib/libsaveargs/tests/testmatch/data.s
index 4d2660b24a..77a5b30394 100644
--- a/usr/src/common/saveargs/tests/testmatch/data.s
+++ b/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)
diff --git a/usr/src/common/saveargs/tests/testmatch/testmatch.c b/usr/src/lib/libsaveargs/tests/testmatch/testmatch.c
index b670a67bbd..0af4a1cb78 100644
--- a/usr/src/common/saveargs/tests/testmatch/testmatch.c
+++ b/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);
}
diff --git a/usr/src/pkg/manifests/system-library.mf b/usr/src/pkg/manifests/system-library.mf
index 90888c3979..452b6aae14 100644
--- a/usr/src/pkg/manifests/system-library.mf
+++ b/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
diff --git a/usr/src/tools/findunref/exception_list.open b/usr/src/tools/findunref/exception_list.open
index 5b0c90ea1a..afc9b44a2f 100644
--- a/usr/src/tools/findunref/exception_list.open
+++ b/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.