Merge ^/head r288197 through r288456.

This commit is contained in:
Dimitry Andric 2015-10-01 19:02:45 +00:00
commit 65dcb5bcb1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/clang370-import/; revision=288457
560 changed files with 11092 additions and 11846 deletions

View File

@ -243,9 +243,9 @@ cleanworld:
# Handle the user-driven targets, using the source relative mk files.
#
.if empty(.MAKEFLAGS:M-n)
.if !(!empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n")
# skip this for -n to avoid changing previous behavior of
# 'make -n buildworld' etc.
# 'make -n buildworld' etc. Using -n -n will run it.
${TGTS}: .MAKE
tinderbox toolchains kernel-toolchains: .MAKE
.endif

View File

@ -257,9 +257,8 @@ BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
WORLDTMP=${WORLDTMP} \
VERSION="${VERSION}" \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
DESTDIR= \
# need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
BSARGS= DESTDIR= \
BOOTSTRAPPING=${OSRELDATE} \
SSP_CFLAGS= \
MK_HTML=no NO_LINT=yes MK_MAN=no \
@ -267,7 +266,11 @@ BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
-DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
MK_LLDB=no MK_TESTS=no \
MK_INCLUDES=yes
MK_INCLUDES=yes
BMAKE= MAKEOBJDIRPREFIX=${WORLDTMP} \
${BMAKEENV} ${MAKE} ${WORLD_FLAGS} -f Makefile.inc1 \
${BSARGS}
# build-tools stage
TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
@ -1255,7 +1258,7 @@ update:
# ELF Tool Chain libraries are needed for ELF tools and dtrace tools.
.if ${BOOTSTRAPPING} < 1100006
_elftoolchain_libs= lib/libelf lib/libdwarf
_elftoolchain_libs= lib/libelf lib/libdwarf
.endif
legacy:
@ -1279,7 +1282,7 @@ legacy:
# binaries is usually quite narrow. Bootstrap tools use the host's compiler and
# libraries, augmented by -legacy.
#
_bt= _bootstrap-tools
_bt= _bootstrap-tools
.if ${MK_GAMES} != "no"
_strfile= games/fortune/strfile
@ -1494,7 +1497,7 @@ _btxld= usr.sbin/btxld
# Rebuild ctfconvert and ctfmerge to avoid difficult-to-diagnose failures
# resulting from missing bug fixes or ELF Toolchain updates.
.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf cddl/usr.bin/ctfconvert \
_dtrace_tools= cddl/lib/libctf cddl/usr.bin/ctfconvert \
cddl/usr.bin/ctfmerge
.endif

View File

@ -101,6 +101,14 @@ OLD_FILES+=usr/lib/clang/3.6.1/lib/freebsd/libclang_rt.ubsan_cxx-x86_64.a
OLD_DIRS+=usr/lib/clang/3.6.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/3.6.1/lib
OLD_DIRS+=usr/lib/clang/3.6.1
# 20150928: unused sgsmsg utility is removed
OLD_FILES+=usr/bin/sgsmsg
# 20150926: remove links to removed/unimplemented mbuf(9) macros
OLD_FILES+=usr/share/man/man9/MEXT_ADD_REF.9.gz
OLD_FILES+=usr/share/man/man9/MEXTFREE.9.gz
OLD_FILES+=usr/share/man/man9/MEXT_IS_REF.9.gz
OLD_FILES+=usr/share/man/man9/MEXT_REM_REF.9.gz
OLD_FILES+=usr/share/man/man9/MFREE.9.gz
# 20150818: *allocm() are gone in jemalloc 4.0.0
OLD_FILES+=usr/share/man/man3/allocm.3.gz
OLD_FILES+=usr/share/man/man3/dallocm.3.gz

View File

@ -13,4 +13,8 @@ CFLAGS+= -DCOLORLS
LIBADD+= termcapw
.endif
.if ${MK_TESTS} != "no"
SUBDIR+= tests
.endif
.include <bsd.prog.mk>

View File

@ -32,7 +32,7 @@
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" $FreeBSD$
.\"
.Dd June 8, 2015
.Dd September 27, 2015
.Dt LS 1
.Os
.Sh NAME
@ -296,9 +296,9 @@ subsection below, except (if the long format is not also requested)
the directory totals are not output when the output is in a
single column, even if multi-column output is requested.
.It Fl t
Sort by descending time modified (most recently modified first). If two files
have the same modification timestamp, sort their names in ascending
lexicographical order.
Sort by descending time modified (most recently modified first).
If two files have the same modification timestamp, sort their names
in ascending lexicographical order.
The
.Fl r
option reverses both of these sort orders.
@ -320,7 +320,7 @@ or use the
option.
This causes
.Nm
to reverse the lexicographal sort order when sorting files with the
to reverse the lexicographical sort order when sorting files with the
same modification timestamp.
.It Fl u
Use time of last access,

11
bin/ls/tests/Makefile Normal file
View File

@ -0,0 +1,11 @@
# $FreeBSD$
TESTSDIR= ${TESTSBASE}/bin/ls
ATF_TESTS_SH+= ls_tests
# This seems like overkill, but the idea in mind is that all of the testcases
# should be runnable as !root
TEST_METADATA.ls_tests+= required_user="unprivileged"
TEST_METADATA.ls_tests+= required_files="/usr/bin/nc"
.include <bsd.test.mk>

359
bin/ls/tests/ls_tests.sh Executable file
View File

@ -0,0 +1,359 @@
#
# Copyright 2015 EMC Corp.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $FreeBSD$
#
create_test_dir()
{
[ -z "$ATF_TMPDIR" ] || return 0
export ATF_TMPDIR=$(pwd)
# XXX: need to nest this because of how kyua creates $TMPDIR; otherwise
# it will run into EPERM issues later
TEST_INPUTS_DIR="${ATF_TMPDIR}/test/inputs"
atf_check -e empty -s exit:0 mkdir -m 0777 -p $TEST_INPUTS_DIR
cd $TEST_INPUTS_DIR
}
create_test_inputs()
{
create_test_dir
atf_check -e empty -s exit:0 mkdir -m 0755 -p a/b
atf_check -e empty -s exit:0 ln -s a/b c
atf_check -e empty -s exit:0 touch d
atf_check -e empty -s exit:0 ln d e
atf_check -e empty -s exit:0 touch .f
atf_check -e empty -s exit:0 mkdir .g
atf_check -e empty -s exit:0 mkfifo h
atf_check -e ignore -s exit:0 dd if=/dev/zero of=i count=1000 bs=1
atf_check -e empty -s exit:0 \
sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid"
atf_check -e empty -s exit:0 touch klmn
atf_check -e empty -s exit:0 touch opqr
atf_check -e empty -s exit:0 touch stuv
atf_check -e empty -s exit:0 touch wxyz
atf_check -e empty -s exit:0 touch 0b00000001
atf_check -e empty -s exit:0 touch 0b00000010
atf_check -e empty -s exit:0 touch 0b00000011
atf_check -e empty -s exit:0 touch 0b00000100
atf_check -e empty -s exit:0 touch 0b00000101
atf_check -e empty -s exit:0 touch 0b00000110
atf_check -e empty -s exit:0 touch 0b00000111
atf_check -e empty -s exit:0 touch 0b00001000
atf_check -e empty -s exit:0 touch 0b00001001
atf_check -e empty -s exit:0 touch 0b00001010
atf_check -e empty -s exit:0 touch 0b00001011
atf_check -e empty -s exit:0 touch 0b00001100
atf_check -e empty -s exit:0 touch 0b00001101
atf_check -e empty -s exit:0 touch 0b00001110
atf_check -e empty -s exit:0 touch 0b00001111
}
atf_test_case a_flag
a_flag_head()
{
atf_set "descr" "Verify -a support"
}
a_flag_body()
{
create_test_dir
# Make sure "." and ".." show up with -a
atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax
create_test_inputs
WITH_a=$PWD/../with_a.out
WITHOUT_a=$PWD/../without_a.out
atf_check -e empty -o save:$WITH_a -s exit:0 ls -A
atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls
echo "-A usage"
cat $WITH_a
echo "No -A usage"
cat $WITHOUT_a
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_a
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_a
done
}
atf_test_case A_flag
A_flag_head()
{
atf_set "descr" "Verify -A support with unprivileged users"
}
A_flag_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 ls -A
create_test_inputs
WITH_A=$PWD/../with_A.out
WITHOUT_A=$PWD/../without_A.out
atf_check -e empty -o save:$WITH_A -s exit:0 ls -A
atf_check -e empty -o save:$WITHOUT_A -s exit:0 ls
echo "-A usage"
cat $WITH_A
echo "No -A usage"
cat $WITHOUT_A
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_A
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_A
done
}
atf_test_case A_flag_implied_when_root
A_flag_implied_when_root_head()
{
atf_set "descr" "Verify that -A is implied for root"
atf_set "require.user" "root"
}
A_flag_implied_when_root_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 ls -A
create_test_inputs
WITH_EXPLICIT=$PWD/../with_explicit_A.out
WITH_IMPLIED=$PWD/../with_implied_A.out
atf_check -e empty -o save:$WITH_EXPLICIT -s exit:0 ls -A
atf_check -e empty -o save:$WITH_IMPLIED -s exit:0 ls
echo "Explicit -A usage"
cat $WITH_EXPLICIT
echo "Implicit -A usage"
cat $WITH_IMPLIED
atf_check_equal "$(cat $WITH_EXPLICIT)" "$(cat $WITH_IMPLIED)"
}
atf_test_case B_flag
B_flag_head()
{
atf_set "descr" "Verify that the output from ls -B prints out non-printable characters"
}
B_flag_body()
{
atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136"
atf_check -e empty -o empty -s exit:0 touch "$(printf "y\013z")"
atf_check -e empty -o match:'y\\013z' -s exit:0 ls -B
}
atf_test_case C_flag
C_flag_head()
{
atf_set "descr" "Verify that the output from ls -C is multi-column, sorted down"
}
C_flag_body()
{
create_test_inputs
WITH_C=$PWD/../with_C.out
atf_check -e empty -o save:$WITH_C -s exit:0 ls -C
echo "With -C usage"
cat $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000001[[:space:]]+0b00000111[[:space:]]+0b00001101[[:space:]]+e[[:space:]]+stuv" $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000010[[:space:]]+0b00001000[[:space:]]+0b00001110[[:space:]]+h[[:space:]]+wxyz" $WITH_C
}
atf_test_case I_flag
I_flag_head()
{
atf_set "descr" "Verify that the output from ls -I is the same as ls for an unprivileged user"
}
I_flag_body()
{
create_test_inputs
WITH_I=$PWD/../with_I.out
WITHOUT_I=$PWD/../without_I.out
atf_check -e empty -o save:$WITH_I -s exit:0 ls -I
atf_check -e empty -o save:$WITHOUT_I -s exit:0 ls
echo "Explicit -I usage"
cat $WITH_I
echo "No -I usage"
cat $WITHOUT_I
atf_check_equal "$(cat $WITH_I)" "$(cat $WITHOUT_I)"
}
atf_test_case I_flag_voids_implied_A_flag_when_root
I_flag_voids_implied_A_flag_when_root_head()
{
atf_set "descr" "Verify that -I voids out implied -A for root"
atf_set "require.user" "root"
}
I_flag_voids_implied_A_flag_when_root_body()
{
create_test_inputs
atf_check -o not-match:'\.f' -s exit:0 ls -I
atf_check -o not-match:'\.g' -s exit:0 ls -I
atf_check -o match:'\.f' -s exit:0 ls -A -I
atf_check -o match:'\.g' -s exit:0 ls -A -I
}
lcomma_flag_head()
{
atf_set "descr" "Verify that -l, prints out the size with , delimiters"
}
lcomma_flag_body()
{
create_test_inputs
atf_check \
-o match:'\-rw\-r\-\-r\-\-[[:space:]]+.+[[:space:]]+1,000[[:space:]]+.+i' \
env LC_ALL=en_US.ISO8859-1 ls -l, i
}
x_flag_head()
{
atf_set "descr" "Verify that -x prints out one item per line"
}
x_flag_body()
{
create_test_inputs
WITH_x=$PWD/../with_x.out
atf_check -e empty -o save:$WITH_x -s exit:0 ls -x
echo "With -x usage"
cat $WITH_x
atf_check -e ignore -o not-empty -s exit:0 \
egrep "a[[:space:]]+c[[:space:]]+d[[:space:]]+e[[:space:]]+h" $WITH_x
atf_check -e ignore -o not-empty -s exit:0 \
egrep "i[[:space:]]+j[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv" $WITH_x
}
1_flag_head()
{
atf_set "descr" "Verify that -1 prints out one item per line"
}
1_flag_body()
{
create_test_inputs
WITH_1=$PWD/../with_1.out
WITHOUT_1=$PWD/../without_1.out
atf_check -e empty -o save:$WITH_1 -s exit:0 ls -1
atf_check -e empty -o save:$WITHOUT_1 -s exit:0 \
sh -c 'for i in $(ls); do echo $i; done'
echo "Explicit -1 usage"
cat $WITH_1
echo "No -1 usage"
cat $WITHOUT_1
atf_check_equal "$(cat $WITH_1)" "$(cat $WITHOUT_1)"
}
atf_init_test_cases()
{
atf_add_test_case A_flag
atf_add_test_case A_flag_implied_when_root
atf_add_test_case B_flag
atf_add_test_case C_flag
#atf_add_test_case D_flag
#atf_add_test_case F_flag
#atf_add_test_case G_flag
#atf_add_test_case H_flag
atf_add_test_case I_flag
atf_add_test_case I_flag_voids_implied_A_flag_when_root
#atf_add_test_case L_flag
#atf_add_test_case P_flag
#atf_add_test_case R_flag
#atf_add_test_case S_flag
#atf_add_test_case T_flag
#atf_add_test_case U_flag
#atf_add_test_case W_flag
#atf_add_test_case Z_flag
atf_add_test_case a_flag
#atf_add_test_case b_flag
#atf_add_test_case c_flag
#atf_add_test_case d_flag
#atf_add_test_case f_flag
#atf_add_test_case g_flag
#atf_add_test_case h_flag
#atf_add_test_case i_flag
#atf_add_test_case k_flag
#atf_add_test_case l_flag
atf_add_test_case lcomma_flag
#atf_add_test_case m_flag
#atf_add_test_case n_flag
#atf_add_test_case o_flag
#atf_add_test_case p_flag
#atf_add_test_case q_flag
#atf_add_test_case r_flag
#atf_add_test_case s_flag
#atf_add_test_case t_flag
#atf_add_test_case u_flag
#atf_add_test_case w_flag
atf_add_test_case x_flag
#atf_add_test_case y_flag
atf_add_test_case 1_flag
}

