MFH: r282615-r283655
Sponsored by: The FreeBSD Foundation
This commit is contained in:
commit
37a48d408f
@ -1421,7 +1421,9 @@ _cat= bin/cat
|
||||
_lex= usr.bin/lex
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} < 1001507
|
||||
# r277259 crunchide: Correct 64-bit section header offset
|
||||
# r281674 crunchide: always include both 32- and 64-bit ELF support
|
||||
.if ${BOOTSTRAPPING} < 1100071
|
||||
_crunch= usr.sbin/crunch
|
||||
.endif
|
||||
|
||||
@ -1485,6 +1487,9 @@ _kerberos5_bootstrap_tools= \
|
||||
.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
|
||||
.endif
|
||||
|
||||
# Rebuild up-to-date libmd for xinstall
|
||||
${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
|
||||
|
||||
bootstrap-tools: .PHONY
|
||||
|
||||
# Please document (add comment) why something is in 'bootstrap-tools'.
|
||||
@ -1587,11 +1592,6 @@ kernel-tools: .MAKE
|
||||
_btxld= usr.sbin/btxld
|
||||
.endif
|
||||
.endif
|
||||
.if ${TARGET_ARCH} != ${MACHINE_ARCH}
|
||||
.if ${MK_RESCUE} != "no"
|
||||
_crunchide= usr.sbin/crunch/crunchide
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# If we're given an XAS, don't build binutils.
|
||||
.if ${XAS:M/*} == ""
|
||||
@ -1626,6 +1626,9 @@ _clang_libs= lib/clang
|
||||
_cc= gnu/usr.bin/cc
|
||||
.endif
|
||||
.endif
|
||||
.if ${MK_USB} != "no"
|
||||
_usb_tools= sys/boot/usb/tools
|
||||
.endif
|
||||
|
||||
cross-tools: .MAKE
|
||||
.for _tool in \
|
||||
@ -1636,7 +1639,7 @@ cross-tools: .MAKE
|
||||
${_cc} \
|
||||
${_btxld} \
|
||||
${_crunchide} \
|
||||
sys/boot/usb/tools
|
||||
${_usb_tools}
|
||||
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
|
||||
cd ${.CURDIR}/${_tool} && \
|
||||
${MAKE} DIRPRFX=${_tool}/ obj && \
|
||||
@ -1781,13 +1784,7 @@ _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
|
||||
# all shared libraries for ELF.
|
||||
#
|
||||
_startup_libs= gnu/lib/csu
|
||||
.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}-elf
|
||||
.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
|
||||
_startup_libs+= lib/csu/${MACHINE_ARCH}
|
||||
.else
|
||||
_startup_libs+= lib/csu/${MACHINE_CPUARCH}
|
||||
.endif
|
||||
_startup_libs+= lib/csu
|
||||
_startup_libs+= gnu/lib/libgcc
|
||||
_startup_libs+= lib/libcompiler_rt
|
||||
_startup_libs+= lib/libc
|
||||
@ -1806,7 +1803,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
|
||||
${_kerberos5_lib_libhdb} \
|
||||
${_kerberos5_lib_libheimbase} \
|
||||
${_kerberos5_lib_libheimntlm} \
|
||||
${_kerberos5_lib_libheimsqlite} \
|
||||
${_libsqlite3} \
|
||||
${_kerberos5_lib_libheimipcc} \
|
||||
${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
|
||||
${_kerberos5_lib_libroken} \
|
||||
@ -1883,6 +1880,13 @@ cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
|
||||
cddl/lib/libzfs__L: lib/libgeom__L
|
||||
cddl/lib/libctf__L: lib/libz__L
|
||||
.endif
|
||||
# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
|
||||
# on select architectures though (see cddl/lib/Makefile)
|
||||
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
|
||||
${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "powerpc" || \
|
||||
${MACHINE_CPUARCH} == "arm"
|
||||
_prebuild_libs+= lib/libproc lib/librtld_db
|
||||
.endif
|
||||
|
||||
.if ${MK_CRYPT} != "no"
|
||||
.if ${MK_OPENSSL} != "no"
|
||||
@ -1913,7 +1917,7 @@ _secure_lib= secure/lib
|
||||
kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
|
||||
kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
|
||||
kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
|
||||
kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
|
||||
kerberos5/lib/libwind__L lib/libsqlite3__L
|
||||
kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
|
||||
kerberos5/lib/libroken__L lib/libcom_err__L
|
||||
kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
|
||||
@ -1926,7 +1930,7 @@ kerberos5/lib/libroken__L: lib/libcrypt__L
|
||||
kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
|
||||
kerberos5/lib/libheimbase__L: lib/libthr__L
|
||||
kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
|
||||
kerberos5/lib/libheimsqlite__L: lib/libthr__L
|
||||
lib/libsqlite3__L: lib/libthr__L
|
||||
.endif
|
||||
|
||||
.if ${MK_GSSAPI} != "no"
|
||||
@ -1942,7 +1946,7 @@ _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
|
||||
_kerberos5_lib_libhx509= kerberos5/lib/libhx509
|
||||
_kerberos5_lib_libroken= kerberos5/lib/libroken
|
||||
_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
|
||||
_kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
|
||||
_libsqlite3= lib/libsqlite3
|
||||
_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
|
||||
_kerberos5_lib_libwind= kerberos5/lib/libwind
|
||||
_libcom_err= lib/libcom_err
|
||||
@ -1956,6 +1960,16 @@ _lib_libypclnt= lib/libypclnt
|
||||
lib/libradius__L: lib/libmd__L
|
||||
.endif
|
||||
|
||||
lib/libproc__L: \
|
||||
${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
|
||||
.if ${MK_CXX} != "no"
|
||||
.if ${MK_LIBCPLUSPLUS} != "no"
|
||||
lib/libproc__L: lib/libcxxrt__L
|
||||
.else # This implies MK_GNUCXX != "no"; see lib/libproc
|
||||
lib/libproc__L: gnu/lib/libsupc++__L
|
||||
.endif
|
||||
.endif
|
||||
|
||||
gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
|
||||
|
||||
.for _lib in ${_prereq_libs}
|
||||
|
@ -38,6 +38,81 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20150525: new clang import which bumps version from 3.6.0 to 3.6.1.
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/__stddef_max_align_t.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/__wmmintrin_aes.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/__wmmintrin_pclmul.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/adxintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/altivec.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/ammintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/arm_acle.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/arm_neon.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx2intrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx512bwintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx512erintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx512fintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx512vlbwintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avx512vlintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/avxintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/bmi2intrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/bmiintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/cpuid.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/emmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/f16cintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/fma4intrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/fmaintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/ia32intrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/immintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/lzcntintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/mm3dnow.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/mm_malloc.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/mmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/module.modulemap
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/nmmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/pmmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/popcntintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/prfchwintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/rdseedintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/rtmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/shaintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/smmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/tbmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/tmmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/wmmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/x86intrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/xmmintrin.h
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/include/xopintrin.h
|
||||
OLD_DIRS+=usr/lib/clang/3.6.0/include
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.asan-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.asan-x86_64.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.asan_cxx-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.asan_cxx-x86_64.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.profile-arm.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.profile-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.profile-x86_64.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.san-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.san-x86_64.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.ubsan-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.ubsan-x86_64.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.ubsan_cxx-i386.a
|
||||
OLD_FILES+=usr/lib/clang/3.6.0/lib/freebsd/libclang_rt.ubsan_cxx-x86_64.a
|
||||
OLD_DIRS+=usr/lib/clang/3.6.0/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/3.6.0/lib
|
||||
OLD_DIRS+=usr/lib/clang/3.6.0
|
||||
# 20150521
|
||||
OLD_FILES+=usr/bin/demandoc
|
||||
OLD_FILES+=usr/share/man/man1/demandoc.1.gz
|
||||
OLD_FILES+=usr/share/man/man3/mandoc.3.gz
|
||||
OLD_FILES+=usr/share/man/man3/mandoc_headers.3.gz
|
||||
# 20150520
|
||||
OLD_FILES+=usr/lib/libheimsqlite.a
|
||||
OLD_FILES+=usr/lib/libheimsqlite.so
|
||||
OLD_LIBS+=usr/lib/libheimsqlite.so.11
|
||||
OLD_FILES+=usr/lib/libheimsqlite_p.a
|
||||
OLD_FILES+=usr/lib32/libheimsqlite.a
|
||||
OLD_FILES+=usr/lib32/libheimsqlite.so
|
||||
OLD_LIBS+=usr/lib32/libheimsqlite.so.11
|
||||
OLD_FILES+=usr/lib32/libheimsqlite_p.a
|
||||
# 20150506
|
||||
OLD_FILES+=usr/share/man/man9/NDHASGIANT.9.gz
|
||||
# 20150504
|
||||
@ -448,6 +523,33 @@ OLD_LIBS+=usr/lib32/libopie.so.7
|
||||
OLD_FILES+=usr/bin/otp-sha
|
||||
OLD_FILES+=usr/share/man/man1/otp-sha.1.gz
|
||||
# 20140807: Remove private lib files that should not be installed.
|
||||
OLD_FILES+=usr/lib32/private/libatf-c.a
|
||||
OLD_FILES+=usr/lib32/private/libatf-c.so
|
||||
OLD_FILES+=usr/lib32/private/libatf-c_p.a
|
||||
OLD_FILES+=usr/lib32/private/libatf-c++.a
|
||||
OLD_FILES+=usr/lib32/private/libatf-c++.so
|
||||
OLD_FILES+=usr/lib32/private/libatf-c++_p.a
|
||||
OLD_FILES+=usr/lib32/private/libbsdstat.a
|
||||
OLD_FILES+=usr/lib32/private/libbsdstat.so
|
||||
OLD_FILES+=usr/lib32/private/libbsdstat_p.a
|
||||
OLD_FILES+=usr/lib32/private/libheimipcc.a
|
||||
OLD_FILES+=usr/lib32/private/libheimipcc.so
|
||||
OLD_FILES+=usr/lib32/private/libheimipcc_p.a
|
||||
OLD_FILES+=usr/lib32/private/libheimipcs.a
|
||||
OLD_FILES+=usr/lib32/private/libheimipcs.so
|
||||
OLD_FILES+=usr/lib32/private/libheimipcs_p.a
|
||||
OLD_FILES+=usr/lib32/private/libldns.a
|
||||
OLD_FILES+=usr/lib32/private/libldns.so
|
||||
OLD_FILES+=usr/lib32/private/libldns_p.a
|
||||
OLD_FILES+=usr/lib32/private/libssh.a
|
||||
OLD_FILES+=usr/lib32/private/libssh.so
|
||||
OLD_FILES+=usr/lib32/private/libssh_p.a
|
||||
OLD_FILES+=usr/lib32/private/libunbound.a
|
||||
OLD_FILES+=usr/lib32/private/libunbound.so
|
||||
OLD_FILES+=usr/lib32/private/libunbound_p.a
|
||||
OLD_FILES+=usr/lib32/private/libucl.a
|
||||
OLD_FILES+=usr/lib32/private/libucl.so
|
||||
OLD_FILES+=usr/lib32/private/libucl_p.a
|
||||
OLD_FILES+=usr/lib/private/libatf-c.a
|
||||
OLD_FILES+=usr/lib/private/libatf-c.so
|
||||
OLD_FILES+=usr/lib/private/libatf-c_p.a
|
||||
@ -468,7 +570,7 @@ OLD_FILES+=usr/lib/private/libldns.so
|
||||
OLD_FILES+=usr/lib/private/libldns_p.a
|
||||
OLD_FILES+=usr/lib/private/libssh.a
|
||||
OLD_FILES+=usr/lib/private/libssh.so
|
||||
OLD_FILES+=usr/lib/private/libssh.p.a
|
||||
OLD_FILES+=usr/lib/private/libssh_p.a
|
||||
OLD_FILES+=usr/lib/private/libunbound.a
|
||||
OLD_FILES+=usr/lib/private/libunbound.so
|
||||
OLD_FILES+=usr/lib/private/libunbound_p.a
|
||||
@ -620,8 +722,12 @@ OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/groupinput
|
||||
# 20140223: Remove libyaml
|
||||
OLD_FILES+=usr/lib/private/libyaml.a
|
||||
OLD_FILES+=usr/lib/private/libyaml.so
|
||||
OLD_FILES+=usr/lib/private/libyaml.so.1
|
||||
OLD_LIBS+=usr/lib/private/libyaml.so.1
|
||||
OLD_FILES+=usr/lib/private/libyaml_p.a
|
||||
OLD_FILES+=usr/lib32/private/libyaml.a
|
||||
OLD_FILES+=usr/lib32/private/libyaml.so
|
||||
OLD_LIBS+=usr/lib32/private/libyaml.so.1
|
||||
OLD_FILES+=usr/lib32/private/libyaml_p.a
|
||||
# 20140216: new clang import which bumps version from 3.3 to 3.4.
|
||||
OLD_FILES+=usr/bin/llvm-prof
|
||||
OLD_FILES+=usr/bin/llvm-ranlib
|
||||
|
18
UPDATING
18
UPDATING
@ -31,6 +31,24 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20150525:
|
||||
Clang and llvm have been upgraded to 3.6.1 release. Please see the
|
||||
20141231 entry below for information about prerequisites and upgrading,
|
||||
if you are not already using 3.5.0 or higher.
|
||||
|
||||
20150521:
|
||||
TI platform code switched to using vendor DTS files and this update
|
||||
may break existing systems running on Beaglebone, Beaglebone Black,
|
||||
and Pandaboard:
|
||||
|
||||
- dtb files should be regenerated/reinstalled. Filenames are the
|
||||
same but content is different now
|
||||
- GPIO addressing was changed, now each GPIO bank (32 pins per bank)
|
||||
has its own /dev/gpiocX device, e.g. pin 121 on /dev/gpioc0 in old
|
||||
addressing scheme is now pin 25 on /dev/gpioc3.
|
||||
- Pandaboard: /etc/ttys should be updated, serial console device is
|
||||
now /dev/ttyu2, not /dev/ttyu0
|
||||
|
||||
20150501:
|
||||
soelim(1) from gnu/usr.bin/groff has been replaced by usr.bin/soelim.
|
||||
If you need the GNU extension from groff soelim(1), install groff
|
||||
|
@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
|
||||
|
@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
|
@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "cache.h"
|
||||
|
@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "cpio.h"
|
||||
#include "extern.h"
|
||||
|
@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/uio.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "options.h"
|
||||
#include "extern.h"
|
||||
|
@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <langinfo.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
|
@ -19,8 +19,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
int getoldopt(int, char **, const char *);
|
||||
|
||||
int
|
||||
getoldopt(int argc, char **argv, const char *optstring)
|
||||
|
@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#ifdef NET2_REGEX
|
||||
#include <regexp.h>
|
||||
#else
|
||||
|
@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
static int gen_init(void);
|
||||
|
@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "sel_subs.h"
|
||||
|
@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
#include "tar.h"
|
||||
|
@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pax.h"
|
||||
#include "extern.h"
|
||||
|
@ -11,6 +11,6 @@ SRCS= fmt.c keyword.c nlist.c print.c ps.c
|
||||
# on large systems.
|
||||
#
|
||||
CFLAGS+=-DLAZY_PS
|
||||
LIBADD= m kvm jail
|
||||
LIBADD= m kvm jail xo
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
282
bin/ps/keyword.c
282
bin/ps/keyword.c
@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libxo/xo.h>
|
||||
|
||||
#include "ps.h"
|
||||
|
||||
@ -64,116 +65,170 @@ static int vcmp(const void *, const void *);
|
||||
|
||||
/* PLEASE KEEP THE TABLE BELOW SORTED ALPHABETICALLY!!! */
|
||||
static VAR var[] = {
|
||||
{"%cpu", "%CPU", NULL, 0, pcpu, 0, CHAR, NULL, 0},
|
||||
{"%mem", "%MEM", NULL, 0, pmem, 0, CHAR, NULL, 0},
|
||||
{"acflag", "ACFLG", NULL, 0, kvar, KOFF(ki_acflag), USHORT, "x", 0},
|
||||
{"acflg", "", "acflag", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"args", "COMMAND", NULL, COMM|LJUST|USER, arguments, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"blocked", "", "sigmask", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"caught", "", "sigcatch", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"class", "CLASS", NULL, LJUST, loginclass, 0, CHAR, NULL, 0},
|
||||
{"comm", "COMMAND", NULL, LJUST, ucomm, 0, CHAR, NULL, 0},
|
||||
{"command", "COMMAND", NULL, COMM|LJUST|USER, command, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"cow", "COW", NULL, 0, kvar, KOFF(ki_cow), UINT, "u", 0},
|
||||
{"cpu", "CPU", NULL, 0, kvar, KOFF(ki_estcpu), UINT, "d", 0},
|
||||
{"cputime", "", "time", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"dsiz", "DSIZ", NULL, 0, kvar, KOFF(ki_dsize), PGTOK, "ld", 0},
|
||||
{"egid", "", "gid", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"egroup", "", "group", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"emul", "EMUL", NULL, LJUST, emulname, 0, CHAR, NULL, 0},
|
||||
{"etime", "ELAPSED", NULL, USER, elapsed, 0, CHAR, NULL, 0},
|
||||
{"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0},
|
||||
{"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0},
|
||||
{"f2", "F2", NULL, 0, kvar, KOFF(ki_flag2), INT, "08x", 0},
|
||||
{"fib", "FIB", NULL, 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
|
||||
{"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"flags2", "", "f2", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
|
||||
{"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0},
|
||||
{"ignored", "", "sigignore", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"inblk", "INBLK", NULL, USER, rvar, ROFF(ru_inblock), LONG, "ld", 0},
|
||||
{"inblock", "", "inblk", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"jid", "JID", NULL, 0, kvar, KOFF(ki_jid), INT, "d", 0},
|
||||
{"jobc", "JOBC", NULL, 0, kvar, KOFF(ki_jobc), SHORT, "d", 0},
|
||||
{"ktrace", "KTRACE", NULL, 0, kvar, KOFF(ki_traceflag), INT, "x", 0},
|
||||
{"label", "LABEL", NULL, LJUST, label, 0, CHAR, NULL, 0},
|
||||
{"lim", "LIM", NULL, 0, maxrss, 0, CHAR, NULL, 0},
|
||||
{"lockname", "LOCK", NULL, LJUST, lockname, 0, CHAR, NULL, 0},
|
||||
{"login", "LOGIN", NULL, LJUST, logname, 0, CHAR, NULL, 0},
|
||||
{"logname", "", "login", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"lstart", "STARTED", NULL, LJUST|USER, lstarted, 0, CHAR, NULL, 0},
|
||||
{"lwp", "LWP", NULL, 0, kvar, KOFF(ki_tid), UINT, LWPFMT, 0},
|
||||
{"majflt", "MAJFLT", NULL, USER, rvar, ROFF(ru_majflt), LONG, "ld", 0},
|
||||
{"minflt", "MINFLT", NULL, USER, rvar, ROFF(ru_minflt), LONG, "ld", 0},
|
||||
{"msgrcv", "MSGRCV", NULL, USER, rvar, ROFF(ru_msgrcv), LONG, "ld", 0},
|
||||
{"msgsnd", "MSGSND", NULL, USER, rvar, ROFF(ru_msgsnd), LONG, "ld", 0},
|
||||
{"mwchan", "MWCHAN", NULL, LJUST, mwchan, 0, CHAR, NULL, 0},
|
||||
{"ni", "", "nice", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"nice", "NI", NULL, 0, kvar, KOFF(ki_nice), CHAR, "d", 0},
|
||||
{"nivcsw", "NIVCSW", NULL, USER, rvar, ROFF(ru_nivcsw), LONG, "ld", 0},
|
||||
{"nlwp", "NLWP", NULL, 0, kvar, KOFF(ki_numthreads), UINT, NLWPFMT, 0},
|
||||
{"nsignals", "", "nsigs", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"nsigs", "NSIGS", NULL, USER, rvar, ROFF(ru_nsignals), LONG, "ld", 0},
|
||||
{"nswap", "NSWAP", NULL, USER, rvar, ROFF(ru_nswap), LONG, "ld", 0},
|
||||
{"nvcsw", "NVCSW", NULL, USER, rvar, ROFF(ru_nvcsw), LONG, "ld", 0},
|
||||
{"nwchan", "NWCHAN", NULL, LJUST, nwchan, 0, CHAR, NULL, 0},
|
||||
{"oublk", "OUBLK", NULL, USER, rvar, ROFF(ru_oublock), LONG, "ld", 0},
|
||||
{"oublock", "", "oublk", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"paddr", "PADDR", NULL, 0, kvar, KOFF(ki_paddr), KPTR, "lx", 0},
|
||||
{"pagein", "PAGEIN", NULL, USER, pagein, 0, CHAR, NULL, 0},
|
||||
{"pcpu", "", "%cpu", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"pending", "", "sig", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"pgid", "PGID", NULL, 0, kvar, KOFF(ki_pgid), UINT, PIDFMT, 0},
|
||||
{"pid", "PID", NULL, 0, kvar, KOFF(ki_pid), UINT, PIDFMT, 0},
|
||||
{"pmem", "", "%mem", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"ppid", "PPID", NULL, 0, kvar, KOFF(ki_ppid), UINT, PIDFMT, 0},
|
||||
{"pri", "PRI", NULL, 0, pri, 0, CHAR, NULL, 0},
|
||||
{"re", "RE", NULL, INF127, kvar, KOFF(ki_swtime), UINT, "d", 0},
|
||||
{"rgid", "RGID", NULL, 0, kvar, KOFF(ki_rgid), UINT, UIDFMT, 0},
|
||||
{"rgroup", "RGROUP", NULL, LJUST, rgroupname, 0, CHAR, NULL, 0},
|
||||
{"rss", "RSS", NULL, 0, kvar, KOFF(ki_rssize), PGTOK, "ld", 0},
|
||||
{"rtprio", "RTPRIO", NULL, 0, priorityr, KOFF(ki_pri), CHAR, NULL, 0},
|
||||
{"ruid", "RUID", NULL, 0, kvar, KOFF(ki_ruid), UINT, UIDFMT, 0},
|
||||
{"ruser", "RUSER", NULL, LJUST, runame, 0, CHAR, NULL, 0},
|
||||
{"sid", "SID", NULL, 0, kvar, KOFF(ki_sid), UINT, PIDFMT, 0},
|
||||
{"sig", "PENDING", NULL, 0, kvar, KOFF(ki_siglist), INT, "x", 0},
|
||||
{"sigcatch", "CAUGHT", NULL, 0, kvar, KOFF(ki_sigcatch), UINT, "x", 0},
|
||||
{"sigignore", "IGNORED", NULL, 0, kvar, KOFF(ki_sigignore),
|
||||
UINT, "x", 0},
|
||||
{"sigmask", "BLOCKED", NULL, 0, kvar, KOFF(ki_sigmask), UINT, "x", 0},
|
||||
{"sl", "SL", NULL, INF127, kvar, KOFF(ki_slptime), UINT, "d", 0},
|
||||
{"ssiz", "SSIZ", NULL, 0, kvar, KOFF(ki_ssize), PGTOK, "ld", 0},
|
||||
{"start", "STARTED", NULL, LJUST|USER, started, 0, CHAR, NULL, 0},
|
||||
{"stat", "", "state", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"state", "STAT", NULL, LJUST, state, 0, CHAR, NULL, 0},
|
||||
{"svgid", "SVGID", NULL, 0, kvar, KOFF(ki_svgid), UINT, UIDFMT, 0},
|
||||
{"svuid", "SVUID", NULL, 0, kvar, KOFF(ki_svuid), UINT, UIDFMT, 0},
|
||||
{"systime", "SYSTIME", NULL, USER, systime, 0, CHAR, NULL, 0},
|
||||
{"tdaddr", "TDADDR", NULL, 0, kvar, KOFF(ki_tdaddr), KPTR, "lx", 0},
|
||||
{"tdev", "TDEV", NULL, 0, tdev, 0, CHAR, NULL, 0},
|
||||
{"tdnam", "TDNAM", NULL, LJUST, tdnam, 0, CHAR, NULL, 0},
|
||||
{"time", "TIME", NULL, USER, cputime, 0, CHAR, NULL, 0},
|
||||
{"tpgid", "TPGID", NULL, 0, kvar, KOFF(ki_tpgid), UINT, PIDFMT, 0},
|
||||
{"tracer", "TRACER", NULL, 0, kvar, KOFF(ki_tracer), UINT, PIDFMT, 0},
|
||||
{"tsid", "TSID", NULL, 0, kvar, KOFF(ki_tsid), UINT, PIDFMT, 0},
|
||||
{"tsiz", "TSIZ", NULL, 0, kvar, KOFF(ki_tsize), PGTOK, "ld", 0},
|
||||
{"tt", "TT ", NULL, 0, tname, 0, CHAR, NULL, 0},
|
||||
{"tty", "TTY", NULL, LJUST, longtname, 0, CHAR, NULL, 0},
|
||||
{"ucomm", "UCOMM", NULL, LJUST, ucomm, 0, CHAR, NULL, 0},
|
||||
{"uid", "UID", NULL, 0, kvar, KOFF(ki_uid), UINT, UIDFMT, 0},
|
||||
{"upr", "UPR", NULL, 0, upr, 0, CHAR, NULL, 0},
|
||||
{"uprocp", "UPROCP", NULL, 0, kvar, KOFF(ki_paddr), KPTR, "lx", 0},
|
||||
{"user", "USER", NULL, LJUST, uname, 0, CHAR, NULL, 0},
|
||||
{"usertime", "USERTIME", NULL, USER, usertime, 0, CHAR, NULL, 0},
|
||||
{"usrpri", "", "upr", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"vsize", "", "vsz", 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"vsz", "VSZ", NULL, 0, vsize, 0, CHAR, NULL, 0},
|
||||
{"wchan", "WCHAN", NULL, LJUST, wchan, 0, CHAR, NULL, 0},
|
||||
{"xstat", "XSTAT", NULL, 0, kvar, KOFF(ki_xstat), USHORT, "x", 0},
|
||||
{"", NULL, NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"%cpu", "%CPU", NULL, "percent-cpu", 0, pcpu, 0, CHAR, NULL, 0},
|
||||
{"%mem", "%MEM", NULL, "percent-memory", 0, pmem, 0, CHAR, NULL, 0},
|
||||
{"acflag", "ACFLG", NULL, "accounting-flag", 0, kvar, KOFF(ki_acflag),
|
||||
USHORT, "x", 0},
|
||||
{"acflg", "", "acflag", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"args", "COMMAND", NULL, "arguments", COMM|LJUST|USER, arguments, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"blocked", "", "sigmask", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"caught", "", "sigcatch", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"class", "CLASS", NULL, "login-class", LJUST, loginclass, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"comm", "COMMAND", NULL, "command", LJUST, ucomm, 0, CHAR, NULL, 0},
|
||||
{"command", "COMMAND", NULL, "command", COMM|LJUST|USER, command, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"cow", "COW", NULL, "copy-on-write-faults", 0, kvar, KOFF(ki_cow),
|
||||
UINT, "u", 0},
|
||||
{"cpu", "CPU", NULL, "cpu-usage", 0, kvar, KOFF(ki_estcpu), UINT, "d",
|
||||
0},
|
||||
{"cputime", "", "time", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"dsiz", "DSIZ", NULL, "data-size", 0, kvar, KOFF(ki_dsize), PGTOK,
|
||||
"ld", 0},
|
||||
{"egid", "", "gid", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"egroup", "", "group", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"emul", "EMUL", NULL, "emulation-envirnment", LJUST, emulname, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"etime", "ELAPSED", NULL, "elapsed-time", USER, elapsed, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"etimes", "ELAPSED", NULL, "elapsed-times", USER, elapseds, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"euid", "", "uid", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"f", "F", NULL, "flags", 0, kvar, KOFF(ki_flag), INT, "x", 0},
|
||||
{"f2", "F2", NULL, "flags2", 0, kvar, KOFF(ki_flag2), INT, "08x", 0},
|
||||
{"fib", "FIB", NULL, "fib", 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
|
||||
{"flags", "", "f", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"flags2", "", "f2", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"gid", "GID", NULL, "gid", 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
|
||||
{"group", "GROUP", NULL, "group", LJUST, egroupname, 0, CHAR, NULL, 0},
|
||||
{"ignored", "", "sigignore", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"inblk", "INBLK", NULL, "read-blocks", USER, rvar, ROFF(ru_inblock),
|
||||
LONG, "ld", 0},
|
||||
{"inblock", "", "inblk", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"jid", "JID", NULL, "jail-id", 0, kvar, KOFF(ki_jid), INT, "d", 0},
|
||||
{"jobc", "JOBC", NULL, "job-control-count", 0, kvar, KOFF(ki_jobc),
|
||||
SHORT, "d", 0},
|
||||
{"ktrace", "KTRACE", NULL, "ktrace", 0, kvar, KOFF(ki_traceflag), INT,
|
||||
"x", 0},
|
||||
{"label", "LABEL", NULL, "label", LJUST, label, 0, CHAR, NULL, 0},
|
||||
{"lim", "LIM", NULL, "memory-limit", 0, maxrss, 0, CHAR, NULL, 0},
|
||||
{"lockname", "LOCK", NULL, "lock-name", LJUST, lockname, 0, CHAR, NULL,
|
||||
0},
|
||||
{"login", "LOGIN", NULL, "login-name", LJUST, logname, 0, CHAR, NULL,
|
||||
0},
|
||||
{"logname", "", "login", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"lstart", "STARTED", NULL, "start-time", LJUST|USER, lstarted, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"lwp", "LWP", NULL, "process-thread-id", 0, kvar, KOFF(ki_tid), UINT,
|
||||
LWPFMT, 0},
|
||||
{"majflt", "MAJFLT", NULL, "major-faults", USER, rvar, ROFF(ru_majflt),
|
||||
LONG, "ld", 0},
|
||||
{"minflt", "MINFLT", NULL, "minor-faults", USER, rvar, ROFF(ru_minflt),
|
||||
LONG, "ld", 0},
|
||||
{"msgrcv", "MSGRCV", NULL, "received-messages", USER, rvar,
|
||||
ROFF(ru_msgrcv), LONG, "ld", 0},
|
||||
{"msgsnd", "MSGSND", NULL, "sent-messages", USER, rvar,
|
||||
ROFF(ru_msgsnd), LONG, "ld", 0},
|
||||
{"mwchan", "MWCHAN", NULL, "wait-channel", LJUST, mwchan, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"ni", "", "nice", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"nice", "NI", NULL, "nice", 0, kvar, KOFF(ki_nice), CHAR, "d", 0},
|
||||
{"nivcsw", "NIVCSW", NULL, "involuntary-context-switches", USER, rvar,
|
||||
ROFF(ru_nivcsw), LONG, "ld", 0},
|
||||
{"nlwp", "NLWP", NULL, "threads", 0, kvar, KOFF(ki_numthreads), UINT,
|
||||
NLWPFMT, 0},
|
||||
{"nsignals", "", "nsigs", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"nsigs", "NSIGS", NULL, "signals-taken", USER, rvar,
|
||||
ROFF(ru_nsignals), LONG, "ld", 0},
|
||||
{"nswap", "NSWAP", NULL, "swaps", USER, rvar, ROFF(ru_nswap), LONG,
|
||||
"ld", 0},
|
||||
{"nvcsw", "NVCSW", NULL, "voluntary-context-switches", USER, rvar,
|
||||
ROFF(ru_nvcsw), LONG, "ld", 0},
|
||||
{"nwchan", "NWCHAN", NULL, "wait-channel-address", LJUST, nwchan, 0,
|
||||
CHAR, NULL, 0},
|
||||
{"oublk", "OUBLK", NULL, "written-blocks", USER, rvar,
|
||||
ROFF(ru_oublock), LONG, "ld", 0},
|
||||
{"oublock", "", "oublk", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"paddr", "PADDR", NULL, "process-address", 0, kvar, KOFF(ki_paddr),
|
||||
KPTR, "lx", 0},
|
||||
{"pagein", "PAGEIN", NULL, "pageins", USER, pagein, 0, CHAR, NULL, 0},
|
||||
{"pcpu", "", "%cpu", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"pending", "", "sig", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"pgid", "PGID", NULL, "process-group", 0, kvar, KOFF(ki_pgid), UINT,
|
||||
PIDFMT, 0},
|
||||
{"pid", "PID", NULL, "pid", 0, kvar, KOFF(ki_pid), UINT, PIDFMT, 0},
|
||||
{"pmem", "", "%mem", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"ppid", "PPID", NULL, "ppid", 0, kvar, KOFF(ki_ppid), UINT, PIDFMT, 0},
|
||||
{"pri", "PRI", NULL, "priority", 0, pri, 0, CHAR, NULL, 0},
|
||||
{"re", "RE", NULL, "residency-time", INF127, kvar, KOFF(ki_swtime),
|
||||
UINT, "d", 0},
|
||||
{"rgid", "RGID", NULL, "real-gid", 0, kvar, KOFF(ki_rgid), UINT,
|
||||
UIDFMT, 0},
|
||||
{"rgroup", "RGROUP", NULL, "real-group", LJUST, rgroupname, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"rss", "RSS", NULL, "rss", 0, kvar, KOFF(ki_rssize), PGTOK, "ld", 0},
|
||||
{"rtprio", "RTPRIO", NULL, "realtime-priority", 0, priorityr,
|
||||
KOFF(ki_pri), CHAR, NULL, 0},
|
||||
{"ruid", "RUID", NULL, "real-uid", 0, kvar, KOFF(ki_ruid), UINT,
|
||||
UIDFMT, 0},
|
||||
{"ruser", "RUSER", NULL, "real-user", LJUST, runame, 0, CHAR, NULL, 0},
|
||||
{"sid", "SID", NULL, "sid", 0, kvar, KOFF(ki_sid), UINT, PIDFMT, 0},
|
||||
{"sig", "PENDING", NULL, "signals-pending", 0, kvar, KOFF(ki_siglist),
|
||||
INT, "x", 0},
|
||||
{"sigcatch", "CAUGHT", NULL, "signals-caught", 0, kvar,
|
||||
KOFF(ki_sigcatch), UINT, "x", 0},
|
||||
{"sigignore", "IGNORED", NULL, "signals-ignored", 0, kvar,
|
||||
KOFF(ki_sigignore), UINT, "x", 0},
|
||||
{"sigmask", "BLOCKED", NULL, "signal-mask", 0, kvar, KOFF(ki_sigmask),
|
||||
UINT, "x", 0},
|
||||
{"sl", "SL", NULL, "sleep-time", INF127, kvar, KOFF(ki_slptime), UINT,
|
||||
"d", 0},
|
||||
{"ssiz", "SSIZ", NULL, "stack-size", 0, kvar, KOFF(ki_ssize), PGTOK,
|
||||
"ld", 0},
|
||||
{"start", "STARTED", NULL, "start-time", LJUST|USER, started, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"stat", "", "state", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"state", "STAT", NULL, "state", LJUST, state, 0, CHAR, NULL, 0},
|
||||
{"svgid", "SVGID", NULL, "saved-gid", 0, kvar, KOFF(ki_svgid), UINT,
|
||||
UIDFMT, 0},
|
||||
{"svuid", "SVUID", NULL, "saved-uid", 0, kvar, KOFF(ki_svuid), UINT,
|
||||
UIDFMT, 0},
|
||||
{"systime", "SYSTIME", NULL, "system-time", USER, systime, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"tdaddr", "TDADDR", NULL, "thread-address", 0, kvar, KOFF(ki_tdaddr),
|
||||
KPTR, "lx", 0},
|
||||
{"tdev", "TDEV", NULL, "terminal-device", 0, tdev, 0, CHAR, NULL, 0},
|
||||
{"tdnam", "TDNAM", NULL, "terminal-device-name", LJUST, tdnam, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"time", "TIME", NULL, "cpu-time", USER, cputime, 0, CHAR, NULL, 0},
|
||||
{"tpgid", "TPGID", NULL, "terminal-process-gid", 0, kvar,
|
||||
KOFF(ki_tpgid), UINT, PIDFMT, 0},
|
||||
{"tracer", "TRACER", NULL, "tracer", 0, kvar, KOFF(ki_tracer), UINT,
|
||||
PIDFMT, 0},
|
||||
{"tsid", "TSID", NULL, "terminal-sid", 0, kvar, KOFF(ki_tsid), UINT,
|
||||
PIDFMT, 0},
|
||||
{"tsiz", "TSIZ", NULL, "text-size", 0, kvar, KOFF(ki_tsize), PGTOK,
|
||||
"ld", 0},
|
||||
{"tt", "TT ", NULL, "terminal-name", 0, tname, 0, CHAR, NULL, 0},
|
||||
{"tty", "TTY", NULL, "tty", LJUST, longtname, 0, CHAR, NULL, 0},
|
||||
{"ucomm", "UCOMM", NULL, "accounting-name", LJUST, ucomm, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"uid", "UID", NULL, "uid", 0, kvar, KOFF(ki_uid), UINT, UIDFMT, 0},
|
||||
{"upr", "UPR", NULL, "user-priority", 0, upr, 0, CHAR, NULL, 0},
|
||||
{"uprocp", "UPROCP", NULL, "process-address", 0, kvar, KOFF(ki_paddr),
|
||||
KPTR, "lx", 0},
|
||||
{"user", "USER", NULL, "user", LJUST, uname, 0, CHAR, NULL, 0},
|
||||
{"usertime", "USERTIME", NULL, "user-time", USER, usertime, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"usrpri", "", "upr", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"vsize", "", "vsz", NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
{"vsz", "VSZ", NULL, "virtual-size", 0, vsize, 0, CHAR, NULL, 0},
|
||||
{"wchan", "WCHAN", NULL, "wait-channel", LJUST, wchan, 0, CHAR, NULL,
|
||||
0},
|
||||
{"xstat", "XSTAT", NULL, "exit-status", 0, kvar, KOFF(ki_xstat),
|
||||
USHORT, "x", 0},
|
||||
{"", NULL, NULL, NULL, 0, NULL, 0, CHAR, NULL, 0},
|
||||
};
|
||||
|
||||
void
|
||||
@ -185,16 +240,19 @@ showkey(void)
|
||||
|
||||
i = 0;
|
||||
sep = "";
|
||||
xo_open_list("key");
|
||||
for (v = var; *(p = v->name); ++v) {
|
||||
int len = strlen(p);
|
||||
if (termwidth && (i += len + 1) > termwidth) {
|
||||
i = len;
|
||||
sep = "\n";
|
||||
}
|
||||
(void) printf("%s%s", sep, p);
|
||||
xo_emit("{P:/%s}{l:key/%s}", sep, p);
|
||||
sep = " ";
|
||||
}
|
||||
(void) printf("\n");
|
||||
xo_emit("\n");
|
||||
xo_close_list("key");
|
||||
xo_finish();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vis.h>
|
||||
#include <libxo/xo.h>
|
||||
|
||||
#include "ps.h"
|
||||
|
||||
@ -85,15 +86,15 @@ printheader(void)
|
||||
v = vent->var;
|
||||
if (v->flag & LJUST) {
|
||||
if (STAILQ_NEXT(vent, next_ve) == NULL) /* last one */
|
||||
(void)printf("%s", vent->header);
|
||||
xo_emit("{T:/%s}", vent->header);
|
||||
else
|
||||
(void)printf("%-*s", v->width, vent->header);
|
||||
xo_emit("{T:/%-*s}", v->width, vent->header);
|
||||
} else
|
||||
(void)printf("%*s", v->width, vent->header);
|
||||
xo_emit("{T:/%*s}", v->width, vent->header);
|
||||
if (STAILQ_NEXT(vent, next_ve) != NULL)
|
||||
(void)putchar(' ');
|
||||
xo_emit("{P: }");
|
||||
}
|
||||
(void)putchar('\n');
|
||||
xo_emit("\n");
|
||||
}
|
||||
|
||||
char *
|
||||
@ -102,7 +103,7 @@ arguments(KINFO *k, VARENT *ve)
|
||||
char *vis_args;
|
||||
|
||||
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
|
||||
|
||||
if (STAILQ_NEXT(ve, next_ve) != NULL && strlen(vis_args) > ARGUMENTS_WIDTH)
|
||||
@ -130,7 +131,7 @@ command(KINFO *k, VARENT *ve)
|
||||
return (str);
|
||||
}
|
||||
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
|
||||
|
||||
if (STAILQ_NEXT(ve, next_ve) == NULL) {
|
||||
@ -139,7 +140,7 @@ command(KINFO *k, VARENT *ve)
|
||||
if (k->ki_env) {
|
||||
if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1))
|
||||
== NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
strvis(vis_env, k->ki_env,
|
||||
VIS_TAB | VIS_NL | VIS_NOSLASH);
|
||||
} else
|
||||
@ -215,7 +216,7 @@ state(KINFO *k, VARENT *ve __unused)
|
||||
|
||||
buf = malloc(16);
|
||||
if (buf == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
|
||||
flag = k->ki_p->ki_flag;
|
||||
tdflags = k->ki_p->ki_tdflags; /* XXXKSE */
|
||||
@ -391,7 +392,7 @@ started(KINFO *k, VARENT *ve __unused)
|
||||
|
||||
buf = malloc(buflen);
|
||||
if (buf == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
|
||||
then = k->ki_p->ki_start.tv_sec;
|
||||
tp = localtime(&then);
|
||||
@ -416,7 +417,7 @@ lstarted(KINFO *k, VARENT *ve __unused)
|
||||
|
||||
buf = malloc(buflen);
|
||||
if (buf == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
|
||||
then = k->ki_p->ki_start.tv_sec;
|
||||
(void)strftime(buf, buflen, "%c", localtime(&then));
|
||||
@ -762,7 +763,7 @@ printval(void *bp, VAR *v)
|
||||
(void)asprintf(&str, ofmt, ps_pgtok(*(u_long *)bp));
|
||||
break;
|
||||
default:
|
||||
errx(1, "unknown type %d", v->type);
|
||||
xo_errx(1, "unknown type %d", v->type);
|
||||
}
|
||||
|
||||
return (str);
|
||||
@ -804,7 +805,7 @@ label(KINFO *k, VARENT *ve __unused)
|
||||
|
||||
string = NULL;
|
||||
if (mac_prepare_process_label(&proclabel) == -1) {
|
||||
warn("mac_prepare_process_label");
|
||||
xo_warn("mac_prepare_process_label");
|
||||
goto out;
|
||||
}
|
||||
error = mac_get_pid(k->ki_p->ki_pid, proclabel);
|
||||
|
@ -29,7 +29,7 @@
|
||||
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 9, 2014
|
||||
.Dd May 27, 2015
|
||||
.Dt PS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -37,6 +37,7 @@
|
||||
.Nd process status
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl -libxo
|
||||
.Op Fl aCcdefHhjlmrSTuvwXxZ
|
||||
.Op Fl O Ar fmt | Fl o Ar fmt
|
||||
.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ...
|
||||
@ -47,6 +48,7 @@
|
||||
.Op Fl t Ar tty Ns Op , Ns Ar tty Ns Ar ...
|
||||
.Op Fl U Ar user Ns Op , Ns Ar user Ns Ar ...
|
||||
.Nm
|
||||
.Op Fl -libxo
|
||||
.Op Fl L
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -348,6 +350,9 @@ the include file
|
||||
.In sys/proc.h :
|
||||
.Bl -column P2_INHERIT_PROTECTED 0x00000001
|
||||
.It Dv "P2_INHERIT_PROTECTED" Ta No "0x00000001" Ta "New children get P_PROTECTED"
|
||||
.It Dv "P2_NOTRACE" Ta No "0x00000002" Ta "No ptrace(2) attach or coredumps"
|
||||
.It Dv "P2_NOTRACE_EXEC" Ta No "0x00000004" Ta "Keep P2_NOPTRACE on exec(2)"
|
||||
.It Dv "P2_AST_SU" Ta No "0x00000008" Ta "Handles SU ast for kthreads"
|
||||
.El
|
||||
.It Cm label
|
||||
The MAC label of the process.
|
||||
@ -733,7 +738,9 @@ Display information on all system processes:
|
||||
.Xr procstat 1 ,
|
||||
.Xr w 1 ,
|
||||
.Xr kvm 3 ,
|
||||
.Xr libxo 3
|
||||
.Xr strftime 3 ,
|
||||
.Xr xo_parse_args 3
|
||||
.Xr mac 4 ,
|
||||
.Xr procfs 5 ,
|
||||
.Xr pstat 8 ,
|
||||
|
101
bin/ps/ps.c
101
bin/ps/ps.c
@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libxo/xo.h>
|
||||
|
||||
#include "ps.h"
|
||||
|
||||
@ -184,7 +185,9 @@ main(int argc, char *argv[])
|
||||
int all, ch, elem, flag, _fmt, i, lineno, linelen, left;
|
||||
int descendancy, nentries, nkept, nselectors;
|
||||
int prtheader, wflag, what, xkeep, xkeep_implied;
|
||||
int fwidthmin, fwidthmax;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
char fmtbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
time(&now); /* Used by routines in print.c. */
|
||||
@ -221,6 +224,11 @@ main(int argc, char *argv[])
|
||||
init_list(&uidlist, addelem_uid, sizeof(uid_t), "user");
|
||||
memf = _PATH_DEVNULL;
|
||||
nlistf = NULL;
|
||||
|
||||
argc = xo_parse_args(argc, argv);
|
||||
if (argc < 0)
|
||||
exit(1);
|
||||
|
||||
while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
|
||||
switch (ch) {
|
||||
case 'A':
|
||||
@ -363,7 +371,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
case 'T':
|
||||
if ((optarg = ttyname(STDIN_FILENO)) == NULL)
|
||||
errx(1, "stdin: not a terminal");
|
||||
xo_errx(1, "stdin: not a terminal");
|
||||
/* FALLTHROUGH */
|
||||
case 't':
|
||||
add_list(&ttylist, optarg);
|
||||
@ -434,8 +442,7 @@ main(int argc, char *argv[])
|
||||
argv++;
|
||||
}
|
||||
if (*argv) {
|
||||
fprintf(stderr, "%s: illegal argument: %s\n",
|
||||
getprogname(), *argv);
|
||||
xo_warnx("illegal argument: %s\n", *argv);
|
||||
usage();
|
||||
}
|
||||
if (optfatal)
|
||||
@ -445,7 +452,7 @@ main(int argc, char *argv[])
|
||||
|
||||
kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
|
||||
if (kd == 0)
|
||||
errx(1, "%s", errbuf);
|
||||
xo_errx(1, "%s", errbuf);
|
||||
|
||||
if (!_fmt)
|
||||
parsefmt(dfmt, 0);
|
||||
@ -453,7 +460,7 @@ main(int argc, char *argv[])
|
||||
if (nselectors == 0) {
|
||||
uidlist.l.ptr = malloc(sizeof(uid_t));
|
||||
if (uidlist.l.ptr == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
nselectors = 1;
|
||||
uidlist.count = uidlist.maxcount = 1;
|
||||
*uidlist.l.uids = getuid();
|
||||
@ -515,11 +522,11 @@ main(int argc, char *argv[])
|
||||
nentries = -1;
|
||||
kp = kvm_getprocs(kd, what, flag, &nentries);
|
||||
if ((kp == NULL && nentries > 0) || (kp != NULL && nentries < 0))
|
||||
errx(1, "%s", kvm_geterr(kd));
|
||||
xo_errx(1, "%s", kvm_geterr(kd));
|
||||
nkept = 0;
|
||||
if (nentries > 0) {
|
||||
if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
for (i = nentries; --i >= 0; ++kp) {
|
||||
/*
|
||||
* If the user specified multiple selection-criteria,
|
||||
@ -629,13 +636,18 @@ main(int argc, char *argv[])
|
||||
/*
|
||||
* Print header.
|
||||
*/
|
||||
xo_open_container("process-information");
|
||||
printheader();
|
||||
if (xo_get_style(NULL) != XO_STYLE_TEXT)
|
||||
termwidth = UNLIMITED;
|
||||
|
||||
/*
|
||||
* Output formatted lines.
|
||||
*/
|
||||
xo_open_list("process");
|
||||
for (i = lineno = 0; i < nkept; i++) {
|
||||
linelen = 0;
|
||||
xo_open_instance("process");
|
||||
STAILQ_FOREACH(vent, &varlist, next_ve) {
|
||||
if (vent->var->flag & LJUST)
|
||||
fmtstr = "%-*s";
|
||||
@ -645,21 +657,27 @@ main(int argc, char *argv[])
|
||||
ks = STAILQ_FIRST(&kinfo[i].ki_ks);
|
||||
STAILQ_REMOVE_HEAD(&kinfo[i].ki_ks, ks_next);
|
||||
/* Truncate rightmost column if necessary. */
|
||||
fwidthmax = _POSIX2_LINE_MAX;
|
||||
if (STAILQ_NEXT(vent, next_ve) == NULL &&
|
||||
termwidth != UNLIMITED && ks->ks_str != NULL) {
|
||||
left = termwidth - linelen;
|
||||
if (left > 0 && left < (int)strlen(ks->ks_str))
|
||||
ks->ks_str[left] = '\0';
|
||||
fwidthmax = left;
|
||||
}
|
||||
|
||||
str = ks->ks_str;
|
||||
if (str == NULL)
|
||||
str = "-";
|
||||
/* No padding for the last column, if it's LJUST. */
|
||||
if (STAILQ_NEXT(vent, next_ve) == NULL &&
|
||||
vent->var->flag & LJUST)
|
||||
linelen += printf(fmtstr, 0, str);
|
||||
else
|
||||
linelen += printf(fmtstr, vent->var->width, str);
|
||||
fwidthmin = (xo_get_style(NULL) != XO_STYLE_TEXT ||
|
||||
(STAILQ_NEXT(vent, next_ve) == NULL &&
|
||||
(vent->var->flag & LJUST))) ? 0 : vent->var->width;
|
||||
snprintf(fmtbuf, sizeof(fmtbuf), "{:%s/%%%s%d..%ds}",
|
||||
vent->var->field ?: vent->var->name,
|
||||
(vent->var->flag & LJUST) ? "-" : "",
|
||||
fwidthmin, fwidthmax);
|
||||
xo_emit(fmtbuf, str);
|
||||
linelen += fwidthmin;
|
||||
|
||||
if (ks->ks_str != NULL) {
|
||||
free(ks->ks_str);
|
||||
@ -669,17 +687,22 @@ main(int argc, char *argv[])
|
||||
ks = NULL;
|
||||
|
||||
if (STAILQ_NEXT(vent, next_ve) != NULL) {
|
||||
(void)putchar(' ');
|
||||
xo_emit("{P: }");
|
||||
linelen++;
|
||||
}
|
||||
}
|
||||
(void)putchar('\n');
|
||||
xo_emit("\n");
|
||||
xo_close_instance("process");
|
||||
if (prtheader && lineno++ == prtheader - 4) {
|
||||
(void)putchar('\n');
|
||||
xo_emit("\n");
|
||||
printheader();
|
||||
lineno = 0;
|
||||
}
|
||||
}
|
||||
xo_close_list("process");
|
||||
xo_close_container("process-information");
|
||||
xo_finish();
|
||||
|
||||
free_list(&gidlist);
|
||||
free_list(&jidlist);
|
||||
free_list(&pidlist);
|
||||
@ -705,9 +728,9 @@ addelem_gid(struct listinfo *inf, const char *elem)
|
||||
|
||||
if (*elem == '\0' || strlen(elem) >= MAXLOGNAME) {
|
||||
if (*elem == '\0')
|
||||
warnx("Invalid (zero-length) %s name", inf->lname);
|
||||
xo_warnx("Invalid (zero-length) %s name", inf->lname);
|
||||
else
|
||||
warnx("%s name too long: %s", inf->lname, elem);
|
||||
xo_warnx("%s name too long: %s", inf->lname, elem);
|
||||
optfatal = 1;
|
||||
return (0); /* Do not add this value. */
|
||||
}
|
||||
@ -732,7 +755,7 @@ addelem_gid(struct listinfo *inf, const char *elem)
|
||||
if (grp == NULL)
|
||||
grp = getgrnam(elem);
|
||||
if (grp == NULL) {
|
||||
warnx("No %s %s '%s'", inf->lname, nameorID, elem);
|
||||
xo_warnx("No %s %s '%s'", inf->lname, nameorID, elem);
|
||||
optfatal = 1;
|
||||
return (0);
|
||||
}
|
||||
@ -773,7 +796,7 @@ addelem_pid(struct listinfo *inf, const char *elem)
|
||||
long tempid;
|
||||
|
||||
if (*elem == '\0') {
|
||||
warnx("Invalid (zero-length) process id");
|
||||
xo_warnx("Invalid (zero-length) process id");
|
||||
optfatal = 1;
|
||||
return (0); /* Do not add this value. */
|
||||
}
|
||||
@ -781,10 +804,10 @@ addelem_pid(struct listinfo *inf, const char *elem)
|
||||
errno = 0;
|
||||
tempid = strtol(elem, &endp, 10);
|
||||
if (*endp != '\0' || tempid < 0 || elem == endp) {
|
||||
warnx("Invalid %s: %s", inf->lname, elem);
|
||||
xo_warnx("Invalid %s: %s", inf->lname, elem);
|
||||
errno = ERANGE;
|
||||
} else if (errno != 0 || tempid > pid_max) {
|
||||
warnx("%s too large: %s", inf->lname, elem);
|
||||
xo_warnx("%s too large: %s", inf->lname, elem);
|
||||
errno = ERANGE;
|
||||
}
|
||||
if (errno == ERANGE) {
|
||||
@ -855,19 +878,19 @@ addelem_tty(struct listinfo *inf, const char *elem)
|
||||
if (ttypath) {
|
||||
if (stat(ttypath, &sb) == -1) {
|
||||
if (pathbuf3[0] != '\0')
|
||||
warn("%s, %s, and %s", pathbuf3, pathbuf2,
|
||||
xo_warn("%s, %s, and %s", pathbuf3, pathbuf2,
|
||||
ttypath);
|
||||
else
|
||||
warn("%s", ttypath);
|
||||
xo_warn("%s", ttypath);
|
||||
optfatal = 1;
|
||||
return (0);
|
||||
}
|
||||
if (!S_ISCHR(sb.st_mode)) {
|
||||
if (pathbuf3[0] != '\0')
|
||||
warnx("%s, %s, and %s: Not a terminal",
|
||||
xo_warnx("%s, %s, and %s: Not a terminal",
|
||||
pathbuf3, pathbuf2, ttypath);
|
||||
else
|
||||
warnx("%s: Not a terminal", ttypath);
|
||||
xo_warnx("%s: Not a terminal", ttypath);
|
||||
optfatal = 1;
|
||||
return (0);
|
||||
}
|
||||
@ -887,9 +910,9 @@ addelem_uid(struct listinfo *inf, const char *elem)
|
||||
|
||||
if (*elem == '\0' || strlen(elem) >= MAXLOGNAME) {
|
||||
if (*elem == '\0')
|
||||
warnx("Invalid (zero-length) %s name", inf->lname);
|
||||
xo_warnx("Invalid (zero-length) %s name", inf->lname);
|
||||
else
|
||||
warnx("%s name too long: %s", inf->lname, elem);
|
||||
xo_warnx("%s name too long: %s", inf->lname, elem);
|
||||
optfatal = 1;
|
||||
return (0); /* Do not add this value. */
|
||||
}
|
||||
@ -899,12 +922,12 @@ addelem_uid(struct listinfo *inf, const char *elem)
|
||||
errno = 0;
|
||||
bigtemp = strtoul(elem, &endp, 10);
|
||||
if (errno != 0 || *endp != '\0' || bigtemp > UID_MAX)
|
||||
warnx("No %s named '%s'", inf->lname, elem);
|
||||
xo_warnx("No %s named '%s'", inf->lname, elem);
|
||||
else {
|
||||
/* The string is all digits, so it might be a userID. */
|
||||
pwd = getpwuid((uid_t)bigtemp);
|
||||
if (pwd == NULL)
|
||||
warnx("No %s name or ID matches '%s'",
|
||||
xo_warnx("No %s name or ID matches '%s'",
|
||||
inf->lname, elem);
|
||||
}
|
||||
}
|
||||
@ -961,7 +984,7 @@ add_list(struct listinfo *inf, const char *argp)
|
||||
while (*argp != '\0' && strchr(W_SEP T_SEP,
|
||||
*argp) == NULL)
|
||||
argp++;
|
||||
warnx("Value too long: %.*s", (int)(argp - savep),
|
||||
xo_warnx("Value too long: %.*s", (int)(argp - savep),
|
||||
savep);
|
||||
optfatal = 1;
|
||||
}
|
||||
@ -1062,7 +1085,7 @@ descendant_sort(KINFO *ki, int items)
|
||||
continue;
|
||||
}
|
||||
if ((ki[src].ki_d.prefix = malloc(lvl * 2 + 1)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
for (n = 0; n < lvl - 2; n++) {
|
||||
ki[src].ki_d.prefix[n * 2] =
|
||||
path[n / 8] & 1 << (n % 8) ? '|' : ' ';
|
||||
@ -1100,7 +1123,7 @@ expand_list(struct listinfo *inf)
|
||||
newlist = realloc(inf->l.ptr, newmax * inf->elemsize);
|
||||
if (newlist == NULL) {
|
||||
free(inf->l.ptr);
|
||||
errx(1, "realloc to %d %ss failed", newmax, inf->lname);
|
||||
xo_errx(1, "realloc to %d %ss failed", newmax, inf->lname);
|
||||
}
|
||||
inf->maxcount = newmax;
|
||||
inf->l.ptr = newlist;
|
||||
@ -1174,7 +1197,7 @@ format_output(KINFO *ki)
|
||||
str = (v->oproc)(ki, vent);
|
||||
ks = malloc(sizeof(*ks));
|
||||
if (ks == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
ks->ks_str = str;
|
||||
STAILQ_INSERT_TAIL(&ki->ki_ks, ks, ks_next);
|
||||
if (str != NULL) {
|
||||
@ -1240,7 +1263,7 @@ saveuser(KINFO *ki)
|
||||
else
|
||||
asprintf(&ki->ki_args, "(%s)", ki->ki_p->ki_comm);
|
||||
if (ki->ki_args == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
} else {
|
||||
ki->ki_args = NULL;
|
||||
}
|
||||
@ -1251,7 +1274,7 @@ saveuser(KINFO *ki)
|
||||
else
|
||||
ki->ki_env = strdup("()");
|
||||
if (ki->ki_env == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
} else {
|
||||
ki->ki_env = NULL;
|
||||
}
|
||||
@ -1372,7 +1395,7 @@ kludge_oldps_options(const char *optlist, char *origval, const char *nextarg)
|
||||
* original value.
|
||||
*/
|
||||
if ((newopts = ns = malloc(len + 3)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
xo_errx(1, "malloc failed");
|
||||
|
||||
if (*origval != '-')
|
||||
*ns++ = '-'; /* add option flag */
|
||||
@ -1401,7 +1424,7 @@ pidmax_init(void)
|
||||
|
||||
intsize = sizeof(pid_max);
|
||||
if (sysctlbyname("kern.pid_max", &pid_max, &intsize, NULL, 0) < 0) {
|
||||
warn("unable to read kern.pid_max");
|
||||
xo_warn("unable to read kern.pid_max");
|
||||
pid_max = 99999;
|
||||
}
|
||||
}
|
||||
@ -1411,7 +1434,7 @@ usage(void)
|
||||
{
|
||||
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
|
||||
|
||||
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
|
||||
(void)xo_error("%s\n%s\n%s\n%s\n",
|
||||
"usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]",
|
||||
" [-J jid[,jid...]] [-M core] [-N system]",
|
||||
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
|
||||
|
@ -65,6 +65,7 @@ typedef struct var {
|
||||
const char *name; /* name(s) of variable */
|
||||
const char *header; /* default header */
|
||||
const char *alias; /* aliases */
|
||||
const char *field; /* xo field name */
|
||||
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
|
||||
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
|
||||
#define USER 0x04 /* needs user structure */
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 8, 2014
|
||||
.Dd May 24, 2015
|
||||
.Dt LOCKSTAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -29,7 +29,7 @@
|
||||
.Nd report kernel lock and profiling statistics
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ACEHI
|
||||
.Op Fl ACEHIV
|
||||
.Op Fl e Ar event-list
|
||||
.Op Fl i Ar rate
|
||||
.Op Fl b | t | h | s Ar depth
|
||||
@ -90,6 +90,10 @@ to
|
||||
is restricted to super-user by default.
|
||||
.Sh OPTIONS
|
||||
The following options are supported:
|
||||
.Bl -tag -width indent
|
||||
.It Fl V
|
||||
Print the D program used to gather the requested data.
|
||||
.El
|
||||
.Ss Event Selection
|
||||
If no event selection options are specified, the default is
|
||||
.Fl C .
|
||||
|
@ -299,6 +299,8 @@ usage(void)
|
||||
{
|
||||
(void) fprintf(stderr,
|
||||
"Usage: lockstat [options] command [args]\n"
|
||||
"\nGeneral options:\n\n"
|
||||
" -V print the corresponding D program\n"
|
||||
"\nEvent selection options:\n\n"
|
||||
" -C watch contention events [on by default]\n"
|
||||
" -E watch error events [off by default]\n"
|
||||
|
@ -1328,15 +1328,28 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
|
||||
* we are looking for. This is necessary to permit ctf_add_type() to
|
||||
* operate recursively on entities such as a struct that contains a
|
||||
* pointer member that refers to the same struct type.
|
||||
*
|
||||
* In the case of integer and floating point types, we match using the
|
||||
* type encoding as well - else we may incorrectly return a bitfield
|
||||
* type, for instance.
|
||||
*/
|
||||
if (dst_type == CTF_ERR && name[0] != '\0') {
|
||||
for (dtd = ctf_list_prev(&dst_fp->ctf_dtdefs); dtd != NULL &&
|
||||
CTF_TYPE_TO_INDEX(dtd->dtd_type) > dst_fp->ctf_dtoldid;
|
||||
dtd = ctf_list_prev(dtd)) {
|
||||
if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) == kind &&
|
||||
dtd->dtd_name != NULL &&
|
||||
strcmp(dtd->dtd_name, name) == 0)
|
||||
return (dtd->dtd_type);
|
||||
if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) != kind ||
|
||||
dtd->dtd_name == NULL ||
|
||||
strcmp(dtd->dtd_name, name) != 0)
|
||||
continue;
|
||||
if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT) {
|
||||
if (ctf_type_encoding(src_fp, src_type,
|
||||
&src_en) != 0)
|
||||
continue;
|
||||
if (bcmp(&src_en, &dtd->dtd_u.dtu_enc,
|
||||
sizeof (ctf_encoding_t)) != 0)
|
||||
continue;
|
||||
}
|
||||
return (dtd->dtd_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,6 +743,7 @@ yyinit(dt_pcb_t *pcb)
|
||||
#ifdef illumos
|
||||
yysptr = yysbuf;
|
||||
#endif
|
||||
YY_FLUSH_BUFFER;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1785,17 +1785,11 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
|
||||
"failed to open %s: %s", file, strerror(errno)));
|
||||
}
|
||||
#else
|
||||
if (dtp->dt_lazyload) {
|
||||
if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0)
|
||||
return (dt_link_error(dtp, NULL, -1, NULL,
|
||||
"failed to open %s: %s", file, strerror(errno)));
|
||||
} else {
|
||||
snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
|
||||
if ((fd = mkstemp(tfile)) == -1)
|
||||
return (dt_link_error(dtp, NULL, -1, NULL,
|
||||
"failed to create temporary file %s: %s",
|
||||
tfile, strerror(errno)));
|
||||
}
|
||||
snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
|
||||
if ((fd = mkostemp(tfile, O_CLOEXEC)) == -1)
|
||||
return (dt_link_error(dtp, NULL, -1, NULL,
|
||||
"failed to create temporary file %s: %s",
|
||||
tfile, strerror(errno)));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -1868,23 +1862,9 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
|
||||
(void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti);
|
||||
#else
|
||||
const char *fmt = "%s -o %s -r %s %s";
|
||||
dt_dirpath_t *dp = dt_list_next(&dtp->dt_lib_path);
|
||||
|
||||
#if defined(__amd64__)
|
||||
/*
|
||||
* Arches which default to 64-bit need to explicitly use
|
||||
* the 32-bit library path.
|
||||
*/
|
||||
int use_32 = (dtp->dt_oflags & DTRACE_O_ILP32);
|
||||
#else
|
||||
/*
|
||||
* Arches which are 32-bit only just use the normal
|
||||
* library path.
|
||||
*/
|
||||
int use_32 = 0;
|
||||
#endif
|
||||
|
||||
(void) snprintf(drti, sizeof (drti), "/usr/lib%s/dtrace/drti.o",
|
||||
use_32 ? "32" : "");
|
||||
(void) snprintf(drti, sizeof (drti), "%s/drti.o", dp->dir_path);
|
||||
|
||||
len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile,
|
||||
drti) + 1;
|
||||
@ -1951,14 +1931,23 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
#ifdef __FreeBSD__
|
||||
if (rename(tfile, file) != 0) {
|
||||
ret = dt_link_error(dtp, NULL, fd, NULL,
|
||||
"failed to rename %s to %s: %s", tfile, file,
|
||||
strerror(errno));
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
(void) close(fd);
|
||||
}
|
||||
|
||||
done:
|
||||
dtrace_dof_destroy(dtp, dof);
|
||||
|
||||
#ifndef illumos
|
||||
unlink(tfile);
|
||||
#ifdef __FreeBSD__
|
||||
if (!dtp->dt_lazyload)
|
||||
(void) unlink(tfile);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
|
@ -792,6 +792,7 @@ const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */
|
||||
#ifdef illumos
|
||||
const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */
|
||||
#else
|
||||
const char *_dtrace_libdir32 = "/usr/lib32/dtrace";
|
||||
const char *_dtrace_provdir = "/dev/dtrace"; /* provider directory */
|
||||
#endif
|
||||
|
||||
@ -1581,8 +1582,19 @@ dt_vopen(int version, int flags, int *errp,
|
||||
* compile, and to provide better error reporting (because the full
|
||||
* reporting of compiler errors requires dtrace_open() to succeed).
|
||||
*/
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef __LP64__
|
||||
if ((dtp->dt_oflags & DTRACE_O_ILP32) != 0) {
|
||||
if (dtrace_setopt(dtp, "libdir", _dtrace_libdir32) != 0)
|
||||
return (set_open_errno(dtp, errp, dtp->dt_errno));
|
||||
}
|
||||
#endif
|
||||
if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0)
|
||||
return (set_open_errno(dtp, errp, dtp->dt_errno));
|
||||
#else
|
||||
if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0)
|
||||
return (set_open_errno(dtp, errp, dtp->dt_errno));
|
||||
#endif
|
||||
|
||||
return (dtp);
|
||||
}
|
||||
|
@ -33,4 +33,11 @@ _drti= drti
|
||||
_libdtrace= libdtrace
|
||||
.endif
|
||||
|
||||
SUBDIR_DEPEND_libdtrace= libctf
|
||||
SUBDIR_DEPEND_libzfs_core= libnvpair
|
||||
SUBDIR_DEPEND_libzfs= libavl libnvpair libumem libuutil libzfs_core
|
||||
SUBDIR_DEPEND_libzpool= libavl libnvpair libumem
|
||||
|
||||
SUBDIR_PARALLEL=
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -50,6 +50,7 @@ DSRCS= errno.d \
|
||||
io.d \
|
||||
ip.d \
|
||||
psinfo.d \
|
||||
siftr.d \
|
||||
signal.d \
|
||||
tcp.d \
|
||||
udp.d \
|
||||
@ -103,6 +104,8 @@ LFLAGS+=-l
|
||||
|
||||
YFLAGS+=-d
|
||||
|
||||
LIBADD= ctf elf proc pthread rtld_db
|
||||
|
||||
CLEANFILES= dt_errtags.c dt_names.c
|
||||
|
||||
dt_errtags.c:
|
||||
|
100
cddl/lib/libdtrace/siftr.d
Normal file
100
cddl/lib/libdtrace/siftr.d
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#pragma D depends_on module siftr
|
||||
#pragma D depends_on provider tcp
|
||||
|
||||
/*
|
||||
* Convert a SIFTR direction value to a string
|
||||
*/
|
||||
#pragma D binding "1.12.1" SIFTR_IN
|
||||
inline int SIFTR_IN = 1;
|
||||
#pragma D binding "1.12.1" SIFTR_OUT
|
||||
inline int SIFTR_OUT = 2;
|
||||
|
||||
/* SIFTR direction strings. */
|
||||
#pragma D binding "1.12.1" siftr_dir_string
|
||||
inline string siftr_dir_string[uint8_t direction] =
|
||||
direction == SIFTR_IN ? "in" :
|
||||
direction == SIFTR_OUT ? "out" :
|
||||
"unknown" ;
|
||||
|
||||
typedef struct siftrinfo {
|
||||
struct timeval tval;
|
||||
uint8_t direction;
|
||||
uint8_t ipver;
|
||||
uint32_t hash;
|
||||
uint16_t tcp_localport;
|
||||
uint16_t tcp_foreignport;
|
||||
uint64_t snd_cwnd;
|
||||
u_long snd_wnd;
|
||||
u_long rcv_wnd;
|
||||
u_long snd_bwnd;
|
||||
u_long snd_ssthresh;
|
||||
int conn_state;
|
||||
u_int max_seg_size;
|
||||
int smoothed_rtt;
|
||||
u_char sack_enabled;
|
||||
u_char snd_scale;
|
||||
u_char rcv_scale;
|
||||
u_int flags;
|
||||
int rxt_length;
|
||||
u_int snd_buf_hiwater;
|
||||
u_int snd_buf_cc;
|
||||
u_int rcv_buf_hiwater;
|
||||
u_int rcv_buf_cc;
|
||||
u_int sent_inflight_bytes;
|
||||
int t_segqlen;
|
||||
u_int flowid;
|
||||
u_int flowtype;
|
||||
} siftrinfo_t;
|
||||
|
||||
#pragma D binding "1.12.1" translator
|
||||
translator siftrinfo_t < struct pkt_node *p > {
|
||||
direction = p == NULL ? 0 : p->direction;
|
||||
ipver = p == NULL ? 0 : p->ipver;
|
||||
hash = p == NULL ? 0 : p->hash;
|
||||
tcp_localport = p == NULL ? 0 : ntohs(p->tcp_localport);
|
||||
tcp_foreignport = p == NULL ? 0 : ntohs(p->tcp_foreignport);
|
||||
snd_cwnd = p == NULL ? 0 : p->snd_cwnd;
|
||||
snd_wnd = p == NULL ? 0 : p->snd_wnd;
|
||||
rcv_wnd = p == NULL ? 0 : p->rcv_wnd;
|
||||
snd_bwnd = p == NULL ? 0 : p->snd_bwnd;
|
||||
snd_ssthresh = p == NULL ? 0 : p->snd_ssthresh;
|
||||
conn_state = p == NULL ? 0 : p->conn_state;
|
||||
max_seg_size = p == NULL ? 0 : p->max_seg_size;
|
||||
smoothed_rtt = p == NULL ? 0 : p->smoothed_rtt;
|
||||
sack_enabled = p == NULL ? 0 : p->sack_enabled;
|
||||
snd_scale = p == NULL ? 0 : p->snd_scale;
|
||||
rcv_scale = p == NULL ? 0 : p->rcv_scale;
|
||||
flags = p == NULL ? 0 : p->flags;
|
||||
rxt_length = p == NULL ? 0 : p->rxt_length;
|
||||
snd_buf_hiwater = p == NULL ? 0 : p->snd_buf_hiwater;
|
||||
snd_buf_cc = p == NULL ? 0 : p->snd_buf_cc;
|
||||
rcv_buf_hiwater = p == NULL ? 0 : p->rcv_buf_hiwater;
|
||||
rcv_buf_cc = p == NULL ? 0 : p->rcv_buf_cc;
|
||||
sent_inflight_bytes = p == NULL ? 0 : p->sent_inflight_bytes;
|
||||
t_segqlen = p == NULL ? 0 : p->t_segqlen;
|
||||
flowid = p == NULL ? 0 : p->flowid;
|
||||
flowtype = p == NULL ? 0 : p->flowtype;
|
||||
};
|
@ -241,78 +241,3 @@ translator tcpinfoh_t < struct tcphdr *p > {
|
||||
translator tcplsinfo_t < int s > {
|
||||
tcps_state = s;
|
||||
};
|
||||
|
||||
/*
|
||||
* Convert a SIFTR direction value to a string
|
||||
*/
|
||||
#pragma D binding "1.12.1" SIFTR_IN
|
||||
inline int SIFTR_IN = 1;
|
||||
#pragma D binding "1.12.1" SIFTR_OUT
|
||||
inline int SIFTR_OUT = 2;
|
||||
|
||||
/* SIFTR direction strings. */
|
||||
#pragma D binding "1.12.1" siftr_dir_string
|
||||
inline string siftr_dir_string[uint8_t direction] =
|
||||
direction == SIFTR_IN ? "in" :
|
||||
direction == SIFTR_OUT ? "out" :
|
||||
"unknown" ;
|
||||
|
||||
typedef struct siftrinfo {
|
||||
struct timeval tval;
|
||||
uint8_t direction;
|
||||
uint8_t ipver;
|
||||
uint32_t hash;
|
||||
uint16_t tcp_localport;
|
||||
uint16_t tcp_foreignport;
|
||||
uint64_t snd_cwnd;
|
||||
u_long snd_wnd;
|
||||
u_long rcv_wnd;
|
||||
u_long snd_bwnd;
|
||||
u_long snd_ssthresh;
|
||||
int conn_state;
|
||||
u_int max_seg_size;
|
||||
int smoothed_rtt;
|
||||
u_char sack_enabled;
|
||||
u_char snd_scale;
|
||||
u_char rcv_scale;
|
||||
u_int flags;
|
||||
int rxt_length;
|
||||
u_int snd_buf_hiwater;
|
||||
u_int snd_buf_cc;
|
||||
u_int rcv_buf_hiwater;
|
||||
u_int rcv_buf_cc;
|
||||
u_int sent_inflight_bytes;
|
||||
int t_segqlen;
|
||||
u_int flowid;
|
||||
u_int flowtype;
|
||||
} siftrinfo_t;
|
||||
|
||||
#pragma D binding "1.12.1" translator
|
||||
translator siftrinfo_t < struct pkt_node *p > {
|
||||
direction = p == NULL ? 0 : p->direction;
|
||||
ipver = p == NULL ? 0 : p->ipver;
|
||||
hash = p == NULL ? 0 : p->hash;
|
||||
tcp_localport = p == NULL ? 0 : ntohs(p->tcp_localport);
|
||||
tcp_foreignport = p == NULL ? 0 : ntohs(p->tcp_foreignport);
|
||||
snd_cwnd = p == NULL ? 0 : p->snd_cwnd;
|
||||
snd_wnd = p == NULL ? 0 : p->snd_wnd;
|
||||
rcv_wnd = p == NULL ? 0 : p->rcv_wnd;
|
||||
snd_bwnd = p == NULL ? 0 : p->snd_bwnd;
|
||||
snd_ssthresh = p == NULL ? 0 : p->snd_ssthresh;
|
||||
conn_state = p == NULL ? 0 : p->conn_state;
|
||||
max_seg_size = p == NULL ? 0 : p->max_seg_size;
|
||||
smoothed_rtt = p == NULL ? 0 : p->smoothed_rtt;
|
||||
sack_enabled = p == NULL ? 0 : p->sack_enabled;
|
||||
snd_scale = p == NULL ? 0 : p->snd_scale;
|
||||
rcv_scale = p == NULL ? 0 : p->rcv_scale;
|
||||
flags = p == NULL ? 0 : p->flags;
|
||||
rxt_length = p == NULL ? 0 : p->rxt_length;
|
||||
snd_buf_hiwater = p == NULL ? 0 : p->snd_buf_hiwater;
|
||||
snd_buf_cc = p == NULL ? 0 : p->snd_buf_cc;
|
||||
rcv_buf_hiwater = p == NULL ? 0 : p->rcv_buf_hiwater;
|
||||
rcv_buf_cc = p == NULL ? 0 : p->rcv_buf_cc;
|
||||
sent_inflight_bytes = p == NULL ? 0 : p->sent_inflight_bytes;
|
||||
t_segqlen = p == NULL ? 0 : p->t_segqlen;
|
||||
flowid = p == NULL ? 0 : p->flowid;
|
||||
flowtype = p == NULL ? 0 : p->flowtype;
|
||||
};
|
||||
|
@ -13,4 +13,6 @@ _zfs= zfs
|
||||
_zpool= zpool
|
||||
.endif
|
||||
|
||||
SUBDIR_PARALLEL=
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -26,4 +26,6 @@ _zstreamdump = zstreamdump
|
||||
.endif
|
||||
.endif
|
||||
|
||||
SUBDIR_PARALLEL=
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -3,8 +3,6 @@
|
||||
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/common
|
||||
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/cvt
|
||||
|
||||
DEBUG_FLAGS= -g
|
||||
|
||||
PROG= ctfconvert
|
||||
SRCS= alist.c \
|
||||
ctf.c \
|
||||
@ -36,7 +34,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
|
||||
-I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
|
||||
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
|
||||
|
||||
DPADD= ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
|
||||
LDADD= -ldwarf -lelf -lz -lpthread
|
||||
LIBADD= dwarf elf z pthread
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -17,7 +17,6 @@ CFLAGS+= -I${OPENSOLARIS_USR_DISTDIR} \
|
||||
-I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \
|
||||
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
|
||||
|
||||
DPADD= ${LIBPTHREAD} ${LIBELF} ${LIBZ}
|
||||
LDADD= -lpthread -lelf -lz
|
||||
LIBADD= elf z
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -46,4 +46,6 @@ _dtruss= dtruss
|
||||
_lockstat= lockstat
|
||||
.endif
|
||||
|
||||
SUBDIR_PARALLEL=
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -20,9 +20,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
|
||||
#CFLAGS+= -DNEED_ERRLOC
|
||||
#YFLAGS+= -d
|
||||
|
||||
DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
|
||||
${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
|
||||
LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lutil \
|
||||
-lrtld_db
|
||||
LIBADD= dtrace
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -38,7 +38,6 @@ exclude EXFAIL common/ip/tst.ipv4localudp.ksh
|
||||
exclude EXFAIL common/mdb/tst.dtracedcmd.ksh
|
||||
exclude EXFAIL common/misc/tst.dofmax.ksh
|
||||
exclude EXFAIL common/misc/tst.include.ksh
|
||||
exclude EXFAIL common/pragma/tst.libchain.ksh
|
||||
exclude EXFAIL common/safety/tst.copyin2.d
|
||||
exclude EXFAIL common/safety/tst.msgdsize.d
|
||||
exclude EXFAIL common/safety/tst.msgsize.d
|
||||
|
@ -21,10 +21,6 @@ CFLAGS+= -DNEED_ERRLOC -g
|
||||
|
||||
#YFLAGS+= -d
|
||||
|
||||
DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
|
||||
${LIBCTF} ${LIBELF} ${LIBZ} ${LIBRT} ${LIBUTIL} \
|
||||
${LIBRTLD_DB}
|
||||
LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lrt -lutil \
|
||||
-lrtld_db
|
||||
LIBADD= elf dtrace rt
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -18,9 +18,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
|
||||
-I${.CURDIR}/../../../cddl/lib/libdtrace \
|
||||
-I${.CURDIR}/../../../sys
|
||||
|
||||
DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} ${LIBCTF}\
|
||||
${LIBELF} ${LIBZ} ${LIBRT} ${LIBRTLD_DB} ${LIBUTIL}
|
||||
LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lrt \
|
||||
-lrtld_db -lutil
|
||||
LIBADD= dtrace proc
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -164,18 +164,22 @@ equal_body()
|
||||
grep '^failed: \${x} != \${y} (a != b)$' resfile
|
||||
}
|
||||
|
||||
atf_test_case flush_stdout_on_timeout
|
||||
flush_stdout_on_timeout_body()
|
||||
atf_test_case flush_stdout_on_death
|
||||
flush_stdout_on_death_body()
|
||||
{
|
||||
"$(atf_get_srcdir)/misc_helpers" -s "$(atf_get_srcdir)" atf_check_timeout \
|
||||
>out 2>err &
|
||||
CONTROL_FILE="$(pwd)/done" "$(atf_get_srcdir)/misc_helpers" \
|
||||
-s "$(atf_get_srcdir)" atf_check_flush_stdout >out 2>err &
|
||||
pid="${!}"
|
||||
sleep 1
|
||||
kill "${pid}"
|
||||
while [ ! -f ./done ]; do
|
||||
echo "Still waiting for helper to create control file"
|
||||
ls
|
||||
sleep 1
|
||||
done
|
||||
kill -9 "${pid}"
|
||||
|
||||
grep 'Executing command.*true' out \
|
||||
|| atf_fail 'First command not in output'
|
||||
grep 'Executing command.*sleep 42' out \
|
||||
grep 'Executing command.*false' out \
|
||||
|| atf_fail 'Second command not in output'
|
||||
}
|
||||
|
||||
@ -187,7 +191,7 @@ atf_init_test_cases()
|
||||
atf_add_test_case null_stdout
|
||||
atf_add_test_case null_stderr
|
||||
atf_add_test_case equal
|
||||
atf_add_test_case flush_stdout_on_timeout
|
||||
atf_add_test_case flush_stdout_on_death
|
||||
}
|
||||
|
||||
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
|
||||
|
@ -139,16 +139,20 @@ atf_check_equal_eval_fail_body()
|
||||
atf_check_equal '${x}' '${y}'
|
||||
}
|
||||
|
||||
atf_test_case atf_check_timeout
|
||||
atf_check_timeout_head()
|
||||
atf_test_case atf_check_flush_stdout
|
||||
atf_check_flush_stdout_head()
|
||||
{
|
||||
atf_set "descr" "Helper test case for the t_atf_check test program"
|
||||
atf_set "timeout" 1
|
||||
atf_set "timeout" "30"
|
||||
}
|
||||
atf_check_timeout_body()
|
||||
atf_check_flush_stdout_body()
|
||||
{
|
||||
atf_check true
|
||||
atf_check sleep 42
|
||||
atf_check -s exit:1 false
|
||||
touch "${CONTROL_FILE:-done}"
|
||||
while :; do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
@ -281,7 +285,7 @@ atf_init_test_cases()
|
||||
atf_add_test_case atf_check_equal_fail
|
||||
atf_add_test_case atf_check_equal_eval_ok
|
||||
atf_add_test_case atf_check_equal_eval_fail
|
||||
atf_add_test_case atf_check_timeout
|
||||
atf_add_test_case atf_check_flush_stdout
|
||||
|
||||
# Add helper tests for t_config.
|
||||
atf_add_test_case config_get
|
||||
|
@ -1,3 +1,16 @@
|
||||
2015-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20150505
|
||||
Merge with NetBSD make, pick up
|
||||
o cond.c: be strict about lhs of comparison when evaluating .if
|
||||
but less so when called from variable expansion.
|
||||
o unit-tests/cond2.mk: test various error conditions
|
||||
|
||||
2015-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* machine.sh (MACHINE): Add Bitrig
|
||||
patch from joerg@netbsd.org
|
||||
|
||||
2015-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Makefile (MAKE_VERSION): 20150418
|
||||
|
@ -96,6 +96,8 @@ unit-tests/comment.exp
|
||||
unit-tests/comment.mk
|
||||
unit-tests/cond1.exp
|
||||
unit-tests/cond1.mk
|
||||
unit-tests/cond2.exp
|
||||
unit-tests/cond2.mk
|
||||
unit-tests/doterror.exp
|
||||
unit-tests/doterror.mk
|
||||
unit-tests/dotwait.exp
|
||||
|
@ -1,7 +1,7 @@
|
||||
# $Id: Makefile,v 1.36 2015/04/18 19:58:53 sjg Exp $
|
||||
# $Id: Makefile,v 1.38 2015/05/05 21:58:05 sjg Exp $
|
||||
|
||||
# Base version on src date
|
||||
MAKE_VERSION= 20150418
|
||||
MAKE_VERSION= 20150505
|
||||
|
||||
PROG= bmake
|
||||
|
||||
@ -94,7 +94,7 @@ SUBDIR+= unit-tests
|
||||
# we skip a lot of this when building as part of FreeBSD etc.
|
||||
|
||||
# list of OS's which are derrived from BSD4.4
|
||||
BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly
|
||||
BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
|
||||
# we are...
|
||||
OS!= uname -s
|
||||
# are we 4.4BSD ?
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $ */
|
||||
/* $NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $");
|
||||
__RCSID("$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -181,6 +181,15 @@ static Token condPushBack=TOK_NONE; /* Single push-back token used in
|
||||
static unsigned int cond_depth = 0; /* current .if nesting level */
|
||||
static unsigned int cond_min_depth = 0; /* depth at makefile open */
|
||||
|
||||
/*
|
||||
* Indicate when we should be strict about lhs of comparisons.
|
||||
* TRUE when Cond_EvalExpression is called from Cond_Eval (.if etc)
|
||||
* FALSE when Cond_EvalExpression is called from var.c:ApplyModifiers
|
||||
* since lhs is already expanded and we cannot tell if
|
||||
* it was a variable reference or not.
|
||||
*/
|
||||
static Boolean lhsStrict;
|
||||
|
||||
static int
|
||||
istoken(const char *str, const char *tok, size_t len)
|
||||
{
|
||||
@ -517,7 +526,7 @@ CondCvtArg(char *str, double *value)
|
||||
*/
|
||||
/* coverity:[+alloc : arg-*2] */
|
||||
static char *
|
||||
CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
|
||||
CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS)
|
||||
{
|
||||
Buffer buf;
|
||||
char *cp;
|
||||
@ -601,6 +610,16 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
|
||||
condExpr--; /* don't skip over next char */
|
||||
break;
|
||||
default:
|
||||
if (strictLHS && !qt && *start != '$' &&
|
||||
!isdigit((unsigned char) *start)) {
|
||||
/* lhs must be quoted, a variable reference or number */
|
||||
if (*freeIt) {
|
||||
free(*freeIt);
|
||||
*freeIt = NULL;
|
||||
}
|
||||
str = NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
Buf_AddByte(&buf, *condExpr);
|
||||
break;
|
||||
}
|
||||
@ -648,7 +667,7 @@ compare_expression(Boolean doEval)
|
||||
* Parse the variable spec and skip over it, saving its
|
||||
* value in lhs.
|
||||
*/
|
||||
lhs = CondGetString(doEval, &lhsQuoted, &lhsFree);
|
||||
lhs = CondGetString(doEval, &lhsQuoted, &lhsFree, lhsStrict);
|
||||
if (!lhs)
|
||||
goto done;
|
||||
|
||||
@ -709,7 +728,7 @@ compare_expression(Boolean doEval)
|
||||
goto done;
|
||||
}
|
||||
|
||||
rhs = CondGetString(doEval, &rhsQuoted, &rhsFree);
|
||||
rhs = CondGetString(doEval, &rhsQuoted, &rhsFree, FALSE);
|
||||
if (!rhs)
|
||||
goto done;
|
||||
|
||||
@ -1135,7 +1154,7 @@ CondE(Boolean doEval)
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint)
|
||||
Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint, Boolean strictLHS)
|
||||
{
|
||||
static const struct If *dflt_info;
|
||||
const struct If *sv_if_info = if_info;
|
||||
@ -1143,6 +1162,8 @@ Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprin
|
||||
Token sv_condPushBack = condPushBack;
|
||||
int rval;
|
||||
|
||||
lhsStrict = strictLHS;
|
||||
|
||||
while (*line == ' ' || *line == '\t')
|
||||
line++;
|
||||
|
||||
@ -1359,7 +1380,7 @@ Cond_Eval(char *line)
|
||||
}
|
||||
|
||||
/* And evaluate the conditional expresssion */
|
||||
if (Cond_EvalExpression(ifp, line, &value, 1) == COND_INVALID) {
|
||||
if (Cond_EvalExpression(ifp, line, &value, 1, TRUE) == COND_INVALID) {
|
||||
/* Syntax error in conditional, error message already output. */
|
||||
/* Skip everything to matching .endif */
|
||||
cond_state[cond_depth] = SKIP_TO_ELSE;
|
||||
|
@ -2,7 +2,7 @@
|
||||
# derrived from /etc/rc_d/os.sh
|
||||
|
||||
# RCSid:
|
||||
# $Id: machine.sh,v 1.16 2010/10/17 00:05:51 sjg Exp $
|
||||
# $Id: machine.sh,v 1.17 2015/05/05 00:10:54 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1994-2002 Simon J. Gerraty
|
||||
#
|
||||
@ -49,6 +49,10 @@ OpenBSD)
|
||||
arch=`Which arch /usr/bin:/usr/ucb:$PATH`
|
||||
MACHINE_ARCH=`$arch -s`;
|
||||
;;
|
||||
Bitrig)
|
||||
MACHINE=$OS$OSMAJOR.$machine
|
||||
MACHINE_ARCH=`uname -m`;
|
||||
;;
|
||||
*BSD)
|
||||
MACHINE=$OS$OSMAJOR.$machine
|
||||
;;
|
||||
|
@ -1,3 +1,9 @@
|
||||
2015-04-30 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20150430
|
||||
|
||||
* dirdeps.mk: fix _count_dirdeps for non-cache case.
|
||||
|
||||
2015-04-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20150411
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: dirdeps.mk,v 1.49 2015/03/11 21:39:28 sjg Exp $
|
||||
# $Id: dirdeps.mk,v 1.51 2015/05/06 06:07:30 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
@ -349,7 +349,7 @@ BUILD_DIRDEPS ?= yes
|
||||
.if !defined(NO_DIRDEPS)
|
||||
.if ${MK_DIRDEPS_CACHE} == "yes"
|
||||
# this is where we will cache all our work
|
||||
DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,^,.,:N.}
|
||||
DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
|
||||
|
||||
# just ensure this exists
|
||||
build-dirdeps:
|
||||
@ -394,13 +394,14 @@ _count_dirdeps: .NOMETA
|
||||
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
|
||||
|
||||
.endif
|
||||
.endif
|
||||
.elif !target(_count_dirdeps)
|
||||
.elif !make(dirdeps) && !target(_count_dirdeps)
|
||||
beforedirdeps: _count_dirdeps
|
||||
_count_dirdeps: .NOMETA
|
||||
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
|
||||
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${BUILD_DIRDEPS} == "yes"
|
||||
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
|
||||
_debug_reldir = 1
|
||||
|
@ -55,7 +55,7 @@
|
||||
# Simon J. Gerraty <sjg@crufty.net>
|
||||
|
||||
# RCSid:
|
||||
# $Id: install-mk,v 1.109 2015/04/16 16:59:00 sjg Exp $
|
||||
# $Id: install-mk,v 1.110 2015/05/01 06:37:49 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1994 Simon J. Gerraty
|
||||
#
|
||||
@ -70,7 +70,7 @@
|
||||
# sjg@crufty.net
|
||||
#
|
||||
|
||||
MK_VERSION=20150411
|
||||
MK_VERSION=20150430
|
||||
OWNER=
|
||||
GROUP=
|
||||
MODE=444
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: nonints.h,v 1.67 2014/09/07 20:55:34 joerg Exp $ */
|
||||
/* $NetBSD: nonints.h,v 1.68 2015/05/05 21:51:09 sjg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -91,7 +91,7 @@ int Compat_Make(void *, void *);
|
||||
|
||||
/* cond.c */
|
||||
struct If;
|
||||
int Cond_EvalExpression(const struct If *, char *, Boolean *, int);
|
||||
int Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
|
||||
int Cond_Eval(char *);
|
||||
void Cond_restore_depth(unsigned int);
|
||||
unsigned int Cond_save_depth(void);
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $Id: Makefile.in,v 1.46 2014/11/06 01:47:57 sjg Exp $
|
||||
# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $
|
||||
#
|
||||
# $NetBSD: Makefile,v 1.51 2014/10/20 23:21:11 sjg Exp $
|
||||
# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
# The main targets are:
|
||||
@ -27,6 +27,7 @@ UNIT_TESTS:= ${srcdir}
|
||||
TESTNAMES= \
|
||||
comment \
|
||||
cond1 \
|
||||
cond2 \
|
||||
error \
|
||||
export \
|
||||
export-all \
|
||||
|
7
contrib/bmake/unit-tests/cond2.exp
Normal file
7
contrib/bmake/unit-tests/cond2.exp
Normal file
@ -0,0 +1,7 @@
|
||||
make: Bad conditional expression ` == "empty"' in == "empty"?oops:ok
|
||||
make: "cond2.mk" line 13: Malformed conditional ({TEST_TYPO} == "Ok")
|
||||
TEST_NOT_SET is empty or not defined
|
||||
make: "cond2.mk" line 20: Malformed conditional (${TEST_NOT_SET} == "empty")
|
||||
make: Fatal errors encountered -- cannot continue
|
||||
make: stopped in unit-tests
|
||||
exit status 1
|
25
contrib/bmake/unit-tests/cond2.mk
Normal file
25
contrib/bmake/unit-tests/cond2.mk
Normal file
@ -0,0 +1,25 @@
|
||||
# $Id: cond2.mk,v 1.1.1.1 2015/05/05 21:53:13 sjg Exp $
|
||||
|
||||
TEST_UNAME_S= NetBSD
|
||||
|
||||
# this should be ok
|
||||
X:= ${${TEST_UNAME_S} == "NetBSD":?Ok:fail}
|
||||
.if $X == "Ok"
|
||||
Y= good
|
||||
.endif
|
||||
# expect: Bad conditional expression ` == "empty"' in == "empty"?oops:ok
|
||||
X:= ${${TEST_NOT_SET} == "empty":?oops:ok}
|
||||
# expect: Malformed conditional ({TEST_TYPO} == "Ok")
|
||||
.if {TEST_TYPO} == "Ok"
|
||||
Y= oops
|
||||
.endif
|
||||
.if empty(TEST_NOT_SET)
|
||||
Y!= echo TEST_NOT_SET is empty or not defined >&2; echo
|
||||
.endif
|
||||
# expect: Malformed conditional (${TEST_NOT_SET} == "empty")
|
||||
.if ${TEST_NOT_SET} == "empty"
|
||||
Y= oops
|
||||
.endif
|
||||
|
||||
all:
|
||||
@echo $@
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $ */
|
||||
/* $NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -3261,7 +3261,7 @@ ApplyModifiers(char *nstr, const char *tstr,
|
||||
|
||||
termc = *--cp;
|
||||
delim = '\0';
|
||||
if (Cond_EvalExpression(NULL, v->name, &value, 0)
|
||||
if (Cond_EvalExpression(NULL, v->name, &value, 0, FALSE)
|
||||
== COND_INVALID) {
|
||||
Error("Bad conditional expression `%s' in %s?%s:%s",
|
||||
v->name, v->name, pattern.lhs, pattern.rhs);
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: addr2line.1 2066 2011-10-26 15:40:28Z jkoshy $
|
||||
.\" $Id: addr2line.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd July 25, 2010
|
||||
.Os
|
||||
@ -99,7 +99,7 @@ Print a help message.
|
||||
Print a version identifier and exit.
|
||||
.El
|
||||
.Sh OUTPUT FORMAT
|
||||
If the
|
||||
If the
|
||||
.Fl f
|
||||
option was not specified,
|
||||
.Nm
|
||||
@ -156,4 +156,4 @@ its source file and line number use:
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: addr2line.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: addr2line.c 3197 2015-05-12 21:01:31Z emaste $");
|
||||
|
||||
static struct option longopts[] = {
|
||||
{"target" , required_argument, NULL, 'b'},
|
||||
@ -84,6 +84,44 @@ version(void)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle DWARF 4 'offset from' DW_AT_high_pc. Although we don't
|
||||
* fully support DWARF 4, some compilers (like FreeBSD Clang 3.5.1)
|
||||
* generate DW_AT_high_pc as an offset from DW_AT_low_pc.
|
||||
*
|
||||
* "If the value of the DW_AT_high_pc is of class address, it is the
|
||||
* relocated address of the first location past the last instruction
|
||||
* associated with the entity; if it is of class constant, the value
|
||||
* is an unsigned integer offset which when added to the low PC gives
|
||||
* the address of the first location past the last instruction
|
||||
* associated with the entity."
|
||||
*
|
||||
* DWARF4 spec, section 2.17.2.
|
||||
*/
|
||||
static int
|
||||
handle_high_pc(Dwarf_Die die, Dwarf_Unsigned lopc, Dwarf_Unsigned *hipc)
|
||||
{
|
||||
Dwarf_Error de;
|
||||
Dwarf_Half form;
|
||||
Dwarf_Attribute at;
|
||||
int ret;
|
||||
|
||||
ret = dwarf_attr(die, DW_AT_high_pc, &at, &de);
|
||||
if (ret == DW_DLV_ERROR) {
|
||||
warnx("dwarf_attr failed: %s", dwarf_errmsg(de));
|
||||
return (ret);
|
||||
}
|
||||
ret = dwarf_whatform(at, &form, &de);
|
||||
if (ret == DW_DLV_ERROR) {
|
||||
warnx("dwarf_whatform failed: %s", dwarf_errmsg(de));
|
||||
return (ret);
|
||||
}
|
||||
if (dwarf_get_form_class(2, 0, 0, form) == DW_FORM_CLASS_CONSTANT)
|
||||
*hipc += lopc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
search_func(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr addr,
|
||||
const char **rlt_func)
|
||||
@ -108,6 +146,8 @@ search_func(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr addr,
|
||||
if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ||
|
||||
dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de))
|
||||
goto cont_search;
|
||||
if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
|
||||
goto cont_search;
|
||||
if (addr < lopc || addr >= hipc)
|
||||
goto cont_search;
|
||||
|
||||
@ -202,6 +242,8 @@ translate(Dwarf_Debug dbg, const char* addrstr)
|
||||
* Check if the address falls into the PC range of
|
||||
* this CU.
|
||||
*/
|
||||
if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
|
||||
continue;
|
||||
if (addr < lopc || addr >= hipc)
|
||||
continue;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: _elftc.h 3175 2015-03-27 17:21:24Z emaste $
|
||||
* $Id: _elftc.h 3209 2015-05-17 13:40:46Z kaiwang27 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -342,12 +342,13 @@ struct name { \
|
||||
|
||||
|
||||
#if defined(__GLIBC__) || defined(__linux__)
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
/*
|
||||
* GLIBC based systems have a global 'char *' pointer referencing
|
||||
* the executable's name.
|
||||
*/
|
||||
extern const char *program_invocation_short_name;
|
||||
#endif /* !_GNU_SOURCE */
|
||||
|
||||
#define ELFTC_GETPROGNAME() program_invocation_short_name
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: elfdefinitions.h 3178 2015-03-30 18:29:13Z emaste $
|
||||
* $Id: elfdefinitions.h 3198 2015-05-14 18:36:19Z emaste $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -565,6 +565,7 @@ _ELF_DEFINE_EM(EM_SPARC, 2, "SPARC") \
|
||||
_ELF_DEFINE_EM(EM_386, 3, "Intel 80386") \
|
||||
_ELF_DEFINE_EM(EM_68K, 4, "Motorola 68000") \
|
||||
_ELF_DEFINE_EM(EM_88K, 5, "Motorola 88000") \
|
||||
_ELF_DEFINE_EM(EM_IAMCU, 6, "Intel MCU") \
|
||||
_ELF_DEFINE_EM(EM_860, 7, "Intel 80860") \
|
||||
_ELF_DEFINE_EM(EM_MIPS, 8, "MIPS I Architecture") \
|
||||
_ELF_DEFINE_EM(EM_S370, 9, "IBM System/370 Processor") \
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: native-elf-format 3167 2015-02-24 19:10:08Z emaste $
|
||||
# $Id: native-elf-format 3186 2015-04-16 22:16:40Z emaste $
|
||||
#
|
||||
# Find the native ELF format for a host platform by compiling a
|
||||
# test object and examining the resulting object.
|
||||
@ -33,7 +33,7 @@ $1 ~ "Data:" {
|
||||
$1 ~ "Machine:" {
|
||||
if (match($0, "Intel.*386")) {
|
||||
elfarch = "EM_386";
|
||||
} else if (match($0, ".*X86-64")) {
|
||||
} else if (match($0, ".*[xX]86-64")) {
|
||||
elfarch = "EM_X86_64";
|
||||
} else {
|
||||
elfarch = "unknown";
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: c++filt.1 2175 2011-11-16 05:51:49Z jkoshy $
|
||||
.\" $Id: c++filt.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd August 24, 2011
|
||||
.Os
|
||||
@ -106,4 +106,4 @@ and exit.
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elfcopy.1 3173 2015-03-27 16:46:13Z emaste $
|
||||
.\" $Id: elfcopy.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd March 27, 2015
|
||||
.Os
|
||||
@ -330,4 +330,4 @@ Do not copy symbols that are not needed for relocation processing.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
has been implemented by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: elfcopy.h 3173 2015-03-27 16:46:13Z emaste $
|
||||
* $Id: elfcopy.h 3221 2015-05-24 23:42:43Z kaiwang27 $
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
@ -237,6 +237,7 @@ struct elfcopy {
|
||||
uint64_t *secndx; /* section index map. */
|
||||
uint64_t *symndx; /* symbol index map. */
|
||||
unsigned char *v_rel; /* symbols needed by relocation. */
|
||||
unsigned char *v_grp; /* symbols refered by section group. */
|
||||
unsigned char *v_secsym; /* sections with section symbol. */
|
||||
STAILQ_HEAD(, segment) v_seg; /* list of segments. */
|
||||
STAILQ_HEAD(, sec_action) v_sac;/* list of section operations. */
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
#include "elfcopy.h"
|
||||
|
||||
ELFTC_VCSID("$Id: main.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: main.c 3216 2015-05-23 21:16:36Z kaiwang27 $");
|
||||
|
||||
enum options
|
||||
{
|
||||
@ -404,8 +404,19 @@ create_elf(struct elfcopy *ecp)
|
||||
* Insert SHDR table into the internal section list as a "pseudo"
|
||||
* section, so later it will get sorted and resynced just as "normal"
|
||||
* sections.
|
||||
*
|
||||
* Under FreeBSD, Binutils objcopy always put the section header
|
||||
* at the end of all the sections. We want to do the same here.
|
||||
*
|
||||
* However, note that the behaviour is still different with Binutils:
|
||||
* elfcopy checks the FreeBSD OSABI tag to tell whether it needs to
|
||||
* move the section headers, while Binutils is probably configured
|
||||
* this way when it's compiled on FreeBSD.
|
||||
*/
|
||||
shtab = insert_shtab(ecp, 0);
|
||||
if (oeh.e_ident[EI_OSABI] == ELFOSABI_FREEBSD)
|
||||
shtab = insert_shtab(ecp, 1);
|
||||
else
|
||||
shtab = insert_shtab(ecp, 0);
|
||||
|
||||
/*
|
||||
* Resync section offsets in the output object. This is needed
|
||||
@ -485,6 +496,11 @@ free_elf(struct elfcopy *ecp)
|
||||
free(sec);
|
||||
}
|
||||
}
|
||||
|
||||
if (ecp->secndx != NULL) {
|
||||
free(ecp->secndx);
|
||||
ecp->secndx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a temporary file. */
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "elfcopy.h"
|
||||
|
||||
ELFTC_VCSID("$Id: sections.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: sections.c 3220 2015-05-24 23:42:39Z kaiwang27 $");
|
||||
|
||||
static void add_gnu_debuglink(struct elfcopy *ecp);
|
||||
static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
|
||||
@ -56,6 +56,7 @@ static void print_data(const char *d, size_t sz);
|
||||
static void print_section(struct section *s);
|
||||
static void *read_section(struct section *s, size_t *size);
|
||||
static void update_reloc(struct elfcopy *ecp, struct section *s);
|
||||
static void update_section_group(struct elfcopy *ecp, struct section *s);
|
||||
|
||||
int
|
||||
is_remove_section(struct elfcopy *ecp, const char *name)
|
||||
@ -552,6 +553,14 @@ copy_content(struct elfcopy *ecp)
|
||||
(s->type == SHT_REL || s->type == SHT_RELA))
|
||||
filter_reloc(ecp, s);
|
||||
|
||||
/*
|
||||
* The section indices in the SHT_GROUP section needs
|
||||
* to be updated since we might have stripped some
|
||||
* sections and changed section numbering.
|
||||
*/
|
||||
if (s->type == SHT_GROUP)
|
||||
update_section_group(ecp, s);
|
||||
|
||||
if (is_modify_section(ecp, s->name))
|
||||
modify_section(ecp, s);
|
||||
|
||||
@ -571,6 +580,71 @@ copy_content(struct elfcopy *ecp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update section group section. The section indices in the SHT_GROUP
|
||||
* section need update after section numbering changed.
|
||||
*/
|
||||
static void
|
||||
update_section_group(struct elfcopy *ecp, struct section *s)
|
||||
{
|
||||
GElf_Shdr ish;
|
||||
Elf_Data *id;
|
||||
uint32_t *ws, *wd;
|
||||
uint64_t n;
|
||||
size_t ishnum;
|
||||
int i, j;
|
||||
|
||||
if (!elf_getshnum(ecp->ein, &ishnum))
|
||||
errx(EXIT_FAILURE, "elf_getshnum failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
if (gelf_getshdr(s->is, &ish) == NULL)
|
||||
errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
if ((id = elf_getdata(s->is, NULL)) == NULL)
|
||||
errx(EXIT_FAILURE, "elf_getdata() failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
if (ish.sh_size == 0)
|
||||
return;
|
||||
|
||||
if (ish.sh_entsize == 0)
|
||||
ish.sh_entsize = 4;
|
||||
|
||||
ws = id->d_buf;
|
||||
|
||||
/* We only support COMDAT section. */
|
||||
#ifndef GRP_COMDAT
|
||||
#define GRP_COMDAT 0x1
|
||||
#endif
|
||||
if ((*ws & GRP_COMDAT) == 0)
|
||||
return;
|
||||
|
||||
if ((s->buf = malloc(ish.sh_size)) == NULL)
|
||||
err(EXIT_FAILURE, "malloc failed");
|
||||
|
||||
s->sz = ish.sh_size;
|
||||
|
||||
wd = s->buf;
|
||||
|
||||
/* Copy the flag word as-is. */
|
||||
*wd = *ws;
|
||||
|
||||
/* Update the section indices. */
|
||||
n = ish.sh_size / ish.sh_entsize;
|
||||
for(i = 1, j = 1; (uint64_t)i < n; i++) {
|
||||
if (ws[i] != SHN_UNDEF && ws[i] < ishnum &&
|
||||
ecp->secndx[ws[i]] != 0)
|
||||
wd[j++] = ecp->secndx[ws[i]];
|
||||
else
|
||||
s->sz -= 4;
|
||||
}
|
||||
|
||||
s->nocopy = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Filter relocation entries, only keep those entries whose
|
||||
* symbol is in the keep list.
|
||||
@ -1028,8 +1102,11 @@ copy_shdr(struct elfcopy *ecp, struct section *s, const char *name, int copy,
|
||||
osh.sh_flags |= SHF_WRITE;
|
||||
if (sec_flags & SF_CODE)
|
||||
osh.sh_flags |= SHF_EXECINSTR;
|
||||
} else
|
||||
} else {
|
||||
osh.sh_flags = ish.sh_flags;
|
||||
if (ish.sh_type == SHT_REL || ish.sh_type == SHT_RELA)
|
||||
osh.sh_flags |= SHF_INFO_LINK;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
@ -1223,6 +1300,14 @@ update_shdr(struct elfcopy *ecp, int update_link)
|
||||
osh.sh_info != 0)
|
||||
osh.sh_info = ecp->secndx[osh.sh_info];
|
||||
|
||||
/*
|
||||
* sh_info of SHT_GROUP section needs to point to the correct
|
||||
* string in the symbol table.
|
||||
*/
|
||||
if (s->type == SHT_GROUP && (ecp->flags & SYMTAB_EXIST) &&
|
||||
(ecp->flags & SYMTAB_INTACT) == 0)
|
||||
osh.sh_info = ecp->symndx[osh.sh_info];
|
||||
|
||||
if (!gelf_update_shdr(s->os, &osh))
|
||||
errx(EXIT_FAILURE, "gelf_update_shdr() failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "elfcopy.h"
|
||||
|
||||
ELFTC_VCSID("$Id: segments.c 3177 2015-03-30 18:19:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: segments.c 3196 2015-05-12 17:33:48Z emaste $");
|
||||
|
||||
static void insert_to_inseg_list(struct segment *seg, struct section *sec);
|
||||
|
||||
@ -442,7 +442,7 @@ copy_phdr(struct elfcopy *ecp)
|
||||
s = seg->v_sec[i];
|
||||
seg->msz = s->vma + s->sz - seg->addr;
|
||||
if (s->type != SHT_NOBITS)
|
||||
seg->fsz = seg->msz;
|
||||
seg->fsz = s->off + s->sz - seg->off;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "elfcopy.h"
|
||||
|
||||
ELFTC_VCSID("$Id: symbols.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: symbols.c 3222 2015-05-24 23:47:23Z kaiwang27 $");
|
||||
|
||||
/* Symbol table buffer structure. */
|
||||
struct symbuf {
|
||||
@ -77,7 +77,8 @@ static int is_weak_symbol(unsigned char st_info);
|
||||
static int lookup_exact_string(hash_head *hash, const char *buf,
|
||||
const char *s);
|
||||
static int generate_symbols(struct elfcopy *ecp);
|
||||
static void mark_symbols(struct elfcopy *ecp, size_t sc);
|
||||
static void mark_reloc_symbols(struct elfcopy *ecp, size_t sc);
|
||||
static void mark_section_group_symbols(struct elfcopy *ecp, size_t sc);
|
||||
static int match_wildcard(const char *name, const char *pattern);
|
||||
uint32_t str_hash(const char *s);
|
||||
|
||||
@ -160,6 +161,10 @@ is_needed_symbol(struct elfcopy *ecp, int i, GElf_Sym *s)
|
||||
if (BIT_ISSET(ecp->v_rel, i))
|
||||
return (1);
|
||||
|
||||
/* Symbols refered by COMDAT sections are needed. */
|
||||
if (BIT_ISSET(ecp->v_grp, i))
|
||||
return (1);
|
||||
|
||||
/*
|
||||
* For relocatable files (.o files), global and weak symbols
|
||||
* are needed.
|
||||
@ -207,7 +212,10 @@ is_remove_symbol(struct elfcopy *ecp, size_t sc, int i, GElf_Sym *s,
|
||||
return (1);
|
||||
|
||||
if (ecp->v_rel == NULL)
|
||||
mark_symbols(ecp, sc);
|
||||
mark_reloc_symbols(ecp, sc);
|
||||
|
||||
if (ecp->v_grp == NULL)
|
||||
mark_section_group_symbols(ecp, sc);
|
||||
|
||||
if (is_needed_symbol(ecp, i, s))
|
||||
return (0);
|
||||
@ -233,7 +241,7 @@ is_remove_symbol(struct elfcopy *ecp, size_t sc, int i, GElf_Sym *s,
|
||||
* Mark symbols refered by relocation entries.
|
||||
*/
|
||||
static void
|
||||
mark_symbols(struct elfcopy *ecp, size_t sc)
|
||||
mark_reloc_symbols(struct elfcopy *ecp, size_t sc)
|
||||
{
|
||||
const char *name;
|
||||
Elf_Data *d;
|
||||
@ -311,6 +319,49 @@ mark_symbols(struct elfcopy *ecp, size_t sc)
|
||||
elf_errmsg(elferr));
|
||||
}
|
||||
|
||||
static void
|
||||
mark_section_group_symbols(struct elfcopy *ecp, size_t sc)
|
||||
{
|
||||
const char *name;
|
||||
Elf_Scn *s;
|
||||
GElf_Shdr sh;
|
||||
size_t indx;
|
||||
int elferr;
|
||||
|
||||
ecp->v_grp = calloc((sc + 7) / 8, 1);
|
||||
if (ecp->v_grp == NULL)
|
||||
err(EXIT_FAILURE, "calloc failed");
|
||||
|
||||
if (elf_getshstrndx(ecp->ein, &indx) == 0)
|
||||
errx(EXIT_FAILURE, "elf_getshstrndx failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
s = NULL;
|
||||
while ((s = elf_nextscn(ecp->ein, s)) != NULL) {
|
||||
if (gelf_getshdr(s, &sh) != &sh)
|
||||
errx(EXIT_FAILURE, "elf_getshdr failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
if (sh.sh_type != SHT_GROUP)
|
||||
continue;
|
||||
|
||||
if ((name = elf_strptr(ecp->ein, indx, sh.sh_name)) == NULL)
|
||||
errx(EXIT_FAILURE, "elf_strptr failed: %s",
|
||||
elf_errmsg(-1));
|
||||
if (is_remove_section(ecp, name))
|
||||
continue;
|
||||
|
||||
if (sh.sh_info > 0 && sh.sh_info < sc)
|
||||
BIT_SET(ecp->v_grp, sh.sh_info);
|
||||
else if (sh.sh_info != 0)
|
||||
warnx("invalid symbox index");
|
||||
}
|
||||
elferr = elf_errno();
|
||||
if (elferr != 0)
|
||||
errx(EXIT_FAILURE, "elf_nextscn failed: %s",
|
||||
elf_errmsg(elferr));
|
||||
}
|
||||
|
||||
static int
|
||||
generate_symbols(struct elfcopy *ecp)
|
||||
{
|
||||
@ -351,6 +402,8 @@ generate_symbols(struct elfcopy *ecp)
|
||||
ecp->symtab->buf = sy_buf;
|
||||
ecp->strtab->buf = st_buf;
|
||||
|
||||
gsym = NULL;
|
||||
|
||||
/*
|
||||
* Create bit vector v_secsym, which is used to mark sections
|
||||
* that already have corresponding STT_SECTION symbols.
|
||||
@ -384,7 +437,7 @@ generate_symbols(struct elfcopy *ecp)
|
||||
/* Symbol table should exist if this function is called. */
|
||||
if (symndx == 0) {
|
||||
warnx("can't find .strtab section");
|
||||
return (0);
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/* Locate .symtab of input object. */
|
||||
@ -413,7 +466,6 @@ generate_symbols(struct elfcopy *ecp)
|
||||
* output object, it is used by update_reloc() later to update
|
||||
* relocation information.
|
||||
*/
|
||||
gsym = NULL;
|
||||
sc = ish.sh_size / ish.sh_entsize;
|
||||
if (sc > 0) {
|
||||
ecp->symndx = calloc(sc, sizeof(*ecp->symndx));
|
||||
@ -427,7 +479,7 @@ generate_symbols(struct elfcopy *ecp)
|
||||
if (elferr != 0)
|
||||
errx(EXIT_FAILURE, "elf_getdata failed: %s",
|
||||
elf_errmsg(elferr));
|
||||
return (0);
|
||||
goto clean;
|
||||
}
|
||||
} else
|
||||
return (0);
|
||||
@ -523,7 +575,7 @@ generate_symbols(struct elfcopy *ecp)
|
||||
* check if that only local symbol is the reserved symbol.
|
||||
*/
|
||||
if (sy_buf->nls <= 1 && sy_buf->ngs == 0)
|
||||
return (0);
|
||||
goto clean;
|
||||
|
||||
/*
|
||||
* Create STT_SECTION symbols for sections that do not already
|
||||
@ -550,6 +602,7 @@ generate_symbols(struct elfcopy *ecp)
|
||||
sym.st_value = s->vma;
|
||||
sym.st_size = 0;
|
||||
sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION);
|
||||
sym.st_other = STV_DEFAULT;
|
||||
/*
|
||||
* Don't let add_to_symtab() touch sym.st_shndx.
|
||||
* In this case, we know the index already.
|
||||
@ -583,6 +636,12 @@ generate_symbols(struct elfcopy *ecp)
|
||||
}
|
||||
|
||||
return (1);
|
||||
|
||||
clean:
|
||||
free(gsym);
|
||||
free_symtab(ecp);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -624,7 +683,9 @@ create_symtab(struct elfcopy *ecp)
|
||||
if (((ecp->flags & SYMTAB_INTACT) == 0) && !generate_symbols(ecp)) {
|
||||
TAILQ_REMOVE(&ecp->v_sec, ecp->symtab, sec_list);
|
||||
TAILQ_REMOVE(&ecp->v_sec, ecp->strtab, sec_list);
|
||||
free(ecp->symtab->buf);
|
||||
free(ecp->symtab);
|
||||
free(ecp->strtab->buf);
|
||||
free(ecp->strtab);
|
||||
ecp->symtab = NULL;
|
||||
ecp->strtab = NULL;
|
||||
@ -697,6 +758,23 @@ free_symtab(struct elfcopy *ecp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ecp->symndx != NULL) {
|
||||
free(ecp->symndx);
|
||||
ecp->symndx = NULL;
|
||||
}
|
||||
if (ecp->v_rel != NULL) {
|
||||
free(ecp->v_rel);
|
||||
ecp->v_rel = NULL;
|
||||
}
|
||||
if (ecp->v_grp != NULL) {
|
||||
free(ecp->v_grp);
|
||||
ecp->v_grp = NULL;
|
||||
}
|
||||
if (ecp->v_secsym != NULL) {
|
||||
free(ecp->v_secsym);
|
||||
ecp->v_secsym = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -1090,7 +1168,7 @@ str_hash(const char *s)
|
||||
{
|
||||
uint32_t hash;
|
||||
|
||||
for (hash = 2166136261; *s; s++)
|
||||
for (hash = 2166136261UL; *s; s++)
|
||||
hash = (hash ^ *s) * 16777619;
|
||||
|
||||
return (hash & (STHASHSIZE - 1));
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf.3 3130 2014-12-21 20:06:29Z jkoshy $
|
||||
.\" $Id: dwarf.3 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd December 21, 2014
|
||||
.Os
|
||||
@ -44,7 +44,7 @@ is defined by the DWARF standard, see
|
||||
.Xr dwarf 4 .
|
||||
.Pp
|
||||
The
|
||||
.Xr DWARF 3
|
||||
.Xr DWARF 3
|
||||
API has two parts:
|
||||
.Bl -bullet
|
||||
.It
|
||||
@ -349,7 +349,7 @@ Retrieve a debugging information entry given an offset.
|
||||
.It Fn dwarf_siblingof , Fn dwarf_siblingof_b
|
||||
Retrieve the sibling descriptor for a debugging information entry.
|
||||
.It Fn dwarf_srclang
|
||||
Retrive the source language attribute for a debugging information
|
||||
Retrieve the source language attribute for a debugging information
|
||||
entry.
|
||||
.It Fn dwarf_tag
|
||||
Retrieve the tag for a debugging information entry.
|
||||
@ -742,12 +742,12 @@ The DWARF standard is defined by
|
||||
The DWARF(3) API originated at Silicon Graphics Inc.
|
||||
.Pp
|
||||
A BSD-licensed implementation of a subset of the API was written by
|
||||
.An "John Birrell" Aq jb@FreeBSD.org
|
||||
.An John Birrell Aq Mt jb@FreeBSD.org
|
||||
for the FreeBSD project.
|
||||
The implementation was subsequently revised and completed by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
.Pp
|
||||
Manual pages for this implementation were written by
|
||||
.An "Joseph Koshy" Aq jkoshy@users.sourceforge.net
|
||||
.An Joseph Koshy Aq Mt jkoshy@users.sourceforge.net
|
||||
and
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_line_entry.3 2953 2013-06-30 20:21:38Z kaiwang27 $
|
||||
.\" $Id: dwarf_add_line_entry.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd June 30, 2013
|
||||
.Os
|
||||
@ -66,7 +66,8 @@ Valid source file indices are those returned by the function
|
||||
.Pp
|
||||
Argument
|
||||
.Ar off
|
||||
specifies a relocatable program address. The ELF symbol to be used
|
||||
specifies a relocatable program address.
|
||||
The ELF symbol to be used
|
||||
for relocation is set by a prior call to the function
|
||||
.Xr dwarf_lne_set_address 3 .
|
||||
.Pp
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_def_macro.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\" $Id: dwarf_def_macro.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
@ -72,7 +72,7 @@ Argument
|
||||
.Ar value
|
||||
should point to a NUL-terminated string containing the value
|
||||
of the macro.
|
||||
If the macro doesn't have a value, argument
|
||||
If the macro does not have a value, argument
|
||||
.Ar value
|
||||
should be set to NULL.
|
||||
.Pp
|
||||
|
@ -22,14 +22,14 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_expand_frame_instructions.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\" $Id: dwarf_expand_frame_instructions.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_EXPAND_FRAME_INSTRUCTIONS 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_expand_frame_instructions
|
||||
.Nd expand frame instructions
|
||||
.Nd expand frame instructions
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formblock.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\" $Id: dwarf_formblock.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd July 23, 2010
|
||||
.Os
|
||||
@ -69,7 +69,7 @@ the DWARF(3) library.
|
||||
The application should not attempt to free this memory
|
||||
area.
|
||||
Portable code may indicate that the memory area is to be freed by
|
||||
by using
|
||||
using
|
||||
.Xr dwarf_dealloc 3 .
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formflag.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\" $Id: dwarf_formflag.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
@ -58,7 +58,7 @@ or
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formflag
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formref.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\" $Id: dwarf_formref.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
@ -101,7 +101,7 @@ ELF section.
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formsig8.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\" $Id: dwarf_formsig8.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd July 24, 2010
|
||||
.Os
|
||||
@ -56,7 +56,7 @@ must be
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formsig8
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formudata.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\" $Id: dwarf_formudata.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
@ -88,7 +88,7 @@ and
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_all_regs.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\" $Id: dwarf_get_fde_info_for_all_regs.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd June 4, 2011
|
||||
.Os
|
||||
@ -90,7 +90,8 @@ typedef struct {
|
||||
For each of the register rules returned,
|
||||
the
|
||||
.Va dw_offset_relevant
|
||||
field is set to 1 if the register rule has a offset value. The
|
||||
field is set to 1 if the register rule has a offset value.
|
||||
The
|
||||
.Va dw_regnum
|
||||
field is set to the register number associated with the regsiter rule.
|
||||
The
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_reg.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\" $Id: dwarf_get_fde_info_for_reg.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd June 4, 2011
|
||||
.Os
|
||||
@ -99,7 +99,7 @@ counter address associated with the register rule found.
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Ss COMPATIBILITY
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_ranges.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\" $Id: dwarf_get_ranges.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
@ -137,7 +137,7 @@ For this type of entry, the field
|
||||
.Va dwr_addr1
|
||||
is the value of the largest representable address offset, and
|
||||
.Va dwr_addr2
|
||||
is a base address for the begining and ending address offsets of
|
||||
is a base address for the beginning and ending address offsets of
|
||||
subsequent address range entries in the list.
|
||||
.It Dv DW_RANGES_END
|
||||
An end of list mark.
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_hasattr.3 3142 2015-01-29 23:11:14Z jkoshy $
|
||||
.\" $Id: dwarf_hasattr.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd April 17, 2010
|
||||
.Os
|
||||
@ -64,7 +64,7 @@ If the named attribute is not present, a zero is written instead.
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_hasattr
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_next_cu_header.3 3128 2014-12-21 20:06:22Z jkoshy $
|
||||
.\" $Id: dwarf_next_cu_header.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd December 21, 2014
|
||||
.Os
|
||||
@ -220,8 +220,7 @@ unit in the section.
|
||||
.Ss Iterating Through Type Units in a Debug Context
|
||||
When a DWARF debug context is allocated using
|
||||
.Xr dwarf_init 3 ,
|
||||
an internal pointer assoicated with the context will point to the
|
||||
fisrt
|
||||
an internal pointer associated with the context will point to the first
|
||||
.Dq \&.debug_types
|
||||
section found in the debug object.
|
||||
The first call to function
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_producer_init.3 2074 2011-10-27 03:34:33Z jkoshy $
|
||||
.\" $Id: dwarf_producer_init.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd August 20, 2011
|
||||
.Os
|
||||
@ -58,7 +58,7 @@ descriptor representing a DWARF producer instance.
|
||||
.Pp
|
||||
The argument
|
||||
.Ar errhand
|
||||
should contain the adddress of a function to be called in case of an
|
||||
should contain the address of a function to be called in case of an
|
||||
error.
|
||||
If this argument is
|
||||
.Dv NULL ,
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_whatattr.3 3142 2015-01-29 23:11:14Z jkoshy $
|
||||
.\" $Id: dwarf_whatattr.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd May 22, 2010
|
||||
.Os
|
||||
@ -51,7 +51,7 @@ and writes it to the location pointed to by argument
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_whatattr
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: libdwarf_reloc.c 3149 2015-02-15 19:00:06Z emaste $");
|
||||
ELFTC_VCSID("$Id: libdwarf_reloc.c 3198 2015-05-14 18:36:19Z emaste $");
|
||||
|
||||
Dwarf_Unsigned
|
||||
_dwarf_get_reloc_type(Dwarf_P_Debug dbg, int is64)
|
||||
@ -75,6 +75,7 @@ _dwarf_get_reloc_size(Dwarf_Debug dbg, Dwarf_Unsigned rel_type)
|
||||
return (4);
|
||||
break;
|
||||
case EM_386:
|
||||
case EM_IAMCU:
|
||||
if (rel_type == R_386_32)
|
||||
return (4);
|
||||
break;
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elf.3 3142 2015-01-29 23:11:14Z jkoshy $
|
||||
.\" $Id: elf.3 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd July 28, 2014
|
||||
.Os
|
||||
@ -555,7 +555,7 @@ flag on an ELF descriptor using
|
||||
.Xr elf_flagelf 3 ,
|
||||
following which the library will use the data offsets and alignments
|
||||
specified by the application when laying out the file.
|
||||
Application control of file layout is described further in the
|
||||
Application control of file layout is described further in the
|
||||
.Xr elf_update 3
|
||||
manual page.
|
||||
.Pp
|
||||
@ -608,5 +608,4 @@ The current implementation of the ELF(3) API appeared in
|
||||
.Fx 7.0 .
|
||||
.Sh AUTHORS
|
||||
The ELF library was written by
|
||||
.An "Joseph Koshy"
|
||||
.Aq jkoshy@FreeBSD.org .
|
||||
.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elf_begin.3 2313 2011-12-11 06:19:24Z jkoshy $
|
||||
.\" $Id: elf_begin.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd December 11, 2011
|
||||
.Os
|
||||
@ -272,7 +272,7 @@ was created.
|
||||
.It Bq Er ELF_E_ARGUMENT
|
||||
An
|
||||
.Xr ar 1
|
||||
archive was opened with with
|
||||
archive was opened with
|
||||
.Ar cmd
|
||||
set to
|
||||
.Dv ELF_C_RDWR .
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elf_cntl.3 289 2009-01-08 08:26:08Z jkoshy $
|
||||
.\" $Id: elf_cntl.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd August 9, 2006
|
||||
.Os
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elf_getdata.3 1766 2011-08-22 06:01:03Z jkoshy $
|
||||
.\" $Id: elf_getdata.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd January 26, 2011
|
||||
.Os
|
||||
@ -174,7 +174,7 @@ These functions return a valid pointer to a data descriptor if successful, or
|
||||
NULL if an error occurs.
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width "[ELF_E_RESOURCE]"
|
||||
.Bl -tag -width "[ELF_E_RESOURCE]"
|
||||
.It Bq Er ELF_E_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar scn
|
||||
|
@ -21,11 +21,11 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elf_open.3 2512 2012-05-31 06:15:57Z jkoshy $
|
||||
.\" $Id: elf_open.3 3181 2015-04-10 13:22:51Z emaste $
|
||||
.\"
|
||||
.Dd May 31, 2012
|
||||
.Os
|
||||
.Dt ELF_OPEN 3
|
||||
.Dt ELF_OPEN 3
|
||||
.Sh NAME
|
||||
.Nm elf_open
|
||||
.Nd open ELF objects and ar(1) archives
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
ELFTC_VCSID("$Id: elf_update.c 3013 2014-03-23 06:16:59Z jkoshy $");
|
||||
ELFTC_VCSID("$Id: elf_update.c 3190 2015-05-04 15:23:08Z jkoshy $");
|
||||
|
||||
/*
|
||||
* Layout strategy:
|
||||
@ -271,8 +271,10 @@ _libelf_compute_section_extents(Elf *e, Elf_Scn *s, off_t rc)
|
||||
* offsets and alignment for sanity.
|
||||
*/
|
||||
if (e->e_flags & ELF_F_LAYOUT) {
|
||||
if (scn_alignment > sh_align || sh_offset % sh_align ||
|
||||
sh_size < scn_size) {
|
||||
if (scn_alignment > sh_align ||
|
||||
sh_offset % sh_align ||
|
||||
sh_size < scn_size ||
|
||||
sh_offset % _libelf_falign(elftype, ec)) {
|
||||
LIBELF_SET_ERROR(LAYOUT, 0);
|
||||
return (0);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: gelf.3 189 2008-07-20 10:38:08Z jkoshy $
|
||||
.\" $Id: gelf.3 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd September 1, 2006
|
||||
.Os
|
||||
@ -197,5 +197,4 @@ This implementation of the API first appeared in
|
||||
.Fx 7.0 .
|
||||
.Sh AUTHORS
|
||||
The GElf API was implemented by
|
||||
.An "Joseph Koshy"
|
||||
.Aq jkoshy@FreeBSD.org .
|
||||
.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elftc_demangle.3 2065 2011-10-26 15:24:47Z jkoshy $
|
||||
.\" $Id: elftc_demangle.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd August 24, 2011
|
||||
.Os
|
||||
@ -88,7 +88,7 @@ To decode a name that uses an unknown encoding style use:
|
||||
.Bd -literal -offset indent
|
||||
char buffer[1024];
|
||||
const char *funcname;
|
||||
|
||||
|
||||
funcname = ...; /* points to string to be demangled */
|
||||
if (elftc_demangle(funcname, buffer, sizeof(buffer), 0) == 0)
|
||||
printf("Demangled name: %\\n", buffer);
|
||||
|
@ -21,7 +21,7 @@
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: elftc_symbol_table_create.3 2825 2012-12-29 14:25:33Z jkoshy $
|
||||
.\" $Id: elftc_symbol_table_create.3 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd December 29, 2012
|
||||
.Os
|
||||
@ -224,7 +224,7 @@ should point to a location that will be updated with one of
|
||||
the following values:
|
||||
.Bl -tag -width indent -compact -offset indent
|
||||
.It Dv ELFTC_INSERT_ERROR
|
||||
An error occured during insertion of the symbol.
|
||||
An error occurred during insertion of the symbol.
|
||||
.It Dv ELFTC_INSERT_EXISTING
|
||||
The name in argument
|
||||
.Ar symbolname
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include "_libelftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3123 2014-12-21 05:46:19Z kaiwang27 $");
|
||||
ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3212 2015-05-17 13:40:55Z kaiwang27 $");
|
||||
|
||||
/**
|
||||
* @file cpp_demangle.c
|
||||
@ -50,7 +50,7 @@ ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3123 2014-12-21 05:46:19Z kaiwang27 $");
|
||||
|
||||
enum type_qualifier {
|
||||
TYPE_PTR, TYPE_REF, TYPE_CMX, TYPE_IMG, TYPE_EXT, TYPE_RST, TYPE_VAT,
|
||||
TYPE_CST
|
||||
TYPE_CST, TYPE_VEC
|
||||
};
|
||||
|
||||
struct vector_type_qualifier {
|
||||
@ -84,6 +84,7 @@ struct cpp_demangle_data {
|
||||
int func_type;
|
||||
const char *cur; /* current mangled name ptr */
|
||||
const char *last_sname; /* last source name */
|
||||
int push_head;
|
||||
};
|
||||
|
||||
#define CPP_DEMANGLE_TRY_LIMIT 128
|
||||
@ -112,6 +113,8 @@ static int cpp_demangle_read_array(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_encoding(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_expr_primary(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_expression(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_expression_flat(struct cpp_demangle_data *,
|
||||
char **);
|
||||
static int cpp_demangle_read_expression_binary(struct cpp_demangle_data *,
|
||||
const char *, size_t);
|
||||
static int cpp_demangle_read_expression_unary(struct cpp_demangle_data *,
|
||||
@ -123,8 +126,12 @@ static int cpp_demangle_read_function(struct cpp_demangle_data *, int *,
|
||||
static int cpp_demangle_local_source_name(struct cpp_demangle_data *ddata);
|
||||
static int cpp_demangle_read_local_name(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_name(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_name_flat(struct cpp_demangle_data *,
|
||||
char**);
|
||||
static int cpp_demangle_read_nested_name(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_number(struct cpp_demangle_data *, long *);
|
||||
static int cpp_demangle_read_number_as_string(struct cpp_demangle_data *,
|
||||
char **);
|
||||
static int cpp_demangle_read_nv_offset(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_offset(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_offset_number(struct cpp_demangle_data *);
|
||||
@ -138,6 +145,8 @@ static int cpp_demangle_read_tmpl_arg(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_tmpl_args(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_tmpl_param(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_type(struct cpp_demangle_data *, int);
|
||||
static int cpp_demangle_read_type_flat(struct cpp_demangle_data *,
|
||||
char **);
|
||||
static int cpp_demangle_read_uqname(struct cpp_demangle_data *);
|
||||
static int cpp_demangle_read_v_offset(struct cpp_demangle_data *);
|
||||
static char *decode_fp_to_double(const char *, size_t);
|
||||
@ -156,8 +165,6 @@ static int vector_type_qualifier_init(struct vector_type_qualifier *);
|
||||
static int vector_type_qualifier_push(struct vector_type_qualifier *,
|
||||
enum type_qualifier);
|
||||
|
||||
static int cpp_demangle_gnu3_push_head;
|
||||
|
||||
/**
|
||||
* @brief Decode the input string by IA-64 C++ ABI style.
|
||||
*
|
||||
@ -190,7 +197,6 @@ cpp_demangle_gnu3(const char *org)
|
||||
if (!cpp_demangle_data_init(&ddata, org + 2))
|
||||
return (NULL);
|
||||
|
||||
cpp_demangle_gnu3_push_head = 0;
|
||||
rtn = NULL;
|
||||
|
||||
if (!cpp_demangle_read_encoding(&ddata))
|
||||
@ -277,6 +283,7 @@ cpp_demangle_data_init(struct cpp_demangle_data *d, const char *cur)
|
||||
d->func_type = 0;
|
||||
d->cur = cur;
|
||||
d->last_sname = NULL;
|
||||
d->push_head = 0;
|
||||
|
||||
return (1);
|
||||
|
||||
@ -309,17 +316,18 @@ cpp_demangle_push_fp(struct cpp_demangle_data *ddata,
|
||||
fp = ddata->cur;
|
||||
while (*ddata->cur != 'E')
|
||||
++ddata->cur;
|
||||
++ddata->cur;
|
||||
|
||||
if ((f = decoder(fp, ddata->cur - fp)) == NULL)
|
||||
return (0);
|
||||
|
||||
rtn = 0;
|
||||
if ((len = strlen(f)) > 0)
|
||||
rtn = cpp_demangle_push_str(ddata, f, len);
|
||||
rtn = cpp_demangle_push_str(ddata, f, len);
|
||||
|
||||
free(f);
|
||||
|
||||
++ddata->cur;
|
||||
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
@ -331,7 +339,7 @@ cpp_demangle_push_str(struct cpp_demangle_data *ddata, const char *str,
|
||||
if (ddata == NULL || str == NULL || len == 0)
|
||||
return (0);
|
||||
|
||||
if (cpp_demangle_gnu3_push_head > 0)
|
||||
if (ddata->push_head > 0)
|
||||
return (vector_str_push(&ddata->output_tmp, str, len));
|
||||
|
||||
return (vector_str_push(&ddata->output, str, len));
|
||||
@ -403,7 +411,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, "*", 1))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
@ -414,7 +423,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, "&", 1))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
@ -425,7 +435,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, " complex", 8))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
@ -434,23 +445,26 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (!cpp_demangle_push_str(ddata, " imaginary", 10))
|
||||
goto clean;
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, " imaginary", 10))
|
||||
if (!vector_str_push(&subst_v, " imaginary",
|
||||
10))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_EXT:
|
||||
if (e_idx > v->ext_name.size - 1)
|
||||
if (v->ext_name.size == 0 ||
|
||||
e_idx > v->ext_name.size - 1)
|
||||
goto clean;
|
||||
if ((e_len = strlen(v->ext_name.container[e_idx])) == 0)
|
||||
if ((e_len = strlen(v->ext_name.container[e_idx])) ==
|
||||
0)
|
||||
goto clean;
|
||||
if ((buf = malloc(sizeof(char) * (e_len + 1))) == NULL)
|
||||
if ((buf = malloc(e_len + 2)) == NULL)
|
||||
goto clean;
|
||||
|
||||
memcpy(buf, " ", 1);
|
||||
memcpy(buf + 1, v->ext_name.container[e_idx], e_len);
|
||||
snprintf(buf, e_len + 2, " %s",
|
||||
v->ext_name.container[e_idx]);
|
||||
|
||||
if (!cpp_demangle_push_str(ddata, buf, e_len + 1)) {
|
||||
free(buf);
|
||||
@ -463,7 +477,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
free(buf);
|
||||
goto clean;
|
||||
}
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v)) {
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v)) {
|
||||
free(buf);
|
||||
goto clean;
|
||||
}
|
||||
@ -478,7 +493,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, " restrict", 9))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
@ -489,7 +505,8 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, " volatile", 9))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
@ -500,11 +517,42 @@ cpp_demangle_push_type_qualifier(struct cpp_demangle_data *ddata,
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, " const", 6))
|
||||
goto clean;
|
||||
if (!cpp_demangle_push_subst_v(ddata, &subst_v))
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v))
|
||||
goto clean;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_VEC:
|
||||
if (v->ext_name.size == 0 ||
|
||||
e_idx > v->ext_name.size - 1)
|
||||
goto clean;
|
||||
if ((e_len = strlen(v->ext_name.container[e_idx])) ==
|
||||
0)
|
||||
goto clean;
|
||||
if ((buf = malloc(e_len + 12)) == NULL)
|
||||
goto clean;
|
||||
snprintf(buf, e_len + 12, " __vector(%s)",
|
||||
v->ext_name.container[e_idx]);
|
||||
if (!cpp_demangle_push_str(ddata, buf, e_len + 11)) {
|
||||
free(buf);
|
||||
goto clean;
|
||||
}
|
||||
if (type_str != NULL) {
|
||||
if (!vector_str_push(&subst_v, buf,
|
||||
e_len + 11)) {
|
||||
free(buf);
|
||||
goto clean;
|
||||
}
|
||||
if (!cpp_demangle_push_subst_v(ddata,
|
||||
&subst_v)) {
|
||||
free(buf);
|
||||
goto clean;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
++e_idx;
|
||||
break;
|
||||
};
|
||||
--idx;
|
||||
}
|
||||
@ -655,10 +703,14 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata)
|
||||
|
||||
switch (*ddata->cur) {
|
||||
case 'b':
|
||||
if (*(ddata->cur + 2) != 'E')
|
||||
return (0);
|
||||
switch (*(++ddata->cur)) {
|
||||
case '0':
|
||||
ddata->cur += 2;
|
||||
return (cpp_demangle_push_str(ddata, "false", 5));
|
||||
case '1':
|
||||
ddata->cur += 2;
|
||||
return (cpp_demangle_push_str(ddata, "true", 4));
|
||||
default:
|
||||
return (0);
|
||||
@ -707,7 +759,8 @@ cpp_demangle_read_expr_primary(struct cpp_demangle_data *ddata)
|
||||
++ddata->cur;
|
||||
}
|
||||
++ddata->cur;
|
||||
return (cpp_demangle_push_str(ddata, num, ddata->cur - num));
|
||||
return (cpp_demangle_push_str(ddata, num,
|
||||
ddata->cur - num - 1));
|
||||
|
||||
default:
|
||||
return (0);
|
||||
@ -998,6 +1051,38 @@ cpp_demangle_read_expression(struct cpp_demangle_data *ddata)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_expression_flat(struct cpp_demangle_data *ddata, char **str)
|
||||
{
|
||||
struct vector_str *output;
|
||||
size_t i, p_idx, idx, exp_len;
|
||||
char *exp;
|
||||
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp :
|
||||
&ddata->output;
|
||||
|
||||
p_idx = output->size;
|
||||
|
||||
if (!cpp_demangle_read_expression(ddata))
|
||||
return (0);
|
||||
|
||||
if ((exp = vector_str_substr(output, p_idx, output->size - 1,
|
||||
&exp_len)) == NULL)
|
||||
return (0);
|
||||
|
||||
idx = output->size;
|
||||
for (i = p_idx; i < idx; ++i) {
|
||||
if (!vector_str_pop(output)) {
|
||||
free(exp);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
*str = exp;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_expression_binary(struct cpp_demangle_data *ddata,
|
||||
const char *name, size_t len)
|
||||
@ -1127,12 +1212,65 @@ cpp_demangle_read_function(struct cpp_demangle_data *ddata, int *ext_c,
|
||||
static int
|
||||
cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
|
||||
{
|
||||
char *name, *type, *num_str;
|
||||
long offset;
|
||||
int rtn;
|
||||
|
||||
if (ddata == NULL || *ddata->cur == '\0')
|
||||
return (0);
|
||||
|
||||
/* special name */
|
||||
switch (SIMPLE_HASH(*ddata->cur, *(ddata->cur + 1))) {
|
||||
case SIMPLE_HASH('G', 'A'):
|
||||
if (!cpp_demangle_push_str(ddata, "hidden alias for ", 17))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_encoding(ddata));
|
||||
|
||||
case SIMPLE_HASH('G', 'R'):
|
||||
if (!cpp_demangle_push_str(ddata, "reference temporary #", 21))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
if (!cpp_demangle_read_name_flat(ddata, &name))
|
||||
return (0);
|
||||
rtn = 0;
|
||||
if (!cpp_demangle_read_number_as_string(ddata, &num_str))
|
||||
goto clean1;
|
||||
if (!cpp_demangle_push_str(ddata, num_str, strlen(num_str)))
|
||||
goto clean2;
|
||||
if (!cpp_demangle_push_str(ddata, " for ", 5))
|
||||
goto clean2;
|
||||
if (!cpp_demangle_push_str(ddata, name, strlen(name)))
|
||||
goto clean2;
|
||||
rtn = 1;
|
||||
clean2:
|
||||
free(num_str);
|
||||
clean1:
|
||||
free(name);
|
||||
return (rtn);
|
||||
|
||||
case SIMPLE_HASH('G', 'T'):
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
switch (*ddata->cur) {
|
||||
case 'n':
|
||||
if (!cpp_demangle_push_str(ddata,
|
||||
"non-transaction clone for ", 26))
|
||||
return (0);
|
||||
case 't':
|
||||
default:
|
||||
if (!cpp_demangle_push_str(ddata,
|
||||
"transaction clone for ", 22))
|
||||
return (0);
|
||||
}
|
||||
++ddata->cur;
|
||||
return (cpp_demangle_read_encoding(ddata));
|
||||
|
||||
case SIMPLE_HASH('G', 'V'):
|
||||
/* sentry object for 1 time init */
|
||||
if (!cpp_demangle_push_str(ddata, "guard variable for ", 20))
|
||||
@ -1154,14 +1292,49 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
|
||||
return (0);
|
||||
return (cpp_demangle_read_encoding(ddata));
|
||||
|
||||
case SIMPLE_HASH('T', 'C'):
|
||||
/* construction vtable */
|
||||
if (!cpp_demangle_push_str(ddata, "construction vtable for ",
|
||||
24))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
if (!cpp_demangle_read_type_flat(ddata, &type))
|
||||
return (0);
|
||||
rtn = 0;
|
||||
if (!cpp_demangle_read_number(ddata, &offset))
|
||||
goto clean3;
|
||||
if (*ddata->cur++ != '_')
|
||||
goto clean3;
|
||||
if (!cpp_demangle_read_type(ddata, 0))
|
||||
goto clean3;
|
||||
if (!cpp_demangle_push_str(ddata, "-in-", 4))
|
||||
goto clean3;
|
||||
if (!cpp_demangle_push_str(ddata, type, strlen(type)))
|
||||
goto clean3;
|
||||
rtn = 1;
|
||||
clean3:
|
||||
free(type);
|
||||
return (rtn);
|
||||
|
||||
case SIMPLE_HASH('T', 'D'):
|
||||
/* typeinfo common proxy */
|
||||
break;
|
||||
|
||||
case SIMPLE_HASH('T', 'F'):
|
||||
/* typeinfo fn */
|
||||
if (!cpp_demangle_push_str(ddata, "typeinfo fn for ", 16))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'h'):
|
||||
/* virtual function non-virtual override thunk */
|
||||
if (cpp_demangle_push_str(ddata,
|
||||
"virtual function non-virtual override ", 38) == 0)
|
||||
if (!cpp_demangle_push_str(ddata,
|
||||
"virtual function non-virtual override ", 38))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
@ -1170,24 +1343,51 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
|
||||
return (0);
|
||||
return (cpp_demangle_read_encoding(ddata));
|
||||
|
||||
case SIMPLE_HASH('T', 'I'):
|
||||
/* typeinfo structure */
|
||||
/* FALLTHROUGH */
|
||||
case SIMPLE_HASH('T', 'S'):
|
||||
/* RTTI name (NTBS) */
|
||||
if (!cpp_demangle_push_str(ddata, "typeinfo for ", 14))
|
||||
case SIMPLE_HASH('T', 'H'):
|
||||
/* TLS init function */
|
||||
if (!cpp_demangle_push_str(ddata, "TLS init function for ",
|
||||
22))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 1));
|
||||
break;
|
||||
|
||||
case SIMPLE_HASH('T', 'I'):
|
||||
/* typeinfo structure */
|
||||
if (!cpp_demangle_push_str(ddata, "typeinfo for ", 13))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'J'):
|
||||
/* java class */
|
||||
if (!cpp_demangle_push_str(ddata, "java Class for ", 15))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'S'):
|
||||
/* RTTI name (NTBS) */
|
||||
if (!cpp_demangle_push_str(ddata, "typeinfo name for ", 18))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'T'):
|
||||
/* VTT table */
|
||||
if (!cpp_demangle_push_str(ddata, "VTT for ", 8))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
return (cpp_demangle_read_type(ddata, 1));
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'v'):
|
||||
/* virtual function virtual override thunk */
|
||||
@ -1208,7 +1408,17 @@ cpp_demangle_read_encoding(struct cpp_demangle_data *ddata)
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
return (cpp_demangle_read_type(ddata, 1));
|
||||
return (cpp_demangle_read_type(ddata, 0));
|
||||
|
||||
case SIMPLE_HASH('T', 'W'):
|
||||
/* TLS wrapper function */
|
||||
if (!cpp_demangle_push_str(ddata, "TLS wrapper function for ",
|
||||
25))
|
||||
return (0);
|
||||
ddata->cur += 2;
|
||||
if (*ddata->cur == '\0')
|
||||
return (0);
|
||||
break;
|
||||
};
|
||||
|
||||
return (cpp_demangle_read_name(ddata));
|
||||
@ -1270,8 +1480,7 @@ cpp_demangle_read_name(struct cpp_demangle_data *ddata)
|
||||
if (ddata == NULL || *ddata->cur == '\0')
|
||||
return (0);
|
||||
|
||||
output = cpp_demangle_gnu3_push_head > 0 ?
|
||||
&ddata->output_tmp : &ddata->output;
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output;
|
||||
|
||||
subst_str = NULL;
|
||||
|
||||
@ -1326,6 +1535,38 @@ cpp_demangle_read_name(struct cpp_demangle_data *ddata)
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_name_flat(struct cpp_demangle_data *ddata, char **str)
|
||||
{
|
||||
struct vector_str *output;
|
||||
size_t i, p_idx, idx, name_len;
|
||||
char *name;
|
||||
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp :
|
||||
&ddata->output;
|
||||
|
||||
p_idx = output->size;
|
||||
|
||||
if (!cpp_demangle_read_name(ddata))
|
||||
return (0);
|
||||
|
||||
if ((name = vector_str_substr(output, p_idx, output->size - 1,
|
||||
&name_len)) == NULL)
|
||||
return (0);
|
||||
|
||||
idx = output->size;
|
||||
for (i = p_idx; i < idx; ++i) {
|
||||
if (!vector_str_pop(output)) {
|
||||
free(name);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
*str = name;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata)
|
||||
{
|
||||
@ -1355,8 +1596,7 @@ cpp_demangle_read_nested_name(struct cpp_demangle_data *ddata)
|
||||
++ddata->cur;
|
||||
}
|
||||
|
||||
output = cpp_demangle_gnu3_push_head > 0 ?
|
||||
&ddata->output_tmp : &ddata->output;
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output;
|
||||
if (!vector_str_init(&v))
|
||||
return (0);
|
||||
|
||||
@ -1452,6 +1692,24 @@ cpp_demangle_read_number(struct cpp_demangle_data *ddata, long *rtn)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_number_as_string(struct cpp_demangle_data *ddata, char **str)
|
||||
{
|
||||
long n;
|
||||
|
||||
if (!cpp_demangle_read_number(ddata, &n)) {
|
||||
*str = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (asprintf(str, "%ld", n) < 0) {
|
||||
*str = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_nv_offset(struct cpp_demangle_data *ddata)
|
||||
{
|
||||
@ -1581,9 +1839,18 @@ static int
|
||||
cpp_demangle_read_sname(struct cpp_demangle_data *ddata)
|
||||
{
|
||||
long len;
|
||||
int err;
|
||||
|
||||
if (ddata == NULL || cpp_demangle_read_number(ddata, &len) == 0 ||
|
||||
len <= 0 || cpp_demangle_push_str(ddata, ddata->cur, len) == 0)
|
||||
len <= 0)
|
||||
return (0);
|
||||
|
||||
if (len == 12 && (memcmp("_GLOBAL__N_1", ddata->cur, 12) == 0))
|
||||
err = cpp_demangle_push_str(ddata, "(anonymous namespace)", 21);
|
||||
else
|
||||
err = cpp_demangle_push_str(ddata, ddata->cur, len);
|
||||
|
||||
if (err == 0)
|
||||
return (0);
|
||||
|
||||
assert(ddata->output.size > 0);
|
||||
@ -1732,8 +1999,7 @@ cpp_demangle_read_subst_std(struct cpp_demangle_data *ddata)
|
||||
|
||||
ddata->cur += 2;
|
||||
|
||||
output = cpp_demangle_gnu3_push_head > 0 ?
|
||||
&ddata->output_tmp : &ddata->output;
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output;
|
||||
|
||||
p_idx = output->size;
|
||||
if (!cpp_demangle_read_uqname(ddata))
|
||||
@ -1783,8 +2049,7 @@ cpp_demangle_read_subst_stdtmpl(struct cpp_demangle_data *ddata,
|
||||
if (ddata == NULL || str == NULL || len == 0)
|
||||
return (0);
|
||||
|
||||
output = cpp_demangle_gnu3_push_head > 0 ? &ddata->output_tmp :
|
||||
&ddata->output;
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output;
|
||||
|
||||
p_idx = output->size;
|
||||
substr = NULL;
|
||||
@ -1852,8 +2117,7 @@ cpp_demangle_read_tmpl_args(struct cpp_demangle_data *ddata)
|
||||
return (0);
|
||||
|
||||
limit = 0;
|
||||
v = cpp_demangle_gnu3_push_head > 0 ?
|
||||
&ddata->output_tmp : &ddata->output;
|
||||
v = ddata->push_head > 0 ? &ddata->output_tmp : &ddata->output;
|
||||
for (;;) {
|
||||
idx = v->size;
|
||||
if (!cpp_demangle_read_tmpl_arg(ddata))
|
||||
@ -1936,14 +2200,14 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
size_t p_idx, type_str_len;
|
||||
int extern_c, is_builtin;
|
||||
long len;
|
||||
char *type_str;
|
||||
char *type_str, *exp_str, *num_str;
|
||||
|
||||
if (ddata == NULL)
|
||||
return (0);
|
||||
|
||||
output = &ddata->output;
|
||||
if (!strncmp(ddata->output.container[ddata->output.size - 1], ">", 1)) {
|
||||
cpp_demangle_gnu3_push_head++;
|
||||
ddata->push_head++;
|
||||
output = &ddata->output_tmp;
|
||||
} else if (delimit == 1) {
|
||||
if (ddata->paren == false) {
|
||||
@ -1978,7 +2242,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
extern_c = 0;
|
||||
is_builtin = 1;
|
||||
p_idx = output->size;
|
||||
type_str = NULL;
|
||||
type_str = exp_str = num_str = NULL;
|
||||
again:
|
||||
/* builtin type */
|
||||
switch (*ddata->cur) {
|
||||
@ -2024,6 +2288,82 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
++ddata->cur;
|
||||
goto rtn;
|
||||
|
||||
case 'D':
|
||||
++ddata->cur;
|
||||
switch (*ddata->cur) {
|
||||
case 'd':
|
||||
/* IEEE 754r decimal floating point (64 bits) */
|
||||
if (!cpp_demangle_push_str(ddata, "decimal64", 9))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'e':
|
||||
/* IEEE 754r decimal floating point (128 bits) */
|
||||
if (!cpp_demangle_push_str(ddata, "decimal128", 10))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'f':
|
||||
/* IEEE 754r decimal floating point (32 bits) */
|
||||
if (!cpp_demangle_push_str(ddata, "decimal32", 9))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'h':
|
||||
/* IEEE 754r half-precision floating point (16 bits) */
|
||||
if (!cpp_demangle_push_str(ddata, "half", 4))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'i':
|
||||
/* char32_t */
|
||||
if (!cpp_demangle_push_str(ddata, "char32_t", 8))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'n':
|
||||
/* std::nullptr_t (i.e., decltype(nullptr)) */
|
||||
if (!cpp_demangle_push_str(ddata, "decltype(nullptr)",
|
||||
17))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 's':
|
||||
/* char16_t */
|
||||
if (!cpp_demangle_push_str(ddata, "char16_t", 8))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
break;
|
||||
case 'v':
|
||||
/* gcc vector_size extension. */
|
||||
++ddata->cur;
|
||||
if (*ddata->cur == '_') {
|
||||
++ddata->cur;
|
||||
if (!cpp_demangle_read_expression_flat(ddata,
|
||||
&exp_str))
|
||||
goto clean;
|
||||
if (!vector_str_push(&v.ext_name, exp_str,
|
||||
strlen(exp_str)))
|
||||
goto clean;
|
||||
} else {
|
||||
if (!cpp_demangle_read_number_as_string(ddata,
|
||||
&num_str))
|
||||
goto clean;
|
||||
if (!vector_str_push(&v.ext_name, num_str,
|
||||
strlen(num_str)))
|
||||
goto clean;
|
||||
}
|
||||
if (*ddata->cur != '_')
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
if (!vector_type_qualifier_push(&v, TYPE_VEC))
|
||||
goto clean;
|
||||
goto again;
|
||||
default:
|
||||
goto clean;
|
||||
}
|
||||
goto rtn;
|
||||
|
||||
case 'e':
|
||||
/* long double */
|
||||
if (!cpp_demangle_push_str(ddata, "long double", 11))
|
||||
@ -2118,7 +2458,7 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
|
||||
case 'o':
|
||||
/* unsigned __int128 */
|
||||
if (!cpp_demangle_push_str(ddata, "unsigned _;int128", 17))
|
||||
if (!cpp_demangle_push_str(ddata, "unsigned __int128", 17))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
goto rtn;
|
||||
@ -2189,6 +2529,8 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
if (!vector_str_push(&v.ext_name, ddata->cur, len))
|
||||
return (0);
|
||||
ddata->cur += len;
|
||||
if (!vector_type_qualifier_push(&v, TYPE_EXT))
|
||||
goto clean;
|
||||
goto again;
|
||||
|
||||
case 'v':
|
||||
@ -2253,14 +2595,16 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
goto clean;
|
||||
|
||||
free(type_str);
|
||||
free(exp_str);
|
||||
free(num_str);
|
||||
vector_type_qualifier_dest(&v);
|
||||
|
||||
if (cpp_demangle_gnu3_push_head > 0) {
|
||||
if (ddata->push_head > 0) {
|
||||
if (*ddata->cur == 'I' && cpp_demangle_read_tmpl_args(ddata)
|
||||
== 0)
|
||||
return (0);
|
||||
|
||||
if (--cpp_demangle_gnu3_push_head > 0)
|
||||
if (--ddata->push_head > 0)
|
||||
return (1);
|
||||
|
||||
if (!vector_str_push(&ddata->output_tmp, " ", 1))
|
||||
@ -2284,11 +2628,45 @@ cpp_demangle_read_type(struct cpp_demangle_data *ddata, int delimit)
|
||||
return (1);
|
||||
clean:
|
||||
free(type_str);
|
||||
free(exp_str);
|
||||
free(num_str);
|
||||
vector_type_qualifier_dest(&v);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
cpp_demangle_read_type_flat(struct cpp_demangle_data *ddata, char **str)
|
||||
{
|
||||
struct vector_str *output;
|
||||
size_t i, p_idx, idx, type_len;
|
||||
char *type;
|
||||
|
||||
output = ddata->push_head > 0 ? &ddata->output_tmp :
|
||||
&ddata->output;
|
||||
|
||||
p_idx = output->size;
|
||||
|
||||
if (!cpp_demangle_read_type(ddata, 0))
|
||||
return (0);
|
||||
|
||||
if ((type = vector_str_substr(output, p_idx, output->size - 1,
|
||||
&type_len)) == NULL)
|
||||
return (0);
|
||||
|
||||
idx = output->size;
|
||||
for (i = p_idx; i < idx; ++i) {
|
||||
if (!vector_str_pop(output)) {
|
||||
free(type);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
*str = type;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* read unqualified-name, unqualified name are operator-name, ctor-dtor-name,
|
||||
* source-name
|
||||
|
@ -1,3 +1,3 @@
|
||||
# $Id: os.Linux.mk 994 2010-06-13 10:39:19Z jkoshy $
|
||||
# $Id: os.Linux.mk 3210 2015-05-17 13:40:49Z kaiwang27 $
|
||||
|
||||
CFLAGS+= -Wall
|
||||
CFLAGS+= -Wall -D_GNU_SOURCE
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: nm.1 3145 2015-02-15 18:04:37Z emaste $
|
||||
.\" $Id: nm.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd February 15, 2015
|
||||
.Os
|
||||
@ -335,4 +335,4 @@ were specified.
|
||||
The
|
||||
.Nm
|
||||
utility and this manual page were written by
|
||||
.An Hyogeol Lee Aq hyogeollee@gmail.com .
|
||||
.An Hyogeol Lee Aq Mt hyogeollee@gmail.com .
|
||||
|
@ -22,7 +22,7 @@
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: readelf.1 3059 2014-06-02 00:42:32Z kaiwang27 $
|
||||
.\" $Id: readelf.1 3219 2015-05-24 23:42:34Z kaiwang27 $
|
||||
.\"
|
||||
.Dd September 13, 2012
|
||||
.Os
|
||||
@ -90,7 +90,7 @@ sections in the ELF object.
|
||||
.It Fl e | Fl -headers
|
||||
Print all program, file and section headers in the ELF object.
|
||||
.It Fl g | Fl -section-groups
|
||||
This option is recognized, but is ignored.
|
||||
Print the contents of the section groups in the ELF object.
|
||||
.It Fl h | Fl -file-header
|
||||
Print the file header of the ELF object.
|
||||
.It Fl l | Fl -program-headers
|
||||
@ -194,4 +194,4 @@ separate lines.
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2014 Kai Wang
|
||||
* Copyright (c) 2009-2015 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: readelf.c 3178 2015-03-30 18:29:13Z emaste $");
|
||||
ELFTC_VCSID("$Id: readelf.c 3223 2015-05-25 20:37:57Z emaste $");
|
||||
|
||||
/*
|
||||
* readelf(1) options.
|
||||
@ -302,6 +302,7 @@ static void dump_gnu_hash(struct readelf *re, struct section *s);
|
||||
static void dump_hash(struct readelf *re);
|
||||
static void dump_phdr(struct readelf *re);
|
||||
static void dump_ppc_attributes(uint8_t *p, uint8_t *pe);
|
||||
static void dump_section_groups(struct readelf *re);
|
||||
static void dump_symtab(struct readelf *re, int i);
|
||||
static void dump_symtabs(struct readelf *re);
|
||||
static uint8_t *dump_unknown_tag(uint64_t tag, uint8_t *p);
|
||||
@ -445,6 +446,7 @@ elf_machine(unsigned int mach)
|
||||
case EM_SPARC: return "Sun SPARC";
|
||||
case EM_386: return "Intel i386";
|
||||
case EM_68K: return "Motorola 68000";
|
||||
case EM_IAMCU: return "Intel MCU";
|
||||
case EM_88K: return "Motorola 88000";
|
||||
case EM_860: return "Intel i860";
|
||||
case EM_MIPS: return "MIPS R3000 Big-Endian only";
|
||||
@ -1050,6 +1052,7 @@ r_type(unsigned int mach, unsigned int type)
|
||||
switch(mach) {
|
||||
case EM_NONE: return "";
|
||||
case EM_386:
|
||||
case EM_IAMCU:
|
||||
switch(type) {
|
||||
case 0: return "R_386_NONE";
|
||||
case 1: return "R_386_32";
|
||||
@ -2381,6 +2384,7 @@ dwarf_reg(unsigned int mach, unsigned int reg)
|
||||
|
||||
switch (mach) {
|
||||
case EM_386:
|
||||
case EM_IAMCU:
|
||||
switch (reg) {
|
||||
case 0: return "eax";
|
||||
case 1: return "ecx";
|
||||
@ -2673,7 +2677,7 @@ dump_phdr(struct readelf *re)
|
||||
{
|
||||
const char *rawfile;
|
||||
GElf_Phdr phdr;
|
||||
size_t phnum;
|
||||
size_t phnum, size;
|
||||
int i, j;
|
||||
|
||||
#define PH_HDR "Type", "Offset", "VirtAddr", "PhysAddr", "FileSiz", \
|
||||
@ -2726,10 +2730,14 @@ dump_phdr(struct readelf *re)
|
||||
" 0x%16.16jx 0x%16.16jx %c%c%c"
|
||||
" %#jx\n", PH_CT);
|
||||
if (phdr.p_type == PT_INTERP) {
|
||||
if ((rawfile = elf_rawfile(re->elf, NULL)) == NULL) {
|
||||
if ((rawfile = elf_rawfile(re->elf, &size)) == NULL) {
|
||||
warnx("elf_rawfile failed: %s", elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if (phdr.p_offset >= size) {
|
||||
warnx("invalid program header offset");
|
||||
continue;
|
||||
}
|
||||
printf(" [Requesting program interpreter: %s]\n",
|
||||
rawfile + phdr.p_offset);
|
||||
}
|
||||
@ -4043,6 +4051,61 @@ dump_liblist(struct readelf *re)
|
||||
|
||||
#undef Elf_Lib
|
||||
|
||||
static void
|
||||
dump_section_groups(struct readelf *re)
|
||||
{
|
||||
struct section *s;
|
||||
const char *symname;
|
||||
Elf_Data *d;
|
||||
uint32_t *w;
|
||||
int i, j, elferr;
|
||||
size_t n;
|
||||
|
||||
for (i = 0; (size_t) i < re->shnum; i++) {
|
||||
s = &re->sl[i];
|
||||
if (s->type != SHT_GROUP)
|
||||
continue;
|
||||
(void) elf_errno();
|
||||
if ((d = elf_getdata(s->scn, NULL)) == NULL) {
|
||||
elferr = elf_errno();
|
||||
if (elferr != 0)
|
||||
warnx("elf_getdata failed: %s",
|
||||
elf_errmsg(elferr));
|
||||
continue;
|
||||
}
|
||||
if (d->d_size <= 0)
|
||||
continue;
|
||||
|
||||
w = d->d_buf;
|
||||
|
||||
/* We only support COMDAT section. */
|
||||
#ifndef GRP_COMDAT
|
||||
#define GRP_COMDAT 0x1
|
||||
#endif
|
||||
if ((*w++ & GRP_COMDAT) == 0)
|
||||
return;
|
||||
|
||||
if (s->entsize == 0)
|
||||
s->entsize = 4;
|
||||
|
||||
symname = get_symbol_name(re, s->link, s->info);
|
||||
n = s->sz / s->entsize;
|
||||
if (n-- < 1)
|
||||
return;
|
||||
|
||||
printf("\nCOMDAT group section [%5d] `%s' [%s] contains %ju"
|
||||
" sections:\n", i, s->name, symname, (uintmax_t)n);
|
||||
printf(" %-10.10s %s\n", "[Index]", "Name");
|
||||
for (j = 0; (size_t) j < n; j++, w++) {
|
||||
if (*w >= re->shnum) {
|
||||
warnx("invalid section index: %u", *w);
|
||||
continue;
|
||||
}
|
||||
printf(" [%5u] %s\n", *w, re->sl[*w].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t *
|
||||
dump_unknown_tag(uint64_t tag, uint8_t *p)
|
||||
{
|
||||
@ -4378,13 +4441,22 @@ dump_mips_options(struct readelf *re, struct section *s)
|
||||
p = d->d_buf;
|
||||
pe = p + d->d_size;
|
||||
while (p < pe) {
|
||||
if (pe - p < 8) {
|
||||
warnx("Truncated MIPS option header");
|
||||
return;
|
||||
}
|
||||
kind = re->dw_decode(&p, 1);
|
||||
size = re->dw_decode(&p, 1);
|
||||
sndx = re->dw_decode(&p, 2);
|
||||
info = re->dw_decode(&p, 4);
|
||||
if (size < 8 || size - 8 > pe - p) {
|
||||
warnx("Malformed MIPS option header");
|
||||
return;
|
||||
}
|
||||
size -= 8;
|
||||
switch (kind) {
|
||||
case ODK_REGINFO:
|
||||
dump_mips_odk_reginfo(re, p, size - 8);
|
||||
dump_mips_odk_reginfo(re, p, size);
|
||||
break;
|
||||
case ODK_EXCEPTIONS:
|
||||
printf(" EXCEPTIONS FPU_MIN: %#x\n",
|
||||
@ -4435,7 +4507,7 @@ dump_mips_options(struct readelf *re, struct section *s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
p += size - 8;
|
||||
p += size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6825,6 +6897,8 @@ dump_elf(struct readelf *re)
|
||||
dump_phdr(re);
|
||||
if (re->options & RE_SS)
|
||||
dump_shdr(re);
|
||||
if (re->options & RE_G)
|
||||
dump_section_groups(re);
|
||||
if (re->options & RE_D)
|
||||
dump_dynamic(re);
|
||||
if (re->options & RE_R)
|
||||
@ -7298,7 +7372,7 @@ Usage: %s [options] file...\n\
|
||||
-c | --archive-index Print the archive symbol table for archives.\n\
|
||||
-d | --dynamic Print the contents of SHT_DYNAMIC sections.\n\
|
||||
-e | --headers Print all headers in the object.\n\
|
||||
-g | --section-groups (accepted, but ignored)\n\
|
||||
-g | --section-groups Print the contents of the section groups.\n\
|
||||
-h | --file-header Print the file header for the object.\n\
|
||||
-l | --program-headers Print the PHDR table for the object.\n\
|
||||
-n | --notes Print the contents of SHT_NOTE sections.\n\
|
||||
@ -7352,8 +7426,8 @@ main(int argc, char **argv)
|
||||
re->options |= RE_AA;
|
||||
break;
|
||||
case 'a':
|
||||
re->options |= RE_AA | RE_D | RE_H | RE_II | RE_L |
|
||||
RE_R | RE_SS | RE_S | RE_VV;
|
||||
re->options |= RE_AA | RE_D | RE_G | RE_H | RE_II |
|
||||
RE_L | RE_R | RE_SS | RE_S | RE_VV;
|
||||
break;
|
||||
case 'c':
|
||||
re->options |= RE_C;
|
||||
@ -7458,11 +7532,10 @@ main(int argc, char **argv)
|
||||
errx(EXIT_FAILURE, "ELF library initialization failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
if (argv[i] != NULL) {
|
||||
re->filename = argv[i];
|
||||
dump_object(re);
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
re->filename = argv[i];
|
||||
dump_object(re);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: size.1 2043 2011-10-23 14:49:16Z jkoshy $
|
||||
.\" $Id: size.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd August 25, 2011
|
||||
.Dt SIZE 1
|
||||
@ -252,6 +252,6 @@ utility first appeared in
|
||||
The
|
||||
.Nm
|
||||
utility was re-written by
|
||||
.An S. Sam Arun Raj Aq samarunraj@gmail.com
|
||||
.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
|
||||
This manual page was written by
|
||||
.An S. Sam Arun Raj Aq samarunraj@gmail.com
|
||||
.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: size.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
ELFTC_VCSID("$Id: size.c 3183 2015-04-10 16:18:42Z emaste $");
|
||||
|
||||
#define BUF_SIZE 1024
|
||||
#define ELF_ALIGN(val,x) (((val)+(x)-1) & ~((x)-1))
|
||||
@ -604,7 +604,7 @@ handle_elf(char const *name)
|
||||
arhdr->ar_name);
|
||||
continue;
|
||||
}
|
||||
/* Core dumps are handled seperately */
|
||||
/* Core dumps are handled separately */
|
||||
if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) {
|
||||
exit_code = handle_core(name, elf, &elfhdr);
|
||||
(void) elf_end(elf);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user