View File

@ -65,6 +65,7 @@ exportcmd -s export -s readonly
#exprcmd expr
falsecmd false
fgcmd -j fg
freebsd_wordexpcmd freebsd_wordexp
getoptscmd getopts
hashcmd hash
histcmd -h fc

View File

@ -1656,3 +1656,57 @@ wordexpcmd(int argc, char **argv)
outbin(argv[i], strlen(argv[i]) + 1, out1);
return (0);
}
/*
* Do most of the work for wordexp(3), new version.
*/
int
freebsd_wordexpcmd(int argc __unused, char **argv __unused)
{
struct arglist arglist;
union node *args, *n;
struct strlist *sp;
size_t count, len;
int ch;
int protected = 0;
int fd = -1;
while ((ch = nextopt("f:p")) != '\0') {
switch (ch) {
case 'f':
fd = number(shoptarg);
break;
case 'p':
protected = 1;
break;
}
}
if (*argptr != NULL)
error("wrong number of arguments");
if (fd < 0)
error("missing fd");
INTOFF;
setinputfd(fd, 1);
INTON;
args = parsewordexp();
popfile(); /* will also close fd */
if (protected)
for (n = args; n != NULL; n = n->narg.next) {
if (n->narg.backquote != NULL) {
outcslow('C', out1);
error("command substitution disabled");
}
}
outcslow(' ', out1);
arglist.lastp = &arglist.list;
for (n = args; n != NULL; n = n->narg.next)
expandarg(n, &arglist, EXP_FULL | EXP_TILDE);
*arglist.lastp = NULL;
for (sp = arglist.list, count = len = 0; sp; sp = sp->next)
count++, len += strlen(sp->text);
out1fmt("%016zx %016zx", count, len);
for (sp = arglist.list; sp; sp = sp->next)
outbin(sp->text, strlen(sp->text) + 1, out1);
return (0);
}

View File

@ -231,6 +231,39 @@ parsecmd(int interact)
}
/*
* Read and parse words for wordexp.
* Returns a list of NARG nodes; NULL if there are no words.
*/
union node *
parsewordexp(void)
{
union node *n, *first = NULL, **pnext;
int t;
/* This assumes the parser is not re-entered,
* which could happen if we add command substitution on PS1/PS2.
*/
parser_temp_free_all();
heredoclist = NULL;
tokpushback = 0;
checkkwd = 0;
doprompt = 0;
setprompt(0);
needprompt = 0;
pnext = &first;
while ((t = readtoken()) != TEOF) {
if (t != TWORD)
synexpect(TWORD);
n = makename();
*pnext = n;
pnext = &n->narg.next;
}
return first;
}
static union node *
list(int nlflag)
{

View File

@ -76,6 +76,7 @@ extern const char *const parsekwd[];
union node *parsecmd(int);
union node *parsewordexp(void);
void forcealias(void);
void fixredir(union node *, const char *, int);
int goodname(const char *);

View File

@ -0,0 +1,112 @@
#
# 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 (c) 2015, Joyent, Inc. All rights reserved.
#
err=/tmp/err.$$
ppriv -s A=basic,dtrace_user $$
#
# When we lack dtrace_kernel, we expect to not be able to get at kernel memory
# via any subroutine or other vector.
#
# trace(func((void *)&\`utsname)); }
/usr/sbin/dtrace -wq -Cs /dev/stdin 2> $err <<EOF
#define FAIL \
printf("able to read kernel memory via %s!\n", badsubr); \
exit(2);
#define CANTREAD1(func) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname); FAIL }
#define CANTREAD2(func, arg1) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1); FAIL }
#define CANTREAD2ARG1(func, arg0) \
BEGIN { badsubr = "func() (arg1)"; func(arg0, (void *)&\`utsname); FAIL }
#define CANTREAD3(func, arg1, arg2) \
BEGIN { badsubr = "func()"; func((void *)&\`utsname, arg1, arg2); FAIL }
CANTREAD1(mutex_owned)
CANTREAD1(mutex_owner)
CANTREAD1(mutex_type_adaptive)
CANTREAD1(mutex_type_spin)
CANTREAD1(rw_read_held)
CANTREAD1(rw_write_held)
CANTREAD1(rw_iswriter)
CANTREAD3(bcopy, alloca(1), 1)
CANTREAD1(msgsize)
CANTREAD1(msgdsize)
CANTREAD1(strlen)
CANTREAD2(strchr, '!')
CANTREAD2(strrchr, '!')
CANTREAD2(strstr, "doogle")
CANTREAD2ARG1(strstr, "doogle")
CANTREAD2(index, "bagnoogle")
CANTREAD2ARG1(index, "bagnoogle")
CANTREAD2(rindex, "bagnoogle")
CANTREAD2ARG1(rindex, "bagnoogle")
CANTREAD2(strtok, "doogle")
CANTREAD2ARG1(strtok, "doogle")
CANTREAD2(json, "doogle")
CANTREAD2ARG1(json, "doogle")
CANTREAD1(toupper)
CANTREAD1(tolower)
CANTREAD2(ddi_pathname, 1)
CANTREAD2(strjoin, "doogle")
CANTREAD2ARG1(strjoin, "doogle")
CANTREAD1(strtoll)
CANTREAD1(dirname)
CANTREAD1(basename)
CANTREAD1(cleanpath)
#if defined(__amd64)
CANTREAD3(copyout, uregs[R_R9], 1)
CANTREAD3(copyoutstr, uregs[R_R9], 1)
#else
#if defined(__i386)
CANTREAD3(copyout, uregs[R_ESP], 1)
CANTREAD3(copyoutstr, uregs[R_ESP], 1)
#endif
#endif
BEGIN
{
exit(0);
}
ERROR
/arg4 != DTRACEFLT_KPRIV/
{
printf("bad error code via %s (expected %d, found %d)\n",
badsubr, DTRACEFLT_KPRIV, arg4);
exit(3);
}
ERROR
/arg4 == DTRACEFLT_KPRIV/
{
printf("illegal kernel access properly prevented from %s\n", badsubr);
}
EOF
status=$?
if [[ $status -eq 1 ]]; then
cat $err
fi
exit $status

View File

@ -0,0 +1,26 @@
/*
* 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 (c) 2015, Joyent, Inc. All rights reserved.
*/
struct mrbig {
char toomany[100000];
};
struct mrbig mrbig;
BEGIN
{
mrbig.toomany[0] = '!';
exit(0);
}

View File

@ -0,0 +1,26 @@
/*
* 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 (c) 2015, Joyent, Inc. All rights reserved.
*/
struct mrbig {
char toomany[100000];
};
this struct mrbig mrbig;
BEGIN
{
this->mrbig.toomany[0] = '!';
exit(0);
}

View File

@ -69,7 +69,7 @@ prov.h: prov.d
$dtrace -h -s prov.d
prov.o: prov.d main.o
$dtrace -G -32 -s prov.d main.o
$dtrace -G -s prov.d main.o
EOF
cat > prov.d <<EOF

View File

@ -77,7 +77,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -66,7 +66,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -82,7 +82,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -75,7 +75,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -76,7 +76,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -70,7 +70,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -69,7 +69,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -70,7 +70,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -71,7 +71,7 @@ EOF
exit 1
fi
$dtrace -G -32 -s $oogle.d $oogle.o -o $oogle.d.o
$dtrace -G -s $oogle.d $oogle.o -o $oogle.d.o
if [ $? -ne 0 ]; then
print -u2 "failed to process $oogle.d"

View File

@ -47,7 +47,7 @@ provider doogle {
EOF
cc -c test.c
$dtrace -G -32 -s doogle.d test.o -o doogle.d.o
$dtrace -G -s doogle.d test.o -o doogle.d.o
if [ $? -eq 0 ]; then
print -u2 "dtrace succeeded despite having no probe sites"

View File

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -56,7 +56,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -57,7 +57,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -68,7 +68,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -72,13 +72,13 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create initial DOF"
exit 1
fi
rm -f prov.o
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create final DOF"
exit 1

View File

@ -67,7 +67,7 @@ if [ $? -ne 0 ]; then
print -u2 "failed to compile test.c"
exit 1
fi
$dtrace -G -32 -s prov.d test.o
$dtrace -G -s prov.d test.o
if [ $? -ne 0 ]; then
print -u2 "failed to create DOF"
exit 1

View File

@ -21,7 +21,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd May 24, 2015
.Dd September 29, 2015
.Dt LOCKSTAT 1
.Os
.Sh NAME
@ -38,7 +38,7 @@
.Op Fl d Ar duration
.Op Fl f Ar function Oo Ns , Ns Ar size Oc
.Op Fl T
.Op Fl ckgwWRpP
.Op Fl kgwWRpP
.Op Fl D Ar count
.Op Fl o filename
.Op Fl x Ar opt Oo Ns = Ns Ar val Oc
@ -172,8 +172,6 @@ This is off by default.
.El
.Ss Data Reporting
.Bl -tag -width indent
.It Fl c
Coalesce lock data for lock arrays.
.It Fl D Ar count
Only display the top
.Ar count

View File

@ -65,7 +65,11 @@ typedef uintptr_t pc_t;
typedef struct lsrec {
struct lsrec *ls_next; /* next in hash chain */
#ifdef illumos
uintptr_t ls_lock; /* lock address */
#else
char *ls_lock; /* lock name */
#endif
uintptr_t ls_caller; /* caller address */
uint32_t ls_count; /* cumulative event count */
uint32_t ls_event; /* type of event */
@ -338,7 +342,9 @@ usage(void)
" -d duration only watch events longer than <duration>\n"
" -T trace (rather than sample) events\n"
"\nData reporting options:\n\n"
#ifdef illumos
" -c coalesce lock data for arrays like pse_mutex[]\n"
#endif
" -k coalesce PCs within functions\n"
" -g show total events generated by function\n"
" -w wherever: don't distinguish events by caller\n"
@ -381,12 +387,16 @@ lockcmp(lsrec_t *a, lsrec_t *b)
if (a->ls_caller > b->ls_caller)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
return (0);
#else
return (strcmp(a->ls_lock, b->ls_lock));
#endif
}
static int
@ -424,26 +434,40 @@ lockcmp_anywhere(lsrec_t *a, lsrec_t *b)
if (a->ls_event > b->ls_event)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
return (0);
#else
return (strcmp(a->ls_lock, b->ls_lock));
#endif
}
static int
lock_and_count_cmp_anywhere(lsrec_t *a, lsrec_t *b)
{
#ifndef illumos
int cmp;
#endif
if (a->ls_event < b->ls_event)
return (-1);
if (a->ls_event > b->ls_event)
return (1);
#ifdef illumos
if (a->ls_lock < b->ls_lock)
return (-1);
if (a->ls_lock > b->ls_lock)
return (1);
#else
cmp = strcmp(a->ls_lock, b->ls_lock);
if (cmp != 0)
return (cmp);
#endif
return (b->ls_count - a->ls_count);
}
@ -698,7 +722,11 @@ dprog_addevent(int event)
caller = "(uintptr_t)arg0";
arg1 = "arg2";
} else {
#ifdef illumos
arg0 = "(uintptr_t)arg0";
#else
arg0 = "stringof(args[0]->lock_object.lo_name)";
#endif
caller = "caller";
}
@ -912,12 +940,17 @@ lsrec_fill(lsrec_t *lsrec, const dtrace_recdesc_t *rec, int nrecs, caddr_t data)
lsrec->ls_event = (uint32_t)*((uint64_t *)(data + rec->dtrd_offset));
rec++;
#ifdef illumos
if (rec->dtrd_size != sizeof (uintptr_t))
fail(0, "bad lock address size in second record");
/* LINTED - alignment */
lsrec->ls_lock = *((uintptr_t *)(data + rec->dtrd_offset));
rec++;
#else
lsrec->ls_lock = strdup((const char *)(data + rec->dtrd_offset));
rec++;
#endif
if (rec->dtrd_size != sizeof (uintptr_t))
fail(0, "bad caller size in third record");
@ -1224,9 +1257,11 @@ main(int argc, char **argv)
events_specified = 1;
break;
#ifdef illumos
case 'c':
g_cflag = 1;
break;
#endif
case 'k':
g_kflag = 1;
@ -1539,6 +1574,9 @@ main(int argc, char **argv)
caller_in_stack = 1;
bcopy(oldlsp, lsp, LS_TIME);
lsp->ls_caller = oldlsp->ls_stack[fr];
#ifndef illumos
lsp->ls_lock = strdup(oldlsp->ls_lock);
#endif
/* LINTED - alignment */
lsp = (lsrec_t *)((char *)lsp + LS_TIME);
}
@ -1547,6 +1585,9 @@ main(int argc, char **argv)
/* LINTED - alignment */
lsp = (lsrec_t *)((char *)lsp + LS_TIME);
}
#ifndef illumos
free(oldlsp->ls_lock);
#endif
}
g_nrecs = g_nrecs_used =
((uintptr_t)lsp - (uintptr_t)newlsp) / LS_TIME;
@ -1604,8 +1645,10 @@ main(int argc, char **argv)
for (i = 0; i < g_nrecs_used; i++) {
int fr;
lsp = sort_buf[i];
#ifdef illumos
if (g_cflag)
coalesce_symbol(&lsp->ls_lock);
#endif
if (g_kflag) {
for (fr = 0; fr < g_stkdepth; fr++)
coalesce_symbol(&lsp->ls_stack[fr]);
@ -1659,6 +1702,15 @@ main(int argc, char **argv)
first = current;
}
#ifndef illumos
/*
* Free lock name buffers
*/
for (i = 0, lsp = (lsrec_t *)data_buf; i < g_nrecs_used; i++,
lsp = (lsrec_t *)((char *)lsp + g_recsize))
free(lsp->ls_lock);
#endif
return (0);
}
@ -1748,8 +1800,12 @@ report_stats(FILE *out, lsrec_t **sort_buf, size_t nrecs, uint64_t total_count,
(void) fprintf(out, "%u %u",
lsp->ls_event, lsp->ls_count);
#ifdef illumos
(void) fprintf(out, " %s",
format_symbol(buf, lsp->ls_lock, g_cflag));
#else
(void) fprintf(out, " %s", lsp->ls_lock);
#endif
(void) fprintf(out, " %s",
format_symbol(buf, lsp->ls_caller, 0));
(void) fprintf(out, " %f",
@ -1811,8 +1867,12 @@ report_stats(FILE *out, lsrec_t **sort_buf, size_t nrecs, uint64_t total_count,
(void) fprintf(out, "%4.2f %8s ",
(double)lsp->ls_refcnt / lsp->ls_count, buf);
#ifdef illumos
(void) fprintf(out, "%-22s ",
format_symbol(buf, lsp->ls_lock, g_cflag));
#else
(void) fprintf(out, "%-22s ", lsp->ls_lock);
#endif
(void) fprintf(out, "%-24s\n",
format_symbol(buf, lsp->ls_caller, 0));
@ -1908,7 +1968,11 @@ report_trace(FILE *out, lsrec_t **sort_buf)
(void) fprintf(out, "%2d %10llu %11p %-24s %-24s\n",
lsp->ls_event, (unsigned long long)lsp->ls_time,
(void *)lsp->ls_next,
#ifdef illumos
format_symbol(buf, lsp->ls_lock, 0),
#else
lsp->ls_lock,
#endif
format_symbol(buf2, lsp->ls_caller, 0));
if (rectype <= LS_STACK(0))

View File

@ -1,126 +0,0 @@
/*
* 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.
*/
#ifndef __STRING_TABLE_DOT_H
#define __STRING_TABLE_DOT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/avl.h>
#include <string_table.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A string is represented in a string table using two values: length, and
* value. Grouping all the strings of a given length together allows for
* efficient matching of tail strings, as each input string value is hashed.
* Each string table uses a 2-level AVL tree of AVL trees to represent this
* organization.
*
* The outer (main) AVL tree contains LenNode structures. The search key for
* nodes on this main tree is the string length. Each such node represents
* all strings of a given length, and all strings of that length are found
* within.
*
* The strings within each LenNode are maintained using a secondary AVL tree
* of StrNode structures. The search key for this inner tree is the string
* itself. The strings are maintained in lexical order.
*/
typedef struct {
avl_node_t sn_avlnode; /* AVL book-keeping */
const char *sn_str; /* string */
size_t sn_refcnt; /* reference count */
} StrNode;
typedef struct {
avl_node_t ln_avlnode; /* AVL book-keeping */
avl_tree_t *ln_strtree; /* AVL tree of associated strings */
size_t ln_strlen; /* length of associated strings */
} LenNode;
/*
* Define a master string data item. Other strings may be suffixes of this
* string. The final string table will consist of the master string values,
* laid end to end, with the other strings referencing their tails.
*/
typedef struct str_master Str_master;
struct str_master {
const char *sm_str; /* pointer to master string */
Str_master *sm_next; /* used for tracking master strings */
size_t sm_strlen; /* length of master string */
uint_t sm_hashval; /* hashval of master string */
size_t sm_stroff; /* offset into destination strtab */
};
/*
* Define a hash data item. This item represents an individual string that has
* been input into the String hash table. The string may either be a suffix of
* another string, or a master string.
*/
typedef struct str_hash Str_hash;
struct str_hash {
size_t hi_strlen; /* string length */
size_t hi_refcnt; /* number of references to str */
uint_t hi_hashval; /* hash for string */
Str_master *hi_mstr; /* pointer to master string */
Str_hash *hi_next; /* next entry in hash bucket */
};
/*
* Controlling data structure for a String Table.
*/
struct str_tbl {
avl_tree_t *st_lentree; /* AVL tree of string lengths */
char *st_strbuf; /* string buffer */
Str_hash **st_hashbcks; /* hash buckets */
Str_master *st_mstrlist; /* list of all master strings */
size_t st_fullstrsize; /* uncompressed table size */
size_t st_nextoff; /* next available string */
size_t st_strsize; /* compressed size */
size_t st_strcnt; /* number of strings */
uint_t st_hbckcnt; /* number of buckets in */
/* hashlist */
uint_t st_flags;
};
#define FLG_STTAB_COMPRESS 0x01 /* compressed string table */
#define FLG_STTAB_COOKED 0x02 /* offset has been assigned */
/*
* Starting value for use with string hashing functions inside of string_table.c
*/
#define HASHSEED 5381
#ifdef __cplusplus
}
#endif
#endif /* __STRING_TABLE_DOT_H */

View File

@ -1,280 +0,0 @@
/*
* 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.
*
* Define an Alist, a list maintained as a reallocable array, and a for() loop
* macro to generalize its traversal. Note that the array can be reallocated
* as it is being traversed, thus the offset of each element is recomputed from
* the start of the structure.
*/
#ifndef _ALIST_H
#define _ALIST_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#ifdef illumos
#include <sys/machelf.h>
#else
#include <sys/elf.h>
#endif
/*
* An Alist implements array lists. The functionality is similar to
* that of a linked list. However, an Alist is represented by a single
* contigious allocation of memory. The head of the memory is a header
* that contains control information for the list. Following the header
* is an array used to hold the user data. In the type definitions that
* follow, we define these as an array with a single element, but when
* we allocate the memory, we actually allocate the amount of memory needed.
*
* There are two "flavors" of array list:
*
* Alist - Contain arbitrary data, usually structs.
* APlist - Contain pointers to data allocated elsewhere.
*
* This differentiation is useful, because pointer lists are heavily
* used, and support a slightly different set of operations that are
* unique to their purpose.
*
* Array lists are initially represented by a NULL pointer. The memory
* for the list is only allocated if an item is inserted. This is very
* efficient for data structures that may or may not be needed for a
* given linker operation --- you only pay for what you use. In addition:
*
* - Array lists grow as needed (memory is reallocated as necessary)
* - Data is kept contiguously (no unused holes in between elements)
* at the beginning of the data area. This locality has
* good cache behavior, as access to adjacent items are
* highly likely to be in the same page of memory.
* - Insert/Delete operations at the end of the list are very
* efficient. However, insert/delete operations elsewhere
* will cause a relatively expensive overlapped memory
* copy of the data following the insert/delete location.
* - As with any generic memory alloctor (i.e. malloc()/free()),
* array lists are not type safe for the data they contain.
* Data is managed as (void *) pointers to data of a given
* length, so the Alist module cannot prevent the caller from
* inserting/extracting the wrong type of data. The caller
* must guard against this.
* - To free an array list, simply call the standard free() function
* on the list pointer.
*/
/*
* Aliste is used to represent list indexes, offsets, and sizes.
*/
typedef size_t Aliste;
/*
* Alist is used to hold non-pointer items --- usually structs:
* - There must be an even number of Aliste fields before the
* al_data field. This ensures that al_data will have
* an alignment of 8, no matter whether sizeof(Aliste)
* is 4 or 8. That means that al_data will have sufficient
* alignment for any use, just like memory allocated via
* malloc().
* - al_nitems and al_next are redundant, in that they are
* directly related:
* al_next = al_nitems * al_size
* We do this to make ALIST_TRAVERSE_BYOFFSET maximally
* efficient. This doesn't waste space, because of the
* requirement to have an even # of Alist fields (above).
*
* Note that Alists allow the data to be referenced by 0 based array
* index, or by their byte offset from the start of the Alist memory
* allocation. The index form is preferred for most use, as it is simpler.
* However, by-offset access is used by rtld link maps, and this ability
* is convenient in that case.
*/
typedef struct {
Aliste al_arritems; /* # of items in al_data allocation */
Aliste al_nitems; /* # items (index of next avail item) */
Aliste al_next; /* offset of next available al_data[] */
Aliste al_size; /* size of each al_data[] item */
void *al_data[1]; /* data (can grow) */
} Alist;
/*
* APlist is a variant of Alist that contains pointers. There are several
* benefits to this special type:
* - API is simpler
* - Pointers are used directly, instead of requiring a
* pointer-to-pointer double indirection.
* - The implementation is slightly more efficient.
* - Operations that make particular sense for pointers
* can be supported without confusing the API for the
* regular Alists.
*/
typedef struct {
Aliste apl_arritems; /* # of items in apl_data allocation */
Aliste apl_nitems; /* # items (index of next avail item) */
void *apl_data[1]; /* data area: (arrcnt * size) bytes */
} APlist;
/*
* The ALIST_OFF_DATA and APLIST_OFF_DATA macros give the byte offset
* from the start of an array list to the first byte of the data area
* used to hold user data. The same trick used by the standard offsetof()
* macro is used.
*/
#define ALIST_OFF_DATA ((size_t)(((Alist *)0)->al_data))
#define APLIST_OFF_DATA ((size_t)(((APlist *)0)->apl_data))
/*
* The TRAVERSE macros are intended to be used within a for(), and
* cause the resulting loop to iterate over each item in the loop,
* in order.
* ALIST_TRAVERSE: Traverse over the items in an Alist,
* using the zero based item array index to refer to
* each item.
* ALIST_TRAVERSE_BY_OFFSET: Traverse over the items in an
* Alist using the byte offset from the head of the
* Alist pointer to refer to each item. It should be noted
* that the first such offset is given by ALIST_OFF_DATA,
* and as such, there will never be a 0 offset. Some code
* uses this fact to treat 0 as a reserved value with
* special meaning.
*
* By-offset access is convenient for some parts of
* rtld, where a value of 0 is used to indicate an
* uninitialized link map control.
*
* APLIST_TRAVERSE: Traverse over the pointers in an APlist, using
* the zero based item array index to refer to each pointer.
*/
/*
* Within the loop:
*
* LIST - Pointer to Alist structure for list
* IDX - The current item index
* OFF - The current item offset
* DATA - Pointer to item
*/
#define ALIST_TRAVERSE(LIST, IDX, DATA) \
(IDX) = 0, \
((LIST) != NULL) && ((DATA) = (void *)(LIST)->al_data); \
\
((LIST) != NULL) && ((IDX) < (LIST)->al_nitems); \
\
(IDX)++, \
(DATA) = (void *) (((LIST)->al_size * (IDX)) + (char *)(LIST)->al_data)
#define ALIST_TRAVERSE_BY_OFFSET(LIST, OFF, DATA) \
(((LIST) != NULL) && ((OFF) = ALIST_OFF_DATA) && \
(((DATA) = (void *)((char *)(LIST) + (OFF))))); \
\
(((LIST) != NULL) && ((OFF) < (LIST)->al_next)); \
\
(((OFF) += ((LIST)->al_size)), \
((DATA) = (void *)((char *)(LIST) + (OFF))))
/*
* Within the loop:
*
* LIST - Pointer to APlist structure for list
* IDX - The current item index
* PTR - item value
*
* Note that this macro is designed to ensure that PTR retains the
* value of the final pointer in the list after exiting the for loop,
* and to avoid dereferencing an out of range address. This is done by
* doing the dereference in the middle expression, using the comma
* operator to ensure that a NULL pointer won't stop the loop.
*/
#define APLIST_TRAVERSE(LIST, IDX, PTR) \
(IDX) = 0; \
\
((LIST) != NULL) && ((IDX) < (LIST)->apl_nitems) && \
(((PTR) = ((LIST)->apl_data)[IDX]), 1); \
\
(IDX)++
/*
* Possible values returned by aplist_test()
*/
typedef enum {
ALE_ALLOCFAIL = 0, /* Memory allocation error */
ALE_EXISTS = 1, /* alist entry already exists */
ALE_NOTFND = 2, /* item not found and insert not required */
ALE_CREATE = 3 /* alist entry created */
} aplist_test_t;
/*
* Access to an Alist item by index or offset. This is needed because the
* size of an item in an Alist is not known by the C compiler, and we
* have to do the indexing arithmetic explicitly.
*
* For an APlist, index the apl_data field directly --- No macro is needed.
*/
#define alist_item(_lp, _idx) \
((void *)(ALIST_OFF_DATA + ((_idx) * (_lp)->al_size) + (char *)(_lp)))
#define alist_item_by_offset(_lp, _off) \
((void *)((_off) + (char *)(_lp)))
/*
* # of items currently found in a list. These macros handle the case
* where the list has not been allocated yet.
*/
#define alist_nitems(_lp) (((_lp) == NULL) ? 0 : (_lp)->al_nitems)
#define aplist_nitems(_lp) (((_lp) == NULL) ? 0 : (_lp)->apl_nitems)
extern void *alist_append(Alist **, const void *, size_t, Aliste);
extern void alist_delete(Alist *, Aliste *);
extern void alist_delete_by_offset(Alist *, Aliste *);
extern void *alist_insert(Alist **, const void *, size_t,
Aliste, Aliste);
extern void *alist_insert_by_offset(Alist **, const void *, size_t,
Aliste, Aliste);
extern void alist_reset(Alist *);
extern void *aplist_append(APlist **, const void *, Aliste);
extern void aplist_delete(APlist *, Aliste *);
extern int aplist_delete_value(APlist *, const void *);
extern void *aplist_insert(APlist **, const void *,
Aliste, Aliste idx);
extern void aplist_reset(APlist *);
extern aplist_test_t aplist_test(APlist **, const void *, Aliste);
#ifdef __cplusplus
}
#endif
#endif /* _ALIST_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,296 +0,0 @@
/*
* 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) 1988 AT&T
* All Rights Reserved
*
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Global include file for all sgs.
*/
#ifndef _SGS_H
#define _SGS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* <assert.h> keys off of NDEBUG */
#ifdef DEBUG
#undef NDEBUG
#else
#define NDEBUG
#endif
#ifndef _ASM
#include <sys/types.h>
#ifdef illumos
#include <sys/machelf.h>
#else
#include <elf.h>
#endif
#include <stdlib.h>
#include <libelf.h>
#include <assert.h>
#include <alist.h>
#endif /* _ASM */
/*
* Software identification.
*/
#define SGS ""
#define SGU_PKG "Software Generation Utilities"
#define SGU_REL "(SGU) Solaris-ELF (4.0)"
#ifndef _ASM
/*
* link_ver_string[] contains a version string for use by the link-editor
* and all other linker components. It is found in libconv, and is
* generated by sgs/libconv/common/bld_vernote.ksh. That script produces
* libconv/{plat}/vernote.s, which is in turn assembled/linked into
* libconv.
*/
extern const char link_ver_string[];
/*
* Macro to round to next double word boundary.
*/
#define S_DROUND(x) (((x) + sizeof (double) - 1) & ~(sizeof (double) - 1))
/*
* General align and round macros.
*/
#define S_ALIGN(x, a) ((x) & ~(((a) ? (a) : 1) - 1))
#define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1))
/*
* Bit manipulation macros; generic bit mask and is `v' in the range
* supportable in `n' bits?
*/
#define S_MASK(n) ((1 << (n)) -1)
#define S_INRANGE(v, n) (((-(1 << (n)) - 1) < (v)) && ((v) < (1 << (n))))
/*
* Yet another definition of the OFFSETOF macro, used with the AVL routines.
*/
#define SGSOFFSETOF(s, m) ((size_t)(&(((s *)0)->m)))
/*
* When casting between integer and pointer types, gcc will complain
* if the integer type used is not large enough to hold the pointer
* value without loss. Although a dubious practice in general, this
* is sometimes done by design. In those cases, the general solution
* is to introduce an intermediate cast to widen the integer value. The
* CAST_PTRINT macro does this, and its use documents the fact that
* the programmer is doing that sort of cast.
*/
#ifdef __GNUC__
#define CAST_PTRINT(cast, value) ((cast)(uintptr_t)value)
#else
#define CAST_PTRINT(cast, value) ((cast)value)
#endif
/*
* General typedefs.
*/
typedef enum {
FALSE = 0,
TRUE = 1
} Boolean;
/*
* Types of errors (used by eprintf()), together with a generic error return
* value.
*/
typedef enum {
ERR_NONE,
ERR_WARNING,
ERR_FATAL,
ERR_ELF,
ERR_NUM /* Must be last */
} Error;
#if defined(_LP64) && !defined(_ELF64)
#define S_ERROR (~(uint_t)0)
#else
#define S_ERROR (~(uintptr_t)0)
#endif
/*
* LIST_TRAVERSE() is used as the only "argument" of a "for" loop to
* traverse a linked list. The node pointer `node' is set to each node in
* turn and the corresponding data pointer is copied to `data'. The macro
* is used as in
* for (LIST_TRAVERSE(List *list, Listnode *node, void *data)) {
* process(data);
* }
*/
#define LIST_TRAVERSE(L, N, D) \
(void) (((N) = (L)->head) != NULL && ((D) = (N)->data) != NULL); \
(N) != NULL; \
(void) (((N) = (N)->next) != NULL && ((D) = (N)->data) != NULL)
typedef struct listnode Listnode;
typedef struct list List;
struct listnode { /* a node on a linked list */
void *data; /* the data item */
Listnode *next; /* the next element */
};
struct list { /* a linked list */
Listnode *head; /* the first element */
Listnode *tail; /* the last element */
};
#ifdef _SYSCALL32
typedef struct listnode32 Listnode32;
typedef struct list32 List32;
struct listnode32 { /* a node on a linked list */
Elf32_Addr data; /* the data item */
Elf32_Addr next; /* the next element */
};
struct list32 { /* a linked list */
Elf32_Addr head; /* the first element */
Elf32_Addr tail; /* the last element */
};
#endif /* _SYSCALL32 */
/*
* Structure to maintain rejected files elf information. Files that are not
* applicable to the present link-edit are rejected and a search for an
* appropriate file may be resumed. The first rejected files information is
* retained so that a better error diagnostic can be given should an appropriate
* file not be located.
*/
typedef struct {
ushort_t rej_type; /* SGS_REJ_ value */
ushort_t rej_flag; /* additional information */
uint_t rej_info; /* numeric and string information */
const char *rej_str; /* associated with error */
const char *rej_name; /* object name - expanded library */
/* name and archive members */
} Rej_desc;
#define SGS_REJ_NONE 0
#define SGS_REJ_MACH 1 /* wrong ELF machine type */
#define SGS_REJ_CLASS 2 /* wrong ELF class (32-bit/64-bit) */
#define SGS_REJ_DATA 3 /* wrong ELF data format (MSG/LSB) */
#define SGS_REJ_TYPE 4 /* bad ELF type */
#define SGS_REJ_BADFLAG 5 /* bad ELF flags value */
#define SGS_REJ_MISFLAG 6 /* mismatched ELF flags value */
#define SGS_REJ_VERSION 7 /* mismatched ELF/lib version */
#define SGS_REJ_HAL 8 /* HAL R1 extensions required */
#define SGS_REJ_US3 9 /* Sun UltraSPARC III extensions */
/* required */
#define SGS_REJ_STR 10 /* generic error - info is a string */
#define SGS_REJ_UNKFILE 11 /* unknown file type */
#define SGS_REJ_HWCAP_1 12 /* hardware capabilities mismatch */
/*
* For those source files used both inside and outside of the
* libld source base (tools/common/string_table.c) we can
* automatically switch between the allocation models
* based off of the 'cc -DUSE_LIBLD_MALLOC' flag.
*/
#ifdef USE_LIBLD_MALLOC
#define calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
#define free libld_free
#define malloc libld_malloc
#define realloc libld_realloc
#define libld_calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
extern void libld_free(void *);
extern void *libld_malloc(size_t);
extern void *libld_realloc(void *, size_t);
#endif
/*
* Data structures (defined in libld.h).
*/
typedef struct ent_desc Ent_desc;
typedef struct group_desc Group_desc;
typedef struct ifl_desc Ifl_desc;
typedef struct is_desc Is_desc;
typedef struct isa_desc Isa_desc;
typedef struct isa_opt Isa_opt;
typedef struct mv_desc Mv_desc;
typedef struct ofl_desc Ofl_desc;
typedef struct os_desc Os_desc;
typedef struct rel_cache Rel_cache;
typedef struct sdf_desc Sdf_desc;
typedef struct sdv_desc Sdv_desc;
typedef struct sg_desc Sg_desc;
typedef struct sort_desc Sort_desc;
typedef struct sec_order Sec_order;
typedef struct sym_desc Sym_desc;
typedef struct sym_aux Sym_aux;
typedef struct sym_avlnode Sym_avlnode;
typedef struct uts_desc Uts_desc;
typedef struct ver_desc Ver_desc;
typedef struct ver_index Ver_index;
typedef struct audit_desc Audit_desc;
typedef struct audit_info Audit_info;
typedef struct audit_list Audit_list;
/*
* Data structures defined in machrel.h.
*/
typedef struct rel_desc Rel_desc;
/*
* Data structures defined in rtld.h.
*/
typedef struct lm_list Lm_list;
#ifdef _SYSCALL32
typedef struct lm_list32 Lm_list32;
#endif /* _SYSCALL32 */
/*
* For the various utilities that include sgs.h
*/
extern int assfail(const char *, const char *, int);
extern void eprintf(Lm_list *, Error, const char *, ...);
extern char *sgs_demangle(char *);
extern uint_t sgs_str_hash(const char *);
extern uint_t findprime(uint_t);
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SGS_H */

View File

@ -1,63 +0,0 @@
/*
* 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.
*/
#ifndef _STRING_TABLE_DOT_H
#define _STRING_TABLE_DOT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Exported, opaque string table handle.
*/
typedef struct str_tbl Str_tbl;
/*
* Exported string table functions.
*/
extern int st_delstring(Str_tbl *, const char *);
extern void st_destroy(Str_tbl *);
extern size_t st_getstrtab_sz(Str_tbl *);
extern const char *st_getstrbuf(Str_tbl *);
extern int st_insert(Str_tbl *, const char *);
extern Str_tbl *st_new(uint_t);
extern int st_setstrbuf(Str_tbl *, char *, size_t);
extern int st_setstring(Str_tbl *, const char *, size_t *);
/*
* Exported flags values for st_new().
*/
#define FLG_STNEW_COMPRESS 0x01 /* compressed string table */
#ifdef __cplusplus
}
#endif
#endif /* _STRING_TABLE_DOT_H */

View File

@ -1,62 +0,0 @@
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# 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
#
# ident "%Z%%M% %I% %E% SMI"
#
#
# Global message identifiers for the sgs utilities. This information is read
# by sgsmsg(1l) using the -i option.
# Each utilities message file references one of the `MSGID' identifiers. Its
# associated numeric setid is used when creating catgets(3c) messages, the
# string domain is used when creating gettext(3i) messages.
#
mesgid setid domain
MSG_ID_RTLD 1 SUNW_OST_SGS /* sgs/rtld */
MSG_ID_LIBRTLD 2 SUNW_OST_SGS /* sgs/librtld */
MSG_ID_LIBLD 3 SUNW_OST_SGS /* sgs/libld */
MSG_ID_LIBLDDBG 4 SUNW_OST_SGS /* sgs/liblddbg */
MSG_ID_LIBLDSTAB 5 SUNW_OST_SGS /* sgs/libldstab */
MSG_ID_LIBRTLD_DB 6 SUNW_OST_SGS /* sgs/librtld_db */
MSG_ID_LIBPROF 7 SUNW_OST_SGS /* sgs/libprof */
MSG_ID_LIBCRLE 8 SUNW_OST_SGS /* sgs/libcrle */
MSG_ID_LIBELF 10 SUNW_OST_SGS /* sgs/libelf */
MSG_ID_LD 20 SUNW_OST_SGS /* sgs/ld */
MSG_ID_LDD 21 SUNW_OST_SGS /* sgs/ldd */
MSG_ID_PVS 22 SUNW_OST_SGS /* sgs/pvs */
MSG_ID_CRLE 23 SUNW_OST_SGS /* sgs/crle */
MSG_ID_ELFDUMP 24 SUNW_OST_SGS /* sgs/elfdump */
MSG_ID_MOE 25 SUNW_OST_SGS /* sgs/moe */
MSG_ID_ELFEDIT 26 SUNW_OST_SGS /* sgs/elfedit */
MSG_ID_ELFEDIT_CAP 27 SUNW_OST_SGS /* cap: */
MSG_ID_ELFEDIT_DYN 27 SUNW_OST_SGS /* dyn: */
MSG_ID_ELFEDIT_EHDR 27 SUNW_OST_SGS /* ehdr: */
MSG_ID_ELFEDIT_PHDR 27 SUNW_OST_SGS /* phdr: */
MSG_ID_ELFEDIT_SHDR 27 SUNW_OST_SGS /* shdr: */
MSG_ID_ELFEDIT_STR 27 SUNW_OST_SGS /* str: */
MSG_ID_ELFEDIT_SYM 27 SUNW_OST_SGS /* sym: */
MSG_ID_ELFEDIT_SYMINFO 27 SUNW_OST_SGS /* syminfo: */
MSG_ID_ELFWRAP 28 SUNW_OST_SGS /* sgs/elfwrap */

View File

@ -1,56 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sgs.h>
/*
* function that will find a prime'ish number. Usefull for
* hashbuckets and related things.
*/
uint_t
findprime(uint_t count)
{
uint_t h, f;
if (count <= 3)
return (3);
/*
* Check to see if divisible by two, if so
* increment.
*/
if ((count & 0x1) == 0)
count++;
for (h = count, f = 2; f * f <= h; f++)
if ((h % f) == 0)
h += f = 1;
return (h);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,685 +0,0 @@
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <_string_table.h>
#include <strings.h>
#include <sgs.h>
#include <stdio.h>
/*
* This file provides the interfaces to build a Str_tbl suitable for use by
* either the sgsmsg message system, or a standard ELF string table (SHT_STRTAB)
* as created by ld(1).
*
* There are two modes which can be used when constructing a string table:
*
* st_new(0)
* standard string table - no compression. This is the
* traditional, fast method.
*
* st_new(FLG_STTAB_COMPRESS)
* builds a compressed string table which both eliminates
* duplicate strings, and permits strings with common suffixes
* (atexit vs. exit) to overlap in the table. This provides space
* savings for many string tables. Although more work than the
* traditional method, the algorithms used are designed to scale
* and keep any overhead at a minimum.
*
* These string tables are built with a common interface in a two-pass manner.
* The first pass finds all of the strings required for the string-table and
* calculates the size required for the final string table.
*
* The second pass allocates the string table, populates the strings into the
* table and returns the offsets the strings have been assigned.
*
* The calling sequence to build and populate a string table is:
*
* st_new(); // initialize strtab
*
* st_insert(st1); // first pass of strings ...
* // calculates size required for
* // string table
*
* st_delstring(st?); // remove string previously
* // inserted
* st_insert(stN);
*
* st_getstrtab_sz(); // freezes strtab and computes
* // size of table.
*
* st_setstrbuf(); // associates a final destination
* // for the string table
*
* st_setstring(st1); // populate the string table
* ... // offsets are based off of second
* // pass through the string table
* st_setstring(stN);
*
* st_destroy(); // tear down string table
* // structures.
*
* String Suffix Compression Algorithm:
*
* Here's a quick high level overview of the Suffix String
* compression algorithm used. First - the heart of the algorithm
* is a Hash table list which represents a dictionary of all unique
* strings inserted into the string table. The hash function for
* this table is a standard string hash except that the hash starts
* at the last character in the string (&str[n - 1]) and works towards
* the first character in the function (&str[0]). As we compute the
* HASH value for a given string, we also compute the hash values
* for all of the possible suffix strings for that string.
*
* As we compute the hash - at each character see if the current
* suffix string for that hash is already present in the table. If
* it is, and the string is a master string. Then change that
* string to a suffix string of the new string being inserted.
*
* When the final hash value is found (hash for str[0...n]), check
* to see if it is in the hash table - if so increment the reference
* count for the string. If it is not yet in the table, insert a
* new hash table entry for a master string.
*
* The above method will find all suffixes of a given string given
* that the strings are inserted from shortest to longest. That is
* why this is a two phase method, we first collect all of the
* strings and store them based off of their length in an AVL tree.
* Once all of the strings have been submitted we then start the
* hash table build by traversing the AVL tree in order and
* inserting the strings from shortest to longest as described
* above.
*/
/* LINTLIBRARY */
static int
avl_len_compare(const void *n1, const void *n2)
{
size_t len1, len2;
len1 = ((LenNode *)n1)->ln_strlen;
len2 = ((LenNode *)n2)->ln_strlen;
if (len1 == len2)
return (0);
if (len2 < len1)
return (1);
return (-1);
}
static int
avl_str_compare(const void *n1, const void *n2)
{
const char *str1, *str2;
int rc;
str1 = ((StrNode *)n1)->sn_str;
str2 = ((StrNode *)n2)->sn_str;
rc = strcmp(str1, str2);
if (rc > 0)
return (1);
if (rc < 0)
return (-1);
return (0);
}
/*
* Return an initialized Str_tbl - returns NULL on failure.
*
* flags:
* FLG_STTAB_COMPRESS - build a compressed string table
*/
Str_tbl *
st_new(uint_t flags)
{
Str_tbl *stp;
if ((stp = calloc(sizeof (Str_tbl), 1)) == NULL)
return (NULL);
/*
* Start with a leading '\0' - it's tradition.
*/
stp->st_strsize = stp->st_fullstrsize = stp->st_nextoff = 1;
/*
* Do we compress this string table?
*/
stp->st_flags = flags;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (stp);
if ((stp->st_lentree = calloc(sizeof (avl_tree_t), 1)) == NULL)
return (NULL);
avl_create(stp->st_lentree, &avl_len_compare, sizeof (LenNode),
SGSOFFSETOF(LenNode, ln_avlnode));
return (stp);
}
/*
* Insert a new string into the Str_tbl. There are two AVL trees used.
*
* . The first LenNode AVL tree maintains a tree of nodes based on string
* sizes.
* . Each LenNode maintains a StrNode AVL tree for each string. Large
* applications have been known to contribute thousands of strings of
* the same size. Should strings need to be removed (-z ignore), then
* the string AVL tree makes this removal efficient and scalable.
*/
int
st_insert(Str_tbl *stp, const char *str)
{
size_t len;
StrNode *snp, sn = { 0 };
LenNode *lnp, ln = { 0 };
avl_index_t where;
/*
* String table can't have been cooked
*/
assert((stp->st_flags & FLG_STTAB_COOKED) == 0);
/*
* Null strings always point to the head of the string
* table - no reason to keep searching.
*/
if ((len = strlen(str)) == 0)
return (0);
stp->st_fullstrsize += len + 1;
stp->st_strcnt++;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (0);
/*
* From the controlling string table, determine which LenNode AVL node
* provides for this string length. If the node doesn't exist, insert
* a new node to represent this string length.
*/
ln.ln_strlen = len;
if ((lnp = avl_find(stp->st_lentree, &ln, &where)) == NULL) {
if ((lnp = calloc(sizeof (LenNode), 1)) == NULL)
return (-1);
lnp->ln_strlen = len;
avl_insert(stp->st_lentree, lnp, where);
if ((lnp->ln_strtree = calloc(sizeof (avl_tree_t), 1)) == NULL)
return (0);
avl_create(lnp->ln_strtree, &avl_str_compare, sizeof (StrNode),
SGSOFFSETOF(StrNode, sn_avlnode));
}
/*
* From the string length AVL node determine whether a StrNode AVL node
* provides this string. If the node doesn't exist, insert a new node
* to represent this string.
*/
sn.sn_str = str;
if ((snp = avl_find(lnp->ln_strtree, &sn, &where)) == NULL) {
if ((snp = calloc(sizeof (StrNode), 1)) == NULL)
return (-1);
snp->sn_str = str;
avl_insert(lnp->ln_strtree, snp, where);
}
snp->sn_refcnt++;
return (0);
}
/*
* Remove a previously inserted string from the Str_tbl.
*/
int
st_delstring(Str_tbl *stp, const char *str)
{
size_t len;
LenNode *lnp, ln = { 0 };
StrNode *snp, sn = { 0 };
/*
* String table can't have been cooked
*/
assert((stp->st_flags & FLG_STTAB_COOKED) == 0);
len = strlen(str);
stp->st_fullstrsize -= len + 1;
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)
return (0);
/*
* Determine which LenNode AVL node provides for this string length.
*/
ln.ln_strlen = len;
if ((lnp = avl_find(stp->st_lentree, &ln, 0)) != NULL) {
sn.sn_str = str;
if ((snp = avl_find(lnp->ln_strtree, &sn, 0)) != NULL) {
/*
* Reduce the reference count, and if zero remove the
* node.
*/
if (--snp->sn_refcnt == 0)
avl_remove(lnp->ln_strtree, snp);
return (0);
}
}
/*
* No strings of this length, or no string itself - someone goofed.
*/
return (-1);
}
/*
* Tear down a String_Table structure.
*/
void
st_destroy(Str_tbl *stp)
{
Str_hash *sthash, *psthash;
Str_master *mstr, *pmstr;
uint_t i;
/*
* cleanup the master strings
*/
for (mstr = stp->st_mstrlist, pmstr = 0; mstr;
mstr = mstr->sm_next) {
if (pmstr)
free(pmstr);
pmstr = mstr;
}
if (pmstr)
free(pmstr);
if (stp->st_hashbcks) {
for (i = 0; i < stp->st_hbckcnt; i++) {
for (sthash = stp->st_hashbcks[i], psthash = 0;
sthash; sthash = sthash->hi_next) {
if (psthash)
free(psthash);
psthash = sthash;
}
if (psthash)
free(psthash);
}
free(stp->st_hashbcks);
}
free(stp);
}
/*
* For a given string - copy it into the buffer associated with
* the string table - and return the offset it has been assigned.
*
* If a value of '-1' is returned - the string was not found in
* the Str_tbl.
*/
int
st_setstring(Str_tbl *stp, const char *str, size_t *stoff)
{
size_t stlen;
uint_t hashval;
Str_hash *sthash;
Str_master *mstr;
int i;
/*
* String table *must* have been previously cooked
*/
assert(stp->st_strbuf);
assert(stp->st_flags & FLG_STTAB_COOKED);
stlen = strlen(str);
/*
* Null string always points to head of string table
*/
if (stlen == 0) {
*stoff = 0;
return (0);
}
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
size_t _stoff;
stlen++; /* count for trailing '\0' */
_stoff = stp->st_nextoff;
/*
* Have we overflowed our assigned buffer?
*/
if ((_stoff + stlen) > stp->st_fullstrsize)
return (-1);
memcpy(stp->st_strbuf + _stoff, str, stlen);
*stoff = _stoff;
stp->st_nextoff += stlen;
return (0);
}
/*
* Calculate reverse hash for string.
*/
hashval = HASHSEED;
for (i = stlen; i >= 0; i--) {
hashval = ((hashval << 5) + hashval) +
str[i]; /* h = ((h * 33) + c) */
}
for (sthash = stp->st_hashbcks[hashval % stp->st_hbckcnt]; sthash;
sthash = sthash->hi_next) {
const char *hstr;
if (sthash->hi_hashval != hashval)
continue;
hstr = &sthash->hi_mstr->sm_str[sthash->hi_mstr->sm_strlen -
sthash->hi_strlen];
if (strcmp(str, hstr) == 0)
break;
}
/*
* Did we find the string?
*/
if (sthash == 0)
return (-1);
/*
* Has this string been copied into the string table?
*/
mstr = sthash->hi_mstr;
if (mstr->sm_stroff == 0) {
size_t mstrlen = mstr->sm_strlen + 1;
mstr->sm_stroff = stp->st_nextoff;
/*
* Have we overflowed our assigned buffer?
*/
if ((mstr->sm_stroff + mstrlen) > stp->st_fullstrsize)
return (-1);
(void) memcpy(stp->st_strbuf + mstr->sm_stroff,
mstr->sm_str, mstrlen);
stp->st_nextoff += mstrlen;
}
/*
* Calculate offset of (sub)string.
*/
*stoff = mstr->sm_stroff + mstr->sm_strlen - sthash->hi_strlen;
return (0);
}
static int
st_hash_insert(Str_tbl *stp, const char *str, size_t len)
{
int i;
uint_t hashval = HASHSEED;
uint_t bckcnt = stp->st_hbckcnt;
Str_hash **hashbcks = stp->st_hashbcks;
Str_hash *sthash;
Str_master *mstr = 0;
/*
* We use a classic 'Bernstein k=33' hash function. But
* instead of hashing from the start of the string to the
* end, we do it in reverse.
*
* This way - we are essentially building all of the
* suffix hashvalues as we go. We can check to see if
* any suffixes already exist in the tree as we generate
* the hash.
*/
for (i = len; i >= 0; i--) {
hashval = ((hashval << 5) + hashval) +
str[i]; /* h = ((h * 33) + c) */
for (sthash = hashbcks[hashval % bckcnt];
sthash; sthash = sthash->hi_next) {
const char *hstr;
Str_master *_mstr;
if (sthash->hi_hashval != hashval)
continue;
_mstr = sthash->hi_mstr;
hstr = &_mstr->sm_str[_mstr->sm_strlen -
sthash->hi_strlen];
if (strcmp(&str[i], hstr))
continue;
if (i == 0) {
/*
* Entry already in table, increment refcnt and
* get out.
*/
sthash->hi_refcnt++;
return (0);
} else {
/*
* If this 'suffix' is presently a 'master
* string, then take over it's record.
*/
if (sthash->hi_strlen == _mstr->sm_strlen) {
/*
* we should only do this once.
*/
assert(mstr == 0);
mstr = _mstr;
}
}
}
}
/*
* Do we need a new master string, or can we take over
* one we already found in the table?
*/
if (mstr == 0) {
/*
* allocate a new master string
*/
if ((mstr = calloc(sizeof (Str_hash), 1)) == 0)
return (-1);
mstr->sm_next = stp->st_mstrlist;
stp->st_mstrlist = mstr;
stp->st_strsize += len + 1;
} else {
/*
* We are taking over a existing master string, the string size
* only increments by the difference between the current string
* and the previous master.
*/
assert(len > mstr->sm_strlen);
stp->st_strsize += len - mstr->sm_strlen;
}
if ((sthash = calloc(sizeof (Str_hash), 1)) == 0)
return (-1);
mstr->sm_hashval = sthash->hi_hashval = hashval;
mstr->sm_strlen = sthash->hi_strlen = len;
mstr->sm_str = str;
sthash->hi_refcnt = 1;
sthash->hi_mstr = mstr;
/*
* Insert string element into head of hash list
*/
hashval = hashval % bckcnt;
sthash->hi_next = hashbcks[hashval];
hashbcks[hashval] = sthash;
return (0);
}
/*
* Return amount of space required for the string table.
*/
size_t
st_getstrtab_sz(Str_tbl *stp)
{
assert(stp->st_fullstrsize > 0);
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
stp->st_flags |= FLG_STTAB_COOKED;
return (stp->st_fullstrsize);
}
if ((stp->st_flags & FLG_STTAB_COOKED) == 0) {
LenNode *lnp;
void *cookie;
stp->st_flags |= FLG_STTAB_COOKED;
/*
* allocate a hash table about the size of # of
* strings input.
*/
stp->st_hbckcnt = findprime(stp->st_strcnt);
if ((stp->st_hashbcks =
calloc(sizeof (Str_hash), stp->st_hbckcnt)) == NULL)
return (0);
/*
* We now walk all of the strings in the list, from shortest to
* longest, and insert them into the hashtable.
*/
if ((lnp = avl_first(stp->st_lentree)) == NULL) {
/*
* Is it possible we have an empty string table, if so,
* the table still contains '\0', so return the size.
*/
if (avl_numnodes(stp->st_lentree) == 0) {
assert(stp->st_strsize == 1);
return (stp->st_strsize);
}
return (0);
}
while (lnp) {
StrNode *snp;
/*
* Walk the string lists and insert them into the hash
* list. Once a string is inserted we no longer need
* it's entry, so the string can be freed.
*/
for (snp = avl_first(lnp->ln_strtree); snp;
snp = AVL_NEXT(lnp->ln_strtree, snp)) {
if (st_hash_insert(stp, snp->sn_str,
lnp->ln_strlen) == -1)
return (0);
}
/*
* Now that the strings have been copied, walk the
* StrNode tree and free all the AVL nodes. Note,
* avl_destroy_nodes() beats avl_remove() as the
* latter balances the nodes as they are removed.
* We just want to tear the whole thing down fast.
*/
cookie = NULL;
while ((snp = avl_destroy_nodes(lnp->ln_strtree,
&cookie)) != NULL)
free(snp);
avl_destroy(lnp->ln_strtree);
free(lnp->ln_strtree);
lnp->ln_strtree = NULL;
/*
* Move on to the next LenNode.
*/
lnp = AVL_NEXT(stp->st_lentree, lnp);
}
/*
* Now that all of the strings have been freed, walk the
* LenNode tree and free all of the AVL nodes. Note,
* avl_destroy_nodes() beats avl_remove() as the latter
* balances the nodes as they are removed. We just want to
* tear the whole thing down fast.
*/
cookie = NULL;
while ((lnp = avl_destroy_nodes(stp->st_lentree,
&cookie)) != NULL)
free(lnp);
avl_destroy(stp->st_lentree);
free(stp->st_lentree);
stp->st_lentree = 0;
}
assert(stp->st_strsize > 0);
assert(stp->st_fullstrsize >= stp->st_strsize);
return (stp->st_strsize);
}
/*
* Associate a buffer with a string table.
*/
const char *
st_getstrbuf(Str_tbl *stp)
{
return (stp->st_strbuf);
}
int
st_setstrbuf(Str_tbl *stp, char *stbuf, size_t bufsize)
{
assert(stp->st_flags & FLG_STTAB_COOKED);
if ((stp->st_flags & FLG_STTAB_COMPRESS) == 0) {
if (bufsize < stp->st_fullstrsize)
return (-1);
} else {
if (bufsize < stp->st_strsize)
return (-1);
}
stp->st_strbuf = stbuf;
#ifdef DEBUG
/*
* for debug builds - start with a stringtable filled in
* with '0xff'. This makes it very easy to find wholes
* which we failed to fill in - in the strtab.
*/
memset(stbuf, 0xff, bufsize);
stbuf[0] = '\0';
#else
memset(stbuf, 0x0, bufsize);
#endif
return (0);
}

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,6 @@
#include "zfs_prop.h"
#include "zfeature_common.h"
int aok;
int
libzfs_errno(libzfs_handle_t *hdl)

View File

@ -45,7 +45,9 @@
* Emulation of kernel services in userland.
*/
#ifndef __FreeBSD__
int aok;
#endif
uint64_t physmem;
vnode_t *rootdir = (vnode_t *)0xabcd1234;
char hw_serial[HW_HOSTID_LEN];

View File

@ -6,7 +6,6 @@ SUBDIR= \
ctfconvert \
ctfdump \
ctfmerge \
sgsmsg \
${_tests} \
${_zinject} \
${_zlook} \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
gnu/lib/csu \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
gnu/lib/csu \

View File

@ -1,17 +0,0 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/sgs/tools/common
.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl
# This program is required as a bootstrap tool for 'make buildworld'
PROG= sgsmsg
MAN=
SRCS= avl.c sgsmsg.c string_table.c findprime.c
WARNS?= 0
CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${.CURDIR}/../../../cddl/compat/opensolaris/include \
-I${OPENSOLARIS_USR_DISTDIR}/cmd/sgs/include \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
.include <bsd.prog.mk>

View File

@ -1,19 +0,0 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libelf \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
cddl/lib/libctf \
cddl/lib/libdtrace \

View File

@ -8,6 +8,7 @@ TESTFILES= \
tst.fds.ksh \
tst.func_access.ksh \
tst.getf.ksh \
tst.kpriv.ksh \
tst.op_access.ksh \
tst.procpriv.ksh \
tst.providers.ksh \

View File

@ -14,6 +14,8 @@ TESTFILES= \
err.D_OP_INCOMPAT.dupltype.d \
err.D_OP_INCOMPAT.dupttype.d \
err.D_SYNTAX.declare.d \
err.bigglobal.d \
err.biglocal.d \
tst.basicvar.d \
tst.basicvar.d.out \
tst.localvar.d \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \

View File

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memcmp)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcmp4, __aeabi_memcmp)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcmp8, __aeabi_memcmp)
.section .note.GNU-stack,"",%progbits

View File

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memcpy)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy4, __aeabi_memcpy)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy8, __aeabi_memcpy)
.section .note.GNU-stack,"",%progbits

View File

@ -18,3 +18,5 @@ END_COMPILERRT_FUNCTION(__aeabi_memmove)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memmove4, __aeabi_memmove)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memmove8, __aeabi_memmove)
.section .note.GNU-stack,"",%progbits

View File

@ -32,3 +32,4 @@ END_COMPILERRT_FUNCTION(__aeabi_memclr)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memclr4, __aeabi_memclr)
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memclr8, __aeabi_memclr)
.section .note.GNU-stack,"",%progbits

View File

@ -60,6 +60,8 @@
.file "crti.asm"
.section .note.GNU-stack,"",%progbits
.section ".init"
.align 2
.global _init

View File

@ -68,6 +68,8 @@
.file "crtn.asm"
.section .note.GNU-stack,"",%progbits
.section ".init"
;;
FUNC_END

View File

@ -1305,3 +1305,5 @@ LSYM(Lchange_\register):
#include "ieee754-sf.S"
#include "bpabi.S"
#endif /* __symbian__ */
.section .note.GNU-stack,"",%progbits

View File

@ -516,7 +516,7 @@ static void emergency_malloc_free(char *ptr)
break;
}
}
assert(buffer > 0 &&
assert(buffer >= 0 &&
"Trying to free something that is not an emergency buffer!");
// emergency_malloc() is expected to return 0-initialized data. We don't
// zero the buffer when allocating it, because the static buffers will
@ -556,7 +556,7 @@ static void free_exception(char *e)
{
// If this allocation is within the address range of the emergency buffer,
// don't call free() because it was not allocated with malloc()
if ((e > emergency_buffer) &&
if ((e >= emergency_buffer) &&
(e < (emergency_buffer + sizeof(emergency_buffer))))
{
emergency_malloc_free(e);

View File

@ -53,6 +53,8 @@ run(int n, ...)
va_start(va, n);
#if defined(__FreeBSD__) && defined(__amd64__)
for (i = 0; i < 5; i++) {
#elif defined(__FreeBSD__) && defined(__aarch64__)
for (i = 0; i < 7; i++) {
#else
for (i = 0; i < 9; i++) {
#endif
@ -116,6 +118,10 @@ ATF_TC_BODY(setcontext_link, tc)
/* FreeBSD/amd64 only permits up to 6 arguments. */
makecontext(&uc[i], (void *)run, 6, i,
0, 1, 2, 3, 4);
#elif defined(__FreeBSD__) && defined(__aarch64__)
/* FreeBSD/arm64 only permits up to 8 arguments. */
makecontext(&uc[i], (void *)run, 8, i,
0, 1, 2, 3, 4, 5, 6);
#else
makecontext(&uc[i], (void *)run, 10, i,
0, 1, 2, 3, 4, 5, 6, 7, 8);

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: nc.1,v 1.67 2014/02/26 20:56:11 claudio Exp $
.\" $OpenBSD: nc.1,v 1.68 2015/03/26 10:35:04 tobias Exp $
.\"
.\" Copyright (c) 1996 David Sacerdote
.\" All rights reserved.
@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 11, 2014
.Dd September 26, 2015
.Dt NC 1
.Os
.Sh NAME
@ -133,7 +133,7 @@ connection to another program (e.g.\&
.Xr ssh 1
using the
.Xr ssh_config 5
.Cm ProxyUseFdPass
.Cm ProxyUseFdpass
option).
.It Fl h
Prints out

View File

@ -1,4 +1,4 @@
/* $OpenBSD: netcat.c,v 1.127 2015/02/14 22:40:22 jca Exp $ */
/* $OpenBSD: netcat.c,v 1.130 2015/07/26 19:12:28 chl Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@ -52,15 +52,16 @@
#include <err.h>
#include <errno.h>
#include <getopt.h>
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include "atomicio.h"
#ifndef SUN_LEN
@ -163,6 +164,8 @@ main(int argc, char *argv[])
uport = NULL;
sv = NULL;
signal(SIGPIPE, SIG_IGN);
while ((ch = getopt_long(argc, argv,
"46DdEe:FhI:i:klNnoO:P:p:rSs:tT:UuV:vw:X:x:z",
longopts, NULL)) != -1) {
@ -1042,7 +1045,6 @@ fdpass(int nfd)
bzero(&mh, sizeof(mh));
bzero(&cmsgbuf, sizeof(cmsgbuf));
bzero(&iov, sizeof(iov));
bzero(&pfd, sizeof(pfd));
mh.msg_control = (caddr_t)&cmsgbuf.buf;
mh.msg_controllen = sizeof(cmsgbuf.buf);
@ -1059,17 +1061,17 @@ fdpass(int nfd)
bzero(&pfd, sizeof(pfd));
pfd.fd = STDOUT_FILENO;
pfd.events = POLLOUT;
for (;;) {
r = sendmsg(STDOUT_FILENO, &mh, 0);
if (r == -1) {
if (errno == EAGAIN || errno == EINTR) {
pfd.events = POLLOUT;
if (poll(&pfd, 1, -1) == -1)
err(1, "poll");
continue;
}
err(1, "sendmsg");
} else if (r == -1)
} else if (r != 1)
errx(1, "sendmsg: unexpected return value %zd", r);
else
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: socks.c,v 1.20 2012/03/08 09:56:28 espie Exp $ */
/* $OpenBSD: socks.c,v 1.21 2015/03/26 21:19:51 tobias Exp $ */
/*
* Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
@ -308,8 +308,8 @@ socks_connect(const char *host, const char *port,
}
/* Terminate headers */
if ((r = atomicio(vwrite, proxyfd, "\r\n", 2)) != 2)
err(1, "write failed (2/%d)", r);
if ((cnt = atomicio(vwrite, proxyfd, "\r\n", 2)) != 2)
err(1, "write failed (%zu/2)", cnt);
/* Read status reply */
proxy_read_line(proxyfd, buf, sizeof(buf));

View File

@ -29,7 +29,7 @@
# when going to single-user mode.
console none unknown off secure
#
ttyv0 "/usr/libexec/getty Pc" xterm off secure
ttyv0 "/usr/libexec/getty Pc" xterm onifconsole secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" xterm off secure
ttyv2 "/usr/libexec/getty Pc" xterm off secure
@ -41,9 +41,9 @@ ttyv7 "/usr/libexec/getty Pc" xterm off secure
#ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
ttyu0 "/usr/libexec/getty std.9600" vt100 on secure
ttyu1 "/usr/libexec/getty std.9600" dialup off secure
ttyu2 "/usr/libexec/getty std.9600" dialup off secure
ttyu3 "/usr/libexec/getty std.9600" dialup off secure
ttyu0 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu2 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu3 "/usr/libexec/getty 3wire" vt100 onifconsole secure
# Dumb console
dcons "/usr/libexec/getty std.9600" vt100 off secure

View File

@ -14,6 +14,8 @@
..
expr
..
ls
..
mv
..
pax

View File

@ -3,6 +3,7 @@
# $FreeBSD$
# PROVIDE: ugidfw
# REQUIRE: FILESYSTEMS
# BEFORE: LOGIN
# KEYWORD: nojail shutdown
@ -33,9 +34,17 @@ ugidfw_start()
ugidfw_stop()
{
local rulecount
# Disable the policy
#
kldunload mac_bsdextended
# Check for the existence of rules and flush them if needed.
rulecount=$(sysctl -in security.mac.bsdextended.rule_count)
if [ ${rulecount:-0} -gt 0 ]; then
ugidfw list | sed -n '2,$p' | cut -d ' ' -f 1 | sort -r -n |
xargs -n 1 ugidfw remove
echo "MAC bsdextended rules flushed."
fi
}
load_rc_config $name

View File

@ -768,6 +768,8 @@ check_startmsgs()
#
# ${name}_prepend n Command added before ${command}.
#
# ${name}_login_class n Login class to use, else "daemon".
#
# ${rc_arg}_cmd n If set, use this as the method when invoked;
# Otherwise, use default command (see below)
#
@ -942,7 +944,7 @@ run_rc_command()
_nice=\$${name}_nice _user=\$${name}_user \
_group=\$${name}_group _groups=\$${name}_groups \
_fib=\$${name}_fib _env=\$${name}_env \
_prepend=\$${name}_prepend
_prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon}
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@ -1050,6 +1052,9 @@ $command $rc_flags $command_args"
fi
fi
# Prepend default limits
_doit="limits -C $_login_class $_doit"
# run the full command
#
if ! _run_rc_doit "$_doit"; then

View File

@ -1,10 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DEP_MACHINE := ${.PARSEFILE:E}
DIRDEPS = \

View File

@ -75,6 +75,4 @@ CLEANFILES+= tm.h tconfig.h options.h optionlist cs-tconfig.h cs-tm.h
tm.h tconfig.h options.h: ${CCDIR}/cc_tools/Makefile
(cd ${.CURDIR}; ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET})
.NOPATH: ${CLEANFILES}
.include <bsd.lib.mk>

View File

@ -16,8 +16,6 @@ INSTALLED_HEADERS= readline.h chardefs.h keymaps.h history.h tilde.h \
CFLAGS+= -I${.OBJDIR}/..
SRCDIR= ${.CURDIR}/../../../../contrib/libreadline
.NOPATH: ${INSTALLED_HEADERS}
beforebuild: ${INSTALLED_HEADERS}
CLEANFILES+= ${INSTALLED_HEADERS}
DPSRCS+= ${INSTALLED_HEADERS}

View File

@ -1,10 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DEP_MACHINE := ${.PARSEFILE:E}
DIRDEPS = \
gnu/lib/libgcc \
include \

View File

@ -1,5 +1,6 @@
# $FreeBSD$
ELF_SCR_EXT= x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw
.include "../Makefile.inc0"
.include <src.opts.mk>
@ -50,9 +51,9 @@ FILESDIR= ${SCRIPTDIR}
HOST= ${TARGET_TUPLE}
LIBSEARCHPATH= \"${TOOLS_PREFIX}/lib\":\"${TOOLS_PREFIX}/usr/lib\"
ELF_SCR_EXT= x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw
.for ext in ${ELF_SCR_EXT}
LDSCRIPTS+= ${NATIVE_EMULATION}.${ext}
ldscripts/${NATIVE_EMULATION}.${ext}: e${NATIVE_EMULATION}.c
.endfor
EMXFR=

View File

@ -16,6 +16,7 @@ _i386_path= \"${TOOLS_PREFIX}/usr/lib32\"
EMS+= ${X86_EMULATION}
.for ext in ${ELF_SCR_EXT}
LDSCRIPTS+= ${X86_EMULATION}.${ext}
ldscripts/${X86_EMULATION}.${ext}: e${X86_EMULATION}.c
.endfor
SRCS+= e${X86_EMULATION}.c

View File

@ -22,6 +22,7 @@ EMS+= ${abi}
#.endif
.for ext in ${ELF_SCR_EXT}
LDSCRIPTS+= ${abi}.${ext}
ldscripts/${abi}.${ext}: e${abi}.c
.endfor
SRCS+= e${abi}.c
CLEANFILES+= e${abi}.c

View File

@ -16,6 +16,7 @@ _ppc32_path= \"${TOOLS_PREFIX}/usr/lib32\"
EMS+= ${PPC32_EMULATION}
.for ext in ${ELF_SCR_EXT}
LDSCRIPTS+= ${PPC32_EMULATION}.${ext}
ldscripts/${PPC32_EMULATION}.${ext}: e${PPC32_EMULATION}.c
.endfor
SRCS+= e${PPC32_EMULATION}.c

View File

@ -17,6 +17,7 @@ e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \
EMS+= elf${BITS}_sparc
.for ext in ${ELF_SCR_EXT}
LDSCRIPTS+= elf${BITS}_sparc.${ext}
ldscripts/elf${BITS}_sparc.${ext}: eelf${BITS}_sparc.c
.endfor
SRCS+= eelf${BITS}_sparc.c

View File

@ -17,3 +17,5 @@ VECS= ${DEFAULT_VECTOR} \
peigen.c: peXXigen.c
sed -e s/XX/pe/g ${.ALLSRC} > ${.TARGET}
CLEANFILES+= peigen.c

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/usr.bin/cc/cc_tools \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/usr.bin/cc/cc_int \
gnu/usr.bin/cc/cc_tools \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/usr.bin/cc/cc_int \
gnu/usr.bin/cc/cc_tools \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/usr.bin/cc/cc_tools \
include \

View File

@ -216,8 +216,6 @@ tconfig.h:
GENSRCS+= tconfig.h
CLEANFILES+= cs-tconfig.h
.NOPATH: ${GENSRCS} ${CLEANFILES}
# Options
optionlist: ${OPT_FILES}
LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET}

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
include \
include/xlocale \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
gnu/usr.bin/cc/cc_tools \
include \

View File

@ -1,8 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DIRDEPS = \
include \
include/xlocale \

View File

@ -1,10 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DEP_MACHINE := ${.PARSEFILE:E}
DIRDEPS = \
gnu/lib/libgcc \
gnu/lib/libregex \

View File

@ -1,10 +1,6 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
DEP_MACHINE := ${.PARSEFILE:E}
DIRDEPS = \
gnu/lib/libgcc \
include \

View File

@ -72,7 +72,6 @@ kgdb_trgt_fetch_registers(int regno __unused)
supply_register(AMD64_R8_REGNUM + 6, (char *)&pcb.pcb_r14);
supply_register(AMD64_R15_REGNUM, (char *)&pcb.pcb_r15);
supply_register(AMD64_RIP_REGNUM, (char *)&pcb.pcb_rip);
amd64_supply_fxsave(current_regcache, -1, (struct fpusave *)(&pcb + 1));
}
void

Some files were not shown because too many files have changed in this diff Show More