Merge ^/head r285924 through r286421.
This commit is contained in:
commit
1347814ced
@ -99,6 +99,8 @@ OLD_FILES+=usr/lib/clang/3.6.1/lib/freebsd/libclang_rt.ubsan_cxx-x86_64.a
|
||||
OLD_DIRS+=usr/lib/clang/3.6.1/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/3.6.1/lib
|
||||
OLD_DIRS+=usr/lib/clang/3.6.1
|
||||
# 20150802: Remove netbsd's test on pw(8)
|
||||
OLD_FILES+=usr/tests/usr.sbin/pw/pw_test
|
||||
# 20150719: Remove libarchive.pc
|
||||
OLD_FILES+=usr/libdata/pkgconfig/libarchive.pc
|
||||
# 20150705: Rename DTrace provider man pages.
|
||||
|
33
UPDATING
33
UPDATING
@ -36,6 +36,24 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
20141231 entry below for information about prerequisites and upgrading,
|
||||
if you are not already using 3.5.0 or higher.
|
||||
|
||||
20150806:
|
||||
The menu.rc and loader.rc files will now be replaced during
|
||||
upgrades. Please migrate local changes to menu.rc.local and
|
||||
loader.rc.local instead.
|
||||
|
||||
20150805:
|
||||
GNU Binutils versions of addr2line, c++filt, nm, readelf, size,
|
||||
strings and strip have been removed. The src.conf(5) knob
|
||||
WITHOUT_ELFTOOLCHAIN_TOOLS no longer provides the binutils tools.
|
||||
|
||||
20150728:
|
||||
As ZFS requires more kernel stack pages than is the default on some
|
||||
architectures e.g. i386, it now warns if KSTACK_PAGES is less than
|
||||
ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing).
|
||||
|
||||
Please consider using 'options KSTACK_PAGES=X' where X is greater
|
||||
than or equal to ZFS_MIN_KSTACK_PAGES i.e. 4 in such configurations.
|
||||
|
||||
20150706:
|
||||
sendmail has been updated to 8.15.2. Starting with FreeBSD 11.0
|
||||
and sendmail 8.15, sendmail uses uncompressed IPv6 addresses by
|
||||
@ -221,7 +239,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
taken from the ELF Tool Chain project rather than GNU binutils. They
|
||||
should be drop-in replacements, with the addition of arm64 support.
|
||||
The WITHOUT_ELFTOOLCHAIN_TOOLS= knob may be used to obtain the
|
||||
binutils tools, if necessary.
|
||||
binutils tools, if necessary. See 20150805 for updated information.
|
||||
|
||||
20150105:
|
||||
The default Unbound configuration now enables remote control
|
||||
@ -574,6 +592,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
or
|
||||
# pkg install pkg; ldd /usr/local/sbin/pkg | grep bsdyml
|
||||
|
||||
20131010:
|
||||
The stable/10 branch has been created in subversion from head
|
||||
revision r256279.
|
||||
|
||||
20131010:
|
||||
The rc.d/jail script has been updated to support jail(8)
|
||||
configuration file. The "jail_<jname>_*" rc.conf(5) variables
|
||||
@ -1117,6 +1139,13 @@ COMMON ITEMS:
|
||||
around can lead to problems if pam has changed too much from your
|
||||
starting point to allow continued authentication after the upgrade.
|
||||
|
||||
This file should be read as a log of events. When a later event changes
|
||||
information of a prior event, the prior event should not be deleted.
|
||||
Instead, a pointer to the entry with the new information should be
|
||||
placed in the old entry. Readers of this file should also sanity check
|
||||
older entries before relying on them blindly. Authors of new entries
|
||||
should write them with this in mind.
|
||||
|
||||
ZFS notes
|
||||
---------
|
||||
When upgrading the boot ZFS pool to a new version, always follow
|
||||
@ -1287,7 +1316,7 @@ FORMAT:
|
||||
|
||||
This file contains a list, in reverse chronological order, of major
|
||||
breakages in tracking -current. It is not guaranteed to be a complete
|
||||
list of such breakages, and only contains entries since October 10, 2007.
|
||||
list of such breakages, and only contains entries since September 23, 2011.
|
||||
If you need to see UPDATING entries from before that date, you will need
|
||||
to fetch an UPDATING file from an older FreeBSD release.
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
lockstat:kernel:mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
mutex_owned();
|
||||
exit(1);
|
||||
|
@ -34,7 +34,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
lockstat:kernel:mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
mutex_owned((kmutex_t *)arg0, 99);
|
||||
exit(1);
|
||||
|
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
|
||||
lockstat:kernel:mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
mutex_type_adaptive();
|
||||
exit(1);
|
||||
|
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
|
||||
lockstat:kernel:mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
mutex_type_adaptive((kmutex_t *)arg0, 99);
|
||||
exit(1);
|
||||
|
@ -48,7 +48,7 @@ BEGIN
|
||||
i = 0;
|
||||
}
|
||||
|
||||
lockstat::mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
|
||||
ptr = mutex_owner((struct mtx *)arg0);
|
||||
|
@ -44,7 +44,7 @@ BEGIN
|
||||
ret = -99;
|
||||
}
|
||||
|
||||
mtx_lock:adaptive-acquire
|
||||
lockstat:::adaptive-acquire
|
||||
{
|
||||
ret = mutex_type_adaptive((struct mtx *)arg0);
|
||||
i++;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
|
@ -58,12 +58,25 @@ fi
|
||||
|
||||
dtrace=$1
|
||||
local=127.0.0.1
|
||||
tcpport=22
|
||||
DIR=/var/tmp/dtest.$$
|
||||
|
||||
tcpport=1024
|
||||
bound=5000
|
||||
while [ $tcpport -lt $bound ]; do
|
||||
nc -z $local $tcpport >/dev/null || break
|
||||
tcpport=$(($tcpport + 1))
|
||||
done
|
||||
if [ $tcpport -eq $bound ]; then
|
||||
echo "couldn't find an available TCP port"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir $DIR
|
||||
cd $DIR
|
||||
|
||||
# nc will exit when the connection is closed.
|
||||
nc -l $local $tcpport &
|
||||
|
||||
cat > test.pl <<-EOPERL
|
||||
use IO::Socket;
|
||||
my \$s = IO::Socket::INET->new(
|
||||
@ -76,7 +89,7 @@ cat > test.pl <<-EOPERL
|
||||
sleep(2);
|
||||
EOPERL
|
||||
|
||||
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
BEGIN
|
||||
{
|
||||
ipsend = tcpsend = ipreceive = tcpreceive = 0;
|
||||
|
@ -79,7 +79,7 @@ cat > test.pl <<-EOPERL
|
||||
sleep(2);
|
||||
EOPERL
|
||||
|
||||
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
BEGIN
|
||||
{
|
||||
ipsend = tcpsend = ipreceive = tcpreceive = 0;
|
||||
|
@ -82,7 +82,7 @@ cat > test.pl <<-EOPERL
|
||||
sleep(2);
|
||||
EOPERL
|
||||
|
||||
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
BEGIN
|
||||
{
|
||||
ipsend = tcpsend = ipreceive = tcpreceive = 0;
|
||||
|
@ -87,7 +87,7 @@ cat > test.pl <<-EOPERL
|
||||
sleep(2);
|
||||
EOPERL
|
||||
|
||||
$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
$dtrace -c 'perl test.pl' -qs /dev/stdin <<EODTRACE
|
||||
BEGIN
|
||||
{
|
||||
ipsend = tcpsend = ipreceive = tcpreceive = 0;
|
||||
|
@ -27,11 +27,11 @@
|
||||
.\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org>
|
||||
.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved.
|
||||
.\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org>
|
||||
.\" Copyright (c) 2014, The FreeBSD Foundation, All Rights Reserved.
|
||||
.\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 12, 2014
|
||||
.Dd July 30, 2015
|
||||
.Dt ZFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -938,7 +938,7 @@ not be used by any other dataset.
|
||||
Disabling checksums is
|
||||
.Em NOT
|
||||
a recommended practice.
|
||||
.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | zle | Cm lz4
|
||||
.It Sy compression Ns = Ns Cm on | off | lzjb | gzip | gzip- Ns Ar N | Cm zle | Cm lz4
|
||||
Controls the compression algorithm used for this dataset. The
|
||||
.Cm lzjb
|
||||
compression algorithm is optimized for performance while providing decent data
|
||||
|
@ -1348,6 +1348,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
|
||||
dtrace_aggdesc_t *agg;
|
||||
caddr_t lim = (caddr_t)buf + len, limit;
|
||||
char format[64] = "%";
|
||||
size_t ret;
|
||||
int i, aggrec, curagg = -1;
|
||||
uint64_t normal;
|
||||
|
||||
@ -1379,7 +1380,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
|
||||
int prec = pfd->pfd_prec;
|
||||
int rval;
|
||||
|
||||
const char *start;
|
||||
char *f = format + 1; /* skip initial '%' */
|
||||
size_t fmtsz = sizeof(format) - 1;
|
||||
const dtrace_recdesc_t *rec;
|
||||
dt_pfprint_f *func;
|
||||
caddr_t addr;
|
||||
@ -1536,6 +1539,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
|
||||
break;
|
||||
}
|
||||
|
||||
start = f;
|
||||
if (pfd->pfd_flags & DT_PFCONV_ALT)
|
||||
*f++ = '#';
|
||||
if (pfd->pfd_flags & DT_PFCONV_ZPAD)
|
||||
@ -1548,6 +1552,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
|
||||
*f++ = '\'';
|
||||
if (pfd->pfd_flags & DT_PFCONV_SPACE)
|
||||
*f++ = ' ';
|
||||
fmtsz -= f - start;
|
||||
|
||||
/*
|
||||
* If we're printing a stack and DT_PFCONV_LEFT is set, we
|
||||
@ -1558,13 +1563,20 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
|
||||
if (func == pfprint_stack && (pfd->pfd_flags & DT_PFCONV_LEFT))
|
||||
width = 0;
|
||||
|
||||
if (width != 0)
|
||||
f += snprintf(f, sizeof (format), "%d", ABS(width));
|
||||
if (width != 0) {
|
||||
ret = snprintf(f, fmtsz, "%d", ABS(width));
|
||||
f += ret;
|
||||
fmtsz = MAX(0, fmtsz - ret);
|
||||
}
|
||||
|
||||
if (prec > 0)
|
||||
f += snprintf(f, sizeof (format), ".%d", prec);
|
||||
if (prec > 0) {
|
||||
ret = snprintf(f, fmtsz, ".%d", prec);
|
||||
f += ret;
|
||||
fmtsz = MAX(0, fmtsz - ret);
|
||||
}
|
||||
|
||||
(void) strcpy(f, pfd->pfd_fmt);
|
||||
if (strlcpy(f, pfd->pfd_fmt, fmtsz) >= fmtsz)
|
||||
return (dt_set_errno(dtp, EDT_COMPILER));
|
||||
pfd->pfd_rec = rec;
|
||||
|
||||
if (func(dtp, fp, format, pfd, addr, size, normal) < 0)
|
||||
|
@ -25,8 +25,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on provider io
|
||||
|
||||
typedef struct devinfo {
|
||||
|
@ -25,6 +25,7 @@
|
||||
* Copyright (c) 2013 Mark Johnston <markj@freebsd.org>
|
||||
*/
|
||||
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on provider ip
|
||||
|
||||
/*
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#pragma D depends_on library ip.d
|
||||
#pragma D depends_on library net.d
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on module nfs
|
||||
|
||||
typedef struct nfsv4opinfo {
|
||||
|
@ -30,7 +30,8 @@
|
||||
|
||||
#pragma D depends_on library ip.d
|
||||
#pragma D depends_on library net.d
|
||||
#pragma D depends_on module nfs.d
|
||||
#pragma D depends_on library nfs.d
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on module nfssrv
|
||||
|
||||
#pragma D binding "1.5" translator
|
||||
|
@ -28,6 +28,8 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma D depends_on module kernel
|
||||
|
||||
typedef struct psinfo {
|
||||
int pr_nlwp; /* number of threads */
|
||||
pid_t pr_pid; /* unique process id */
|
||||
|
@ -28,8 +28,6 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)regs.d.in 1.1 04/09/28 SMI"
|
||||
|
||||
inline int R_GS = 0;
|
||||
#pragma D binding "1.0" R_GS
|
||||
inline int R_FS = 1;
|
||||
|
@ -27,9 +27,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#pragma D depends_on module unix
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on provider sched
|
||||
|
||||
struct cpuinfo {
|
||||
|
@ -21,6 +21,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on module siftr
|
||||
#pragma D depends_on provider tcp
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#pragma D depends_on library ip.d
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on provider tcp
|
||||
|
||||
/*
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#pragma D depends_on library ip.d
|
||||
#pragma D depends_on module kernel
|
||||
#pragma D depends_on provider udp
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include <src.opts.mk>
|
||||
|
||||
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/dtrace
|
||||
|
||||
PROG= dtrace
|
||||
@ -22,4 +24,8 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
|
||||
|
||||
LIBADD= dtrace
|
||||
|
||||
.if ${MK_DTRACE_TESTS} != "no"
|
||||
SUBDIR+= tests
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -151,7 +151,7 @@ int
|
||||
op_ip(struct snmp_context *ctx, struct snmp_value *value,
|
||||
u_int sub, u_int idx __unused, enum snmp_op op)
|
||||
{
|
||||
int old;
|
||||
int old = 0;
|
||||
|
||||
switch (op) {
|
||||
|
||||
|
35
contrib/elftoolchain/ar/Makefile
Normal file
35
contrib/elftoolchain/ar/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
# $Id: Makefile 3107 2014-12-20 08:31:58Z kaiwang27 $
|
||||
|
||||
TOP= ..
|
||||
|
||||
PROG= ar
|
||||
SRCS= ar.c read.c util.c write.c
|
||||
LSRC= acplex.l
|
||||
YSRC= acpyacc.y
|
||||
|
||||
WARNS?= 5
|
||||
|
||||
DPADD= ${LIBARCHIVE} ${LIBELFTC} ${LIBELF} ${LIBZ}
|
||||
LDADD= -larchive -lelftc -lelf -lz
|
||||
|
||||
CFLAGS+=-I. -I${.CURDIR}
|
||||
|
||||
LINKS= ${BINDIR}/ar ${BINDIR}/ranlib
|
||||
|
||||
EXTRA_TARGETS= ranlib
|
||||
|
||||
CLEANFILES+= ${EXTRA_TARGETS}
|
||||
|
||||
MAN= ar.1 ranlib.1 ar.5
|
||||
|
||||
all: ${EXTRA_TARGETS}
|
||||
|
||||
${EXTRA_TARGETS}: ${PROG}
|
||||
ln -s ${PROG} ${.TARGET}
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.prog.mk"
|
||||
|
||||
.if ${OS_HOST} == "OpenBSD"
|
||||
CFLAGS+= -I/usr/local/include
|
||||
LDFLAGS+= -L/usr/local/lib
|
||||
.endif
|
83
contrib/elftoolchain/ar/acplex.l
Normal file
83
contrib/elftoolchain/ar/acplex.l
Normal file
@ -0,0 +1,83 @@
|
||||
%{
|
||||
/*-
|
||||
* Copyright (c) 2008 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: acplex.l 3174 2015-03-27 17:13:41Z emaste $");
|
||||
|
||||
#include "acpyacc.h"
|
||||
|
||||
#define YY_NO_UNPUT
|
||||
#if !defined(ELFTC_BROKEN_YY_NO_INPUT)
|
||||
#define YY_NO_INPUT
|
||||
#endif
|
||||
|
||||
int lineno = 1;
|
||||
|
||||
int yylex(void);
|
||||
|
||||
%}
|
||||
|
||||
%option nounput
|
||||
%option noyywrap
|
||||
|
||||
%%
|
||||
|
||||
ADDLIB|addlib { return (ADDLIB); }
|
||||
ADDMOD|addmod { return (ADDMOD); }
|
||||
CLEAR|clear { return (CLEAR); }
|
||||
CREATE|create { return (CREATE); }
|
||||
DELETE|delete { return (DELETE); }
|
||||
DIRECTORY|directory { return (DIRECTORY); }
|
||||
END|end { return (END); }
|
||||
EXTRACT|extract { return (EXTRACT); }
|
||||
LIST|list { return (LIST); }
|
||||
OPEN|open { return (OPEN); }
|
||||
REPLACE|replace { return (REPLACE); }
|
||||
VERBOSE|verbose { return (VERBOSE); }
|
||||
SAVE|save { return (SAVE); }
|
||||
"(" { return (LP); }
|
||||
")" { return (RP); }
|
||||
"," { return (COMMA); }
|
||||
|
||||
[-_A-Za-z0-9/:$.\\]+ {
|
||||
yylval.str = strdup(yytext);
|
||||
if (yylval.str == NULL)
|
||||
err(EXIT_FAILURE, "strdup failed");
|
||||
return (FNAME);
|
||||
}
|
||||
|
||||
[ \t] /* whitespace */
|
||||
"*".* /* comment */
|
||||
";".* /* comment */
|
||||
"+\n" { lineno++; /* '+' is line continuation char */ }
|
||||
"\n" { lineno++; return (EOL); }
|
658
contrib/elftoolchain/ar/acpyacc.y
Normal file
658
contrib/elftoolchain/ar/acpyacc.y
Normal file
@ -0,0 +1,658 @@
|
||||
%{
|
||||
/*-
|
||||
* Copyright (c) 2008 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libelftc.h"
|
||||
|
||||
#include "ar.h"
|
||||
|
||||
ELFTC_VCSID("$Id");
|
||||
|
||||
|
||||
#define TEMPLATE "arscp.XXXXXXXX"
|
||||
|
||||
struct list {
|
||||
char *str;
|
||||
struct list *next;
|
||||
};
|
||||
|
||||
|
||||
extern int yylex(void);
|
||||
extern int yyparse(void);
|
||||
|
||||
static void yyerror(const char *);
|
||||
static void arscp_addlib(char *archive, struct list *list);
|
||||
static void arscp_addmod(struct list *list);
|
||||
static void arscp_clear(void);
|
||||
static void arscp_create(char *in, char *out);
|
||||
static void arscp_delete(struct list *list);
|
||||
static void arscp_dir(char *archive, struct list *list, char *rlt);
|
||||
static void arscp_end(int eval);
|
||||
static void arscp_extract(struct list *list);
|
||||
static void arscp_free_argv(void);
|
||||
static void arscp_free_mlist(struct list *list);
|
||||
static void arscp_list(void);
|
||||
static struct list *arscp_mlist(struct list *list, char *str);
|
||||
static void arscp_mlist2argv(struct list *list);
|
||||
static int arscp_mlist_len(struct list *list);
|
||||
static void arscp_open(char *fname);
|
||||
static void arscp_prompt(void);
|
||||
static void arscp_replace(struct list *list);
|
||||
static void arscp_save(void);
|
||||
static int arscp_target_exist(void);
|
||||
|
||||
extern int lineno;
|
||||
|
||||
static struct bsdar *bsdar;
|
||||
static char *target;
|
||||
static char *tmpac;
|
||||
static int interactive;
|
||||
static int verbose;
|
||||
|
||||
%}
|
||||
|
||||
%token ADDLIB
|
||||
%token ADDMOD
|
||||
%token CLEAR
|
||||
%token CREATE
|
||||
%token DELETE
|
||||
%token DIRECTORY
|
||||
%token END
|
||||
%token EXTRACT
|
||||
%token LIST
|
||||
%token OPEN
|
||||
%token REPLACE
|
||||
%token VERBOSE
|
||||
%token SAVE
|
||||
%token LP
|
||||
%token RP
|
||||
%token COMMA
|
||||
%token EOL
|
||||
%token <str> FNAME
|
||||
%type <list> mod_list
|
||||
|
||||
%union {
|
||||
char *str;
|
||||
struct list *list;
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
begin
|
||||
: { arscp_prompt(); } ar_script
|
||||
;
|
||||
|
||||
ar_script
|
||||
: cmd_list
|
||||
|
|
||||
;
|
||||
|
||||
mod_list
|
||||
: FNAME { $$ = arscp_mlist(NULL, $1); }
|
||||
| mod_list separator FNAME { $$ = arscp_mlist($1, $3); }
|
||||
;
|
||||
|
||||
separator
|
||||
: COMMA
|
||||
|
|
||||
;
|
||||
|
||||
cmd_list
|
||||
: rawcmd
|
||||
| cmd_list rawcmd
|
||||
;
|
||||
|
||||
rawcmd
|
||||
: cmd EOL { arscp_prompt(); }
|
||||
;
|
||||
|
||||
cmd
|
||||
: addlib_cmd
|
||||
| addmod_cmd
|
||||
| clear_cmd
|
||||
| create_cmd
|
||||
| delete_cmd
|
||||
| directory_cmd
|
||||
| end_cmd
|
||||
| extract_cmd
|
||||
| list_cmd
|
||||
| open_cmd
|
||||
| replace_cmd
|
||||
| verbose_cmd
|
||||
| save_cmd
|
||||
| invalid_cmd
|
||||
| empty_cmd
|
||||
| error
|
||||
;
|
||||
|
||||
addlib_cmd
|
||||
: ADDLIB FNAME LP mod_list RP { arscp_addlib($2, $4); }
|
||||
| ADDLIB FNAME { arscp_addlib($2, NULL); }
|
||||
;
|
||||
|
||||
addmod_cmd
|
||||
: ADDMOD mod_list { arscp_addmod($2); }
|
||||
;
|
||||
|
||||
clear_cmd
|
||||
: CLEAR { arscp_clear(); }
|
||||
;
|
||||
|
||||
create_cmd
|
||||
: CREATE FNAME { arscp_create(NULL, $2); }
|
||||
;
|
||||
|
||||
delete_cmd
|
||||
: DELETE mod_list { arscp_delete($2); }
|
||||
;
|
||||
|
||||
directory_cmd
|
||||
: DIRECTORY FNAME { arscp_dir($2, NULL, NULL); }
|
||||
| DIRECTORY FNAME LP mod_list RP { arscp_dir($2, $4, NULL); }
|
||||
| DIRECTORY FNAME LP mod_list RP FNAME { arscp_dir($2, $4, $6); }
|
||||
;
|
||||
|
||||
end_cmd
|
||||
: END { arscp_end(EXIT_SUCCESS); }
|
||||
;
|
||||
|
||||
extract_cmd
|
||||
: EXTRACT mod_list { arscp_extract($2); }
|
||||
;
|
||||
|
||||
list_cmd
|
||||
: LIST { arscp_list(); }
|
||||
;
|
||||
|
||||
open_cmd
|
||||
: OPEN FNAME { arscp_open($2); }
|
||||
;
|
||||
|
||||
replace_cmd
|
||||
: REPLACE mod_list { arscp_replace($2); }
|
||||
;
|
||||
|
||||
save_cmd
|
||||
: SAVE { arscp_save(); }
|
||||
;
|
||||
|
||||
verbose_cmd
|
||||
: VERBOSE { verbose = !verbose; }
|
||||
;
|
||||
|
||||
empty_cmd
|
||||
:
|
||||
;
|
||||
|
||||
invalid_cmd
|
||||
: FNAME { yyerror(NULL); }
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
yyerror(const char *s)
|
||||
{
|
||||
|
||||
(void) s;
|
||||
printf("Syntax error in archive script, line %d\n", lineno);
|
||||
}
|
||||
|
||||
/*
|
||||
* The arscp_open() function will first open an archive and check its
|
||||
* validity. If the archive format is valid, it will call
|
||||
* arscp_create() to create a temporary copy of the archive.
|
||||
*/
|
||||
static void
|
||||
arscp_open(char *fname)
|
||||
{
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
int r;
|
||||
|
||||
if ((a = archive_read_new()) == NULL)
|
||||
bsdar_errc(bsdar, 0, "archive_read_new failed");
|
||||
archive_read_support_format_ar(a);
|
||||
AC(archive_read_open_filename(a, fname, DEF_BLKSZ));
|
||||
if ((r = archive_read_next_header(a, &entry)))
|
||||
bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
|
||||
AC(archive_read_close(a));
|
||||
ACV(archive_read_free(a));
|
||||
if (r != ARCHIVE_OK)
|
||||
return;
|
||||
arscp_create(fname, fname);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an archive.
|
||||
*
|
||||
* If the parameter 'in' is NULL (the 'CREATE' command), a new empty
|
||||
* archive will be created. If the parameter 'in' is not NULL (the
|
||||
* 'OPEN' command), the resulting archive will be a modified version
|
||||
* of the existing archive.
|
||||
*/
|
||||
static void
|
||||
arscp_create(char *in, char *out)
|
||||
{
|
||||
struct archive *a;
|
||||
int ifd, ofd;
|
||||
|
||||
/* Delete the previously created temporary archive, if any. */
|
||||
if (tmpac) {
|
||||
if (unlink(tmpac) < 0)
|
||||
bsdar_errc(bsdar, errno, "unlink failed");
|
||||
free(tmpac);
|
||||
}
|
||||
|
||||
tmpac = strdup(TEMPLATE);
|
||||
if (tmpac == NULL)
|
||||
bsdar_errc(bsdar, errno, "strdup failed");
|
||||
if ((ofd = mkstemp(tmpac)) < 0)
|
||||
bsdar_errc(bsdar, errno, "mkstemp failed");
|
||||
|
||||
if (in) {
|
||||
/*
|
||||
* The 'OPEN' command creates a temporary copy of the
|
||||
* input archive.
|
||||
*/
|
||||
if ((ifd = open(in, O_RDONLY)) < 0 ||
|
||||
elftc_copyfile(ifd, ofd) < 0) {
|
||||
bsdar_warnc(bsdar, errno, "'OPEN' failed");
|
||||
(void) close(ofd);
|
||||
if (ifd != -1)
|
||||
(void) close(ifd);
|
||||
return;
|
||||
}
|
||||
(void) close(ifd);
|
||||
(void) close(ofd);
|
||||
} else {
|
||||
/*
|
||||
* The 'CREATE' command creates an "empty" archive (an
|
||||
* archive consisting only of the archive header).
|
||||
*/
|
||||
if ((a = archive_write_new()) == NULL)
|
||||
bsdar_errc(bsdar, 0, "archive_write_new failed");
|
||||
archive_write_set_format_ar_svr4(a);
|
||||
AC(archive_write_open_fd(a, ofd));
|
||||
AC(archive_write_close(a));
|
||||
ACV(archive_write_free(a));
|
||||
}
|
||||
|
||||
/* Override the previous target, if any. */
|
||||
if (target)
|
||||
free(target);
|
||||
|
||||
target = out;
|
||||
bsdar->filename = tmpac;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add all modules of an archive to the current archive. If the
|
||||
* parameter 'list' is not NULL, only those modules specified by
|
||||
* 'list' will be added.
|
||||
*/
|
||||
static void
|
||||
arscp_addlib(char *archive, struct list *list)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
arscp_mlist2argv(list);
|
||||
bsdar->addlib = archive;
|
||||
ar_write_archive(bsdar, 'A');
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add modules to the current archive.
|
||||
*/
|
||||
static void
|
||||
arscp_addmod(struct list *list)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
arscp_mlist2argv(list);
|
||||
ar_write_archive(bsdar, 'q');
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete modules from the current archive.
|
||||
*/
|
||||
static void
|
||||
arscp_delete(struct list *list)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
arscp_mlist2argv(list);
|
||||
ar_write_archive(bsdar, 'd');
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract modules from the current archive.
|
||||
*/
|
||||
static void
|
||||
arscp_extract(struct list *list)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
arscp_mlist2argv(list);
|
||||
ar_read_archive(bsdar, 'x');
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
/*
|
||||
* List the contents of an archive (simple mode).
|
||||
*/
|
||||
static void
|
||||
arscp_list(void)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
bsdar->argc = 0;
|
||||
bsdar->argv = NULL;
|
||||
/* Always verbose. */
|
||||
bsdar->options |= AR_V;
|
||||
ar_read_archive(bsdar, 't');
|
||||
bsdar->options &= ~AR_V;
|
||||
}
|
||||
|
||||
/*
|
||||
* List the contents of an archive (advanced mode).
|
||||
*/
|
||||
static void
|
||||
arscp_dir(char *archive, struct list *list, char *rlt)
|
||||
{
|
||||
FILE *out;
|
||||
|
||||
/* If rlt != NULL, redirect the output to it. */
|
||||
out = NULL;
|
||||
if (rlt) {
|
||||
out = bsdar->output;
|
||||
if ((bsdar->output = fopen(rlt, "w")) == NULL)
|
||||
bsdar_errc(bsdar, errno, "fopen %s failed", rlt);
|
||||
}
|
||||
|
||||
bsdar->filename = archive;
|
||||
if (list)
|
||||
arscp_mlist2argv(list);
|
||||
else {
|
||||
bsdar->argc = 0;
|
||||
bsdar->argv = NULL;
|
||||
}
|
||||
if (verbose)
|
||||
bsdar->options |= AR_V;
|
||||
ar_read_archive(bsdar, 't');
|
||||
bsdar->options &= ~AR_V;
|
||||
|
||||
if (rlt) {
|
||||
if (fclose(bsdar->output) == EOF)
|
||||
bsdar_errc(bsdar, errno, "fclose %s failed", rlt);
|
||||
bsdar->output = out;
|
||||
free(rlt);
|
||||
}
|
||||
free(archive);
|
||||
bsdar->filename = tmpac;
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Replace modules in the current archive.
|
||||
*/
|
||||
static void
|
||||
arscp_replace(struct list *list)
|
||||
{
|
||||
|
||||
if (!arscp_target_exist())
|
||||
return;
|
||||
arscp_mlist2argv(list);
|
||||
ar_write_archive(bsdar, 'r');
|
||||
arscp_free_argv();
|
||||
arscp_free_mlist(list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename the temporary archive to the target archive.
|
||||
*/
|
||||
static void
|
||||
arscp_save(void)
|
||||
{
|
||||
mode_t mask;
|
||||
|
||||
if (target) {
|
||||
if (rename(tmpac, target) < 0)
|
||||
bsdar_errc(bsdar, errno, "rename failed");
|
||||
/*
|
||||
* Because mkstemp() creates temporary files with mode
|
||||
* 0600, we set target archive's mode as per the
|
||||
* process umask.
|
||||
*/
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
if (chmod(target, 0666 & ~mask) < 0)
|
||||
bsdar_errc(bsdar, errno, "chmod failed");
|
||||
free(tmpac);
|
||||
free(target);
|
||||
tmpac = NULL;
|
||||
target= NULL;
|
||||
bsdar->filename = NULL;
|
||||
} else
|
||||
bsdar_warnc(bsdar, 0, "no open output archive");
|
||||
}
|
||||
|
||||
/*
|
||||
* Discard the contents of the current archive. This is achieved by
|
||||
* invoking the 'CREATE' cmd on the current archive.
|
||||
*/
|
||||
static void
|
||||
arscp_clear(void)
|
||||
{
|
||||
char *new_target;
|
||||
|
||||
if (target) {
|
||||
new_target = strdup(target);
|
||||
if (new_target == NULL)
|
||||
bsdar_errc(bsdar, errno, "strdup failed");
|
||||
arscp_create(NULL, new_target);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Quit ar(1). Note that the 'END' cmd will not 'SAVE' the current
|
||||
* archive before exiting.
|
||||
*/
|
||||
static void
|
||||
arscp_end(int eval)
|
||||
{
|
||||
|
||||
if (target)
|
||||
free(target);
|
||||
if (tmpac) {
|
||||
if (unlink(tmpac) == -1)
|
||||
bsdar_errc(bsdar, errno, "unlink %s failed", tmpac);
|
||||
free(tmpac);
|
||||
}
|
||||
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if a target was specified, i.e, whether an 'OPEN' or 'CREATE'
|
||||
* had been issued by the user.
|
||||
*/
|
||||
static int
|
||||
arscp_target_exist(void)
|
||||
{
|
||||
|
||||
if (target)
|
||||
return (1);
|
||||
|
||||
bsdar_warnc(bsdar, 0, "no open output archive");
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct the list of modules.
|
||||
*/
|
||||
static struct list *
|
||||
arscp_mlist(struct list *list, char *str)
|
||||
{
|
||||
struct list *l;
|
||||
|
||||
l = malloc(sizeof(*l));
|
||||
if (l == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
l->str = str;
|
||||
l->next = list;
|
||||
|
||||
return (l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the length of an mlist.
|
||||
*/
|
||||
static int
|
||||
arscp_mlist_len(struct list *list)
|
||||
{
|
||||
int len;
|
||||
|
||||
for(len = 0; list; list = list->next)
|
||||
len++;
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the space allocated for a module list.
|
||||
*/
|
||||
static void
|
||||
arscp_free_mlist(struct list *list)
|
||||
{
|
||||
struct list *l;
|
||||
|
||||
/* Note: list->str was freed in arscp_free_argv(). */
|
||||
for(; list; list = l) {
|
||||
l = list->next;
|
||||
free(list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a module list to an 'argv' array.
|
||||
*/
|
||||
static void
|
||||
arscp_mlist2argv(struct list *list)
|
||||
{
|
||||
char **argv;
|
||||
int i, n;
|
||||
|
||||
n = arscp_mlist_len(list);
|
||||
argv = malloc(n * sizeof(*argv));
|
||||
if (argv == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
|
||||
/* Note that module names are stored in reverse order. */
|
||||
for(i = n - 1; i >= 0; i--, list = list->next) {
|
||||
if (list == NULL)
|
||||
bsdar_errc(bsdar, errno, "invalid mlist");
|
||||
argv[i] = list->str;
|
||||
}
|
||||
|
||||
bsdar->argc = n;
|
||||
bsdar->argv = argv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the space allocated for an argv array and its elements.
|
||||
*/
|
||||
static void
|
||||
arscp_free_argv(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < bsdar->argc; i++)
|
||||
free(bsdar->argv[i]);
|
||||
|
||||
free(bsdar->argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Show a prompt if we are in interactive mode.
|
||||
*/
|
||||
static void
|
||||
arscp_prompt(void)
|
||||
{
|
||||
|
||||
if (interactive) {
|
||||
printf("AR >");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The main function implementing script mode.
|
||||
*/
|
||||
void
|
||||
ar_mode_script(struct bsdar *ar)
|
||||
{
|
||||
|
||||
bsdar = ar;
|
||||
interactive = isatty(fileno(stdin));
|
||||
while(yyparse()) {
|
||||
if (!interactive)
|
||||
arscp_end(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Script ends without END */
|
||||
arscp_end(EXIT_SUCCESS);
|
||||
}
|
603
contrib/elftoolchain/ar/ar.1
Normal file
603
contrib/elftoolchain/ar/ar.1
Normal file
@ -0,0 +1,603 @@
|
||||
.\" Copyright (c) 2007,2009-2012 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: ar.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd December 10, 2012
|
||||
.Os
|
||||
.Dt AR 1
|
||||
.Sh NAME
|
||||
.Nm ar
|
||||
.Nd manage archives
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Fl d
|
||||
.Op Fl T
|
||||
.Op Fl f
|
||||
.Op Fl j
|
||||
.Op Fl v
|
||||
.Op Fl z
|
||||
.Ar archive
|
||||
.Ar
|
||||
.Nm
|
||||
.Fl m
|
||||
.Op Fl T
|
||||
.Op Fl a Ar position-after
|
||||
.Op Fl b Ar position-before
|
||||
.Op Fl f
|
||||
.Op Fl i Ar position-before
|
||||
.Op Fl j
|
||||
.Op Fl s | Fl S
|
||||
.Op Fl z
|
||||
.Ar archive
|
||||
.Ar
|
||||
.Nm
|
||||
.Fl p
|
||||
.Op Fl T
|
||||
.Op Fl f
|
||||
.Op Fl v
|
||||
.Ar archive
|
||||
.Op Ar
|
||||
.Nm
|
||||
.Fl q
|
||||
.Op Fl T
|
||||
.Op Fl c
|
||||
.Op Fl D
|
||||
.Op Fl f
|
||||
.Op Fl F Ar flavor | Fl -flavor Ar flavor
|
||||
.Op Fl s | Fl S
|
||||
.Op Fl v
|
||||
.Op Fl z
|
||||
.Ar archive
|
||||
.Ar
|
||||
.Nm
|
||||
.Fl r
|
||||
.Op Fl T
|
||||
.Op Fl a Ar position-after
|
||||
.Op Fl b Ar position-before
|
||||
.Op Fl c
|
||||
.Op Fl D
|
||||
.Op Fl f
|
||||
.Op Fl F Ar flavor | Fl -flavor Ar flavor
|
||||
.Op Fl i Ar position-before
|
||||
.Op Fl j
|
||||
.Op Fl s | Fl S
|
||||
.Op Fl u
|
||||
.Op Fl v
|
||||
.Op Fl z
|
||||
.Ar archive
|
||||
.Ar
|
||||
.Nm
|
||||
.Fl s
|
||||
.Op Fl D
|
||||
.Op Fl j
|
||||
.Op Fl z
|
||||
.Ar archive
|
||||
.Nm
|
||||
.Fl t
|
||||
.Op Fl f
|
||||
.Op Fl T
|
||||
.Op Fl v
|
||||
.Ar archive
|
||||
.Op Ar
|
||||
.Nm
|
||||
.Fl x
|
||||
.Op Fl C
|
||||
.Op Fl T
|
||||
.Op Fl f
|
||||
.Op Fl o
|
||||
.Op Fl u
|
||||
.Op Fl v
|
||||
.Ar archive
|
||||
.Op Ar
|
||||
.Nm
|
||||
.Fl M
|
||||
.Nm
|
||||
.Fl V
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility creates and maintains groups of files combined into an
|
||||
archive.
|
||||
Once an archive has been created, new files can be added to it, and
|
||||
existing files can be extracted, deleted or replaced.
|
||||
.Pp
|
||||
Files are named in the archive by their last file name component,
|
||||
so if a file referenced by a path containing a
|
||||
.Dq /
|
||||
is archived, it will be named by the last component of the path.
|
||||
Similarly when matching paths listed on the command line against
|
||||
file names stored in the archive, only the last component of the
|
||||
path will be compared.
|
||||
.Pp
|
||||
The normal use of
|
||||
.Nm
|
||||
is for the creation and maintenance of libraries suitable for use
|
||||
with the link editor
|
||||
.Xr ld 1 ,
|
||||
although it is not restricted to this purpose.
|
||||
The
|
||||
.Nm
|
||||
utility can create and manage an archive symbol table (see
|
||||
.Xr ar 5 )
|
||||
used to speed up link editing operations.
|
||||
If a symbol table is present in an archive, it will be
|
||||
kept up-to-date by subsequent operations on the archive.
|
||||
.Sh OPTIONS
|
||||
The
|
||||
.Nm
|
||||
utility supports the following options:
|
||||
.Bl -tag -width indent
|
||||
.It Fl a Ar member-after
|
||||
When used with option
|
||||
.Fl m
|
||||
this option specifies that the archive members specified by
|
||||
arguments
|
||||
.Ar
|
||||
are moved to after the archive member named by argument
|
||||
.Ar member-after .
|
||||
When used with option
|
||||
.Fl r
|
||||
this option specifies that the files specified by arguments
|
||||
.Ar
|
||||
are added after the archive member named by argument
|
||||
.Ar member-after .
|
||||
.It Fl b Ar member-before
|
||||
When used with option
|
||||
.Fl m
|
||||
this option specifies that the archive members specified by
|
||||
arguments
|
||||
.Ar
|
||||
are moved to before the archive member named by argument
|
||||
.Ar member-before .
|
||||
When used with option
|
||||
.Fl r
|
||||
this option specifies that the files specified by arguments
|
||||
.Ar
|
||||
are added before the archive member named by argument
|
||||
.Ar member-before .
|
||||
.It Fl c
|
||||
Suppress the informational message printed when a new archive is
|
||||
created using the
|
||||
.Fl r
|
||||
and
|
||||
.Fl q
|
||||
options.
|
||||
.It Fl C
|
||||
Prevent extracted files from replacing like-named files
|
||||
in the file system.
|
||||
.It Fl d
|
||||
Delete the members named by arguments
|
||||
.Ar
|
||||
from the archive specified by argument
|
||||
.Ar archive .
|
||||
The archive's symbol table, if present, is updated to reflect
|
||||
the new contents of the archive.
|
||||
.It Fl D
|
||||
When used in combination with the
|
||||
.Fl r
|
||||
or
|
||||
.Fl q
|
||||
option, insert 0's instead of the real mtime, uid and gid values
|
||||
and 0644 instead of file mode from the members named by arguments
|
||||
.Ar .
|
||||
This ensures that checksums on the resulting archives are reproducible
|
||||
when member contents are identical.
|
||||
.It Fl f
|
||||
Synonymous with option
|
||||
.Fl T .
|
||||
.It Fl F Ar flavor | Fl -flavor Ar flavor
|
||||
Create archives with the specified archive format.
|
||||
Legal values for argument
|
||||
.Ar flavor
|
||||
are:
|
||||
.Bl -tag -width indent -compact
|
||||
.It Ar bsd
|
||||
Create BSD format archives.
|
||||
.It Ar gnu
|
||||
An alias for
|
||||
.Ar svr4 .
|
||||
.It Ar svr4
|
||||
Create SVR4 format archives.
|
||||
.El
|
||||
If this option is not specified,
|
||||
.Nm
|
||||
will create archives using the SVR4 format.
|
||||
.It Fl i Ar member-before
|
||||
Synonymous with option
|
||||
.Fl b .
|
||||
.It Fl j
|
||||
This option is accepted for compatibility with the
|
||||
.Tn FreeBSD
|
||||
version of the
|
||||
.Nm
|
||||
utility, but is ignored.
|
||||
.It Fl l
|
||||
This option is accepted for compatibility with GNU
|
||||
.Xr ar 1 ,
|
||||
but is ignored.
|
||||
.It Fl m
|
||||
Move archive members specified by arguments
|
||||
.Ar
|
||||
within the archive.
|
||||
If a position has been specified by one of the
|
||||
.Fl a ,
|
||||
.Fl b
|
||||
or
|
||||
.Fl i
|
||||
options, the members are moved to before or after the specified
|
||||
position.
|
||||
If no position has been specified, the specified members are moved
|
||||
to the end of the archive.
|
||||
If the archive has a symbol table, it is updated to reflect the
|
||||
new contents of the archive.
|
||||
.It Fl M
|
||||
Read and execute MRI librarian commands from standard input.
|
||||
The commands understood by the
|
||||
.Nm
|
||||
utility are described in the section
|
||||
.Sx "MRI Librarian Commands" .
|
||||
.It Fl o
|
||||
Preserve the original modification times of members when extracting
|
||||
them.
|
||||
.It Fl p
|
||||
Write the contents of the specified archive members named by
|
||||
arguments
|
||||
.Ar
|
||||
to standard output.
|
||||
If no members were specified, the contents of all the files in the
|
||||
archive are written in the order they appear in the archive.
|
||||
.It Fl q
|
||||
Append the files specified by arguments
|
||||
.Ar
|
||||
to the archive specified by argument
|
||||
.Ar archive
|
||||
without checking if the files already exist in the archive.
|
||||
The archive symbol table will be updated as needed.
|
||||
If the file specified by the argument
|
||||
.Ar archive
|
||||
does not already exist, a new archive will be created.
|
||||
.It Fl r
|
||||
Replace (add) the files specified by arguments
|
||||
.Ar
|
||||
in the archive specified by argument
|
||||
.Ar archive ,
|
||||
creating the archive if necessary.
|
||||
Replacing existing members will not change the order of members within
|
||||
the archive.
|
||||
If a file named in arguments
|
||||
.Ar
|
||||
does not exist, existing members in the archive that match that
|
||||
name are not changed.
|
||||
New files are added to the end of the archive unless one of the
|
||||
positioning options
|
||||
.Fl a ,
|
||||
.Fl b
|
||||
or
|
||||
.Fl i
|
||||
is specified.
|
||||
The archive symbol table, if it exists, is updated to reflect the
|
||||
new state of the archive.
|
||||
.It Fl s
|
||||
Add an archive symbol table (see
|
||||
.Xr ar 5 )
|
||||
to the archive specified by argument
|
||||
.Ar archive .
|
||||
Invoking
|
||||
.Nm
|
||||
with the
|
||||
.Fl s
|
||||
option alone is equivalent to invoking
|
||||
.Xr ranlib 1 .
|
||||
.It Fl S
|
||||
Do not generate an archive symbol table.
|
||||
.It Fl t
|
||||
For
|
||||
.Nm ,
|
||||
list the files specified by arguments
|
||||
.Ar
|
||||
in the order in which they appear in the archive, one per line.
|
||||
If no files are specified, all files in the archive are listed.
|
||||
.It Fl T
|
||||
Use only the first fifteen characters of the archive member name or
|
||||
command line file name argument when naming archive members.
|
||||
.It Fl u
|
||||
Conditionally update the archive or extract members.
|
||||
When used with the
|
||||
.Fl r
|
||||
option, files named by arguments
|
||||
.Ar
|
||||
will be replaced in the archive if they are newer than their
|
||||
archived versions.
|
||||
When used with the
|
||||
.Fl x
|
||||
option, the members specified by arguments
|
||||
.Ar
|
||||
will be extracted only if they are newer than the corresponding
|
||||
files in the file system.
|
||||
.It Fl v
|
||||
Provide verbose output.
|
||||
When used with the
|
||||
.Fl d ,
|
||||
.Fl m ,
|
||||
.Fl q
|
||||
or
|
||||
.Fl x
|
||||
options,
|
||||
.Nm
|
||||
gives a file-by-file description of the archive modification being
|
||||
performed, which consists of three white-space separated fields:
|
||||
the option letter, a dash
|
||||
.Dq "-" ,
|
||||
and the file name.
|
||||
When used with the
|
||||
.Fl r
|
||||
option,
|
||||
.Nm
|
||||
displays the description as above, but the initial letter is an
|
||||
.Dq a
|
||||
if the file is added to the archive, or an
|
||||
.Dq r
|
||||
if the file replaces a file already in the archive.
|
||||
When used with the
|
||||
.Fl p
|
||||
option, the name of the file enclosed in
|
||||
.Dq <
|
||||
and
|
||||
.Dq >
|
||||
characters is written to standard output preceded by a single newline
|
||||
character and followed by two newline characters.
|
||||
The contents of the named file follow the file name.
|
||||
When used with the
|
||||
.Fl t
|
||||
option,
|
||||
.Nm
|
||||
displays eight whitespace separated fields:
|
||||
the file permissions as displayed by
|
||||
.Xr strmode 3 ,
|
||||
decimal user and group IDs separated by a slash (
|
||||
.Dq / Ns ) ,
|
||||
the file size in bytes, the file modification time in
|
||||
.Xr strftime 3
|
||||
format
|
||||
.Dq "%b %e %H:%M %Y" ,
|
||||
and the name of the file.
|
||||
.It Fl V
|
||||
Print a version identifier and exit.
|
||||
.It Fl x
|
||||
Extract archive members specified by arguments
|
||||
.Ar
|
||||
into the current directory.
|
||||
If no members have been specified, extract all members of the archive.
|
||||
If the file corresponding to an extracted member does not exist it
|
||||
will be created.
|
||||
If the file corresponding to an extracted member does exist, its owner
|
||||
and group will not be changed while its contents will be overwritten
|
||||
and its permissions will set to that entered in the archive.
|
||||
The file's access and modification time would be that of the time
|
||||
of extraction unless the
|
||||
.Fl o
|
||||
option was specified.
|
||||
.It Fl z
|
||||
This option is accepted for compatibility with the
|
||||
.Tn FreeBSD
|
||||
version of the
|
||||
.Nm
|
||||
utility, but is ignored.
|
||||
.El
|
||||
.Ss "MRI Librarian Commands"
|
||||
If the
|
||||
.Fl M
|
||||
option is specified, the
|
||||
.Nm
|
||||
utility will read and execute commands from its standard input.
|
||||
If standard input is a terminal, the
|
||||
.Nm
|
||||
utility will display the prompt
|
||||
.Dq Li "AR >"
|
||||
before reading a line, and will continue operation even if errors are
|
||||
encountered.
|
||||
If standard input is not a terminal, the
|
||||
.Nm
|
||||
utility will not display a prompt and will terminate execution on
|
||||
encountering an error.
|
||||
.Pp
|
||||
Each input line contains a single command.
|
||||
Words in an input line are separated by whitespace characters.
|
||||
The first word of the line is the command, the remaining words are
|
||||
the arguments to the command.
|
||||
The command word may be specified in either case.
|
||||
Arguments may be separated by commas or blanks.
|
||||
.Pp
|
||||
Empty lines are allowed and are ignored.
|
||||
Long lines are continued by ending them with the
|
||||
.Dq Li +
|
||||
character.
|
||||
.Pp
|
||||
The
|
||||
.Dq Li *
|
||||
and
|
||||
.Dq Li "\;"
|
||||
characters start a comment.
|
||||
Comments extend till the end of the line.
|
||||
.Pp
|
||||
When executing an MRI librarian script the
|
||||
.Nm
|
||||
utility works on a temporary copy of an archive.
|
||||
Changes to the copy are made permanent using the
|
||||
.Ic save
|
||||
command.
|
||||
.Pp
|
||||
Commands understood by the
|
||||
.Nm
|
||||
utility are:
|
||||
.Bl -tag -width indent
|
||||
.It Ic addlib Ar archive | Ic addlib Ar archive Pq Ar member Oo Li , Ar member Oc Ns ...
|
||||
Add the contents of the archive named by argument
|
||||
.Ar archive
|
||||
to the current archive.
|
||||
If specific members are named using the arguments
|
||||
.Ar member ,
|
||||
then those members are added to the current archive.
|
||||
If no members are specified, the entire contents of the archive
|
||||
are added to the current archive.
|
||||
.It Ic addmod Ar member Oo Li , Ar member Oc Ns ...
|
||||
Add the files named by arguments
|
||||
.Ar member
|
||||
to the current archive.
|
||||
.It Ic clear
|
||||
Discard all the contents of the current archive.
|
||||
.It Ic create Ar archive
|
||||
Create a new archive named by the argument
|
||||
.Ar archive ,
|
||||
and makes it the current archive.
|
||||
If the named archive already exists, it will be overwritten
|
||||
when the
|
||||
.Ic save
|
||||
command is issued.
|
||||
.It Ic delete Ar module Oo Li , Ar member Oc Ns ...
|
||||
Delete the modules named by the arguments
|
||||
.Ar member
|
||||
from the current archive.
|
||||
.It Ic directory Ar archive Po Ar member Oo Li , Ar member Oc Ns ... Pc Op Ar outputfile
|
||||
List each named module in the archive.
|
||||
The format of the output depends on the verbosity setting set using
|
||||
the
|
||||
.Ic verbose
|
||||
command.
|
||||
Output is sent to standard output, or to the file specified by
|
||||
argument
|
||||
.Ar outputfile .
|
||||
.It Ic end
|
||||
Exit successfully from the
|
||||
.Nm
|
||||
utility.
|
||||
Any unsaved changes to the current archive will be discarded.
|
||||
.It Ic extract Ar member Oo Li , Ar member Oc Ns ...
|
||||
Extract the members named by the arguments
|
||||
.Ar member
|
||||
from the current archive.
|
||||
.It Ic list
|
||||
Display the contents of the current archive in verbose style.
|
||||
.It Ic open Ar archive
|
||||
Open the archive named by argument
|
||||
.Ar archive
|
||||
and make it the current archive.
|
||||
.It Ic replace Ar member Oo Li , Ar member Oc Ns ...
|
||||
Replace named members in the current archive with the files specified
|
||||
by arguments
|
||||
.Ar member .
|
||||
The files must be present in the current directory and the named
|
||||
modules must already exist in the current archive.
|
||||
.It Ic save
|
||||
Commit all changes to the current archive.
|
||||
.It Ic verbose
|
||||
Toggle the verbosity of the
|
||||
.Ic directory
|
||||
command.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To create a new archive
|
||||
.Pa ex.a
|
||||
containing three files
|
||||
.Pa ex1.o ,
|
||||
.Pa ex2.o
|
||||
and
|
||||
.Pa ex3.o ,
|
||||
use:
|
||||
.Dl "ar -rc ex.a ex1.o ex2.o ex3.o"
|
||||
.Pp
|
||||
To add an archive symbol table to an existing archive
|
||||
.Pa ex.a ,
|
||||
use:
|
||||
.Dl "ar -s ex.a"
|
||||
.Pp
|
||||
To delete file
|
||||
.Pa ex1.o
|
||||
from archive
|
||||
.Pa ex.a ,
|
||||
use:
|
||||
.D1 "ar -d ex.a ex1.o"
|
||||
.Pp
|
||||
To verbosely list the contents of archive
|
||||
.Pa ex.a ,
|
||||
use:
|
||||
.D1 "ar -tv ex.a"
|
||||
.Pp
|
||||
To create a new archive
|
||||
.Pa ex.a
|
||||
containing the files
|
||||
.Pa ex1.o ,
|
||||
and
|
||||
.Pa ex2.o ,
|
||||
using MRI librarian commands, use the following script:
|
||||
.Bd -literal -offset indent
|
||||
create ex.a * specify the output archive
|
||||
addmod ex1.o ex2.o * add modules
|
||||
save * save pending changes
|
||||
end * exit the utility
|
||||
.Ed
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr ld 1 ,
|
||||
.Xr ranlib 1 ,
|
||||
.Xr archive 3 ,
|
||||
.Xr elf 3 ,
|
||||
.Xr strftime 3 ,
|
||||
.Xr strmode 3 ,
|
||||
.Xr ar 5
|
||||
.Sh STANDARDS COMPLIANCE
|
||||
The
|
||||
.Nm
|
||||
utility's support for the
|
||||
.Fl a ,
|
||||
.Fl b ,
|
||||
.Fl c ,
|
||||
.Fl i ,
|
||||
.Fl m ,
|
||||
.Fl p ,
|
||||
.Fl q ,
|
||||
.Fl r ,
|
||||
.Fl s ,
|
||||
.Fl t ,
|
||||
.Fl u ,
|
||||
.Fl v ,
|
||||
.Fl C
|
||||
and
|
||||
.Fl T
|
||||
options is believed to be compliant with
|
||||
.St -p1003.2 .
|
||||
.Sh HISTORY
|
||||
An
|
||||
.Nm
|
||||
command first appeared in AT&T UNIX Version 1.
|
||||
In
|
||||
.Fx 8.0 ,
|
||||
.An Kai Wang Aq Mt kaiw@FreeBSD.org
|
||||
reimplemented
|
||||
.Nm
|
||||
using the
|
||||
.Lb libarchive
|
||||
and the
|
||||
.Lb libelf .
|
327
contrib/elftoolchain/ar/ar.5
Normal file
327
contrib/elftoolchain/ar/ar.5
Normal file
@ -0,0 +1,327 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: ar.5 3182 2015-04-10 16:08:10Z emaste $
|
||||
.\"
|
||||
.Dd November 28, 2010
|
||||
.Os
|
||||
.Dt AR 5
|
||||
.Sh NAME
|
||||
.Nm ar
|
||||
.Nd archive file format for
|
||||
.Xr ar 1
|
||||
and
|
||||
.Xr ranlib 1
|
||||
.Sh SYNOPSIS
|
||||
.In ar.h
|
||||
.Sh DESCRIPTION
|
||||
.Xr ar 1
|
||||
archives are created and managed by the
|
||||
.Xr ar 1
|
||||
and
|
||||
.Xr ranlib 1
|
||||
utilities.
|
||||
These archives are typically used during program development to
|
||||
hold libraries of program objects.
|
||||
An
|
||||
.Xr ar 1
|
||||
archive is contained in a single operating system file.
|
||||
.Pp
|
||||
This manual page documents two variants of the
|
||||
.Xr ar 1
|
||||
archive format: the BSD archive format, and the SVR4/GNU archive
|
||||
format.
|
||||
.Pp
|
||||
In both variants the archive file starts with an identifying byte
|
||||
sequence of the seven ASCII characters
|
||||
.Sq Li "!<arch>"
|
||||
followed by a ASCII linefeed character
|
||||
.Po
|
||||
see the constant
|
||||
.Dq ARMAG
|
||||
in the header file
|
||||
.In ar.h
|
||||
.Pc .
|
||||
.Pp
|
||||
Archive members follow the initial identifying byte sequence.
|
||||
Each archive member is prefixed by a fixed size header describing the
|
||||
file attributes associated with the member.
|
||||
.Ss "Archive Headers"
|
||||
An archive header describes the file attributes for the archive member that
|
||||
follows it.
|
||||
The
|
||||
.Xr ar 5
|
||||
format only supports a limited number of attributes: the file name,
|
||||
the file creation time stamp, the uid and gid of the creator, the file
|
||||
mode and the file size.
|
||||
.Pp
|
||||
Archive headers are placed at an even byte offset in the archive file.
|
||||
If the data for an archive member ends at an odd byte offset, then a
|
||||
padding byte with value 0x0A is used to position the next archive
|
||||
header on an even byte offset.
|
||||
.Pp
|
||||
An archive header comprises the following fixed sized fields:
|
||||
.Bl -tag -width "Li ar_name"
|
||||
.It Ar ar_name
|
||||
(16 bytes) The file name of the archive member.
|
||||
The format of this field varies between the BSD and SVR4/GNU formats and
|
||||
is described in more detail in the section
|
||||
.Sx "Representing File Names"
|
||||
below.
|
||||
.It Ar ar_date
|
||||
(12 bytes) The file modification time for the member in seconds since the
|
||||
epoch, encoded as a decimal number.
|
||||
.It Ar ar_uid
|
||||
(6 bytes) The uid associated with the archive member, encoded as a
|
||||
decimal number.
|
||||
.It Ar ar_gid
|
||||
(6 bytes) The gid associated with the archive member, encoded as a
|
||||
decimal number.
|
||||
.It Ar ar_mode
|
||||
(8 bytes) The file mode for the archive member, encoded as an octal
|
||||
number.
|
||||
.It Ar ar_size
|
||||
(10 bytes) In the SVR4/GNU archive format this field holds the size in
|
||||
bytes of the archive member, encoded as a decimal number.
|
||||
In the BSD archive format, for short file names, this field
|
||||
holds the size in bytes of the archive member, encoded as a decimal
|
||||
number.
|
||||
For long file names
|
||||
.Po
|
||||
see
|
||||
.Sx "Representing File Names"
|
||||
below
|
||||
.Pc ,
|
||||
the field contains the combined size of the
|
||||
archive member and its file name, encoded as a decimal number.
|
||||
.It Ar ar_fmag
|
||||
(2 bytes) This field holds 2 bytes with values 0x96 and 0x0A
|
||||
respectively, marking the end of the header.
|
||||
.El
|
||||
.Pp
|
||||
Unused bytes in the fields of an archive header are set to the value
|
||||
0x20.
|
||||
.Ss "Representing File Names"
|
||||
The BSD and SVR4/GNU variants use different schemes for encoding file
|
||||
names for members.
|
||||
.Bl -tag -width "SVR4/GNU"
|
||||
.It "BSD"
|
||||
File names that are up to 16 bytes long and which do not contain
|
||||
embedded spaces are stored directly in the
|
||||
.Ar ar_name
|
||||
field of the archive header.
|
||||
File names that are either longer than 16 bytes or which contain
|
||||
embedded spaces are stored immediately after the archive header
|
||||
and the
|
||||
.Ar ar_name
|
||||
field of the archive header is set to the string
|
||||
.Dq "#1/"
|
||||
followed by a decimal representation of the number of bytes needed for
|
||||
the file name.
|
||||
In addition, the
|
||||
.Ar ar_size
|
||||
field of the archive header is set to the decimal representation of
|
||||
the combined sizes of the archive member and the file name.
|
||||
The file contents of the member follows the file name without further
|
||||
padding.
|
||||
.Pp
|
||||
As an example, if the file name for a member was
|
||||
.Dq "A B"
|
||||
and its contents was the string
|
||||
.Dq "C D" ,
|
||||
then the
|
||||
.Ar ar_name
|
||||
field of the header would contain
|
||||
.Dq Li "#1/3" ,
|
||||
the
|
||||
.Ar ar_size
|
||||
field of the header would contain
|
||||
.Dq Li 6 ,
|
||||
and the bytes immediately following the header would be 0x41, 0x20,
|
||||
0x42, 0x43, 0x20 and 0x44
|
||||
.Po
|
||||
ASCII
|
||||
.Dq "A BC D"
|
||||
.Pc .
|
||||
.It "SVR4/GNU"
|
||||
File names that are up to 15 characters long are stored directly in the
|
||||
.Ar ar_name
|
||||
field of the header, terminated by a
|
||||
.Dq Li /
|
||||
character.
|
||||
.Pp
|
||||
If the file name is larger than would fit in space for the
|
||||
.Ar ar_name
|
||||
field, then the actual file name is kept in the archive
|
||||
string table
|
||||
.Po
|
||||
see
|
||||
.Sx "Archive String Tables"
|
||||
below
|
||||
.Pc ,
|
||||
and the decimal offset of the file name in the string table is stored
|
||||
in the
|
||||
.Ar ar_name
|
||||
field, prefixed by a
|
||||
.Dq Li /
|
||||
character.
|
||||
.Pp
|
||||
As an example, if the real file name has been stored at offset 768 in
|
||||
the archive string table, the
|
||||
.Ar ar_name
|
||||
field of the header will contain the string
|
||||
.Dq /768 .
|
||||
.El
|
||||
.Ss "Special Archive Members"
|
||||
The following archive members are special.
|
||||
.Bl -tag -width indent
|
||||
.It Dq Li /
|
||||
In the SVR4/GNU variant of the archive format, the archive member with
|
||||
name
|
||||
.Dq Li /
|
||||
denotes an archive symbol table.
|
||||
If present, this member will be the very first member in the
|
||||
archive.
|
||||
.It Dq Li //
|
||||
In the SVR4/GNU variant of the archive format, the archive member with
|
||||
name
|
||||
.Dq Li //
|
||||
denotes the archive string table.
|
||||
This special member is used to hold filenames that do not fit in the
|
||||
file name field of the header
|
||||
.Po
|
||||
see
|
||||
.Sx "Representing File Names"
|
||||
above
|
||||
.Pc .
|
||||
If present, this member immediately follows the archive symbol table
|
||||
if an archive symbol table is present, or is the first member otherwise.
|
||||
.It Dq Li "__.SYMDEF"
|
||||
This special member contains the archive symbol table in the BSD
|
||||
variant of the archive format.
|
||||
If present, this member will be the very first member in the
|
||||
archive.
|
||||
.El
|
||||
.Ss "Archive String Tables"
|
||||
An archive string table is used in the SVR4/GNU archive format to hold
|
||||
file names that are too large to fit into the constraints of the
|
||||
.Ar ar_name
|
||||
field of the archive header.
|
||||
An archive string table contains a sequence of file names.
|
||||
Each file name in the archive string table is terminated by the
|
||||
byte sequence 0x2F, 0x0A
|
||||
.Po
|
||||
the ASCII string
|
||||
.Dq "/\en"
|
||||
.Pc .
|
||||
No padding is used to separate adjacent file names.
|
||||
.Ss "Archive Symbol Tables"
|
||||
Archive symbol tables are used to speed up link editing by providing a
|
||||
mapping between the program symbols defined in the archive
|
||||
and the corresponding archive members.
|
||||
Archive symbol tables are managed by the
|
||||
.Xr ranlib 1
|
||||
utility.
|
||||
.Pp
|
||||
The format of archive symbol tables is as follows:
|
||||
.Bl -tag -width "SVR4/GNU"
|
||||
.It BSD
|
||||
In the BSD archive format, the archive symbol table comprises
|
||||
of two parts: a part containing an array of
|
||||
.Vt "struct ranlib"
|
||||
descriptors, followed by a part containing a symbol string table.
|
||||
The sizes and layout of the structures that make up a BSD format
|
||||
archive symbol table are machine dependent.
|
||||
.Pp
|
||||
The part containing
|
||||
.Vt "struct ranlib"
|
||||
descriptors begins with a field containing the size in bytes of the
|
||||
array of
|
||||
.Vt "struct ranlib"
|
||||
descriptors encoded as a C
|
||||
.Vt long
|
||||
value.
|
||||
.Pp
|
||||
The array of
|
||||
.Vt "struct ranlib"
|
||||
descriptors follows the size field.
|
||||
Each
|
||||
.Vt "struct ranlib"
|
||||
descriptor describes one symbol.
|
||||
.Pp
|
||||
A
|
||||
.Vt "struct ranlib"
|
||||
descriptor comprises two fields:
|
||||
.Bl -tag -width "Ar ran_strx" -compact
|
||||
.It Ar ran_strx
|
||||
.Pq C Vt long
|
||||
This field contains the zero-based offset of the symbol name in the
|
||||
symbol string table.
|
||||
.It Ar ran_off
|
||||
.Pq C Vt long
|
||||
This field is the file offset to the archive header for the archive
|
||||
member defining the symbol.
|
||||
.El
|
||||
.Pp
|
||||
The part containing the symbol string table begins with a field
|
||||
containing the size in bytes of the string table, encoded as a C
|
||||
.Vt long
|
||||
value.
|
||||
This string table follows the size field, and contains
|
||||
NUL-terminated strings for the symbols in the symbol table.
|
||||
.It SVR4/GNU
|
||||
In the SVR4/GNU archive format, the archive symbol table starts with a
|
||||
4-byte binary value containing the number of entries contained in the
|
||||
archive symbol table.
|
||||
This count of entries is stored most significant byte first.
|
||||
.Pp
|
||||
Next, there are
|
||||
.Ar count
|
||||
4-byte numbers, each stored most significant byte first.
|
||||
Each number is a binary offset to the archive header for the member in
|
||||
the archive file for the corresponding symbol table entry.
|
||||
.Pp
|
||||
After the binary offset values, there are
|
||||
.Ar count
|
||||
NUL-terminated strings in sequence, holding the symbol names for
|
||||
the corresponding symbol table entries.
|
||||
.El
|
||||
.Sh STANDARDS COMPLIANCE
|
||||
The
|
||||
.Xr ar 1
|
||||
archive format is not currently specified by a standard.
|
||||
.Pp
|
||||
This manual page documents the
|
||||
.Xr ar 1
|
||||
archive formats used by the
|
||||
.Bx 4.4
|
||||
and
|
||||
.Ux SVR4
|
||||
operating system releases.
|
||||
.Sh SEE ALSO
|
||||
.Xr ar 1 ,
|
||||
.Xr ld 1 ,
|
||||
.Xr ranlib 1 ,
|
||||
.Xr elf 3 ,
|
||||
.Xr elf_getarsym 3 ,
|
||||
.Xr elf_rand 3
|
433
contrib/elftoolchain/ar/ar.c
Normal file
433
contrib/elftoolchain/ar/ar.c
Normal file
@ -0,0 +1,433 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Kai Wang
|
||||
* Copyright (c) 2007 Tim Kientzle
|
||||
* Copyright (c) 2007 Joseph Koshy
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Hugh Smith at The University of Guelph.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <archive.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <libelftc.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ar.h"
|
||||
|
||||
ELFTC_VCSID("$Id: ar.c 3183 2015-04-10 16:18:42Z emaste $");
|
||||
|
||||
enum options
|
||||
{
|
||||
OPTION_HELP
|
||||
};
|
||||
|
||||
static struct option longopts[] =
|
||||
{
|
||||
{"flavor", required_argument, NULL, 'F'},
|
||||
{"help", no_argument, NULL, OPTION_HELP},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
static void bsdar_usage(void);
|
||||
static void ranlib_usage(void);
|
||||
static void set_mode(struct bsdar *bsdar, char opt);
|
||||
static void only_mode(struct bsdar *bsdar, const char *opt,
|
||||
const char *valid_modes);
|
||||
static void bsdar_version(void);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct bsdar *bsdar, bsdar_storage;
|
||||
char *arcmd, *argv1_saved;
|
||||
size_t len;
|
||||
int i, opt;
|
||||
|
||||
bsdar = &bsdar_storage;
|
||||
memset(bsdar, 0, sizeof(*bsdar));
|
||||
|
||||
arcmd = argv1_saved = NULL;
|
||||
bsdar->output = stdout;
|
||||
|
||||
if ((bsdar->progname = ELFTC_GETPROGNAME()) == NULL)
|
||||
bsdar->progname = "ar";
|
||||
|
||||
if (elf_version(EV_CURRENT) == EV_NONE)
|
||||
bsdar_errc(bsdar, 0, "ELF library initialization failed: %s",
|
||||
elf_errmsg(-1));
|
||||
|
||||
/*
|
||||
* Act like ranlib if our name ends in "ranlib"; this
|
||||
* accommodates names like "arm-freebsd7.1-ranlib",
|
||||
* "bsdranlib", etc.
|
||||
*/
|
||||
len = strlen(bsdar->progname);
|
||||
if (len >= strlen("ranlib") &&
|
||||
strcmp(bsdar->progname + len - strlen("ranlib"), "ranlib") == 0) {
|
||||
while ((opt = getopt_long(argc, argv, "tDV", longopts,
|
||||
NULL)) != -1) {
|
||||
switch(opt) {
|
||||
case 't':
|
||||
/* Ignored. */
|
||||
break;
|
||||
case 'D':
|
||||
bsdar->options |= AR_D;
|
||||
break;
|
||||
case 'V':
|
||||
bsdar_version();
|
||||
break;
|
||||
case OPTION_HELP:
|
||||
ranlib_usage();
|
||||
default:
|
||||
ranlib_usage();
|
||||
}
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if (*argv == NULL)
|
||||
ranlib_usage();
|
||||
|
||||
bsdar->options |= AR_S;
|
||||
for (;(bsdar->filename = *argv++) != NULL;)
|
||||
ar_write_archive(bsdar, 's');
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
if (argc < 2)
|
||||
bsdar_usage();
|
||||
|
||||
/*
|
||||
* Tack on a leading '-', for old-style usage.
|
||||
*/
|
||||
if (*argv[1] != '-') {
|
||||
argv1_saved = argv[1];
|
||||
len = strlen(argv[1]) + 2;
|
||||
if ((arcmd = malloc(len)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
(void) snprintf(arcmd, len, "-%s", argv[1]);
|
||||
argv[1] = arcmd;
|
||||
}
|
||||
}
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "abCcdDfF:ijlMmopqrSsTtuVvxz",
|
||||
longopts, NULL)) != -1) {
|
||||
switch(opt) {
|
||||
case 'a':
|
||||
bsdar->options |= AR_A;
|
||||
break;
|
||||
case 'b':
|
||||
case 'i':
|
||||
bsdar->options |= AR_B;
|
||||
break;
|
||||
case 'C':
|
||||
bsdar->options |= AR_CC;
|
||||
break;
|
||||
case 'c':
|
||||
bsdar->options |= AR_C;
|
||||
break;
|
||||
case 'd':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'D':
|
||||
bsdar->options |= AR_D;
|
||||
break;
|
||||
case 'F':
|
||||
if (!strcasecmp(optarg, "svr4") ||
|
||||
!strcasecmp(optarg, "gnu"))
|
||||
bsdar->options &= ~AR_BSD;
|
||||
else if (!strcasecmp(optarg, "bsd"))
|
||||
bsdar->options |= AR_BSD;
|
||||
else
|
||||
bsdar_usage();
|
||||
break;
|
||||
case 'f':
|
||||
case 'T':
|
||||
bsdar->options |= AR_TR;
|
||||
break;
|
||||
case 'j':
|
||||
/* ignored */
|
||||
break;
|
||||
case 'l':
|
||||
/* ignored, for GNU ar comptibility */
|
||||
break;
|
||||
case 'M':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'm':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'o':
|
||||
bsdar->options |= AR_O;
|
||||
break;
|
||||
case 'p':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'q':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'r':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'S':
|
||||
bsdar->options |= AR_SS;
|
||||
break;
|
||||
case 's':
|
||||
bsdar->options |= AR_S;
|
||||
break;
|
||||
case 't':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'u':
|
||||
bsdar->options |= AR_U;
|
||||
break;
|
||||
case 'V':
|
||||
bsdar_version();
|
||||
break;
|
||||
case 'v':
|
||||
bsdar->options |= AR_V;
|
||||
break;
|
||||
case 'x':
|
||||
set_mode(bsdar, opt);
|
||||
break;
|
||||
case 'z':
|
||||
/* ignored */
|
||||
break;
|
||||
case OPTION_HELP:
|
||||
bsdar_usage();
|
||||
default:
|
||||
bsdar_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore argv[1] if we had modified it. */
|
||||
if (arcmd != NULL) {
|
||||
argv[1] = argv1_saved;
|
||||
free(arcmd);
|
||||
arcmd = argv1_saved = NULL;
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if (*argv == NULL && bsdar->mode != 'M')
|
||||
bsdar_usage();
|
||||
|
||||
if (bsdar->options & AR_A && bsdar->options & AR_B)
|
||||
bsdar_errc(bsdar, 0,
|
||||
"only one of -a and -[bi] options allowed");
|
||||
|
||||
if (bsdar->options & AR_J && bsdar->options & AR_Z)
|
||||
bsdar_errc(bsdar, 0,
|
||||
"only one of -j and -z options allowed");
|
||||
|
||||
if (bsdar->options & AR_S && bsdar->options & AR_SS)
|
||||
bsdar_errc(bsdar, 0,
|
||||
"only one of -s and -S options allowed");
|
||||
|
||||
if (bsdar->options & (AR_A | AR_B)) {
|
||||
if (*argv == NULL)
|
||||
bsdar_errc(bsdar, 0,
|
||||
"no position operand specified");
|
||||
if ((bsdar->posarg = basename(*argv)) == NULL)
|
||||
bsdar_errc(bsdar, errno,
|
||||
"basename failed");
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (bsdar->options & AR_A)
|
||||
only_mode(bsdar, "-a", "mqr");
|
||||
if (bsdar->options & AR_B)
|
||||
only_mode(bsdar, "-b", "mqr");
|
||||
if (bsdar->options & AR_C)
|
||||
only_mode(bsdar, "-c", "qr");
|
||||
if (bsdar->options & AR_CC)
|
||||
only_mode(bsdar, "-C", "x");
|
||||
if (bsdar->options & AR_D)
|
||||
only_mode(bsdar, "-D", "qr");
|
||||
if (bsdar->options & AR_O)
|
||||
only_mode(bsdar, "-o", "x");
|
||||
if (bsdar->options & AR_SS)
|
||||
only_mode(bsdar, "-S", "mqr");
|
||||
if (bsdar->options & AR_U)
|
||||
only_mode(bsdar, "-u", "qrx");
|
||||
|
||||
if (bsdar->mode == 'M') {
|
||||
ar_mode_script(bsdar);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if ((bsdar->filename = *argv) == NULL)
|
||||
bsdar_usage();
|
||||
|
||||
bsdar->argc = --argc;
|
||||
bsdar->argv = ++argv;
|
||||
|
||||
if ((!bsdar->mode || strchr("ptx", bsdar->mode)) &&
|
||||
bsdar->options & AR_S) {
|
||||
ar_write_archive(bsdar, 's');
|
||||
if (!bsdar->mode)
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
switch(bsdar->mode) {
|
||||
case 'd': case 'm': case 'q': case 'r':
|
||||
ar_write_archive(bsdar, bsdar->mode);
|
||||
break;
|
||||
|
||||
case 'p': case 't': case 'x':
|
||||
ar_read_archive(bsdar, bsdar->mode);
|
||||
break;
|
||||
default:
|
||||
bsdar_usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
for (i = 0; i < bsdar->argc; i++)
|
||||
if (bsdar->argv[i] != NULL)
|
||||
bsdar_warnc(bsdar, 0, "%s: not found in archive",
|
||||
bsdar->argv[i]);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
set_mode(struct bsdar *bsdar, char opt)
|
||||
{
|
||||
|
||||
if (bsdar->mode != '\0' && bsdar->mode != opt)
|
||||
bsdar_errc(bsdar, 0, "Can't specify both -%c and -%c",
|
||||
opt, bsdar->mode);
|
||||
bsdar->mode = opt;
|
||||
}
|
||||
|
||||
static void
|
||||
only_mode(struct bsdar *bsdar, const char *opt, const char *valid_modes)
|
||||
{
|
||||
|
||||
if (strchr(valid_modes, bsdar->mode) == NULL)
|
||||
bsdar_errc(bsdar, 0, "Option %s is not permitted in mode -%c",
|
||||
opt, bsdar->mode);
|
||||
}
|
||||
|
||||
#define AR_USAGE_MESSAGE "\
|
||||
Usage: %s <command> [options] archive file...\n\
|
||||
Manage archives.\n\n\
|
||||
Where <command> is one of:\n\
|
||||
-d Delete members from the archive.\n\
|
||||
-m Move archive members within the archive.\n\
|
||||
-p Write the contents of members to standard output.\n\
|
||||
-q Append files to an archive.\n\
|
||||
-r Replace (add) files to an archive.\n\
|
||||
-s Add an archive symbol to an archive.\n\
|
||||
-t List files in an archive.\n\
|
||||
-x Extract members from an archive.\n\
|
||||
-M Execute MRI librarian commands.\n\
|
||||
-V Print a version identifier and exit.\n\n\
|
||||
Options:\n\
|
||||
-a MEMBER Add members after the specified member.\n\
|
||||
-b MEMBER | -i MEMBER\n\
|
||||
Add members before the specified member.\n\
|
||||
-c Do not print a message when creating a new archive.\n\
|
||||
-f | -T Only use the first fifteen characters of the member name.\n\
|
||||
-j (This option is accepted, but is ignored).\n\
|
||||
-l (This option is accepted, but is ignored).\n\
|
||||
-o Preserve modification times when extracting members.\n\
|
||||
-u Conditionally update or extract members.\n\
|
||||
-v Be verbose.\n\
|
||||
-z (This option is accepted, but is ignored).\n\
|
||||
-C Do not overwrite existing files in the file system.\n\
|
||||
-D Use fixed metadata, for consistent archive checksums.\n\
|
||||
-F FORMAT | --flavor=FORMAT\n\
|
||||
Create archives with the specified format.\n\
|
||||
-S Do not generate an archive symbol table.\n"
|
||||
|
||||
static void
|
||||
bsdar_usage(void)
|
||||
{
|
||||
(void) fprintf(stderr, AR_USAGE_MESSAGE, ELFTC_GETPROGNAME());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#define RANLIB_USAGE_MESSAGE "\
|
||||
Usage: %s [options] archive...\n\
|
||||
Update or create archive symbol tables.\n\n\
|
||||
Options:\n\
|
||||
-t (This option is accepted, but ignored).\n\
|
||||
-D Use fixed metadata, for consistent archive checksums.\n\
|
||||
-V Print a version identifier and exit.\n"
|
||||
|
||||
static void
|
||||
ranlib_usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, RANLIB_USAGE_MESSAGE, ELFTC_GETPROGNAME());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void
|
||||
bsdar_version(void)
|
||||
{
|
||||
(void)printf("%s (%s, %s)\n", ELFTC_GETPROGNAME(), archive_version_string(),
|
||||
elftc_version());
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
143
contrib/elftoolchain/ar/ar.h
Normal file
143
contrib/elftoolchain/ar/ar.h
Normal file
@ -0,0 +1,143 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ar.h 2496 2012-04-24 02:33:40Z jkoshy $
|
||||
*/
|
||||
|
||||
#include <libelf.h>
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
/*
|
||||
* ar(1) options.
|
||||
*/
|
||||
#define AR_A 0x0001 /* position-after */
|
||||
#define AR_B 0x0002 /* position-before */
|
||||
#define AR_C 0x0004 /* creating new archive */
|
||||
#define AR_CC 0x0008 /* do not overwrite when extracting */
|
||||
#define AR_J 0x0010 /* bzip2 compression */
|
||||
#define AR_O 0x0020 /* preserve original mtime when extracting */
|
||||
#define AR_S 0x0040 /* write archive symbol table */
|
||||
#define AR_SS 0x0080 /* do not write archive symbol table */
|
||||
#define AR_TR 0x0100 /* only keep first 15 chars for member name */
|
||||
#define AR_U 0x0200 /* only extract or update newer members.*/
|
||||
#define AR_V 0x0400 /* verbose mode */
|
||||
#define AR_Z 0x0800 /* gzip compression */
|
||||
#define AR_D 0x1000 /* insert dummy mode, mtime, uid and gid */
|
||||
#define AR_BSD 0x2000 /* use the BSD archive format */
|
||||
|
||||
#define DEF_BLKSZ 10240 /* default block size */
|
||||
|
||||
/* Special names. */
|
||||
|
||||
#define AR_STRINGTAB_NAME_SVR4 "//"
|
||||
#define AR_SYMTAB_NAME_BSD "__.SYMDEF"
|
||||
#define AR_SYMTAB_NAME_SVR4 "/"
|
||||
|
||||
/*
|
||||
* Convenient wrapper for general libarchive error handling.
|
||||
*/
|
||||
#define AC(CALL) do { \
|
||||
if ((CALL)) \
|
||||
bsdar_errc(bsdar, 0, "%s", \
|
||||
archive_error_string(a)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* The 'ACV' wrapper is used for libarchive APIs that changed from
|
||||
* returning 'void' to returning an 'int' in later versions of libarchive.
|
||||
*/
|
||||
#if ARCHIVE_VERSION_NUMBER >= 2000000
|
||||
#define ACV(CALL) AC(CALL)
|
||||
#else
|
||||
#define ACV(CALL) do { \
|
||||
(CALL); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* In-memory representation of archive member(object).
|
||||
*/
|
||||
struct ar_obj {
|
||||
Elf *elf; /* object file descriptor */
|
||||
char *name; /* member name */
|
||||
uid_t uid; /* user id */
|
||||
gid_t gid; /* group id */
|
||||
mode_t md; /* octal file permissions */
|
||||
size_t size; /* member size */
|
||||
time_t mtime; /* modification time */
|
||||
dev_t dev; /* inode's device */
|
||||
ino_t ino; /* inode's number */
|
||||
|
||||
TAILQ_ENTRY(ar_obj) objs;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure encapsulates the "global" data for "ar" program.
|
||||
*/
|
||||
struct bsdar {
|
||||
const char *filename; /* archive name. */
|
||||
const char *addlib; /* target of ADDLIB. */
|
||||
const char *posarg; /* position arg for modifiers -a, -b. */
|
||||
char mode; /* program mode */
|
||||
int options; /* command line options */
|
||||
FILE *output; /* default output stream */
|
||||
|
||||
const char *progname; /* program name */
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
dev_t ar_dev; /* archive device. */
|
||||
ino_t ar_ino; /* archive inode. */
|
||||
|
||||
/*
|
||||
* Fields for the archive string table.
|
||||
*/
|
||||
char *as; /* buffer for archive string table. */
|
||||
size_t as_sz; /* current size of as table. */
|
||||
size_t as_cap; /* capacity of as table buffer. */
|
||||
|
||||
/*
|
||||
* Fields for the archive symbol table.
|
||||
*/
|
||||
uint32_t s_cnt; /* current number of symbols. */
|
||||
uint32_t *s_so; /* symbol offset table. */
|
||||
size_t s_so_cap; /* capacity of so table buffer. */
|
||||
char *s_sn; /* symbol name table */
|
||||
size_t s_sn_cap; /* capacity of sn table buffer. */
|
||||
size_t s_sn_sz; /* current size of sn table. */
|
||||
/* Current member's offset (relative to the end of pseudo members.) */
|
||||
off_t rela_off;
|
||||
|
||||
TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */
|
||||
};
|
||||
|
||||
void ar_mode_script(struct bsdar *ar);
|
||||
void ar_read_archive(struct bsdar *_ar, int _mode);
|
||||
void ar_write_archive(struct bsdar *_ar, int _mode);
|
||||
void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...);
|
||||
int bsdar_is_pseudomember(struct bsdar *_ar, const char *_name);
|
||||
const char *bsdar_strmode(mode_t m);
|
||||
void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...);
|
65
contrib/elftoolchain/ar/benchmark/acp.sh
Executable file
65
contrib/elftoolchain/ar/benchmark/acp.sh
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
# $Id: acp.sh 2086 2011-10-27 05:18:01Z jkoshy $
|
||||
|
||||
# This script is adapted from Jan Psota's Tar Comparison Program(TCP).
|
||||
|
||||
n=3 # number of repetitions
|
||||
AR="bsdar gnuar" # ar archivers to compare
|
||||
|
||||
test $# -ge 2 || {
|
||||
echo "usage: $0 source_dir where_to_place_archive [where_to_extract_it]"
|
||||
exit 0
|
||||
}
|
||||
|
||||
THISDIR=`/bin/pwd`
|
||||
src=$1
|
||||
dst=$2/acp.a
|
||||
ext=${3:-$2}/acptmp
|
||||
test -e $dst -o -e /tmp/acp \
|
||||
&& { echo "$dst or /tmp/acp exists, exiting"; exit 1; }
|
||||
mkdir -p $ext || exit 1
|
||||
|
||||
show_result ()
|
||||
{
|
||||
awk -vL="`du -k $dst`" '{printf "%s\t%s\t%s\%10.1d KB/s\n",
|
||||
$1, $3, $5, ($1>0?L/$1:0)}' /tmp/acp | sort | head -n 1
|
||||
}
|
||||
|
||||
test -d $src || { echo "'$src' is not a directory"; exit 1; }
|
||||
|
||||
# ar versions
|
||||
for ar in $AR; do echo -n "$ar: "; $ar -V | head -n 1;
|
||||
done
|
||||
|
||||
echo
|
||||
echo "best time of $n repetitions"
|
||||
echo -n " src=$src, "
|
||||
echo -n "`du -sh $src | awk '{print $1}'`"
|
||||
echo -n " in "
|
||||
echo "`find $src | wc -l` files"
|
||||
echo " archive=$dst, extract to $ext"
|
||||
|
||||
echo "program operation real user system speed"
|
||||
for op in "cru $dst $src/*" "t $dst" "x `basename $dst`"; do
|
||||
for ar in $AR; do
|
||||
echo -n "$ar "
|
||||
echo $op | grep -q ^cr && echo -n "create "
|
||||
echo $op | grep -q ^t && echo -n "list "
|
||||
echo $op | grep -q ^x && echo -n "extract "
|
||||
num=0
|
||||
while [ $num -lt $n ]; do
|
||||
echo $op | grep -q ^cr && rm -f $dst
|
||||
echo $op | grep -q ^x && { rm -rf $ext; mkdir -p $ext
|
||||
cp $dst $ext; cd $ext; }
|
||||
sync
|
||||
time $ar $op > /dev/null 2>> /tmp/acp
|
||||
echo $op | grep -q ^x && cd $THISDIR
|
||||
num=`expr $num + 1`
|
||||
done
|
||||
show_result
|
||||
rm -rf /tmp/acp
|
||||
done
|
||||
echo
|
||||
done
|
||||
rm -rf $ext $dst
|
||||
rm -f /tmp/acp
|
9
contrib/elftoolchain/ar/os.Linux.mk
Normal file
9
contrib/elftoolchain/ar/os.Linux.mk
Normal file
@ -0,0 +1,9 @@
|
||||
.if ${OS_DISTRIBUTION} == "Ubuntu"
|
||||
.if ${OS_DISTRIBUTION_VERSION} >= 14
|
||||
# Ubuntu Trusty Tahr and later.
|
||||
|
||||
# Use the --nounput option to flex(1), to prevent unused functions from
|
||||
# being generated.
|
||||
LFLAGS += --nounput
|
||||
.endif
|
||||
.endif
|
86
contrib/elftoolchain/ar/ranlib.1
Normal file
86
contrib/elftoolchain/ar/ranlib.1
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 2007,2009-2012 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: ranlib.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd December 9, 2012
|
||||
.Os
|
||||
.Dt RANLIB 1
|
||||
.Sh NAME
|
||||
.Nm ranlib
|
||||
.Nd update archive symbol tables
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl D
|
||||
.Op Fl t
|
||||
.Ar archive Ns ...
|
||||
.Nm
|
||||
.Fl V
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm ranlib
|
||||
utility is used to update an existing archive symbol table in an
|
||||
.Xr ar 1
|
||||
archive, or to add an archive symbol table to an archive lacking one.
|
||||
.Sh OPTIONS
|
||||
The
|
||||
.Nm
|
||||
utility supports the following options:
|
||||
.Bl -tag -width indent
|
||||
.It Fl D
|
||||
Use zeros for the mtime, uid and gid fields, and use mode 0644 for the
|
||||
file mode field for all archive member headers.
|
||||
This ensures that checksums on the resulting archives are reproducible
|
||||
when member contents are identical.
|
||||
.It Fl t
|
||||
This option is accepted, but is ignored.
|
||||
.It Fl V
|
||||
Print a version identifier and exit.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To update the archive symbol table for an archive
|
||||
.Pa lib.a ,
|
||||
use:
|
||||
.Dl "ranlib lib.a"
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh SEE ALSO
|
||||
.Xr ar 1 ,
|
||||
.Xr ld 1 ,
|
||||
.Xr archive 3 ,
|
||||
.Xr elf 3 ,
|
||||
.Xr ar 5
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
command first appeared in AT&T UNIX Version 7.
|
||||
.Pp
|
||||
In
|
||||
.Fx 8.0 ,
|
||||
.An Kai Wang Aq Mt kaiw@FreeBSD.org
|
||||
reimplemented
|
||||
.Nm
|
||||
using the
|
||||
.Lb libarchive
|
||||
and the
|
||||
.Lb libelf .
|
199
contrib/elftoolchain/ar/read.c
Normal file
199
contrib/elftoolchain/ar/read.c
Normal file
@ -0,0 +1,199 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Kai Wang
|
||||
* Copyright (c) 2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ar.h"
|
||||
|
||||
ELFTC_VCSID("$Id: read.c 3180 2015-04-09 15:13:57Z emaste $");
|
||||
|
||||
/*
|
||||
* Handle read modes: 'x', 't' and 'p'.
|
||||
*/
|
||||
void
|
||||
ar_read_archive(struct bsdar *bsdar, int mode)
|
||||
{
|
||||
FILE *out;
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
struct stat sb;
|
||||
struct tm *tp;
|
||||
const char *bname;
|
||||
const char *name;
|
||||
mode_t md;
|
||||
size_t size;
|
||||
time_t mtime;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
char **av;
|
||||
char buf[25];
|
||||
char find;
|
||||
int i, flags, r;
|
||||
|
||||
assert(mode == 'p' || mode == 't' || mode == 'x');
|
||||
|
||||
if ((a = archive_read_new()) == NULL)
|
||||
bsdar_errc(bsdar, 0, "archive_read_new failed");
|
||||
archive_read_support_format_ar(a);
|
||||
AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ));
|
||||
|
||||
out = bsdar->output;
|
||||
|
||||
for (;;) {
|
||||
r = archive_read_next_header(a, &entry);
|
||||
if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
|
||||
r == ARCHIVE_FATAL)
|
||||
bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
|
||||
if (r == ARCHIVE_EOF || r == ARCHIVE_FATAL)
|
||||
break;
|
||||
if (r == ARCHIVE_RETRY) {
|
||||
bsdar_warnc(bsdar, 0, "Retrying...");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (archive_format(a) == ARCHIVE_FORMAT_AR_BSD)
|
||||
bsdar->options |= AR_BSD;
|
||||
else
|
||||
bsdar->options &= ~AR_BSD;
|
||||
|
||||
if ((name = archive_entry_pathname(entry)) == NULL)
|
||||
break;
|
||||
|
||||
/* Skip pseudo members. */
|
||||
if (bsdar_is_pseudomember(bsdar, name))
|
||||
continue;
|
||||
|
||||
if (bsdar->argc > 0) {
|
||||
find = 0;
|
||||
for(i = 0; i < bsdar->argc; i++) {
|
||||
av = &bsdar->argv[i];
|
||||
if (*av == NULL)
|
||||
continue;
|
||||
if ((bname = basename(*av)) == NULL)
|
||||
bsdar_errc(bsdar, errno,
|
||||
"basename failed");
|
||||
if (strcmp(bname, name) != 0)
|
||||
continue;
|
||||
|
||||
*av = NULL;
|
||||
find = 1;
|
||||
break;
|
||||
}
|
||||
if (!find)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode == 't') {
|
||||
if (bsdar->options & AR_V) {
|
||||
md = archive_entry_mode(entry);
|
||||
uid = archive_entry_uid(entry);
|
||||
gid = archive_entry_gid(entry);
|
||||
size = archive_entry_size(entry);
|
||||
mtime = archive_entry_mtime(entry);
|
||||
(void)fprintf(out, "%s %6d/%-6d %8ju ",
|
||||
bsdar_strmode(md) + 1, uid, gid,
|
||||
(uintmax_t)size);
|
||||
tp = localtime(&mtime);
|
||||
(void)strftime(buf, sizeof(buf),
|
||||
"%b %e %H:%M %Y", tp);
|
||||
(void)fprintf(out, "%s %s", buf, name);
|
||||
} else
|
||||
(void)fprintf(out, "%s", name);
|
||||
r = archive_read_data_skip(a);
|
||||
if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
|
||||
r == ARCHIVE_FATAL) {
|
||||
(void)fprintf(out, "\n");
|
||||
bsdar_warnc(bsdar, 0, "%s",
|
||||
archive_error_string(a));
|
||||
}
|
||||
|
||||
if (r == ARCHIVE_FATAL)
|
||||
break;
|
||||
|
||||
(void)fprintf(out, "\n");
|
||||
} else {
|
||||
/* mode == 'x' || mode = 'p' */
|
||||
if (mode == 'p') {
|
||||
if (bsdar->options & AR_V) {
|
||||
(void)fprintf(out, "\n<%s>\n\n",
|
||||
name);
|
||||
fflush(out);
|
||||
}
|
||||
r = archive_read_data_into_fd(a, fileno(out));
|
||||
} else {
|
||||
/* mode == 'x' */
|
||||
if (stat(name, &sb) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"stat %s failed",
|
||||
bsdar->filename);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/* stat success, file exist */
|
||||
if (bsdar->options & AR_CC)
|
||||
continue;
|
||||
if (bsdar->options & AR_U &&
|
||||
archive_entry_mtime(entry) <=
|
||||
sb.st_mtime)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bsdar->options & AR_V)
|
||||
(void)fprintf(out, "x - %s\n", name);
|
||||
/* Disallow absolute paths. */
|
||||
if (name[0] == '/') {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"Absolute path '%s'", name);
|
||||
continue;
|
||||
}
|
||||
/* Basic path security flags. */
|
||||
flags = ARCHIVE_EXTRACT_SECURE_SYMLINKS |
|
||||
ARCHIVE_EXTRACT_SECURE_NODOTDOT;
|
||||
if (bsdar->options & AR_O)
|
||||
flags |= ARCHIVE_EXTRACT_TIME;
|
||||
|
||||
r = archive_read_extract(a, entry, flags);
|
||||
}
|
||||
|
||||
if (r)
|
||||
bsdar_warnc(bsdar, 0, "%s",
|
||||
archive_error_string(a));
|
||||
}
|
||||
}
|
||||
AC(archive_read_close(a));
|
||||
ACV(archive_read_free(a));
|
||||
}
|
184
contrib/elftoolchain/ar/util.c
Normal file
184
contrib/elftoolchain/ar/util.c
Normal file
@ -0,0 +1,184 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007 Tim Kientzle
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ar.h"
|
||||
|
||||
ELFTC_VCSID("$Id: util.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
|
||||
static void bsdar_vwarnc(struct bsdar *, int code,
|
||||
const char *fmt, va_list ap);
|
||||
static void bsdar_verrc(struct bsdar *bsdar, int code,
|
||||
const char *fmt, va_list ap);
|
||||
|
||||
static void
|
||||
bsdar_vwarnc(struct bsdar *bsdar, int code, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
fprintf(stderr, "%s: warning: ", bsdar->progname);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
if (code != 0)
|
||||
fprintf(stderr, ": %s", strerror(code));
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
bsdar_warnc(struct bsdar *bsdar, int code, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
bsdar_vwarnc(bsdar, code, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static void
|
||||
bsdar_verrc(struct bsdar *bsdar, int code, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
fprintf(stderr, "%s: fatal: ", bsdar->progname);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
if (code != 0)
|
||||
fprintf(stderr, ": %s", strerror(code));
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
bsdar_errc(struct bsdar *bsdar, int code, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
bsdar_verrc(bsdar, code, fmt, ap);
|
||||
va_end(ap);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#define AR_STRMODE_SIZE 12
|
||||
const char *
|
||||
bsdar_strmode(mode_t m)
|
||||
{
|
||||
static char buf[AR_STRMODE_SIZE];
|
||||
|
||||
#if ELFTC_HAVE_STRMODE
|
||||
/* Use the system's strmode(3). */
|
||||
strmode(m, buf);
|
||||
return buf;
|
||||
|
||||
#else
|
||||
char c;
|
||||
|
||||
/*
|
||||
* The first character of the string denotes the type of the
|
||||
* entry.
|
||||
*/
|
||||
if (S_ISBLK(m))
|
||||
c = 'b';
|
||||
else if (S_ISCHR(m))
|
||||
c = 'c';
|
||||
else if (S_ISDIR(m))
|
||||
c = 'd';
|
||||
#if defined(S_ISFIFO)
|
||||
else if (S_ISFIFO(m))
|
||||
c = 'p';
|
||||
#endif
|
||||
#if defined(S_ISLNK)
|
||||
else if (S_ISLNK(m))
|
||||
c = 'l';
|
||||
#endif
|
||||
else if (S_ISREG(m))
|
||||
c = '-';
|
||||
#if defined(S_ISSOCK)
|
||||
else if (S_ISSOCK(m))
|
||||
c = 's';
|
||||
#endif
|
||||
else
|
||||
c = '?';
|
||||
buf[0] = c;
|
||||
|
||||
/* The next 3 characters show permissions for the owner. */
|
||||
buf[1] = (m & S_IRUSR) ? 'r' : '-';
|
||||
buf[2] = m & S_IWUSR ? 'w' : '-';
|
||||
if (m & S_ISUID)
|
||||
c = (m & S_IXUSR) ? 's' : 'S';
|
||||
else
|
||||
c = (m & S_IXUSR) ? 'x' : '-';
|
||||
buf[3] = c;
|
||||
|
||||
/* The next 3 characters describe permissions for the group. */
|
||||
buf[4] = (m & S_IRGRP) ? 'r' : '-';
|
||||
buf[5] = m & S_IWGRP ? 'w' : '-';
|
||||
if (m & S_ISGID)
|
||||
c = (m & S_IXGRP) ? 's' : 'S';
|
||||
else
|
||||
c = (m & S_IXGRP) ? 'x' : '-';
|
||||
buf[6] = c;
|
||||
|
||||
|
||||
/* The next 3 characters describe permissions for others. */
|
||||
buf[7] = (m & S_IROTH) ? 'r' : '-';
|
||||
buf[8] = m & S_IWOTH ? 'w' : '-';
|
||||
if (m & S_ISVTX) /* sticky bit */
|
||||
c = (m & S_IXOTH) ? 't' : 'T';
|
||||
else
|
||||
c = (m & S_IXOTH) ? 'x' : '-';
|
||||
buf[9] = c;
|
||||
|
||||
/* End the string with a blank and NUL-termination. */
|
||||
buf[10] = ' ';
|
||||
buf[11] = '\0';
|
||||
|
||||
return buf;
|
||||
#endif /* !ELTC_HAVE_STRMODE */
|
||||
}
|
||||
|
||||
int
|
||||
bsdar_is_pseudomember(struct bsdar *bsdar, const char *name)
|
||||
{
|
||||
/*
|
||||
* The "__.SYMDEF" member is special in the BSD format
|
||||
* variant.
|
||||
*/
|
||||
if (bsdar->options & AR_BSD)
|
||||
return (strcmp(name, AR_SYMTAB_NAME_BSD) == 0);
|
||||
else
|
||||
/*
|
||||
* The names "/ " and "// " are special in the SVR4
|
||||
* variant.
|
||||
*/
|
||||
return (strcmp(name, AR_STRINGTAB_NAME_SVR4) == 0 ||
|
||||
strcmp(name, AR_SYMTAB_NAME_SVR4) == 0);
|
||||
}
|
975
contrib/elftoolchain/ar/write.c
Normal file
975
contrib/elftoolchain/ar/write.c
Normal file
@ -0,0 +1,975 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <gelf.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ar.h"
|
||||
|
||||
ELFTC_VCSID("$Id: write.c 3183 2015-04-10 16:18:42Z emaste $");
|
||||
|
||||
#define _ARMAG_LEN 8 /* length of the magic string */
|
||||
#define _ARHDR_LEN 60 /* length of the archive header */
|
||||
#define _INIT_AS_CAP 128 /* initial archive string table size */
|
||||
#define _INIT_SYMOFF_CAP (256*(sizeof(uint32_t))) /* initial so table size */
|
||||
#define _INIT_SYMNAME_CAP 1024 /* initial sn table size */
|
||||
#define _MAXNAMELEN_SVR4 15 /* max member name length in svr4 variant */
|
||||
#define _MAXNAMELEN_BSD 16 /* max member name length in bsd variant */
|
||||
#define _TRUNCATE_LEN 15 /* number of bytes to keep for member name */
|
||||
|
||||
static void add_to_ar_str_table(struct bsdar *bsdar, const char *name);
|
||||
static void add_to_ar_sym_table(struct bsdar *bsdar, const char *name);
|
||||
static struct ar_obj *create_obj_from_file(struct bsdar *bsdar,
|
||||
const char *name, time_t mtime);
|
||||
static void create_symtab_entry(struct bsdar *bsdar, Elf *e);
|
||||
static void free_obj(struct ar_obj *obj);
|
||||
static void insert_obj(struct bsdar *bsdar, struct ar_obj *obj,
|
||||
struct ar_obj *pos);
|
||||
static void read_objs(struct bsdar *bsdar, const char *archive,
|
||||
int checkargv);
|
||||
static void write_cleanup(struct bsdar *bsdar);
|
||||
static void write_data(struct bsdar *bsdar, struct archive *a,
|
||||
const void *buf, size_t s);
|
||||
static void write_objs(struct bsdar *bsdar);
|
||||
|
||||
/*
|
||||
* Create an object from a file, and return the created object
|
||||
* descriptor. Return NULL if either an error occurs, or if the '-u'
|
||||
* option was specified and the member is not newer than the existing
|
||||
* one in the archive.
|
||||
*/
|
||||
static struct ar_obj *
|
||||
create_obj_from_file(struct bsdar *bsdar, const char *name, time_t mtime)
|
||||
{
|
||||
struct ar_obj *obj;
|
||||
struct stat sb;
|
||||
const char *bname;
|
||||
char *tmpname;
|
||||
int fd;
|
||||
|
||||
if (name == NULL)
|
||||
return (NULL);
|
||||
|
||||
obj = malloc(sizeof(struct ar_obj));
|
||||
if (obj == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
|
||||
obj->elf = NULL;
|
||||
|
||||
if ((fd = open(name, O_RDONLY, 0)) < 0) {
|
||||
bsdar_warnc(bsdar, errno, "can't open file: %s", name);
|
||||
free(obj);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
tmpname = strdup(name);
|
||||
if ((bname = basename(tmpname)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "basename failed");
|
||||
if (bsdar->options & AR_TR && strlen(bname) > _TRUNCATE_LEN) {
|
||||
if ((obj->name = malloc(_TRUNCATE_LEN + 1)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
(void)strncpy(obj->name, bname, _TRUNCATE_LEN);
|
||||
obj->name[_TRUNCATE_LEN] = '\0';
|
||||
} else
|
||||
if ((obj->name = strdup(bname)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "strdup failed");
|
||||
free(tmpname);
|
||||
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
bsdar_warnc(bsdar, errno, "can't fstat file: %s", obj->name);
|
||||
goto giveup;
|
||||
}
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
bsdar_warnc(bsdar, 0, "%s is not an ordinary file", obj->name);
|
||||
goto giveup;
|
||||
}
|
||||
|
||||
if (sb.st_dev == bsdar->ar_dev && sb.st_ino == bsdar->ar_ino) {
|
||||
bsdar_warnc(bsdar, 0, "cannot add archive \"%s\" to itself",
|
||||
obj->name);
|
||||
goto giveup;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the '-u' option is specified and member is not newer
|
||||
* than the existing one, we should not replace the member.
|
||||
* However, if mtime == 0, i.e., if nonexistent members are to
|
||||
* be forcibly replaced, then the '-u' option is to be ignored.
|
||||
*/
|
||||
if (mtime != 0 && bsdar->options & AR_U && sb.st_mtime <= mtime)
|
||||
goto giveup;
|
||||
|
||||
/*
|
||||
* When the '-D' option is specified, the mtime and UID/GID of
|
||||
* the member will be set to 0, and the file mode will be set
|
||||
* to 644. This ensures that checksums will match for two
|
||||
* archives containing identical content.
|
||||
*/
|
||||
if (bsdar->options & AR_D) {
|
||||
obj->uid = 0;
|
||||
obj->gid = 0;
|
||||
obj->mtime = 0;
|
||||
obj->md = S_IFREG | 0644;
|
||||
} else {
|
||||
obj->uid = sb.st_uid;
|
||||
obj->gid = sb.st_gid;
|
||||
obj->mtime = sb.st_mtime;
|
||||
obj->md = sb.st_mode;
|
||||
}
|
||||
obj->size = sb.st_size;
|
||||
obj->dev = sb.st_dev;
|
||||
obj->ino = sb.st_ino;
|
||||
|
||||
if (obj->size == 0) {
|
||||
return (obj);
|
||||
}
|
||||
|
||||
if ((obj->elf = elf_open(fd)) == NULL) {
|
||||
bsdar_warnc(bsdar, 0, "file initialization failed for %s: %s",
|
||||
obj->name, elf_errmsg(-1));
|
||||
goto giveup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the object fully into memory and close its file
|
||||
* descriptor.
|
||||
*/
|
||||
if (elf_cntl(obj->elf, ELF_C_FDREAD) < 0) {
|
||||
bsdar_warnc(bsdar, 0, "%s could not be read in: %s",
|
||||
obj->name, elf_errmsg(-1));
|
||||
goto giveup;
|
||||
}
|
||||
|
||||
if (close(fd) < 0)
|
||||
bsdar_errc(bsdar, errno, "close failed: %s",
|
||||
obj->name);
|
||||
|
||||
return (obj);
|
||||
|
||||
giveup:
|
||||
if (obj->elf)
|
||||
elf_end(obj->elf);
|
||||
|
||||
if (close(fd) < 0)
|
||||
bsdar_errc(bsdar, errno, "close failed: %s",
|
||||
obj->name);
|
||||
free(obj->name);
|
||||
free(obj);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free an object and its associated allocations.
|
||||
*/
|
||||
static void
|
||||
free_obj(struct ar_obj *obj)
|
||||
{
|
||||
if (obj->elf)
|
||||
elf_end(obj->elf);
|
||||
|
||||
free(obj->name);
|
||||
free(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert an object into a list, either before/after the 'pos' obj or
|
||||
* at the end of the list.
|
||||
*/
|
||||
static void
|
||||
insert_obj(struct bsdar *bsdar, struct ar_obj *obj, struct ar_obj *pos)
|
||||
{
|
||||
if (obj == NULL)
|
||||
bsdar_errc(bsdar, 0, "try to insert a null obj");
|
||||
|
||||
if (pos == NULL || obj == pos)
|
||||
/*
|
||||
* If the object to move happens to be the position
|
||||
* obj, or if there is no position obj, move the
|
||||
* object to the end.
|
||||
*/
|
||||
goto tail;
|
||||
|
||||
if (bsdar->options & AR_B) {
|
||||
TAILQ_INSERT_BEFORE(pos, obj, objs);
|
||||
return;
|
||||
}
|
||||
if (bsdar->options & AR_A) {
|
||||
TAILQ_INSERT_AFTER(&bsdar->v_obj, pos, obj, objs);
|
||||
return;
|
||||
}
|
||||
|
||||
tail:
|
||||
TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Read objects from archive into the 'v_obj' list. Note that
|
||||
* 'checkargv' is set when read_objs() is used to read objects from
|
||||
* the target of 'ADDLIB' command in ar script mode; in this case the
|
||||
* 'argv' array specifies the members that 'ADDLIB' is to operate on.
|
||||
*/
|
||||
static void
|
||||
read_objs(struct bsdar *bsdar, const char *archive, int checkargv)
|
||||
{
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
struct ar_obj *obj;
|
||||
const char *name;
|
||||
const char *bname;
|
||||
char *buff;
|
||||
char **av;
|
||||
size_t size;
|
||||
int i, r, find;
|
||||
|
||||
if ((a = archive_read_new()) == NULL)
|
||||
bsdar_errc(bsdar, 0, "archive_read_new failed");
|
||||
archive_read_support_format_ar(a);
|
||||
AC(archive_read_open_filename(a, archive, DEF_BLKSZ));
|
||||
for (;;) {
|
||||
r = archive_read_next_header(a, &entry);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
bsdar_errc(bsdar, 0, "%s", archive_error_string(a));
|
||||
if (r == ARCHIVE_EOF)
|
||||
break;
|
||||
if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY)
|
||||
bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
|
||||
if (r == ARCHIVE_RETRY) {
|
||||
bsdar_warnc(bsdar, 0, "Retrying...");
|
||||
continue;
|
||||
}
|
||||
|
||||
name = archive_entry_pathname(entry);
|
||||
|
||||
/*
|
||||
* Skip pseudo members.
|
||||
*/
|
||||
if (bsdar_is_pseudomember(bsdar, name))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* If 'checkargv' is set, only read those members
|
||||
* specified in argv.
|
||||
*/
|
||||
if (checkargv && bsdar->argc > 0) {
|
||||
find = 0;
|
||||
for(i = 0; i < bsdar->argc; i++) {
|
||||
av = &bsdar->argv[i];
|
||||
if (*av == NULL)
|
||||
continue;
|
||||
if ((bname = basename(*av)) == NULL)
|
||||
bsdar_errc(bsdar, errno,
|
||||
"basename failed");
|
||||
if (strcmp(bname, name) != 0)
|
||||
continue;
|
||||
|
||||
*av = NULL;
|
||||
find = 1;
|
||||
break;
|
||||
}
|
||||
if (!find)
|
||||
continue;
|
||||
}
|
||||
|
||||
size = archive_entry_size(entry);
|
||||
|
||||
if (size > 0) {
|
||||
if ((buff = malloc(size)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
if (archive_read_data(a, buff, size) != (ssize_t)size) {
|
||||
bsdar_warnc(bsdar, 0, "%s",
|
||||
archive_error_string(a));
|
||||
free(buff);
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
buff = NULL;
|
||||
|
||||
obj = malloc(sizeof(struct ar_obj));
|
||||
if (obj == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
obj->elf = NULL;
|
||||
if (buff) {
|
||||
obj->elf = elf_openmemory(buff, size);
|
||||
if (obj->elf == NULL) {
|
||||
bsdar_warnc(bsdar, 0, "elf_openmemory() "
|
||||
"failed for %s: %s", name,
|
||||
elf_errmsg(-1));
|
||||
free(buff);
|
||||
free(obj);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((obj->name = strdup(name)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "strdup failed");
|
||||
obj->size = size;
|
||||
obj->uid = archive_entry_uid(entry);
|
||||
obj->gid = archive_entry_gid(entry);
|
||||
obj->md = archive_entry_mode(entry);
|
||||
obj->mtime = archive_entry_mtime(entry);
|
||||
obj->dev = 0;
|
||||
obj->ino = 0;
|
||||
|
||||
TAILQ_INSERT_TAIL(&bsdar->v_obj, obj, objs);
|
||||
}
|
||||
AC(archive_read_close(a));
|
||||
ACV(archive_read_free(a));
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an archive.
|
||||
*/
|
||||
void
|
||||
ar_write_archive(struct bsdar *bsdar, int mode)
|
||||
{
|
||||
struct ar_obj *nobj, *obj, *obj_temp, *pos;
|
||||
struct stat sb;
|
||||
const char *bname;
|
||||
char **av;
|
||||
int i;
|
||||
|
||||
TAILQ_INIT(&bsdar->v_obj);
|
||||
nobj = NULL;
|
||||
pos = NULL;
|
||||
memset(&sb, 0, sizeof(sb));
|
||||
|
||||
assert(mode == 'A' || mode == 'd' || mode == 'm' || mode == 'q' ||
|
||||
mode == 'r' || mode == 's');
|
||||
|
||||
/*
|
||||
* Test if the specified archive exists, to determine
|
||||
* whether we are creating a new archive.
|
||||
*/
|
||||
if (stat(bsdar->filename, &sb) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
bsdar_warnc(bsdar, 0, "stat %s failed",
|
||||
bsdar->filename);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We do not create archive in mode 'd', 'm' and 's'. */
|
||||
if (mode != 'r' && mode != 'q') {
|
||||
bsdar_warnc(bsdar, 0, "%s: no such file",
|
||||
bsdar->filename);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Issue a message if the '-c' option was not specified. */
|
||||
if (!(bsdar->options & AR_C))
|
||||
bsdar_warnc(bsdar, 0, "creating %s", bsdar->filename);
|
||||
goto new_archive;
|
||||
}
|
||||
|
||||
bsdar->ar_dev = sb.st_dev;
|
||||
bsdar->ar_ino = sb.st_ino;
|
||||
|
||||
/*
|
||||
* First read members from the existing archive.
|
||||
*/
|
||||
read_objs(bsdar, bsdar->filename, 0);
|
||||
|
||||
/*
|
||||
* For mode 's', no member will be moved, deleted or replaced.
|
||||
*/
|
||||
if (mode == 's')
|
||||
goto write_objs;
|
||||
|
||||
/*
|
||||
* For mode 'q', we don't need to adjust existing members either.
|
||||
* Also, -a, -b and -i are ignored in this mode. New members are
|
||||
* always inserted at tail.
|
||||
*/
|
||||
if (mode == 'q')
|
||||
goto new_archive;
|
||||
|
||||
/*
|
||||
* Mode 'A' adds the contents of another archive to the tail
|
||||
* of current archive. Note that mode 'A' is a special mode
|
||||
* for the 'ADDLIB' command in ar's script mode. Currently
|
||||
* there is no option that invokes this function from ar's
|
||||
* command line.
|
||||
*/
|
||||
if (mode == 'A') {
|
||||
/*
|
||||
* Read objects from the target archive of the
|
||||
* 'ADDLIB' command. If there are members specified in
|
||||
* 'argv', read those members only, otherwise the
|
||||
* entire archive will be read.
|
||||
*/
|
||||
read_objs(bsdar, bsdar->addlib, 1);
|
||||
goto write_objs;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to find the position member specified by user.
|
||||
*/
|
||||
if (bsdar->options & AR_A || bsdar->options & AR_B) {
|
||||
TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
|
||||
if (strcmp(obj->name, bsdar->posarg) == 0) {
|
||||
pos = obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we cannot find the position specified by the
|
||||
* user, silently insert objects at the tail of the
|
||||
* list.
|
||||
*/
|
||||
if (pos == NULL)
|
||||
bsdar->options &= ~(AR_A | AR_B);
|
||||
}
|
||||
|
||||
for (i = 0; i < bsdar->argc; i++) {
|
||||
av = &bsdar->argv[i];
|
||||
|
||||
TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) {
|
||||
if ((bname = basename(*av)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "basename failed");
|
||||
if (bsdar->options & AR_TR) {
|
||||
if (strncmp(bname, obj->name, _TRUNCATE_LEN))
|
||||
continue;
|
||||
} else
|
||||
if (strcmp(bname, obj->name) != 0)
|
||||
continue;
|
||||
|
||||
if (mode == 'r') {
|
||||
/*
|
||||
* If the new member should not
|
||||
* replace the old one, skip it.
|
||||
*/
|
||||
nobj = create_obj_from_file(bsdar, *av,
|
||||
obj->mtime);
|
||||
if (nobj == NULL)
|
||||
goto skip_obj;
|
||||
}
|
||||
|
||||
if (bsdar->options & AR_V)
|
||||
(void)fprintf(bsdar->output, "%c - %s\n",
|
||||
mode, *av);
|
||||
|
||||
TAILQ_REMOVE(&bsdar->v_obj, obj, objs);
|
||||
if (mode == 'd' || mode == 'r')
|
||||
free_obj(obj);
|
||||
|
||||
if (mode == 'm')
|
||||
insert_obj(bsdar, obj, pos);
|
||||
if (mode == 'r')
|
||||
insert_obj(bsdar, nobj, pos);
|
||||
|
||||
skip_obj:
|
||||
*av = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new_archive:
|
||||
/*
|
||||
* When operating in mode 'r', directly add the specified
|
||||
* objects which do not exist in current archive. When
|
||||
* operating in mode 'q', all objects specified by the command
|
||||
* line args are appended to the archive, without checking
|
||||
* existing members in the archive.
|
||||
*/
|
||||
for (i = 0; i < bsdar->argc; i++) {
|
||||
av = &bsdar->argv[i];
|
||||
if (*av != NULL && (mode == 'r' || mode == 'q')) {
|
||||
nobj = create_obj_from_file(bsdar, *av, 0);
|
||||
if (nobj != NULL)
|
||||
insert_obj(bsdar, nobj, pos);
|
||||
if (bsdar->options & AR_V && nobj != NULL)
|
||||
(void)fprintf(bsdar->output, "a - %s\n", *av);
|
||||
*av = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
write_objs:
|
||||
write_objs(bsdar);
|
||||
write_cleanup(bsdar);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release memory.
|
||||
*/
|
||||
static void
|
||||
write_cleanup(struct bsdar *bsdar)
|
||||
{
|
||||
struct ar_obj *obj, *obj_temp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(obj, &bsdar->v_obj, objs, obj_temp) {
|
||||
TAILQ_REMOVE(&bsdar->v_obj, obj, objs);
|
||||
free_obj(obj);
|
||||
}
|
||||
|
||||
free(bsdar->as);
|
||||
free(bsdar->s_so);
|
||||
free(bsdar->s_sn);
|
||||
bsdar->as = NULL;
|
||||
bsdar->s_so = NULL;
|
||||
bsdar->s_sn = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper for archive_write_data().
|
||||
*/
|
||||
static void
|
||||
write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s)
|
||||
{
|
||||
if (archive_write_data(a, buf, s) != (ssize_t)s)
|
||||
bsdar_errc(bsdar, 0, "%s", archive_error_string(a));
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the size of the symbol table for an archive.
|
||||
*/
|
||||
static size_t
|
||||
bsdar_symtab_size(struct bsdar *bsdar)
|
||||
{
|
||||
size_t sz;
|
||||
|
||||
if (bsdar->options & AR_BSD) {
|
||||
/*
|
||||
* A BSD style symbol table has two parts.
|
||||
* Each part is preceded by its size in bytes,
|
||||
* encoded as a C 'long'. In the first part,
|
||||
* there are 's_cnt' entries, each entry being
|
||||
* 2 'long's in size. The second part
|
||||
* contains a string table.
|
||||
*/
|
||||
sz = 2 * sizeof(long) + (bsdar->s_cnt * 2 * sizeof(long)) +
|
||||
bsdar->s_sn_sz;
|
||||
} else {
|
||||
/*
|
||||
* An SVR4 style symbol table comprises of a 32 bit
|
||||
* number holding the number of entries, followed by
|
||||
* that many 32-bit offsets, followed by a string
|
||||
* table.
|
||||
*/
|
||||
sz = sizeof(uint32_t) + bsdar->s_cnt * sizeof(uint32_t) +
|
||||
bsdar->s_sn_sz;
|
||||
}
|
||||
|
||||
return (sz);
|
||||
}
|
||||
|
||||
static void
|
||||
write_svr4_symtab_entry(struct bsdar *bsdar, struct archive *a)
|
||||
{
|
||||
int nr;
|
||||
uint32_t i;
|
||||
|
||||
/* Translate offsets to big-endian form. */
|
||||
for (i = 0; i < bsdar->s_cnt; i++)
|
||||
bsdar->s_so[i] = htobe32(bsdar->s_so[i]);
|
||||
|
||||
nr = htobe32(bsdar->s_cnt);
|
||||
write_data(bsdar, a, &nr, sizeof(uint32_t));
|
||||
write_data(bsdar, a, bsdar->s_so, sizeof(uint32_t) *
|
||||
bsdar->s_cnt);
|
||||
write_data(bsdar, a, bsdar->s_sn, bsdar->s_sn_sz);
|
||||
}
|
||||
|
||||
static void
|
||||
write_bsd_symtab_entry(struct bsdar *bsdar, struct archive *a)
|
||||
{
|
||||
long br_sz, br_off, br_strx;
|
||||
char *s;
|
||||
uint32_t i;
|
||||
|
||||
/*
|
||||
* Write out the size in the byte of the array of 'ranlib'
|
||||
* descriptors to follow.
|
||||
*/
|
||||
|
||||
br_sz = (long) (bsdar->s_cnt * 2 * sizeof(long));
|
||||
write_data(bsdar, a, &br_sz, sizeof(long));
|
||||
|
||||
/*
|
||||
* Write out the array of 'ranlib' descriptors. Each
|
||||
* descriptor comprises of (a) an offset into the following
|
||||
* string table and (b) a file offset to the relevant member.
|
||||
*/
|
||||
for (i = 0, s = bsdar->s_sn; i < bsdar->s_cnt; i++) {
|
||||
br_strx = (long) (s - bsdar->s_sn);
|
||||
br_off = (long) bsdar->s_so[i];
|
||||
write_data(bsdar, a, &br_strx, sizeof(long));
|
||||
write_data(bsdar, a, &br_off, sizeof(long));
|
||||
|
||||
/* Find the start of the next symbol in the string table. */
|
||||
while (*s++ != '\0')
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the size of the string table as a 'long',
|
||||
* followed by the string table itself.
|
||||
*/
|
||||
br_sz = (long) bsdar->s_sn_sz;
|
||||
write_data(bsdar, a, &br_sz, sizeof(long));
|
||||
write_data(bsdar, a, bsdar->s_sn, bsdar->s_sn_sz);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write the resulting archive members.
|
||||
*/
|
||||
static void
|
||||
write_objs(struct bsdar *bsdar)
|
||||
{
|
||||
struct ar_obj *obj;
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
size_t s_sz; /* size of archive symbol table. */
|
||||
size_t pm_sz; /* size of pseudo members */
|
||||
size_t namelen; /* size of member name. */
|
||||
size_t obj_sz; /* size of object + extended header. */
|
||||
int i;
|
||||
char *buf;
|
||||
const char *entry_name;
|
||||
|
||||
bsdar->rela_off = 0;
|
||||
|
||||
/*
|
||||
* Create the archive symbol table and the archive string
|
||||
* table, if needed.
|
||||
*/
|
||||
TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
|
||||
if (!(bsdar->options & AR_SS) && obj->elf != NULL)
|
||||
create_symtab_entry(bsdar, obj->elf);
|
||||
|
||||
obj_sz = 0;
|
||||
namelen = strlen(obj->name);
|
||||
if (bsdar->options & AR_BSD) {
|
||||
/* Account for the space used by the file name. */
|
||||
if (namelen > _MAXNAMELEN_BSD ||
|
||||
strchr(obj->name, ' '))
|
||||
obj_sz += namelen;
|
||||
} else if (namelen > _MAXNAMELEN_SVR4)
|
||||
add_to_ar_str_table(bsdar, obj->name);
|
||||
|
||||
obj_sz += obj->size; /* add the actual object size */
|
||||
|
||||
/* Roundup the final size and add the header length. */
|
||||
bsdar->rela_off += _ARHDR_LEN + obj_sz + (obj_sz & 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pad the symbol name string table. It is treated specially
|
||||
* because symbol name table should be padded by a '\0', and
|
||||
* not '\n' as for normal members. The size of the 'sn' table
|
||||
* includes the pad byte.
|
||||
*/
|
||||
if (bsdar->s_cnt != 0 && bsdar->s_sn_sz % 2 != 0)
|
||||
bsdar->s_sn[bsdar->s_sn_sz++] = '\0';
|
||||
|
||||
/*
|
||||
* The archive string table is padded by a "\n" like a normal
|
||||
* member. The difference is that the size of archive string
|
||||
* table includes the pad byte, while normal members' size
|
||||
* fields do not.
|
||||
*/
|
||||
if (bsdar->as != NULL && bsdar->as_sz % 2 != 0)
|
||||
bsdar->as[bsdar->as_sz++] = '\n';
|
||||
|
||||
/*
|
||||
* If there is a symbol table, calculate the size of pseudo
|
||||
* members, and convert previously stored relative offsets to
|
||||
* absolute ones.
|
||||
*
|
||||
* absolute_offset = relative_offset + size_of_pseudo_members)
|
||||
*/
|
||||
|
||||
s_sz = bsdar_symtab_size(bsdar);
|
||||
if (bsdar->s_cnt != 0) {
|
||||
pm_sz = _ARMAG_LEN + (_ARHDR_LEN + s_sz);
|
||||
if (bsdar->as != NULL) /* SVR4 archives only */
|
||||
pm_sz += _ARHDR_LEN + bsdar->as_sz;
|
||||
for (i = 0; (size_t) i < bsdar->s_cnt; i++)
|
||||
bsdar->s_so[i] = bsdar->s_so[i] + pm_sz;
|
||||
}
|
||||
|
||||
if ((a = archive_write_new()) == NULL)
|
||||
bsdar_errc(bsdar, 0, "archive_write_new failed");
|
||||
|
||||
if (bsdar->options & AR_BSD)
|
||||
archive_write_set_format_ar_bsd(a);
|
||||
else
|
||||
archive_write_set_format_ar_svr4(a);
|
||||
|
||||
AC(archive_write_open_filename(a, bsdar->filename));
|
||||
|
||||
/*
|
||||
* Write the archive symbol table, if there is one. If
|
||||
* options '-s' was explicitly specified or if we were invoked
|
||||
* as 'ranlib', write the symbol table even if it is empty.
|
||||
*/
|
||||
if ((bsdar->s_cnt != 0 && !(bsdar->options & AR_SS)) ||
|
||||
bsdar->options & AR_S) {
|
||||
if (bsdar->options & AR_BSD)
|
||||
entry_name = AR_SYMTAB_NAME_BSD;
|
||||
else
|
||||
entry_name = AR_SYMTAB_NAME_SVR4;
|
||||
|
||||
entry = archive_entry_new();
|
||||
archive_entry_copy_pathname(entry, entry_name);
|
||||
if ((bsdar->options & AR_D) == 0)
|
||||
archive_entry_set_mtime(entry, time(NULL), 0);
|
||||
archive_entry_set_size(entry, s_sz);
|
||||
AC(archive_write_header(a, entry));
|
||||
if (bsdar->options & AR_BSD)
|
||||
write_bsd_symtab_entry(bsdar, a);
|
||||
else
|
||||
write_svr4_symtab_entry(bsdar, a);
|
||||
archive_entry_free(entry);
|
||||
}
|
||||
|
||||
/* Write the archive string table, if any. */
|
||||
if (bsdar->as != NULL) {
|
||||
entry = archive_entry_new();
|
||||
archive_entry_copy_pathname(entry, AR_STRINGTAB_NAME_SVR4);
|
||||
archive_entry_set_size(entry, bsdar->as_sz);
|
||||
AC(archive_write_header(a, entry));
|
||||
write_data(bsdar, a, bsdar->as, bsdar->as_sz);
|
||||
archive_entry_free(entry);
|
||||
}
|
||||
|
||||
/* Write normal members. */
|
||||
TAILQ_FOREACH(obj, &bsdar->v_obj, objs) {
|
||||
if ((buf = elf_rawfile(obj->elf, NULL)) == NULL) {
|
||||
bsdar_warnc(bsdar, 0, "elf_rawfile() failed: %s",
|
||||
elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
|
||||
entry = archive_entry_new();
|
||||
archive_entry_copy_pathname(entry, obj->name);
|
||||
archive_entry_set_uid(entry, obj->uid);
|
||||
archive_entry_set_gid(entry, obj->gid);
|
||||
archive_entry_set_mode(entry, obj->md);
|
||||
archive_entry_set_size(entry, obj->size);
|
||||
archive_entry_set_mtime(entry, obj->mtime, 0);
|
||||
archive_entry_set_dev(entry, obj->dev);
|
||||
archive_entry_set_ino(entry, obj->ino);
|
||||
archive_entry_set_filetype(entry, AE_IFREG);
|
||||
AC(archive_write_header(a, entry));
|
||||
write_data(bsdar, a, buf, obj->size);
|
||||
archive_entry_free(entry);
|
||||
}
|
||||
|
||||
AC(archive_write_close(a));
|
||||
ACV(archive_write_free(a));
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract global symbols from ELF binary members.
|
||||
*/
|
||||
static void
|
||||
create_symtab_entry(struct bsdar *bsdar, Elf *e)
|
||||
{
|
||||
Elf_Scn *scn;
|
||||
GElf_Shdr shdr;
|
||||
GElf_Sym sym;
|
||||
Elf_Data *data;
|
||||
char *name;
|
||||
size_t n, shstrndx;
|
||||
int elferr, tabndx, len, i;
|
||||
|
||||
if (elf_kind(e) != ELF_K_ELF) {
|
||||
/* Silently a ignore non-ELF member. */
|
||||
return;
|
||||
}
|
||||
if (elf_getshstrndx(e, &shstrndx) == 0) {
|
||||
bsdar_warnc(bsdar, 0, "elf_getshstrndx failed: %s",
|
||||
elf_errmsg(-1));
|
||||
return;
|
||||
}
|
||||
|
||||
tabndx = -1;
|
||||
scn = NULL;
|
||||
while ((scn = elf_nextscn(e, scn)) != NULL) {
|
||||
if (gelf_getshdr(scn, &shdr) != &shdr) {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"elf_getshdr failed: %s", elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if ((name = elf_strptr(e, shstrndx, shdr.sh_name)) == NULL) {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"elf_strptr failed: %s", elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if (strcmp(name, ".strtab") == 0) {
|
||||
tabndx = elf_ndxscn(scn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
elferr = elf_errno();
|
||||
if (elferr != 0)
|
||||
bsdar_warnc(bsdar, 0, "elf_nextscn failed: %s",
|
||||
elf_errmsg(elferr));
|
||||
if (tabndx == -1) {
|
||||
bsdar_warnc(bsdar, 0, "can't find .strtab section");
|
||||
return;
|
||||
}
|
||||
|
||||
scn = NULL;
|
||||
while ((scn = elf_nextscn(e, scn)) != NULL) {
|
||||
if (gelf_getshdr(scn, &shdr) != &shdr) {
|
||||
bsdar_warnc(bsdar, 0, "elf_getshdr failed: %s",
|
||||
elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
if (shdr.sh_type != SHT_SYMTAB)
|
||||
continue;
|
||||
|
||||
data = NULL;
|
||||
n = 0;
|
||||
while (n < shdr.sh_size &&
|
||||
(data = elf_getdata(scn, data)) != NULL) {
|
||||
len = data->d_size / shdr.sh_entsize;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (gelf_getsym(data, i, &sym) != &sym) {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"gelf_getsym failed: %s",
|
||||
elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Keep only global and weak symbols. */
|
||||
if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL &&
|
||||
GELF_ST_BIND(sym.st_info) != STB_WEAK)
|
||||
continue;
|
||||
|
||||
/* Keep only defined symbols. */
|
||||
if (sym.st_shndx == SHN_UNDEF)
|
||||
continue;
|
||||
|
||||
if ((name = elf_strptr(e, tabndx,
|
||||
sym.st_name)) == NULL) {
|
||||
bsdar_warnc(bsdar, 0,
|
||||
"elf_strptr failed: %s",
|
||||
elf_errmsg(-1));
|
||||
continue;
|
||||
}
|
||||
|
||||
add_to_ar_sym_table(bsdar, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
elferr = elf_errno();
|
||||
if (elferr != 0)
|
||||
bsdar_warnc(bsdar, 0, "elf_nextscn failed: %s",
|
||||
elf_errmsg(elferr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Append to the archive string table buffer.
|
||||
*/
|
||||
static void
|
||||
add_to_ar_str_table(struct bsdar *bsdar, const char *name)
|
||||
{
|
||||
|
||||
if (bsdar->as == NULL) {
|
||||
bsdar->as_cap = _INIT_AS_CAP;
|
||||
bsdar->as_sz = 0;
|
||||
if ((bsdar->as = malloc(bsdar->as_cap)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* The space required for holding one member name in the 'as'
|
||||
* table includes: strlen(name) + (1 for '/') + (1 for '\n') +
|
||||
* (possibly 1 for padding).
|
||||
*/
|
||||
while (bsdar->as_sz + strlen(name) + 3 > bsdar->as_cap) {
|
||||
bsdar->as_cap *= 2;
|
||||
bsdar->as = realloc(bsdar->as, bsdar->as_cap);
|
||||
if (bsdar->as == NULL)
|
||||
bsdar_errc(bsdar, errno, "realloc failed");
|
||||
}
|
||||
strncpy(&bsdar->as[bsdar->as_sz], name, strlen(name));
|
||||
bsdar->as_sz += strlen(name);
|
||||
bsdar->as[bsdar->as_sz++] = '/';
|
||||
bsdar->as[bsdar->as_sz++] = '\n';
|
||||
}
|
||||
|
||||
/*
|
||||
* Append to the archive symbol table buffer.
|
||||
*/
|
||||
static void
|
||||
add_to_ar_sym_table(struct bsdar *bsdar, const char *name)
|
||||
{
|
||||
|
||||
if (bsdar->s_so == NULL) {
|
||||
if ((bsdar->s_so = malloc(_INIT_SYMOFF_CAP)) ==
|
||||
NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
bsdar->s_so_cap = _INIT_SYMOFF_CAP;
|
||||
bsdar->s_cnt = 0;
|
||||
}
|
||||
|
||||
if (bsdar->s_sn == NULL) {
|
||||
if ((bsdar->s_sn = malloc(_INIT_SYMNAME_CAP)) == NULL)
|
||||
bsdar_errc(bsdar, errno, "malloc failed");
|
||||
bsdar->s_sn_cap = _INIT_SYMNAME_CAP;
|
||||
bsdar->s_sn_sz = 0;
|
||||
}
|
||||
|
||||
if (bsdar->s_cnt * sizeof(uint32_t) >= bsdar->s_so_cap) {
|
||||
bsdar->s_so_cap *= 2;
|
||||
bsdar->s_so = realloc(bsdar->s_so, bsdar->s_so_cap);
|
||||
if (bsdar->s_so == NULL)
|
||||
bsdar_errc(bsdar, errno, "realloc failed");
|
||||
}
|
||||
bsdar->s_so[bsdar->s_cnt] = bsdar->rela_off;
|
||||
bsdar->s_cnt++;
|
||||
|
||||
/*
|
||||
* The space required for holding one symbol name in the 'sn'
|
||||
* table includes: strlen(name) + (1 for '\n') + (possibly 1
|
||||
* for padding).
|
||||
*/
|
||||
while (bsdar->s_sn_sz + strlen(name) + 2 > bsdar->s_sn_cap) {
|
||||
bsdar->s_sn_cap *= 2;
|
||||
bsdar->s_sn = realloc(bsdar->s_sn, bsdar->s_sn_cap);
|
||||
if (bsdar->s_sn == NULL)
|
||||
bsdar_errc(bsdar, errno, "realloc failed");
|
||||
}
|
||||
strncpy(&bsdar->s_sn[bsdar->s_sn_sz], name, strlen(name));
|
||||
bsdar->s_sn_sz += strlen(name);
|
||||
bsdar->s_sn[bsdar->s_sn_sz++] = '\0';
|
||||
}
|
9
contrib/elftoolchain/brandelf/Makefile
Normal file
9
contrib/elftoolchain/brandelf/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $Id: Makefile 2066 2011-10-26 15:40:28Z jkoshy $
|
||||
|
||||
TOP= ..
|
||||
|
||||
PROG= brandelf
|
||||
WARNS?= 6
|
||||
LDADD= -lelftc -lelf
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.prog.mk"
|
151
contrib/elftoolchain/brandelf/brandelf.1
Normal file
151
contrib/elftoolchain/brandelf/brandelf.1
Normal file
@ -0,0 +1,151 @@
|
||||
.\" Copyright (c) 1997
|
||||
.\" John-Mark Gurney. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of the author nor the names of any co-contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY John-Mark Gurney AND CONTRIBUTORS ``AS IS''
|
||||
.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD: src/usr.bin/brandelf/brandelf.1,v 1.17 2007/03/09 14:36:18 ru Exp $
|
||||
.\" $Id: brandelf.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd October 27, 2014
|
||||
.Dt BRANDELF 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm brandelf
|
||||
.Nd mark an ELF binary for a specific ABI
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl V | Fl -version
|
||||
.Op Fl f Ar ELF_ABI_number
|
||||
.Op Fl h | Fl -help
|
||||
.Op Fl l
|
||||
.Op Fl t Ar brand
|
||||
.Op Fl v
|
||||
.Ar
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility marks an ELF binary to be run under a certain ABI.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl f Ar ELF_ABI_number
|
||||
Forces branding with the supplied ELF ABI number.
|
||||
Incompatible with the
|
||||
.Fl t
|
||||
option.
|
||||
These values are assigned by SCO/USL.
|
||||
.It Fl h | Fl -help
|
||||
Print a usage message and exit.
|
||||
.It Fl l
|
||||
Writes the list of all known ELF types to standard output.
|
||||
.It Fl t Ar brand
|
||||
Brands the given ELF binaries to be of the ABI specified by argument
|
||||
.Ar brand .
|
||||
Supported ABIs include
|
||||
.Dq Li 86Open ,
|
||||
.Dq Li AIX ,
|
||||
.Dq Li ARM ,
|
||||
.Dq Li AROS ,
|
||||
.Dq Li FreeBSD ,
|
||||
.Dq Li GNU ,
|
||||
.Dq Li HP/UX ,
|
||||
.Dq Li Hurd ,
|
||||
.Dq Li IRIX ,
|
||||
.Dq Li Linux
|
||||
(an alias for
|
||||
.Dq Li GNU ) ,
|
||||
.Dq Li Modesto ,
|
||||
.Dq Li NSK ,
|
||||
.Dq Li NetBSD ,
|
||||
.Dq Li None ,
|
||||
.Dq Li OpenBSD ,
|
||||
.Dq Li OpenVMS ,
|
||||
.Dq Li Standalone ,
|
||||
.Dq Li SVR4
|
||||
(an alias for
|
||||
.Dq Li None ) ,
|
||||
.Dq Li Solaris
|
||||
and
|
||||
.Dq Li Tru64 .
|
||||
.It Fl v
|
||||
This option is accepted for compatibility with other versions of
|
||||
.Nm ,
|
||||
but is otherwise ignored.
|
||||
.It Fl V | Fl -version
|
||||
Print a version identifier and exit.
|
||||
.El
|
||||
.Pp
|
||||
If the options
|
||||
.Fl f Ar ELF_ABI_number
|
||||
or
|
||||
.Fl t Ar brand
|
||||
were specified,
|
||||
.Nm
|
||||
will brand the files named by command-line arguments
|
||||
.Ar
|
||||
to be of type
|
||||
.Ar ELF_ABI_number
|
||||
or
|
||||
.Ar brand
|
||||
respectively.
|
||||
.Pp
|
||||
If neither of the
|
||||
.Fl f
|
||||
or
|
||||
.Fl t
|
||||
options were specified,
|
||||
.Nm
|
||||
will display the current branding for the files named by the arguments
|
||||
.Ar .
|
||||
.Sh EXIT STATUS
|
||||
Exit status is 0 on success, and 1 if the command
|
||||
fails if a file does not exist, is too short, fails to brand properly,
|
||||
or the brand requested is not one of the known types and the
|
||||
.Fl f
|
||||
option is not set.
|
||||
.Sh EXAMPLES
|
||||
The following is an example of a typical usage
|
||||
of the
|
||||
.Nm
|
||||
command:
|
||||
.Bd -literal -offset indent
|
||||
brandelf file
|
||||
brandelf -t GNU file
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Rs
|
||||
.%A The Santa Cruz Operation, Inc.
|
||||
.%T System V Application Binary Interface
|
||||
.%D April 29, 1998 (DRAFT)
|
||||
.%O http://www.sco.com/developer/devspecs/
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
manual page first appeared in
|
||||
.Fx 2.2 .
|
||||
.Sh AUTHORS
|
||||
This manual page was written by
|
||||
.An John-Mark Gurney Aq Mt gurney_j@efn.org .
|
311
contrib/elftoolchain/brandelf/brandelf.c
Normal file
311
contrib/elftoolchain/brandelf/brandelf.c
Normal file
@ -0,0 +1,311 @@
|
||||
/*-
|
||||
* Copyright (c) 2008 Hyogeol Lee
|
||||
* Copyright (c) 2000, 2001 David O'Brien
|
||||
* Copyright (c) 1996 Søren Schmidt
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <gelf.h>
|
||||
#include <getopt.h>
|
||||
#include <libelf.h>
|
||||
#include <libelftc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
ELFTC_VCSID("$Id: brandelf.c 3174 2015-03-27 17:13:41Z emaste $");
|
||||
|
||||
static int elftype(const char *);
|
||||
static const char *iselftype(int);
|
||||
static void printelftypes(void);
|
||||
static void printversion(void);
|
||||
static void usage(void);
|
||||
|
||||
struct ELFtypes {
|
||||
const char *str;
|
||||
int value;
|
||||
};
|
||||
/* XXX - any more types? */
|
||||
static struct ELFtypes elftypes[] = {
|
||||
{ "86Open", ELFOSABI_86OPEN },
|
||||
{ "AIX", ELFOSABI_AIX },
|
||||
{ "ARM", ELFOSABI_ARM },
|
||||
{ "AROS", ELFOSABI_AROS },
|
||||
{ "FreeBSD", ELFOSABI_FREEBSD },
|
||||
{ "GNU", ELFOSABI_GNU },
|
||||
{ "HP/UX", ELFOSABI_HPUX},
|
||||
{ "Hurd", ELFOSABI_HURD },
|
||||
{ "IRIX", ELFOSABI_IRIX },
|
||||
{ "Linux", ELFOSABI_GNU },
|
||||
{ "Modesto", ELFOSABI_MODESTO },
|
||||
{ "NSK", ELFOSABI_NSK },
|
||||
{ "NetBSD", ELFOSABI_NETBSD},
|
||||
{ "None", ELFOSABI_NONE},
|
||||
{ "OpenBSD", ELFOSABI_OPENBSD },
|
||||
{ "OpenVMS", ELFOSABI_OPENVMS },
|
||||
{ "Standalone", ELFOSABI_STANDALONE },
|
||||
{ "SVR4", ELFOSABI_NONE },
|
||||
{ "Solaris", ELFOSABI_SOLARIS },
|
||||
{ "Tru64", ELFOSABI_TRU64 }
|
||||
};
|
||||
|
||||
static struct option brandelf_longopts[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
GElf_Ehdr ehdr;
|
||||
Elf *elf;
|
||||
Elf_Kind kind;
|
||||
int type = ELFOSABI_NONE;
|
||||
int retval = 0;
|
||||
int ch, change = 0, force = 0, listed = 0;
|
||||
|
||||
if (elf_version(EV_CURRENT) == EV_NONE)
|
||||
errx(EXIT_FAILURE, "elf_version error");
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "Vf:hlt:v", brandelf_longopts,
|
||||
NULL)) != -1)
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
if (change)
|
||||
errx(EXIT_FAILURE, "ERROR: the -f option is "
|
||||
"incompatible with the -t option.");
|
||||
force = 1;
|
||||
type = atoi(optarg);
|
||||
if (errno == ERANGE || type < 0 || type > 255) {
|
||||
warnx("ERROR: invalid argument to option "
|
||||
"-f: %s", optarg);
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
usage();
|
||||
break;
|
||||
case 'l':
|
||||
printelftypes();
|
||||
listed = 1;
|
||||
break;
|
||||
case 'v':
|
||||
/* This flag is ignored. */
|
||||
break;
|
||||
case 't':
|
||||
if (force)
|
||||
errx(EXIT_FAILURE, "the -t option is "
|
||||
"incompatible with the -f option.");
|
||||
if ((type = elftype(optarg)) == -1) {
|
||||
warnx("ERROR: invalid ELF type '%s'", optarg);
|
||||
usage();
|
||||
}
|
||||
|
||||
change = 1;
|
||||
break;
|
||||
case 'V':
|
||||
printversion();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (!argc) {
|
||||
if (listed)
|
||||
exit(0);
|
||||
else {
|
||||
warnx("no file(s) specified");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
while (argc) {
|
||||
int fd;
|
||||
|
||||
elf = NULL;
|
||||
|
||||
if ((fd = open(argv[0], (change || force) ? O_RDWR :
|
||||
O_RDONLY, 0)) < 0) {
|
||||
warn("error opening file %s", argv[0]);
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((elf = elf_begin(fd, (change || force) ? ELF_C_RDWR :
|
||||
ELF_C_READ, NULL)) == NULL) {
|
||||
warnx("elf_begin failed: %s", elf_errmsg(-1));
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((kind = elf_kind(elf)) != ELF_K_ELF) {
|
||||
if (kind == ELF_K_AR)
|
||||
warnx("file '%s' is an archive.", argv[0]);
|
||||
else
|
||||
warnx("file '%s' is not an ELF file.",
|
||||
argv[0]);
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (gelf_getehdr(elf, &ehdr) == NULL) {
|
||||
warnx("gelf_getehdr: %s", elf_errmsg(-1));
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!change && !force) {
|
||||
fprintf(stdout,
|
||||
"File '%s' is of brand '%s' (%u).\n",
|
||||
argv[0], iselftype(ehdr.e_ident[EI_OSABI]),
|
||||
ehdr.e_ident[EI_OSABI]);
|
||||
if (!iselftype(type)) {
|
||||
warnx("ELF ABI Brand '%u' is unknown",
|
||||
type);
|
||||
printelftypes();
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Keep the existing layout of the ELF object.
|
||||
*/
|
||||
if (elf_flagelf(elf, ELF_C_SET, ELF_F_LAYOUT) == 0) {
|
||||
warnx("elf_flagelf failed: %s",
|
||||
elf_errmsg(-1));
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the ABI type.
|
||||
*/
|
||||
ehdr.e_ident[EI_OSABI] = type;
|
||||
if (gelf_update_ehdr(elf, &ehdr) == 0) {
|
||||
warnx("gelf_update_ehdr error: %s",
|
||||
elf_errmsg(-1));
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write back changes.
|
||||
*/
|
||||
if (elf_update(elf, ELF_C_WRITE) == -1) {
|
||||
warnx("elf_update error: %s", elf_errmsg(-1));
|
||||
retval = 1;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
fail:
|
||||
|
||||
if (elf)
|
||||
elf_end(elf);
|
||||
|
||||
if (fd >= 0 && close(fd) == -1) {
|
||||
warnx("%s: close error", argv[0]);
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
#define USAGE_MESSAGE "\
|
||||
Usage: %s [options] file...\n\
|
||||
Set or display the ABI field for an ELF object.\n\n\
|
||||
Supported options are:\n\
|
||||
-f NUM Set the ELF ABI to the number 'NUM'.\n\
|
||||
-h | --help Print a usage message and exit.\n\
|
||||
-l List known ELF ABI names.\n\
|
||||
-t ABI Set the ELF ABI to the value named by \"ABI\".\n\
|
||||
-V | --version Print a version identifier and exit.\n"
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void) fprintf(stderr, USAGE_MESSAGE, ELFTC_GETPROGNAME());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
printversion(void)
|
||||
{
|
||||
(void) printf("%s (%s)\n", ELFTC_GETPROGNAME(), elftc_version());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
iselftype(int etype)
|
||||
{
|
||||
size_t elfwalk;
|
||||
|
||||
for (elfwalk = 0;
|
||||
elfwalk < sizeof(elftypes)/sizeof(elftypes[0]);
|
||||
elfwalk++)
|
||||
if (etype == elftypes[elfwalk].value)
|
||||
return (elftypes[elfwalk].str);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
elftype(const char *elfstrtype)
|
||||
{
|
||||
size_t elfwalk;
|
||||
|
||||
for (elfwalk = 0;
|
||||
elfwalk < sizeof(elftypes)/sizeof(elftypes[0]);
|
||||
elfwalk++)
|
||||
if (strcasecmp(elfstrtype, elftypes[elfwalk].str) == 0)
|
||||
return (elftypes[elfwalk].value);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
printelftypes(void)
|
||||
{
|
||||
size_t elfwalk;
|
||||
|
||||
(void) printf("Known ELF types are: ");
|
||||
for (elfwalk = 0;
|
||||
elfwalk < sizeof(elftypes)/sizeof(elftypes[0]);
|
||||
elfwalk++)
|
||||
(void) printf("%s(%u) ", elftypes[elfwalk].str,
|
||||
elftypes[elfwalk].value);
|
||||
(void) printf("\n");
|
||||
}
|
11
contrib/elftoolchain/elfdump/Makefile
Normal file
11
contrib/elftoolchain/elfdump/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
# $Id: Makefile 2289 2011-12-04 07:11:47Z jkoshy $
|
||||
|
||||
TOP= ..
|
||||
|
||||
PROG= elfdump
|
||||
WARNS?= 6
|
||||
|
||||
DPADD= ${LIBELFTC} ${LIBELF}
|
||||
LDADD= -lelftc -lelf
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.prog.mk"
|
158
contrib/elftoolchain/elfdump/elfdump.1
Normal file
158
contrib/elftoolchain/elfdump/elfdump.1
Normal file
@ -0,0 +1,158 @@
|
||||
.\" Copyright (c) 2003 David O'Brien
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD: src/usr.bin/elfdump/elfdump.1,v 1.6 2005/01/18 13:43:48 ru Exp $
|
||||
.\" $Id: elfdump.1 3195 2015-05-12 17:22:19Z emaste $
|
||||
.\"
|
||||
.Dd August 25, 2011
|
||||
.Dt ELFDUMP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm elfdump
|
||||
.Nd "display information about"
|
||||
.Tn ELF
|
||||
files
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Fl a | cdeGhiknprsv
|
||||
.Op Fl S
|
||||
.Op Fl V
|
||||
.Op Fl N Ar name
|
||||
.Op Fl w Ar file
|
||||
.Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
dumps various information about the specified
|
||||
.Tn ELF
|
||||
.Ar file .
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width ".Fl w Ar file"
|
||||
.It Fl a
|
||||
Dump all information.
|
||||
.It Fl c
|
||||
Dump shared headers.
|
||||
.It Fl d
|
||||
Dump dynamic symbols.
|
||||
.It Fl e
|
||||
Dump ELF header.
|
||||
.It Fl G
|
||||
Dump the GOT.
|
||||
.It Fl h
|
||||
Dump the hash values.
|
||||
.It Fl i
|
||||
Dump the dynamic interpreter.
|
||||
.It Fl k
|
||||
Dump the ELF checksum.
|
||||
.It Fl n
|
||||
Dump note sections.
|
||||
.It Fl N Ar name
|
||||
Only dump the section with the specific
|
||||
.Ar name .
|
||||
Archive symbol table can be specified with
|
||||
the special section name ARSYM.
|
||||
More than one
|
||||
.Fl N
|
||||
option may appear.
|
||||
.It Fl p
|
||||
Dump the program header.
|
||||
.It Fl r
|
||||
Dump relocations.
|
||||
.It Fl s
|
||||
Dump the symbol table.
|
||||
.It Fl S
|
||||
Output in the Solaris
|
||||
.Nm
|
||||
format.
|
||||
.It Fl v
|
||||
Dump the symbol-versioning sections.
|
||||
.It Fl V
|
||||
Print a version identifier and exit.
|
||||
.It Fl w Ar file
|
||||
Write output to a
|
||||
.Ar file
|
||||
instead of the standard output.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
.Sh EXAMPLES
|
||||
The following is an example of a typical usage
|
||||
of the
|
||||
.Nm
|
||||
command:
|
||||
.Pp
|
||||
.Dl "elfdump -a -w output /bin/ls"
|
||||
.Pp
|
||||
To dump the content of '.dynsym' symbol table:
|
||||
.Pp
|
||||
.Dl "elfdump -s -N .dynsym /bin/ls"
|
||||
.Pp
|
||||
To dump the archive symbol table,
|
||||
but not the symbol tables of archive members:
|
||||
.Pp
|
||||
.Dl "elfdump -s -N ARSYM /usr/lib/libelf.a"
|
||||
.Pp
|
||||
To dump the content of .got section and
|
||||
the symbol-versioning sections in Solaris
|
||||
.Nm
|
||||
format:
|
||||
.Pp
|
||||
.Dl "elfdump -S -Gv /bin/ls"
|
||||
.Sh SEE ALSO
|
||||
.Xr objdump 1 ,
|
||||
.Xr readelf 1 ,
|
||||
.Xr elf 3
|
||||
.Rs
|
||||
.%A "AT&T Unix Systems Labs"
|
||||
.%T "System V Application Binary Interface"
|
||||
.%O http://www.sco.com/developers/gabi/
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
utility first appeared in
|
||||
.Fx 5.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
was written by
|
||||
.An Jake Burkholder Aq Mt jake@FreeBSD.org .
|
||||
Later it was rewritten based on the
|
||||
libelf library.
|
||||
This
|
||||
manual page was written by
|
||||
.An David O'Brien Aq Mt obrien@FreeBSD.org .
|
||||
.Pp
|
||||
.An Kai Wang Aq Mt kaiw@FreeBSD.org
|
||||
rewrote it using the
|
||||
.Lb libelf
|
||||
and implemented additional functionality.
|
||||
.Sh BUGS
|
||||
Does not fully implement the
|
||||
.Tn ELF
|
||||
gABI.
|
2819
contrib/elftoolchain/elfdump/elfdump.c
Normal file
2819
contrib/elftoolchain/elfdump/elfdump.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -553,7 +553,9 @@ c_cpp_builtins (cpp_reader *pfile)
|
||||
/* Make the choice of the stack protector runtime visible to source code.
|
||||
The macro names and values here were chosen for compatibility with an
|
||||
earlier implementation, i.e. ProPolice. */
|
||||
if (flag_stack_protect == 2)
|
||||
if (flag_stack_protect == 3)
|
||||
cpp_define (pfile, "__SSP_STRONG__=3");
|
||||
else if (flag_stack_protect == 2)
|
||||
cpp_define (pfile, "__SSP_ALL__=2");
|
||||
else if (flag_stack_protect == 1)
|
||||
cpp_define (pfile, "__SSP__=1");
|
||||
|
@ -810,6 +810,12 @@ clear_tree_used (tree block)
|
||||
clear_tree_used (t);
|
||||
}
|
||||
|
||||
enum {
|
||||
SPCT_FLAG_DEFAULT = 1,
|
||||
SPCT_FLAG_ALL = 2,
|
||||
SPCT_FLAG_STRONG = 3
|
||||
};
|
||||
|
||||
/* Examine TYPE and determine a bit mask of the following features. */
|
||||
|
||||
#define SPCT_HAS_LARGE_CHAR_ARRAY 1
|
||||
@ -879,7 +885,8 @@ stack_protect_decl_phase (tree decl)
|
||||
if (bits & SPCT_HAS_SMALL_CHAR_ARRAY)
|
||||
has_short_buffer = true;
|
||||
|
||||
if (flag_stack_protect == 2)
|
||||
if (flag_stack_protect == SPCT_FLAG_ALL
|
||||
|| flag_stack_protect == SPCT_FLAG_STRONG)
|
||||
{
|
||||
if ((bits & (SPCT_HAS_SMALL_CHAR_ARRAY | SPCT_HAS_LARGE_CHAR_ARRAY))
|
||||
&& !(bits & SPCT_HAS_AGGREGATE))
|
||||
@ -947,12 +954,36 @@ create_stack_guard (void)
|
||||
cfun->stack_protect_guard = guard;
|
||||
}
|
||||
|
||||
/* Helper routine to check if a record or union contains an array field. */
|
||||
|
||||
static int
|
||||
record_or_union_type_has_array_p (tree tree_type)
|
||||
{
|
||||
tree fields = TYPE_FIELDS (tree_type);
|
||||
tree f;
|
||||
|
||||
for (f = fields; f; f = TREE_CHAIN (f))
|
||||
if (TREE_CODE (f) == FIELD_DECL)
|
||||
{
|
||||
tree field_type = TREE_TYPE (f);
|
||||
if ((TREE_CODE (field_type) == RECORD_TYPE
|
||||
|| TREE_CODE (field_type) == UNION_TYPE
|
||||
|| TREE_CODE (field_type) == QUAL_UNION_TYPE)
|
||||
&& record_or_union_type_has_array_p (field_type))
|
||||
return 1;
|
||||
if (TREE_CODE (field_type) == ARRAY_TYPE)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Expand all variables used in the function. */
|
||||
|
||||
static void
|
||||
expand_used_vars (void)
|
||||
{
|
||||
tree t, outer_block = DECL_INITIAL (current_function_decl);
|
||||
bool gen_stack_protect_signal = false;
|
||||
|
||||
/* Compute the phase of the stack frame for this function. */
|
||||
{
|
||||
@ -972,6 +1003,29 @@ expand_used_vars (void)
|
||||
has_protected_decls = false;
|
||||
has_short_buffer = false;
|
||||
|
||||
if (flag_stack_protect == SPCT_FLAG_STRONG)
|
||||
for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
|
||||
{
|
||||
tree var = TREE_VALUE (t);
|
||||
if (!is_global_var (var))
|
||||
{
|
||||
tree var_type = TREE_TYPE (var);
|
||||
/* Examine local referenced variables that have their addresses
|
||||
* taken, contain an array, or are arrays. */
|
||||
if (TREE_CODE (var) == VAR_DECL
|
||||
&& (TREE_CODE (var_type) == ARRAY_TYPE
|
||||
|| TREE_ADDRESSABLE (var)
|
||||
|| ((TREE_CODE (var_type) == RECORD_TYPE
|
||||
|| TREE_CODE (var_type) == UNION_TYPE
|
||||
|| TREE_CODE (var_type) == QUAL_UNION_TYPE)
|
||||
&& record_or_union_type_has_array_p (var_type))))
|
||||
{
|
||||
gen_stack_protect_signal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point all variables on the unexpanded_var_list with TREE_USED
|
||||
set are not associated with any block scope. Lay them out. */
|
||||
for (t = cfun->unexpanded_var_list; t; t = TREE_CHAIN (t))
|
||||
@ -1032,12 +1086,26 @@ expand_used_vars (void)
|
||||
dump_stack_var_partition ();
|
||||
}
|
||||
|
||||
/* There are several conditions under which we should create a
|
||||
stack guard: protect-all, alloca used, protected decls present. */
|
||||
if (flag_stack_protect == 2
|
||||
|| (flag_stack_protect
|
||||
&& (current_function_calls_alloca || has_protected_decls)))
|
||||
create_stack_guard ();
|
||||
switch (flag_stack_protect)
|
||||
{
|
||||
case SPCT_FLAG_ALL:
|
||||
create_stack_guard ();
|
||||
break;
|
||||
|
||||
case SPCT_FLAG_STRONG:
|
||||
if (gen_stack_protect_signal
|
||||
|| current_function_calls_alloca || has_protected_decls)
|
||||
create_stack_guard ();
|
||||
break;
|
||||
|
||||
case SPCT_FLAG_DEFAULT:
|
||||
if (current_function_calls_alloca || has_protected_decls)
|
||||
create_stack_guard();
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
/* Assign rtl to each variable based on these partitions. */
|
||||
if (stack_vars_num > 0)
|
||||
|
@ -878,6 +878,10 @@ fstack-protector-all
|
||||
Common Report RejectNegative Var(flag_stack_protect, 2) VarExists
|
||||
Use a stack protection method for every function
|
||||
|
||||
fstack-protector-strong
|
||||
Common Report RejectNegative Var(flag_stack_protect, 3)
|
||||
Use a smart stack protection method for certain functions
|
||||
|
||||
fstrength-reduce
|
||||
Common
|
||||
Does nothing. Preserved for backward compatibility.
|
||||
|
@ -2134,6 +2134,10 @@ use.
|
||||
This macro is defined, with value 2, when @option{-fstack-protector-all} is
|
||||
in use.
|
||||
|
||||
@item __SSP_STRONG__
|
||||
This macro is defined, with value 3, when @option{-fstack-protector-strong} is
|
||||
in use.
|
||||
|
||||
@item __TIMESTAMP__
|
||||
This macro expands to a string constant that describes the date and time
|
||||
of the last modification of the current source file. The string constant
|
||||
|
@ -339,7 +339,7 @@ in the following sections.
|
||||
\&\fB\-fsched2\-use\-superblocks
|
||||
\&\-fsched2\-use\-traces \-fsee \-freschedule\-modulo\-scheduled\-loops
|
||||
\&\-fsection\-anchors \-fsignaling\-nans \-fsingle\-precision\-constant
|
||||
\&\-fstack\-protector \-fstack\-protector\-all
|
||||
\&\-fstack\-protector \-fstack\-protector\-all \-fstack\-protector\-strong
|
||||
\&\-fstrict\-aliasing \-fstrict\-overflow \-ftracer \-fthread\-jumps
|
||||
\&\-funroll\-all\-loops \-funroll\-loops \-fpeel\-loops
|
||||
\&\-fsplit\-ivs\-in\-unroller \-funswitch\-loops
|
||||
@ -5193,6 +5193,11 @@ If a guard check fails, an error message is printed and the program exits.
|
||||
.IP "\fB\-fstack\-protector\-all\fR" 4
|
||||
.IX Item "-fstack-protector-all"
|
||||
Like \fB\-fstack\-protector\fR except that all functions are protected.
|
||||
.IP "\fB\-fstack\-protector\-strong\fR" 4
|
||||
.IX Item "-fstack-protector-strong"
|
||||
Like \fB\-fstack\-protector\fR but includes additional functions to
|
||||
be protected \-\-\- those that have local array definitions, or have
|
||||
references to local frame addresses.
|
||||
.IP "\fB\-fsection\-anchors\fR" 4
|
||||
.IX Item "-fsection-anchors"
|
||||
Try to reduce the number of symbolic address calculations by using
|
||||
|
@ -331,7 +331,7 @@ in the following sections.
|
||||
-fsched2-use-superblocks @gol
|
||||
-fsched2-use-traces -fsee -freschedule-modulo-scheduled-loops @gol
|
||||
-fsection-anchors -fsignaling-nans -fsingle-precision-constant @gol
|
||||
-fstack-protector -fstack-protector-all @gol
|
||||
-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
|
||||
-fstrict-aliasing -fstrict-overflow -ftracer -fthread-jumps @gol
|
||||
-funroll-all-loops -funroll-loops -fpeel-loops @gol
|
||||
-fsplit-ivs-in-unroller -funswitch-loops @gol
|
||||
@ -5810,6 +5810,11 @@ If a guard check fails, an error message is printed and the program exits.
|
||||
@item -fstack-protector-all
|
||||
Like @option{-fstack-protector} except that all functions are protected.
|
||||
|
||||
@item -fstack-protector-strong
|
||||
Like @option{-fstack-protector} but includes additional functions to
|
||||
be protected --- those that have local array definitions, or have
|
||||
references to local frame addresses.
|
||||
|
||||
@item -fsection-anchors
|
||||
@opindex fsection-anchors
|
||||
Try to reduce the number of symbolic address calculations by using
|
||||
|
@ -680,7 +680,7 @@ proper position among the other output files. */
|
||||
#ifdef TARGET_LIBC_PROVIDES_SSP
|
||||
#define LINK_SSP_SPEC "%{fstack-protector:}"
|
||||
#else
|
||||
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}"
|
||||
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -585,13 +585,23 @@ static int
|
||||
archive_read_format_tar_skip(struct archive_read *a)
|
||||
{
|
||||
int64_t bytes_skipped;
|
||||
int64_t request;
|
||||
struct sparse_block *p;
|
||||
struct tar* tar;
|
||||
|
||||
tar = (struct tar *)(a->format->data);
|
||||
|
||||
bytes_skipped = __archive_read_consume(a,
|
||||
tar->entry_bytes_remaining + tar->entry_padding +
|
||||
tar->entry_bytes_unconsumed);
|
||||
/* Do not consume the hole of a sparse file. */
|
||||
request = 0;
|
||||
for (p = tar->sparse_list; p != NULL; p = p->next) {
|
||||
if (!p->hole)
|
||||
request += p->remaining;
|
||||
}
|
||||
if (request > tar->entry_bytes_remaining)
|
||||
request = tar->entry_bytes_remaining;
|
||||
request += tar->entry_padding + tar->entry_bytes_unconsumed;
|
||||
|
||||
bytes_skipped = __archive_read_consume(a, request);
|
||||
if (bytes_skipped < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
|
@ -0,0 +1,135 @@
|
||||
/*-
|
||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
__FBSDID("$FreeBSD");
|
||||
|
||||
/*
|
||||
* To test skip a sparse file entry, this test does not read file data.
|
||||
*/
|
||||
DEFINE_TEST(test_read_format_gtar_sparse_skip_entry)
|
||||
{
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
const char *refname = "test_read_format_gtar_sparse_skip_entry.tar.Z.uu";
|
||||
#else
|
||||
const char *refname = "test_read_format_gtar_sparse_skip_entry.tar.Z";
|
||||
#endif
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
const void *p;
|
||||
size_t s;
|
||||
int64_t o;
|
||||
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
copy_reference_file(refname);
|
||||
#else
|
||||
extract_reference_file(refname);
|
||||
#endif
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK,
|
||||
archive_read_open_filename(a, refname, 10240));
|
||||
|
||||
/* Verify regular first file. */
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assertEqualString("a", archive_entry_pathname(ae));
|
||||
assertEqualInt(10737418244, archive_entry_size(ae));
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
||||
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
|
||||
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
|
||||
#endif
|
||||
|
||||
/* Verify regular second file. */
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assertEqualString("b", archive_entry_pathname(ae));
|
||||
assertEqualInt(4, archive_entry_size(ae));
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
||||
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
|
||||
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
|
||||
#endif
|
||||
|
||||
|
||||
/* End of archive. */
|
||||
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
|
||||
|
||||
/* Verify archive format. */
|
||||
assertEqualIntA(a, ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0));
|
||||
assertEqualIntA(a, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE,
|
||||
archive_format(a));
|
||||
|
||||
/* Close the archive. */
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
|
||||
|
||||
/*
|
||||
* Read just one block of a sparse file and skip it.
|
||||
*/
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK,
|
||||
archive_read_open_filename(a, refname, 10240));
|
||||
|
||||
/* Verify regular first file. */
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assertEqualString("a", archive_entry_pathname(ae));
|
||||
assertEqualInt(10737418244, archive_entry_size(ae));
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
||||
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
|
||||
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
|
||||
#endif
|
||||
assertEqualInt(0, archive_read_data_block(a, &p, &s, &o));
|
||||
assertEqualInt(4096, s);
|
||||
assertEqualInt(0, o);
|
||||
|
||||
|
||||
/* Verify regular second file. */
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assertEqualString("b", archive_entry_pathname(ae));
|
||||
assertEqualInt(4, archive_entry_size(ae));
|
||||
#ifndef __FreeBSD__ /* Backport test. */
|
||||
assertEqualInt(archive_entry_is_encrypted(ae), 0);
|
||||
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
|
||||
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
|
||||
#endif
|
||||
|
||||
|
||||
/* End of archive. */
|
||||
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
|
||||
|
||||
/* Verify archive format. */
|
||||
assertEqualIntA(a, ARCHIVE_FILTER_COMPRESS, archive_filter_code(a, 0));
|
||||
assertEqualIntA(a, ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE,
|
||||
archive_format(a));
|
||||
|
||||
/* Close the archive. */
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
begin 644 -
|
||||
M'YV04,+@05(F#)DR<EZ$`<"PH<.'$"-*G$BQHL6*,#+:L$$#!(",,6[4@.$1
|
||||
MI$B2'S.JS#A#A@P0,63,L`$C!HP9-VB\K"FCAHT8`$#@N4BTJ-&C2"/6F4,G
|
||||
MC)R48^J424HQZE2J$E=F+*G5(]:O8,.*'3M6!LDY:?24Z6'S!DX:,7#(H$%#
|
||||
MP0R2;>BD:;,V!@T8-6)NE&'#10T<-#;>R(%CAEV28_3R9?LW\(P8-F[`<#%C
|
||||
M)@T<->#6>`PBC.2^E07;J#'#Q>J-F5DJ<`GBB),J+N;`<3JGC(LV8=2\D<-V
|
||||
M]DO;N'7S]MTFC9OA/6#,CE'[=N[=<GJ[<!-F<AB[-:HGQZY=3D$V:-6RA>$V
|
||||
M9]RY=<G*GT^_OOW[^/.#13Z%?!DC:;!1AD+Z%6B12AMUE%)((W'%($I:U603
|
||||
M#!W%-%---^6T4PPM8184#`:&"-9233V5D57SH2A?A%RMY)6(,,8HHPP*2/=7
|
||||
M#C8HT-9;[_VE0'PR!BGDD$06:>212"9YD1EOO*&`DE!&*>645%9IY9589JGE
|
||||
MEEQVZ>678(8IYIADEFGFF6BFJ>::;+;IYIMPQBGGG'36:>>=>.:IYYY\]NGG
|
||||
MGX`&*NB@A!9JJ)YB](D@1PZ>U&B#*468484RT11###7<8!8(&-)4PX=^DN@4
|
||||
B5%*E6.J*746JTHN'2LFDDZW&*NNLM-9JZZVXYJKKKKR&!0``
|
||||
`
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
.Dd June 7, 2012 \" DATE
|
||||
.Dt LLDB 1 \" Program name and manual section number
|
||||
.Os Darwin \" Operating System
|
||||
.Os
|
||||
.Sh NAME \" Section Header - required - don't modify
|
||||
.Nm lldb
|
||||
.Nd The debugger
|
||||
|
@ -86,6 +86,7 @@ infrastructure in FreeBSD:
|
||||
share/man/man8/rc.sendmail.8
|
||||
share/mk/bsd.libnames.mk
|
||||
share/sendmail/Makefile
|
||||
tools/build/mk/OptionalObsoleteFiles.inc
|
||||
usr.bin/Makefile
|
||||
usr.bin/vacation/Makefile
|
||||
usr.sbin/Makefile
|
||||
|
@ -82,6 +82,7 @@ struct KbdintAuthctxt
|
||||
void *ctxt;
|
||||
KbdintDevice *device;
|
||||
u_int nreq;
|
||||
u_int devices_done;
|
||||
};
|
||||
|
||||
#ifdef USE_PAM
|
||||
@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
|
||||
if (len == 0)
|
||||
break;
|
||||
for (i = 0; devices[i]; i++) {
|
||||
if (!auth2_method_allowed(authctxt,
|
||||
if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
|
||||
!auth2_method_allowed(authctxt,
|
||||
"keyboard-interactive", devices[i]->name))
|
||||
continue;
|
||||
if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0)
|
||||
if (strncmp(kbdintctxt->devices, devices[i]->name,
|
||||
len) == 0) {
|
||||
kbdintctxt->device = devices[i];
|
||||
kbdintctxt->devices_done |= 1 << i;
|
||||
}
|
||||
}
|
||||
t = kbdintctxt->devices;
|
||||
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
|
||||
|
@ -1247,29 +1247,39 @@ verify_host_key(char *host, struct sockaddr *hostaddr, Key *host_key)
|
||||
{
|
||||
int flags = 0;
|
||||
char *fp;
|
||||
Key *plain = NULL;
|
||||
|
||||
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
|
||||
debug("Server host key: %s %s", key_type(host_key), fp);
|
||||
free(fp);
|
||||
|
||||
/* XXX certs are not yet supported for DNS */
|
||||
if (!key_is_cert(host_key) && options.verify_host_key_dns &&
|
||||
verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
|
||||
if (flags & DNS_VERIFY_FOUND) {
|
||||
|
||||
if (options.verify_host_key_dns == 1 &&
|
||||
flags & DNS_VERIFY_MATCH &&
|
||||
flags & DNS_VERIFY_SECURE)
|
||||
return 0;
|
||||
|
||||
if (flags & DNS_VERIFY_MATCH) {
|
||||
matching_host_key_dns = 1;
|
||||
} else {
|
||||
warn_changed_key(host_key);
|
||||
error("Update the SSHFP RR in DNS with the new "
|
||||
"host key to get rid of this message.");
|
||||
if (options.verify_host_key_dns) {
|
||||
/*
|
||||
* XXX certs are not yet supported for DNS, so downgrade
|
||||
* them and try the plain key.
|
||||
*/
|
||||
plain = key_from_private(host_key);
|
||||
if (key_is_cert(plain))
|
||||
key_drop_cert(plain);
|
||||
if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
|
||||
if (flags & DNS_VERIFY_FOUND) {
|
||||
if (options.verify_host_key_dns == 1 &&
|
||||
flags & DNS_VERIFY_MATCH &&
|
||||
flags & DNS_VERIFY_SECURE) {
|
||||
key_free(plain);
|
||||
return 0;
|
||||
}
|
||||
if (flags & DNS_VERIFY_MATCH) {
|
||||
matching_host_key_dns = 1;
|
||||
} else {
|
||||
warn_changed_key(plain);
|
||||
error("Update the SSHFP RR in DNS "
|
||||
"with the new host key to get rid "
|
||||
"of this message.");
|
||||
}
|
||||
}
|
||||
}
|
||||
key_free(plain);
|
||||
}
|
||||
|
||||
return check_host_key(host, hostaddr, options.port, host_key, RDRW,
|
||||
|
@ -664,7 +664,7 @@ opensm_enable="NO" # Opensm(8) for infiniband devices defaults to off
|
||||
casperd_enable="YES" # casperd(8) daemon
|
||||
|
||||
# rctl(8) requires kernel options RACCT and RCTL
|
||||
rctl_enable="NO" # Load rctl(8) rules on boot
|
||||
rctl_enable="YES" # Load rctl(8) rules on boot
|
||||
rctl_rules="/etc/rctl.conf" # rctl(8) ruleset. See rctl.conf(5).
|
||||
|
||||
iovctl_files="" # Config files for iovctl(8)
|
||||
|
@ -1249,6 +1249,70 @@ ifscript_down()
|
||||
fi
|
||||
}
|
||||
|
||||
# wlan_up
|
||||
# Create IEEE802.3 interfaces.
|
||||
#
|
||||
wlan_up()
|
||||
{
|
||||
local _list _iflist wlan parent ifn
|
||||
_list=
|
||||
_iflist=$*
|
||||
|
||||
for wlan in `set | egrep ^wlans_[a-z]+[0-9]+=[a-z]+[0-9]+`; do
|
||||
# Parse wlans_$parent=$ifn
|
||||
wlan=`echo $wlan | sed -E 's/wlans_([a-z]+[0-9]+)=([a-z]+[0-9]+)/\1:\2/'`
|
||||
OIFS=$IFS; IFS=:; set -- $wlan; parent=$1; ifn=$2; IFS=$OIFS
|
||||
case $_iflist in
|
||||
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
# Skip if ${ifn} already exists.
|
||||
if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
${IFCONFIG_CMD} ${ifn} create wlandev ${parent}
|
||||
if [ $? -eq 0 ]; then
|
||||
_list="$_list $ifn"
|
||||
fi
|
||||
done
|
||||
if [ -n "${_list# }" ]; then
|
||||
echo "Created wlan(4) interfaces: ${_list# }."
|
||||
fi
|
||||
debug "Created wlan(4)s: ${_list# }"
|
||||
}
|
||||
|
||||
# wlan_down
|
||||
# Destroy IEEE802.3 interfaces.
|
||||
#
|
||||
wlan_down()
|
||||
{
|
||||
local _list _iflist wlan parent ifn
|
||||
_list=
|
||||
_iflist=$*
|
||||
|
||||
for wlan in `set | egrep ^wlans_[a-z]+[0-9]+=[a-z]+[0-9]+`; do
|
||||
# Parse wlans_$parent=$ifn
|
||||
wlan=`echo $wlan | sed -E 's/wlans_([a-z]+[0-9]+)=([a-z]+[0-9]+)/\1:\2/'`
|
||||
OIFS=$IFS; IFS=:; set -- $wlan; parent=$1; ifn=$2; IFS=$OIFS
|
||||
case $_iflist in
|
||||
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
# Skip if ${ifn} doesn't exists.
|
||||
if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
${IFCONFIG_CMD} -n ${ifn} destroy
|
||||
if [ $? -eq 0 ]; then
|
||||
_list="$_list $ifn"
|
||||
fi
|
||||
done
|
||||
if [ -n "${_list# }" ]; then
|
||||
echo "Destroyed wlan(4) interfaces: ${_list# }."
|
||||
fi
|
||||
debug "Destroyed wlan(4)s: ${_list# }"
|
||||
}
|
||||
|
||||
# clone_up
|
||||
# Create cloneable interfaces.
|
||||
#
|
||||
@ -1398,6 +1462,9 @@ clone_down()
|
||||
# Create and configure child interfaces. Return 0 if child
|
||||
# interfaces are created.
|
||||
#
|
||||
# XXXGL: the wlan code in this functions is superseded by wlan_up(),
|
||||
# and will go away soon.
|
||||
#
|
||||
childif_create()
|
||||
{
|
||||
local cfg child child_vlans child_wlans create_args debug_flags ifn i
|
||||
|
@ -30,6 +30,6 @@ KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330
|
||||
# REFUSE korean polish portuguese russian ukrainian vietnamese
|
||||
|
||||
# List of INDEX files to build and the DESCRIBE file to use for each
|
||||
INDEX INDEX-8 DESCRIBE.8
|
||||
INDEX INDEX-9 DESCRIBE.9
|
||||
INDEX INDEX-10 DESCRIBE.10
|
||||
INDEX INDEX-11 DESCRIBE.11
|
||||
|
@ -37,6 +37,8 @@ name="netif"
|
||||
rcvar="${name}_enable"
|
||||
start_cmd="netif_start"
|
||||
stop_cmd="netif_stop"
|
||||
wlanup_cmd="wlan_up"
|
||||
wlandown_cmd="wlan_down"
|
||||
cloneup_cmd="clone_up"
|
||||
clonedown_cmd="clone_down"
|
||||
clear_cmd="doclear"
|
||||
@ -65,6 +67,9 @@ netif_start()
|
||||
trap : 2
|
||||
fi
|
||||
|
||||
# Create IEEE802.3 interface
|
||||
wlan_up $cmdifn
|
||||
|
||||
# Create cloned interfaces
|
||||
clone_up $cmdifn
|
||||
|
||||
@ -91,12 +96,14 @@ netif_start()
|
||||
netif_stop()
|
||||
{
|
||||
_clone_down=1
|
||||
_wlan_down=1
|
||||
netif_stop0 $*
|
||||
}
|
||||
|
||||
doclear()
|
||||
{
|
||||
_clone_down=
|
||||
_wlan_down=
|
||||
netif_stop0 $*
|
||||
}
|
||||
|
||||
@ -111,6 +118,11 @@ netif_stop0()
|
||||
# Deconfigure the interface(s)
|
||||
netif_common ifn_stop $cmdifn
|
||||
|
||||
# Destroy wlan interfaces
|
||||
if [ -n "$_wlan_down" ]; then
|
||||
wlan_down $cmdifn
|
||||
fi
|
||||
|
||||
# Destroy cloned interfaces
|
||||
if [ -n "$_clone_down" ]; then
|
||||
clone_down $cmdifn
|
||||
|
@ -10,6 +10,7 @@
|
||||
. /etc/rc.subr
|
||||
|
||||
name="rctl"
|
||||
rcvar="rctl_enable"
|
||||
start_cmd="rctl_start"
|
||||
stop_cmd="rctl_stop"
|
||||
|
||||
|
10
etc/rc.subr
10
etc/rc.subr
@ -1266,8 +1266,11 @@ _run_rc_killcmd()
|
||||
# run_rc_script file arg
|
||||
# Start the script `file' with `arg', and correctly handle the
|
||||
# return value from the script.
|
||||
# If `file' ends with `.sh', it's sourced into the current environment
|
||||
# when $rc_fast_and_loose is set, otherwise it is run as a child process.
|
||||
# If `file' ends with `.sh' and lives in /etc/rc.d, ignore it as it's
|
||||
# an old-style startup file.
|
||||
# If `file' ends with `.sh' and does not live in /etc/rc.d, it's sourced
|
||||
# into the current environment if $rc_fast_and_loose is set; otherwise
|
||||
# it is run as a child process.
|
||||
# If `file' appears to be a backup or scratch file, ignore it.
|
||||
# Otherwise if it is executable run as a child process.
|
||||
#
|
||||
@ -1333,7 +1336,8 @@ load_rc_config()
|
||||
# If a service name was specified, attempt to load
|
||||
# service-specific configuration
|
||||
if [ -n "$_name" ] ; then
|
||||
for _d in /etc ${local_startup%*/rc.d}; do
|
||||
for _d in /etc ${local_startup}; do
|
||||
_d=${_d%/rc.d}
|
||||
if [ -f ${_d}/rc.conf.d/"$_name" ]; then
|
||||
debug "Sourcing ${_d}/rc.conf.d/$_name"
|
||||
. ${_d}/rc.conf.d/"$_name"
|
||||
|
@ -7,24 +7,13 @@ SUBDIR= doc\
|
||||
libbfd \
|
||||
libopcodes \
|
||||
libbinutils \
|
||||
${_addr2line} \
|
||||
as \
|
||||
ld \
|
||||
${_nm} \
|
||||
objcopy \
|
||||
${_objcopy} \
|
||||
objdump \
|
||||
${_readelf} \
|
||||
${_size} \
|
||||
${_strings} \
|
||||
${_strip}
|
||||
|
||||
.if ${MK_ELFTOOLCHAIN_TOOLS} == "no"
|
||||
_addr2line= addr2line
|
||||
_nm= nm
|
||||
_readelf= readelf
|
||||
_size= size
|
||||
_strings= strings
|
||||
_strip= strip
|
||||
.if ${MK_ELFTOOLCHAIN_TOOLS} == "no" || ${MK_ELFCOPY_AS_OBJCOPY} == "no"
|
||||
_objcopy= objcopy
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
PROG= addr2line
|
||||
SRCS= addr2line.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
|
||||
CFLAGS+= -I${SRCDIR}/binutils
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,266 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "ADDR2LINE 1"
|
||||
.TH ADDR2LINE 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
addr2line \- convert addresses into file names and line numbers
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
addr2line [\fB\-b\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR]
|
||||
[\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR]]
|
||||
[\fB\-e\fR \fIfilename\fR|\fB\-\-exe=\fR\fIfilename\fR]
|
||||
[\fB\-f\fR|\fB\-\-functions\fR] [\fB\-s\fR|\fB\-\-basename\fR]
|
||||
[\fB\-i\fR|\fB\-\-inlines\fR]
|
||||
[\fB\-j\fR|\fB\-\-section=\fR\fIname\fR]
|
||||
[\fB\-H\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
[addr addr ...]
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
\&\fBaddr2line\fR translates addresses into file names and line numbers.
|
||||
Given an address in an executable or an offset in a section of a relocatable
|
||||
object, it uses the debugging information to figure out which file name and
|
||||
line number are associated with it.
|
||||
.PP
|
||||
The executable or relocatable object to use is specified with the \fB\-e\fR
|
||||
option. The default is the file \fIa.out\fR. The section in the relocatable
|
||||
object to use is specified with the \fB\-j\fR option.
|
||||
.PP
|
||||
\&\fBaddr2line\fR has two modes of operation.
|
||||
.PP
|
||||
In the first, hexadecimal addresses are specified on the command line,
|
||||
and \fBaddr2line\fR displays the file name and line number for each
|
||||
address.
|
||||
.PP
|
||||
In the second, \fBaddr2line\fR reads hexadecimal addresses from
|
||||
standard input, and prints the file name and line number for each
|
||||
address on standard output. In this mode, \fBaddr2line\fR may be used
|
||||
in a pipe to convert dynamically chosen addresses.
|
||||
.PP
|
||||
The format of the output is \fB\s-1FILENAME:LINENO\s0\fR. The file name and
|
||||
line number for each address is printed on a separate line. If the
|
||||
\&\fB\-f\fR option is used, then each \fB\s-1FILENAME:LINENO\s0\fR line is
|
||||
preceded by a \fB\s-1FUNCTIONNAME\s0\fR line which is the name of the function
|
||||
containing the address.
|
||||
.PP
|
||||
If the file name or function name can not be determined,
|
||||
\&\fBaddr2line\fR will print two question marks in their place. If the
|
||||
line number can not be determined, \fBaddr2line\fR will print 0.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
The long and short forms of options, shown here as alternatives, are
|
||||
equivalent.
|
||||
.IP "\fB\-b\fR \fIbfdname\fR" 4
|
||||
.IX Item "-b bfdname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--target=bfdname"
|
||||
.PD
|
||||
Specify that the object-code format for the object files is
|
||||
\&\fIbfdname\fR.
|
||||
.IP "\fB\-C\fR" 4
|
||||
.IX Item "-C"
|
||||
.PD 0
|
||||
.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4
|
||||
.IX Item "--demangle[=style]"
|
||||
.PD
|
||||
Decode (\fIdemangle\fR) low-level symbol names into user-level names.
|
||||
Besides removing any initial underscore prepended by the system, this
|
||||
makes \*(C+ function names readable. Different compilers have different
|
||||
mangling styles. The optional demangling style argument can be used to
|
||||
choose an appropriate demangling style for your compiler.
|
||||
.IP "\fB\-e\fR \fIfilename\fR" 4
|
||||
.IX Item "-e filename"
|
||||
.PD 0
|
||||
.IP "\fB\-\-exe=\fR\fIfilename\fR" 4
|
||||
.IX Item "--exe=filename"
|
||||
.PD
|
||||
Specify the name of the executable for which addresses should be
|
||||
translated. The default file is \fIa.out\fR.
|
||||
.IP "\fB\-f\fR" 4
|
||||
.IX Item "-f"
|
||||
.PD 0
|
||||
.IP "\fB\-\-functions\fR" 4
|
||||
.IX Item "--functions"
|
||||
.PD
|
||||
Display function names as well as file and line number information.
|
||||
.IP "\fB\-s\fR" 4
|
||||
.IX Item "-s"
|
||||
.PD 0
|
||||
.IP "\fB\-\-basenames\fR" 4
|
||||
.IX Item "--basenames"
|
||||
.PD
|
||||
Display only the base of each file name.
|
||||
.IP "\fB\-i\fR" 4
|
||||
.IX Item "-i"
|
||||
.PD 0
|
||||
.IP "\fB\-\-inlines\fR" 4
|
||||
.IX Item "--inlines"
|
||||
.PD
|
||||
If the address belongs to a function that was inlined, the source
|
||||
information for all enclosing scopes back to the first non-inlined
|
||||
function will also be printed. For example, if \f(CW\*(C`main\*(C'\fR inlines
|
||||
\&\f(CW\*(C`callee1\*(C'\fR which inlines \f(CW\*(C`callee2\*(C'\fR, and address is from
|
||||
\&\f(CW\*(C`callee2\*(C'\fR, the source information for \f(CW\*(C`callee1\*(C'\fR and \f(CW\*(C`main\*(C'\fR
|
||||
will also be printed.
|
||||
.IP "\fB\-j\fR" 4
|
||||
.IX Item "-j"
|
||||
.PD 0
|
||||
.IP "\fB\-\-section\fR" 4
|
||||
.IX Item "--section"
|
||||
.PD
|
||||
Read offsets relative to the specified section instead of absolute addresses.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,18 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
PROG= nm
|
||||
SRCS= nm.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
|
||||
CFLAGS+= -I${SRCDIR}/bfd
|
||||
CFLAGS+= -I${SRCDIR}/binutils
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,450 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "NM 1"
|
||||
.TH NM 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
nm \- list symbols from object files
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
nm [\fB\-a\fR|\fB\-\-debug\-syms\fR] [\fB\-g\fR|\fB\-\-extern\-only\fR]
|
||||
[\fB\-B\fR] [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR]] [\fB\-D\fR|\fB\-\-dynamic\fR]
|
||||
[\fB\-S\fR|\fB\-\-print\-size\fR] [\fB\-s\fR|\fB\-\-print\-armap\fR]
|
||||
[\fB\-A\fR|\fB\-o\fR|\fB\-\-print\-file\-name\fR][\fB\-\-special\-syms\fR]
|
||||
[\fB\-n\fR|\fB\-v\fR|\fB\-\-numeric\-sort\fR] [\fB\-p\fR|\fB\-\-no\-sort\fR]
|
||||
[\fB\-r\fR|\fB\-\-reverse\-sort\fR] [\fB\-\-size\-sort\fR] [\fB\-u\fR|\fB\-\-undefined\-only\fR]
|
||||
[\fB\-t\fR \fIradix\fR|\fB\-\-radix=\fR\fIradix\fR] [\fB\-P\fR|\fB\-\-portability\fR]
|
||||
[\fB\-\-target=\fR\fIbfdname\fR] [\fB\-f\fR\fIformat\fR|\fB\-\-format=\fR\fIformat\fR]
|
||||
[\fB\-\-defined\-only\fR] [\fB\-l\fR|\fB\-\-line\-numbers\fR] [\fB\-\-no\-demangle\fR]
|
||||
[\fB\-V\fR|\fB\-\-version\fR] [\fB\-X 32_64\fR] [\fB\-\-help\fR] [\fIobjfile\fR...]
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
\&\s-1GNU\s0 \fBnm\fR lists the symbols from object files \fIobjfile\fR....
|
||||
If no object files are listed as arguments, \fBnm\fR assumes the file
|
||||
\&\fIa.out\fR.
|
||||
.PP
|
||||
For each symbol, \fBnm\fR shows:
|
||||
.IP "\(bu" 4
|
||||
The symbol value, in the radix selected by options (see below), or
|
||||
hexadecimal by default.
|
||||
.IP "\(bu" 4
|
||||
The symbol type. At least the following types are used; others are, as
|
||||
well, depending on the object file format. If lowercase, the symbol is
|
||||
local; if uppercase, the symbol is global (external).
|
||||
.RS 4
|
||||
.ie n .IP """A""" 4
|
||||
.el .IP "\f(CWA\fR" 4
|
||||
.IX Item "A"
|
||||
The symbol's value is absolute, and will not be changed by further
|
||||
linking.
|
||||
.ie n .IP """B""" 4
|
||||
.el .IP "\f(CWB\fR" 4
|
||||
.IX Item "B"
|
||||
The symbol is in the uninitialized data section (known as \s-1BSS\s0).
|
||||
.ie n .IP """C""" 4
|
||||
.el .IP "\f(CWC\fR" 4
|
||||
.IX Item "C"
|
||||
The symbol is common. Common symbols are uninitialized data. When
|
||||
linking, multiple common symbols may appear with the same name. If the
|
||||
symbol is defined anywhere, the common symbols are treated as undefined
|
||||
references.
|
||||
.ie n .IP """D""" 4
|
||||
.el .IP "\f(CWD\fR" 4
|
||||
.IX Item "D"
|
||||
The symbol is in the initialized data section.
|
||||
.ie n .IP """G""" 4
|
||||
.el .IP "\f(CWG\fR" 4
|
||||
.IX Item "G"
|
||||
The symbol is in an initialized data section for small objects. Some
|
||||
object file formats permit more efficient access to small data objects,
|
||||
such as a global int variable as opposed to a large global array.
|
||||
.ie n .IP """I""" 4
|
||||
.el .IP "\f(CWI\fR" 4
|
||||
.IX Item "I"
|
||||
The symbol is an indirect reference to another symbol. This is a \s-1GNU\s0
|
||||
extension to the a.out object file format which is rarely used.
|
||||
.ie n .IP """N""" 4
|
||||
.el .IP "\f(CWN\fR" 4
|
||||
.IX Item "N"
|
||||
The symbol is a debugging symbol.
|
||||
.ie n .IP """R""" 4
|
||||
.el .IP "\f(CWR\fR" 4
|
||||
.IX Item "R"
|
||||
The symbol is in a read only data section.
|
||||
.ie n .IP """S""" 4
|
||||
.el .IP "\f(CWS\fR" 4
|
||||
.IX Item "S"
|
||||
The symbol is in an uninitialized data section for small objects.
|
||||
.ie n .IP """T""" 4
|
||||
.el .IP "\f(CWT\fR" 4
|
||||
.IX Item "T"
|
||||
The symbol is in the text (code) section.
|
||||
.ie n .IP """U""" 4
|
||||
.el .IP "\f(CWU\fR" 4
|
||||
.IX Item "U"
|
||||
The symbol is undefined.
|
||||
.ie n .IP """V""" 4
|
||||
.el .IP "\f(CWV\fR" 4
|
||||
.IX Item "V"
|
||||
The symbol is a weak object. When a weak defined symbol is linked with
|
||||
a normal defined symbol, the normal defined symbol is used with no error.
|
||||
When a weak undefined symbol is linked and the symbol is not defined,
|
||||
the value of the weak symbol becomes zero with no error.
|
||||
.ie n .IP """W""" 4
|
||||
.el .IP "\f(CWW\fR" 4
|
||||
.IX Item "W"
|
||||
The symbol is a weak symbol that has not been specifically tagged as a
|
||||
weak object symbol. When a weak defined symbol is linked with a normal
|
||||
defined symbol, the normal defined symbol is used with no error.
|
||||
When a weak undefined symbol is linked and the symbol is not defined,
|
||||
the value of the symbol is determined in a system-specific manner without
|
||||
error. On some systems, uppercase indicates that a default value has been
|
||||
specified.
|
||||
.ie n .IP """\-""" 4
|
||||
.el .IP "\f(CW\-\fR" 4
|
||||
.IX Item "-"
|
||||
The symbol is a stabs symbol in an a.out object file. In this case, the
|
||||
next values printed are the stabs other field, the stabs desc field, and
|
||||
the stab type. Stabs symbols are used to hold debugging information.
|
||||
.ie n .IP """?""" 4
|
||||
.el .IP "\f(CW?\fR" 4
|
||||
.IX Item "?"
|
||||
The symbol type is unknown, or object file format specific.
|
||||
.RE
|
||||
.RS 4
|
||||
.RE
|
||||
.IP "\(bu" 4
|
||||
The symbol name.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
The long and short forms of options, shown here as alternatives, are
|
||||
equivalent.
|
||||
.IP "\fB\-A\fR" 4
|
||||
.IX Item "-A"
|
||||
.PD 0
|
||||
.IP "\fB\-o\fR" 4
|
||||
.IX Item "-o"
|
||||
.IP "\fB\-\-print\-file\-name\fR" 4
|
||||
.IX Item "--print-file-name"
|
||||
.PD
|
||||
Precede each symbol by the name of the input file (or archive member)
|
||||
in which it was found, rather than identifying the input file once only,
|
||||
before all of its symbols.
|
||||
.IP "\fB\-a\fR" 4
|
||||
.IX Item "-a"
|
||||
.PD 0
|
||||
.IP "\fB\-\-debug\-syms\fR" 4
|
||||
.IX Item "--debug-syms"
|
||||
.PD
|
||||
Display all symbols, even debugger-only symbols; normally these are not
|
||||
listed.
|
||||
.IP "\fB\-B\fR" 4
|
||||
.IX Item "-B"
|
||||
The same as \fB\-\-format=bsd\fR (for compatibility with the \s-1MIPS\s0 \fBnm\fR).
|
||||
.IP "\fB\-C\fR" 4
|
||||
.IX Item "-C"
|
||||
.PD 0
|
||||
.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4
|
||||
.IX Item "--demangle[=style]"
|
||||
.PD
|
||||
Decode (\fIdemangle\fR) low-level symbol names into user-level names.
|
||||
Besides removing any initial underscore prepended by the system, this
|
||||
makes \*(C+ function names readable. Different compilers have different
|
||||
mangling styles. The optional demangling style argument can be used to
|
||||
choose an appropriate demangling style for your compiler.
|
||||
.IP "\fB\-\-no\-demangle\fR" 4
|
||||
.IX Item "--no-demangle"
|
||||
Do not demangle low-level symbol names. This is the default.
|
||||
.IP "\fB\-D\fR" 4
|
||||
.IX Item "-D"
|
||||
.PD 0
|
||||
.IP "\fB\-\-dynamic\fR" 4
|
||||
.IX Item "--dynamic"
|
||||
.PD
|
||||
Display the dynamic symbols rather than the normal symbols. This is
|
||||
only meaningful for dynamic objects, such as certain types of shared
|
||||
libraries.
|
||||
.IP "\fB\-f\fR \fIformat\fR" 4
|
||||
.IX Item "-f format"
|
||||
.PD 0
|
||||
.IP "\fB\-\-format=\fR\fIformat\fR" 4
|
||||
.IX Item "--format=format"
|
||||
.PD
|
||||
Use the output format \fIformat\fR, which can be \f(CW\*(C`bsd\*(C'\fR,
|
||||
\&\f(CW\*(C`sysv\*(C'\fR, or \f(CW\*(C`posix\*(C'\fR. The default is \f(CW\*(C`bsd\*(C'\fR.
|
||||
Only the first character of \fIformat\fR is significant; it can be
|
||||
either upper or lower case.
|
||||
.IP "\fB\-g\fR" 4
|
||||
.IX Item "-g"
|
||||
.PD 0
|
||||
.IP "\fB\-\-extern\-only\fR" 4
|
||||
.IX Item "--extern-only"
|
||||
.PD
|
||||
Display only external symbols.
|
||||
.IP "\fB\-l\fR" 4
|
||||
.IX Item "-l"
|
||||
.PD 0
|
||||
.IP "\fB\-\-line\-numbers\fR" 4
|
||||
.IX Item "--line-numbers"
|
||||
.PD
|
||||
For each symbol, use debugging information to try to find a filename and
|
||||
line number. For a defined symbol, look for the line number of the
|
||||
address of the symbol. For an undefined symbol, look for the line
|
||||
number of a relocation entry which refers to the symbol. If line number
|
||||
information can be found, print it after the other symbol information.
|
||||
.IP "\fB\-n\fR" 4
|
||||
.IX Item "-n"
|
||||
.PD 0
|
||||
.IP "\fB\-v\fR" 4
|
||||
.IX Item "-v"
|
||||
.IP "\fB\-\-numeric\-sort\fR" 4
|
||||
.IX Item "--numeric-sort"
|
||||
.PD
|
||||
Sort symbols numerically by their addresses, rather than alphabetically
|
||||
by their names.
|
||||
.IP "\fB\-p\fR" 4
|
||||
.IX Item "-p"
|
||||
.PD 0
|
||||
.IP "\fB\-\-no\-sort\fR" 4
|
||||
.IX Item "--no-sort"
|
||||
.PD
|
||||
Do not bother to sort the symbols in any order; print them in the order
|
||||
encountered.
|
||||
.IP "\fB\-P\fR" 4
|
||||
.IX Item "-P"
|
||||
.PD 0
|
||||
.IP "\fB\-\-portability\fR" 4
|
||||
.IX Item "--portability"
|
||||
.PD
|
||||
Use the \s-1POSIX\s0.2 standard output format instead of the default format.
|
||||
Equivalent to \fB\-f posix\fR.
|
||||
.IP "\fB\-S\fR" 4
|
||||
.IX Item "-S"
|
||||
.PD 0
|
||||
.IP "\fB\-\-print\-size\fR" 4
|
||||
.IX Item "--print-size"
|
||||
.PD
|
||||
Print size, not the value, of defined symbols for the \f(CW\*(C`bsd\*(C'\fR output format.
|
||||
.IP "\fB\-s\fR" 4
|
||||
.IX Item "-s"
|
||||
.PD 0
|
||||
.IP "\fB\-\-print\-armap\fR" 4
|
||||
.IX Item "--print-armap"
|
||||
.PD
|
||||
When listing symbols from archive members, include the index: a mapping
|
||||
(stored in the archive by \fBar\fR or \fBranlib\fR) of which modules
|
||||
contain definitions for which names.
|
||||
.IP "\fB\-r\fR" 4
|
||||
.IX Item "-r"
|
||||
.PD 0
|
||||
.IP "\fB\-\-reverse\-sort\fR" 4
|
||||
.IX Item "--reverse-sort"
|
||||
.PD
|
||||
Reverse the order of the sort (whether numeric or alphabetic); let the
|
||||
last come first.
|
||||
.IP "\fB\-\-size\-sort\fR" 4
|
||||
.IX Item "--size-sort"
|
||||
Sort symbols by size. The size is computed as the difference between
|
||||
the value of the symbol and the value of the symbol with the next higher
|
||||
value. If the \f(CW\*(C`bsd\*(C'\fR output format is used the size of the symbol
|
||||
is printed, rather than the value, and \fB\-S\fR must be used in order
|
||||
both size and value to be printed.
|
||||
.IP "\fB\-\-special\-syms\fR" 4
|
||||
.IX Item "--special-syms"
|
||||
Display symbols which have a target-specific special meaning. These
|
||||
symbols are usually used by the target for some special processing and
|
||||
are not normally helpful when included included in the normal symbol
|
||||
lists. For example for \s-1ARM\s0 targets this option would skip the mapping
|
||||
symbols used to mark transitions between \s-1ARM\s0 code, \s-1THUMB\s0 code and
|
||||
data.
|
||||
.IP "\fB\-t\fR \fIradix\fR" 4
|
||||
.IX Item "-t radix"
|
||||
.PD 0
|
||||
.IP "\fB\-\-radix=\fR\fIradix\fR" 4
|
||||
.IX Item "--radix=radix"
|
||||
.PD
|
||||
Use \fIradix\fR as the radix for printing the symbol values. It must be
|
||||
\&\fBd\fR for decimal, \fBo\fR for octal, or \fBx\fR for hexadecimal.
|
||||
.IP "\fB\-\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--target=bfdname"
|
||||
Specify an object code format other than your system's default format.
|
||||
.IP "\fB\-u\fR" 4
|
||||
.IX Item "-u"
|
||||
.PD 0
|
||||
.IP "\fB\-\-undefined\-only\fR" 4
|
||||
.IX Item "--undefined-only"
|
||||
.PD
|
||||
Display only undefined symbols (those external to each object file).
|
||||
.IP "\fB\-\-defined\-only\fR" 4
|
||||
.IX Item "--defined-only"
|
||||
Display only defined symbols for each object file.
|
||||
.IP "\fB\-V\fR" 4
|
||||
.IX Item "-V"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\fR" 4
|
||||
.IX Item "--version"
|
||||
.PD
|
||||
Show the version number of \fBnm\fR and exit.
|
||||
.IP "\fB\-X\fR" 4
|
||||
.IX Item "-X"
|
||||
This option is ignored for compatibility with the \s-1AIX\s0 version of
|
||||
\&\fBnm\fR. It takes one parameter which must be the string
|
||||
\&\fB32_64\fR. The default mode of \s-1AIX\s0 \fBnm\fR corresponds
|
||||
to \fB\-X 32\fR, which is not supported by \s-1GNU\s0 \fBnm\fR.
|
||||
.IP "\fB\-\-help\fR" 4
|
||||
.IX Item "--help"
|
||||
Show a summary of the options to \fBnm\fR and exit.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\&\fIar\fR\|(1), \fIobjdump\fR\|(1), \fIranlib\fR\|(1), and the Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,20 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
# No a.out vs. ELF version so don't install in /usr/libexec/elf
|
||||
BINDIR=/usr/bin
|
||||
|
||||
PROG= readelf
|
||||
SRCS= ${PROG}.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils -I${SRCDIR}/binutils
|
||||
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,377 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "READELF 1"
|
||||
.TH READELF 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
readelf \- Displays information about ELF files.
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
readelf [\fB\-a\fR|\fB\-\-all\fR]
|
||||
[\fB\-h\fR|\fB\-\-file\-header\fR]
|
||||
[\fB\-l\fR|\fB\-\-program\-headers\fR|\fB\-\-segments\fR]
|
||||
[\fB\-S\fR|\fB\-\-section\-headers\fR|\fB\-\-sections\fR]
|
||||
[\fB\-g\fR|\fB\-\-section\-groups\fR]
|
||||
[\fB\-t\fR|\fB\-\-section\-details\fR]
|
||||
[\fB\-e\fR|\fB\-\-headers\fR]
|
||||
[\fB\-s\fR|\fB\-\-syms\fR|\fB\-\-symbols\fR]
|
||||
[\fB\-n\fR|\fB\-\-notes\fR]
|
||||
[\fB\-r\fR|\fB\-\-relocs\fR]
|
||||
[\fB\-u\fR|\fB\-\-unwind\fR]
|
||||
[\fB\-d\fR|\fB\-\-dynamic\fR]
|
||||
[\fB\-V\fR|\fB\-\-version\-info\fR]
|
||||
[\fB\-A\fR|\fB\-\-arch\-specific\fR]
|
||||
[\fB\-D\fR|\fB\-\-use\-dynamic\fR]
|
||||
[\fB\-x\fR <number or name>|\fB\-\-hex\-dump=\fR<number or name>]
|
||||
[\fB\-w[liaprmfFsoR]\fR|
|
||||
\fB\-\-debug\-dump\fR[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges]]
|
||||
[\fB\-I\fR|\fB\-histogram\fR]
|
||||
[\fB\-v\fR|\fB\-\-version\fR]
|
||||
[\fB\-W\fR|\fB\-\-wide\fR]
|
||||
[\fB\-H\fR|\fB\-\-help\fR]
|
||||
\fIelffile\fR...
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
\&\fBreadelf\fR displays information about one or more \s-1ELF\s0 format object
|
||||
files. The options control what particular information to display.
|
||||
.PP
|
||||
\&\fIelffile\fR... are the object files to be examined. 32\-bit and
|
||||
64\-bit \s-1ELF\s0 files are supported, as are archives containing \s-1ELF\s0 files.
|
||||
.PP
|
||||
This program performs a similar function to \fBobjdump\fR but it
|
||||
goes into more detail and it exists independently of the \s-1BFD\s0
|
||||
library, so if there is a bug in \s-1BFD\s0 then readelf will not be
|
||||
affected.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
The long and short forms of options, shown here as alternatives, are
|
||||
equivalent. At least one option besides \fB\-v\fR or \fB\-H\fR must be
|
||||
given.
|
||||
.IP "\fB\-a\fR" 4
|
||||
.IX Item "-a"
|
||||
.PD 0
|
||||
.IP "\fB\-\-all\fR" 4
|
||||
.IX Item "--all"
|
||||
.PD
|
||||
Equivalent to specifying \fB\-\-file\-header\fR,
|
||||
\&\fB\-\-program\-headers\fR, \fB\-\-sections\fR, \fB\-\-symbols\fR,
|
||||
\&\fB\-\-relocs\fR, \fB\-\-dynamic\fR, \fB\-\-notes\fR and
|
||||
\&\fB\-\-version\-info\fR.
|
||||
.IP "\fB\-h\fR" 4
|
||||
.IX Item "-h"
|
||||
.PD 0
|
||||
.IP "\fB\-\-file\-header\fR" 4
|
||||
.IX Item "--file-header"
|
||||
.PD
|
||||
Displays the information contained in the \s-1ELF\s0 header at the start of the
|
||||
file.
|
||||
.IP "\fB\-l\fR" 4
|
||||
.IX Item "-l"
|
||||
.PD 0
|
||||
.IP "\fB\-\-program\-headers\fR" 4
|
||||
.IX Item "--program-headers"
|
||||
.IP "\fB\-\-segments\fR" 4
|
||||
.IX Item "--segments"
|
||||
.PD
|
||||
Displays the information contained in the file's segment headers, if it
|
||||
has any.
|
||||
.IP "\fB\-S\fR" 4
|
||||
.IX Item "-S"
|
||||
.PD 0
|
||||
.IP "\fB\-\-sections\fR" 4
|
||||
.IX Item "--sections"
|
||||
.IP "\fB\-\-section\-headers\fR" 4
|
||||
.IX Item "--section-headers"
|
||||
.PD
|
||||
Displays the information contained in the file's section headers, if it
|
||||
has any.
|
||||
.IP "\fB\-g\fR" 4
|
||||
.IX Item "-g"
|
||||
.PD 0
|
||||
.IP "\fB\-\-section\-groups\fR" 4
|
||||
.IX Item "--section-groups"
|
||||
.PD
|
||||
Displays the information contained in the file's section groups, if it
|
||||
has any.
|
||||
.IP "\fB\-t\fR" 4
|
||||
.IX Item "-t"
|
||||
.PD 0
|
||||
.IP "\fB\-\-section\-details\fR" 4
|
||||
.IX Item "--section-details"
|
||||
.PD
|
||||
Displays the detailed section information. Implies \fB\-S\fR.
|
||||
.IP "\fB\-s\fR" 4
|
||||
.IX Item "-s"
|
||||
.PD 0
|
||||
.IP "\fB\-\-symbols\fR" 4
|
||||
.IX Item "--symbols"
|
||||
.IP "\fB\-\-syms\fR" 4
|
||||
.IX Item "--syms"
|
||||
.PD
|
||||
Displays the entries in symbol table section of the file, if it has one.
|
||||
.IP "\fB\-e\fR" 4
|
||||
.IX Item "-e"
|
||||
.PD 0
|
||||
.IP "\fB\-\-headers\fR" 4
|
||||
.IX Item "--headers"
|
||||
.PD
|
||||
Display all the headers in the file. Equivalent to \fB\-h \-l \-S\fR.
|
||||
.IP "\fB\-n\fR" 4
|
||||
.IX Item "-n"
|
||||
.PD 0
|
||||
.IP "\fB\-\-notes\fR" 4
|
||||
.IX Item "--notes"
|
||||
.PD
|
||||
Displays the contents of the \s-1NOTE\s0 segments and/or sections, if any.
|
||||
.IP "\fB\-r\fR" 4
|
||||
.IX Item "-r"
|
||||
.PD 0
|
||||
.IP "\fB\-\-relocs\fR" 4
|
||||
.IX Item "--relocs"
|
||||
.PD
|
||||
Displays the contents of the file's relocation section, if it has one.
|
||||
.IP "\fB\-u\fR" 4
|
||||
.IX Item "-u"
|
||||
.PD 0
|
||||
.IP "\fB\-\-unwind\fR" 4
|
||||
.IX Item "--unwind"
|
||||
.PD
|
||||
Displays the contents of the file's unwind section, if it has one. Only
|
||||
the unwind sections for \s-1IA64\s0 \s-1ELF\s0 files are currently supported.
|
||||
.IP "\fB\-d\fR" 4
|
||||
.IX Item "-d"
|
||||
.PD 0
|
||||
.IP "\fB\-\-dynamic\fR" 4
|
||||
.IX Item "--dynamic"
|
||||
.PD
|
||||
Displays the contents of the file's dynamic section, if it has one.
|
||||
.IP "\fB\-V\fR" 4
|
||||
.IX Item "-V"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\-info\fR" 4
|
||||
.IX Item "--version-info"
|
||||
.PD
|
||||
Displays the contents of the version sections in the file, it they
|
||||
exist.
|
||||
.IP "\fB\-A\fR" 4
|
||||
.IX Item "-A"
|
||||
.PD 0
|
||||
.IP "\fB\-\-arch\-specific\fR" 4
|
||||
.IX Item "--arch-specific"
|
||||
.PD
|
||||
Displays architecture-specific information in the file, if there
|
||||
is any.
|
||||
.IP "\fB\-D\fR" 4
|
||||
.IX Item "-D"
|
||||
.PD 0
|
||||
.IP "\fB\-\-use\-dynamic\fR" 4
|
||||
.IX Item "--use-dynamic"
|
||||
.PD
|
||||
When displaying symbols, this option makes \fBreadelf\fR use the
|
||||
symbol table in the file's dynamic section, rather than the one in the
|
||||
symbols section.
|
||||
.IP "\fB\-x <number or name>\fR" 4
|
||||
.IX Item "-x <number or name>"
|
||||
.PD 0
|
||||
.IP "\fB\-\-hex\-dump=<number or name>\fR" 4
|
||||
.IX Item "--hex-dump=<number or name>"
|
||||
.PD
|
||||
Displays the contents of the indicated section as a hexadecimal dump.
|
||||
A number identifies a particular section by index in the section table;
|
||||
any other string identifies all sections with that name in the object file.
|
||||
.IP "\fB\-w[liaprmfFsoR]\fR" 4
|
||||
.IX Item "-w[liaprmfFsoR]"
|
||||
.PD 0
|
||||
.IP "\fB\-\-debug\-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames\-interp,=str,=loc,=Ranges]\fR" 4
|
||||
.IX Item "--debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges]"
|
||||
.PD
|
||||
Displays the contents of the debug sections in the file, if any are
|
||||
present. If one of the optional letters or words follows the switch
|
||||
then only data found in those specific sections will be dumped.
|
||||
.IP "\fB\-I\fR" 4
|
||||
.IX Item "-I"
|
||||
.PD 0
|
||||
.IP "\fB\-\-histogram\fR" 4
|
||||
.IX Item "--histogram"
|
||||
.PD
|
||||
Display a histogram of bucket list lengths when displaying the contents
|
||||
of the symbol tables.
|
||||
.IP "\fB\-v\fR" 4
|
||||
.IX Item "-v"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\fR" 4
|
||||
.IX Item "--version"
|
||||
.PD
|
||||
Display the version number of readelf.
|
||||
.IP "\fB\-W\fR" 4
|
||||
.IX Item "-W"
|
||||
.PD 0
|
||||
.IP "\fB\-\-wide\fR" 4
|
||||
.IX Item "--wide"
|
||||
.PD
|
||||
Don't break output lines to fit into 80 columns. By default
|
||||
\&\fBreadelf\fR breaks section header and segment listing lines for
|
||||
64\-bit \s-1ELF\s0 files, so that they fit into 80 columns. This option causes
|
||||
\&\fBreadelf\fR to print each section header resp. each segment one a
|
||||
single line, which is far more readable on terminals wider than 80 columns.
|
||||
.IP "\fB\-H\fR" 4
|
||||
.IX Item "-H"
|
||||
.PD 0
|
||||
.IP "\fB\-\-help\fR" 4
|
||||
.IX Item "--help"
|
||||
.PD
|
||||
Display the command line options understood by \fBreadelf\fR.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\&\fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
PROG= size
|
||||
SRCS= size.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
|
||||
CFLAGS+= -I${SRCDIR}/binutils
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,263 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "SIZE 1"
|
||||
.TH SIZE 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
size \- list section sizes and total size
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
size [\fB\-A\fR|\fB\-B\fR|\fB\-\-format=\fR\fIcompatibility\fR]
|
||||
[\fB\-\-help\fR]
|
||||
[\fB\-d\fR|\fB\-o\fR|\fB\-x\fR|\fB\-\-radix=\fR\fInumber\fR]
|
||||
[\fB\-t\fR|\fB\-\-totals\fR]
|
||||
[\fB\-\-target=\fR\fIbfdname\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
[\fIobjfile\fR...]
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
The \s-1GNU\s0 \fBsize\fR utility lists the section sizes\-\-\-and the total
|
||||
size\-\-\-for each of the object or archive files \fIobjfile\fR in its
|
||||
argument list. By default, one line of output is generated for each
|
||||
object file or each module in an archive.
|
||||
.PP
|
||||
\&\fIobjfile\fR... are the object files to be examined.
|
||||
If none are specified, the file \f(CW\*(C`a.out\*(C'\fR will be used.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
The command line options have the following meanings:
|
||||
.IP "\fB\-A\fR" 4
|
||||
.IX Item "-A"
|
||||
.PD 0
|
||||
.IP "\fB\-B\fR" 4
|
||||
.IX Item "-B"
|
||||
.IP "\fB\-\-format=\fR\fIcompatibility\fR" 4
|
||||
.IX Item "--format=compatibility"
|
||||
.PD
|
||||
Using one of these options, you can choose whether the output from \s-1GNU\s0
|
||||
\&\fBsize\fR resembles output from System V \fBsize\fR (using \fB\-A\fR,
|
||||
or \fB\-\-format=sysv\fR), or Berkeley \fBsize\fR (using \fB\-B\fR, or
|
||||
\&\fB\-\-format=berkeley\fR). The default is the one-line format similar to
|
||||
Berkeley's.
|
||||
.Sp
|
||||
Here is an example of the Berkeley (default) format of output from
|
||||
\&\fBsize\fR:
|
||||
.Sp
|
||||
.Vb 4
|
||||
\& $ size \-\-format=Berkeley ranlib size
|
||||
\& text data bss dec hex filename
|
||||
\& 294880 81920 11592 388392 5ed28 ranlib
|
||||
\& 294880 81920 11888 388688 5ee50 size
|
||||
.Ve
|
||||
.Sp
|
||||
This is the same data, but displayed closer to System V conventions:
|
||||
.Sp
|
||||
.Vb 7
|
||||
\& $ size \-\-format=SysV ranlib size
|
||||
\& ranlib :
|
||||
\& section size addr
|
||||
\& .text 294880 8192
|
||||
\& .data 81920 303104
|
||||
\& .bss 11592 385024
|
||||
\& Total 388392
|
||||
\&
|
||||
\&
|
||||
\& size :
|
||||
\& section size addr
|
||||
\& .text 294880 8192
|
||||
\& .data 81920 303104
|
||||
\& .bss 11888 385024
|
||||
\& Total 388688
|
||||
.Ve
|
||||
.IP "\fB\-\-help\fR" 4
|
||||
.IX Item "--help"
|
||||
Show a summary of acceptable arguments and options.
|
||||
.IP "\fB\-d\fR" 4
|
||||
.IX Item "-d"
|
||||
.PD 0
|
||||
.IP "\fB\-o\fR" 4
|
||||
.IX Item "-o"
|
||||
.IP "\fB\-x\fR" 4
|
||||
.IX Item "-x"
|
||||
.IP "\fB\-\-radix=\fR\fInumber\fR" 4
|
||||
.IX Item "--radix=number"
|
||||
.PD
|
||||
Using one of these options, you can control whether the size of each
|
||||
section is given in decimal (\fB\-d\fR, or \fB\-\-radix=10\fR); octal
|
||||
(\fB\-o\fR, or \fB\-\-radix=8\fR); or hexadecimal (\fB\-x\fR, or
|
||||
\&\fB\-\-radix=16\fR). In \fB\-\-radix=\fR\fInumber\fR, only the three
|
||||
values (8, 10, 16) are supported. The total size is always given in two
|
||||
radices; decimal and hexadecimal for \fB\-d\fR or \fB\-x\fR output, or
|
||||
octal and hexadecimal if you're using \fB\-o\fR.
|
||||
.IP "\fB\-t\fR" 4
|
||||
.IX Item "-t"
|
||||
.PD 0
|
||||
.IP "\fB\-\-totals\fR" 4
|
||||
.IX Item "--totals"
|
||||
.PD
|
||||
Show totals of all objects listed (Berkeley format listing mode only).
|
||||
.IP "\fB\-\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--target=bfdname"
|
||||
Specify that the object-code format for \fIobjfile\fR is
|
||||
\&\fIbfdname\fR. This option may not be necessary; \fBsize\fR can
|
||||
automatically recognize many formats.
|
||||
.IP "\fB\-V\fR" 4
|
||||
.IX Item "-V"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\fR" 4
|
||||
.IX Item "--version"
|
||||
.PD
|
||||
Display the version number of \fBsize\fR.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\&\fIar\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -1,17 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
PROG= strings
|
||||
SRCS= strings.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
|
||||
CFLAGS+= -I${SRCDIR}/binutils
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,254 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "STRINGS 1"
|
||||
.TH STRINGS 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
strings \- print the strings of printable characters in files.
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
strings [\fB\-afov\fR] [\fB\-\fR\fImin-len\fR]
|
||||
[\fB\-n\fR \fImin-len\fR] [\fB\-\-bytes=\fR\fImin-len\fR]
|
||||
[\fB\-t\fR \fIradix\fR] [\fB\-\-radix=\fR\fIradix\fR]
|
||||
[\fB\-e\fR \fIencoding\fR] [\fB\-\-encoding=\fR\fIencoding\fR]
|
||||
[\fB\-\fR] [\fB\-\-all\fR] [\fB\-\-print\-file\-name\fR]
|
||||
[\fB\-T\fR \fIbfdname\fR] [\fB\-\-target=\fR\fIbfdname\fR]
|
||||
[\fB\-\-help\fR] [\fB\-\-version\fR] \fIfile\fR...
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
For each \fIfile\fR given, \s-1GNU\s0 \fBstrings\fR prints the printable
|
||||
character sequences that are at least 4 characters long (or the number
|
||||
given with the options below) and are followed by an unprintable
|
||||
character. By default, it only prints the strings from the initialized
|
||||
and loaded sections of object files; for other types of files, it prints
|
||||
the strings from the whole file.
|
||||
.PP
|
||||
\&\fBstrings\fR is mainly useful for determining the contents of non-text
|
||||
files.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
.IP "\fB\-a\fR" 4
|
||||
.IX Item "-a"
|
||||
.PD 0
|
||||
.IP "\fB\-\-all\fR" 4
|
||||
.IX Item "--all"
|
||||
.IP "\fB\-\fR" 4
|
||||
.IX Item "-"
|
||||
.PD
|
||||
Do not scan only the initialized and loaded sections of object files;
|
||||
scan the whole files.
|
||||
.IP "\fB\-f\fR" 4
|
||||
.IX Item "-f"
|
||||
.PD 0
|
||||
.IP "\fB\-\-print\-file\-name\fR" 4
|
||||
.IX Item "--print-file-name"
|
||||
.PD
|
||||
Print the name of the file before each string.
|
||||
.IP "\fB\-\-help\fR" 4
|
||||
.IX Item "--help"
|
||||
Print a summary of the program usage on the standard output and exit.
|
||||
.IP "\fB\-\fR\fImin-len\fR" 4
|
||||
.IX Item "-min-len"
|
||||
.PD 0
|
||||
.IP "\fB\-n\fR \fImin-len\fR" 4
|
||||
.IX Item "-n min-len"
|
||||
.IP "\fB\-\-bytes=\fR\fImin-len\fR" 4
|
||||
.IX Item "--bytes=min-len"
|
||||
.PD
|
||||
Print sequences of characters that are at least \fImin-len\fR characters
|
||||
long, instead of the default 4.
|
||||
.IP "\fB\-o\fR" 4
|
||||
.IX Item "-o"
|
||||
Like \fB\-t o\fR. Some other versions of \fBstrings\fR have \fB\-o\fR
|
||||
act like \fB\-t d\fR instead. Since we can not be compatible with both
|
||||
ways, we simply chose one.
|
||||
.IP "\fB\-t\fR \fIradix\fR" 4
|
||||
.IX Item "-t radix"
|
||||
.PD 0
|
||||
.IP "\fB\-\-radix=\fR\fIradix\fR" 4
|
||||
.IX Item "--radix=radix"
|
||||
.PD
|
||||
Print the offset within the file before each string. The single
|
||||
character argument specifies the radix of the offset\-\-\-\fBo\fR for
|
||||
octal, \fBx\fR for hexadecimal, or \fBd\fR for decimal.
|
||||
.IP "\fB\-e\fR \fIencoding\fR" 4
|
||||
.IX Item "-e encoding"
|
||||
.PD 0
|
||||
.IP "\fB\-\-encoding=\fR\fIencoding\fR" 4
|
||||
.IX Item "--encoding=encoding"
|
||||
.PD
|
||||
Select the character encoding of the strings that are to be found.
|
||||
Possible values for \fIencoding\fR are: \fBs\fR = single\-7\-bit\-byte
|
||||
characters (\s-1ASCII\s0, \s-1ISO\s0 8859, etc., default), \fBS\fR =
|
||||
single\-8\-bit\-byte characters, \fBb\fR = 16\-bit bigendian, \fBl\fR =
|
||||
16\-bit littleendian, \fBB\fR = 32\-bit bigendian, \fBL\fR = 32\-bit
|
||||
littleendian. Useful for finding wide character strings.
|
||||
.IP "\fB\-T\fR \fIbfdname\fR" 4
|
||||
.IX Item "-T bfdname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--target=bfdname"
|
||||
.PD
|
||||
Specify an object code format other than your system's default format.
|
||||
.IP "\fB\-v\fR" 4
|
||||
.IX Item "-v"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\fR" 4
|
||||
.IX Item "--version"
|
||||
.PD
|
||||
Print the program version number on the standard output and exit.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
\&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjdump\fR\|(1), \fIranlib\fR\|(1), \fIreadelf\fR\|(1)
|
||||
and the Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -1,18 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include "../Makefile.inc0"
|
||||
|
||||
.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc
|
||||
|
||||
PROG= strip
|
||||
SRCS= objcopy.c is-strip.c
|
||||
CFLAGS+= -D_GNU_SOURCE
|
||||
CFLAGS+= -I${.CURDIR}/${RELTOP}/libbinutils
|
||||
CFLAGS+= -I${SRCDIR}/binutils -I${SRCDIR}/bfd
|
||||
DPADD= ${RELTOP}/libbinutils/libbinutils.a
|
||||
DPADD+= ${RELTOP}/libbfd/libbfd.a
|
||||
DPADD+= ${RELTOP}/libiberty/libiberty.a
|
||||
LDADD= ${DPADD}
|
||||
INSTALLFLAGS= -S
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,21 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/binutils/libbfd \
|
||||
gnu/usr.bin/binutils/libbinutils \
|
||||
gnu/usr.bin/binutils/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -1,392 +0,0 @@
|
||||
.\" $FreeBSD$
|
||||
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "STRIP 1"
|
||||
.TH STRIP 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
strip \- Discard symbols from object files
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
strip [\fB\-F\fR \fIbfdname\fR |\fB\-\-target=\fR\fIbfdname\fR]
|
||||
[\fB\-I\fR \fIbfdname\fR |\fB\-\-input\-target=\fR\fIbfdname\fR]
|
||||
[\fB\-O\fR \fIbfdname\fR |\fB\-\-output\-target=\fR\fIbfdname\fR]
|
||||
[\fB\-s\fR|\fB\-\-strip\-all\fR]
|
||||
[\fB\-S\fR|\fB\-g\fR|\fB\-d\fR|\fB\-\-strip\-debug\fR]
|
||||
[\fB\-K\fR \fIsymbolname\fR |\fB\-\-keep\-symbol=\fR\fIsymbolname\fR]
|
||||
[\fB\-N\fR \fIsymbolname\fR |\fB\-\-strip\-symbol=\fR\fIsymbolname\fR]
|
||||
[\fB\-w\fR|\fB\-\-wildcard\fR]
|
||||
[\fB\-x\fR|\fB\-\-discard\-all\fR] [\fB\-X\fR |\fB\-\-discard\-locals\fR]
|
||||
[\fB\-R\fR \fIsectionname\fR |\fB\-\-remove\-section=\fR\fIsectionname\fR]
|
||||
[\fB\-o\fR \fIfile\fR] [\fB\-p\fR|\fB\-\-preserve\-dates\fR]
|
||||
[\fB\-\-keep\-file\-symbols\fR]
|
||||
[\fB\-\-only\-keep\-debug\fR]
|
||||
[\fB\-v\fR |\fB\-\-verbose\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
[\fB\-\-help\fR] [\fB\-\-info\fR]
|
||||
\fIobjfile\fR...
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
\&\s-1GNU\s0 \fBstrip\fR discards all symbols from object files
|
||||
\&\fIobjfile\fR. The list of object files may include archives.
|
||||
At least one object file must be given.
|
||||
.PP
|
||||
\&\fBstrip\fR modifies the files named in its argument,
|
||||
rather than writing modified copies under different names.
|
||||
.SH "OPTIONS"
|
||||
.IX Header "OPTIONS"
|
||||
.IP "\fB\-F\fR \fIbfdname\fR" 4
|
||||
.IX Item "-F bfdname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--target=bfdname"
|
||||
.PD
|
||||
Treat the original \fIobjfile\fR as a file with the object
|
||||
code format \fIbfdname\fR, and rewrite it in the same format.
|
||||
.IP "\fB\-\-help\fR" 4
|
||||
.IX Item "--help"
|
||||
Show a summary of the options to \fBstrip\fR and exit.
|
||||
.IP "\fB\-\-info\fR" 4
|
||||
.IX Item "--info"
|
||||
Display a list showing all architectures and object formats available.
|
||||
.IP "\fB\-I\fR \fIbfdname\fR" 4
|
||||
.IX Item "-I bfdname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--input-target=bfdname"
|
||||
.PD
|
||||
Treat the original \fIobjfile\fR as a file with the object
|
||||
code format \fIbfdname\fR.
|
||||
.IP "\fB\-O\fR \fIbfdname\fR" 4
|
||||
.IX Item "-O bfdname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4
|
||||
.IX Item "--output-target=bfdname"
|
||||
.PD
|
||||
Replace \fIobjfile\fR with a file in the output format \fIbfdname\fR.
|
||||
.IP "\fB\-R\fR \fIsectionname\fR" 4
|
||||
.IX Item "-R sectionname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-remove\-section=\fR\fIsectionname\fR" 4
|
||||
.IX Item "--remove-section=sectionname"
|
||||
.PD
|
||||
Remove any section named \fIsectionname\fR from the output file. This
|
||||
option may be given more than once. Note that using this option
|
||||
inappropriately may make the output file unusable.
|
||||
.IP "\fB\-s\fR" 4
|
||||
.IX Item "-s"
|
||||
.PD 0
|
||||
.IP "\fB\-\-strip\-all\fR" 4
|
||||
.IX Item "--strip-all"
|
||||
.PD
|
||||
Remove all symbols.
|
||||
.IP "\fB\-g\fR" 4
|
||||
.IX Item "-g"
|
||||
.PD 0
|
||||
.IP "\fB\-S\fR" 4
|
||||
.IX Item "-S"
|
||||
.IP "\fB\-d\fR" 4
|
||||
.IX Item "-d"
|
||||
.IP "\fB\-\-strip\-debug\fR" 4
|
||||
.IX Item "--strip-debug"
|
||||
.PD
|
||||
Remove debugging symbols only.
|
||||
.IP "\fB\-\-strip\-unneeded\fR" 4
|
||||
.IX Item "--strip-unneeded"
|
||||
Remove all symbols that are not needed for relocation processing.
|
||||
.IP "\fB\-K\fR \fIsymbolname\fR" 4
|
||||
.IX Item "-K symbolname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4
|
||||
.IX Item "--keep-symbol=symbolname"
|
||||
.PD
|
||||
When stripping symbols, keep symbol \fIsymbolname\fR even if it would
|
||||
normally be stripped. This option may be given more than once.
|
||||
.IP "\fB\-N\fR \fIsymbolname\fR" 4
|
||||
.IX Item "-N symbolname"
|
||||
.PD 0
|
||||
.IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4
|
||||
.IX Item "--strip-symbol=symbolname"
|
||||
.PD
|
||||
Remove symbol \fIsymbolname\fR from the source file. This option may be
|
||||
given more than once, and may be combined with strip options other than
|
||||
\&\fB\-K\fR.
|
||||
.IP "\fB\-o\fR \fIfile\fR" 4
|
||||
.IX Item "-o file"
|
||||
Put the stripped output in \fIfile\fR, rather than replacing the
|
||||
existing file. When this argument is used, only one \fIobjfile\fR
|
||||
argument may be specified.
|
||||
.IP "\fB\-p\fR" 4
|
||||
.IX Item "-p"
|
||||
.PD 0
|
||||
.IP "\fB\-\-preserve\-dates\fR" 4
|
||||
.IX Item "--preserve-dates"
|
||||
.PD
|
||||
Preserve the access and modification dates of the file.
|
||||
.IP "\fB\-w\fR" 4
|
||||
.IX Item "-w"
|
||||
.PD 0
|
||||
.IP "\fB\-\-wildcard\fR" 4
|
||||
.IX Item "--wildcard"
|
||||
.PD
|
||||
Permit regular expressions in \fIsymbolname\fRs used in other command
|
||||
line options. The question mark (?), asterisk (*), backslash (\e) and
|
||||
square brackets ([]) operators can be used anywhere in the symbol
|
||||
name. If the first character of the symbol name is the exclamation
|
||||
point (!) then the sense of the switch is reversed for that symbol.
|
||||
For example:
|
||||
.Sp
|
||||
.Vb 1
|
||||
\& \-w \-K !foo \-K fo*
|
||||
.Ve
|
||||
.Sp
|
||||
would cause strip to only keep symbols that start with the letters
|
||||
\&\*(L"fo\*(R", but to discard the symbol \*(L"foo\*(R".
|
||||
.IP "\fB\-x\fR" 4
|
||||
.IX Item "-x"
|
||||
.PD 0
|
||||
.IP "\fB\-\-discard\-all\fR" 4
|
||||
.IX Item "--discard-all"
|
||||
.PD
|
||||
Remove non-global symbols.
|
||||
.IP "\fB\-X\fR" 4
|
||||
.IX Item "-X"
|
||||
.PD 0
|
||||
.IP "\fB\-\-discard\-locals\fR" 4
|
||||
.IX Item "--discard-locals"
|
||||
.PD
|
||||
Remove compiler-generated local symbols.
|
||||
(These usually start with \fBL\fR or \fB.\fR.)
|
||||
.IP "\fB\-\-keep\-file\-symbols\fR" 4
|
||||
.IX Item "--keep-file-symbols"
|
||||
When stripping a file, perhaps with \fB\-\-strip\-debug\fR or
|
||||
\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names,
|
||||
which would otherwise get stripped.
|
||||
.IP "\fB\-\-only\-keep\-debug\fR" 4
|
||||
.IX Item "--only-keep-debug"
|
||||
Strip a file, removing contents of any sections that would not be
|
||||
stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections
|
||||
intact. In \s-1ELF\s0 files, this preserves all note sections in the output.
|
||||
.Sp
|
||||
The intention is that this option will be used in conjunction with
|
||||
\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a
|
||||
stripped binary which will occupy less space in \s-1RAM\s0 and in a
|
||||
distribution and the second a debugging information file which is only
|
||||
needed if debugging abilities are required. The suggested procedure
|
||||
to create these files is as follows:
|
||||
.RS 4
|
||||
.IP "1.<Link the executable as normal. Assuming that it is called>" 4
|
||||
.IX Item "1.<Link the executable as normal. Assuming that it is called>"
|
||||
\&\f(CW\*(C`foo\*(C'\fR then...
|
||||
.ie n .IP "1.<Run ""objcopy \-\-only\-keep\-debug foo foo.dbg"" to>" 4
|
||||
.el .IP "1.<Run \f(CWobjcopy \-\-only\-keep\-debug foo foo.dbg\fR to>" 4
|
||||
.IX Item "1.<Run objcopy --only-keep-debug foo foo.dbg to>"
|
||||
create a file containing the debugging info.
|
||||
.ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"" to create a>" 4
|
||||
.el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR to create a>" 4
|
||||
.IX Item "1.<Run objcopy --strip-debug foo to create a>"
|
||||
stripped executable.
|
||||
.ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.dbg foo"">" 4
|
||||
.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.dbg foo\fR>" 4
|
||||
.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.dbg foo>"
|
||||
to add a link to the debugging info into the stripped executable.
|
||||
.RE
|
||||
.RS 4
|
||||
.Sp
|
||||
Note \- the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info
|
||||
file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is
|
||||
optional. You could instead do this:
|
||||
.IP "1.<Link the executable as normal.>" 4
|
||||
.IX Item "1.<Link the executable as normal.>"
|
||||
.PD 0
|
||||
.ie n .IP "1.<Copy ""foo"" to ""foo.full"">" 4
|
||||
.el .IP "1.<Copy \f(CWfoo\fR to \f(CWfoo.full\fR>" 4
|
||||
.IX Item "1.<Copy foo to foo.full>"
|
||||
.ie n .IP "1.<Run ""strip \-\-strip\-debug foo"">" 4
|
||||
.el .IP "1.<Run \f(CWstrip \-\-strip\-debug foo\fR>" 4
|
||||
.IX Item "1.<Run strip --strip-debug foo>"
|
||||
.ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.full foo"">" 4
|
||||
.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.full foo\fR>" 4
|
||||
.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.full foo>"
|
||||
.RE
|
||||
.RS 4
|
||||
.PD
|
||||
.Sp
|
||||
ie the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the
|
||||
full executable. It does not have to be a file created by the
|
||||
\&\fB\-\-only\-keep\-debug\fR switch.
|
||||
.Sp
|
||||
Note \- this switch is only intended for use on fully linked files. It
|
||||
does not make sense to use it on object files where the debugging
|
||||
information may be incomplete. Besides the gnu_debuglink feature
|
||||
currently only supports the presence of one filename containing
|
||||
debugging information, not multiple filenames on a one-per-object-file
|
||||
basis.
|
||||
.RE
|
||||
.IP "\fB\-V\fR" 4
|
||||
.IX Item "-V"
|
||||
.PD 0
|
||||
.IP "\fB\-\-version\fR" 4
|
||||
.IX Item "--version"
|
||||
.PD
|
||||
Show the version number for \fBstrip\fR.
|
||||
.IP "\fB\-v\fR" 4
|
||||
.IX Item "-v"
|
||||
.PD 0
|
||||
.IP "\fB\-\-verbose\fR" 4
|
||||
.IX Item "--verbose"
|
||||
.PD
|
||||
Verbose output: list all object files modified. In the case of
|
||||
archives, \fBstrip \-v\fR lists all members of the archive.
|
||||
.IP "\fB@\fR\fIfile\fR" 4
|
||||
.IX Item "@file"
|
||||
Read command-line options from \fIfile\fR. The options read are
|
||||
inserted in place of the original @\fIfile\fR option. If \fIfile\fR
|
||||
does not exist, or cannot be read, then the option will be treated
|
||||
literally, and not removed.
|
||||
.Sp
|
||||
Options in \fIfile\fR are separated by whitespace. A whitespace
|
||||
character may be included in an option by surrounding the entire
|
||||
option in either single or double quotes. Any character (including a
|
||||
backslash) may be included by prefixing the character to be included
|
||||
with a backslash. The \fIfile\fR may itself contain additional
|
||||
@\fIfile\fR options; any such options will be processed recursively.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
the Info entries for \fIbinutils\fR.
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
.PP
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, with no Front-Cover Texts, and with no
|
||||
Back-Cover Texts. A copy of the license is included in the
|
||||
section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R".
|
@ -13,9 +13,6 @@ SUBDIR+= cpp
|
||||
|
||||
.if ${MK_CXX} != "no"
|
||||
SUBDIR+= cc1plus c++
|
||||
.if ${MK_ELFTOOLCHAIN_TOOLS} == "no"
|
||||
SUBDIR+= c++filt
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${MK_GCOV} != "no"
|
||||
|
@ -1,19 +0,0 @@
|
||||
# $FreeBSD$
|
||||
|
||||
MAN=
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.include "../Makefile.inc"
|
||||
.include "../Makefile.fe"
|
||||
|
||||
.PATH: ${GCCLIB}/libiberty
|
||||
|
||||
PROG= c++filt
|
||||
SRCS= cp-demangle.c
|
||||
|
||||
CFLAGS+= -DSTANDALONE_DEMANGLER -DVERSION=\"$(GCC_VERSION)\"
|
||||
|
||||
DPADD= ${LIBIBERTY}
|
||||
LDADD= ${LIBIBERTY}
|
||||
|
||||
.include <bsd.prog.mk>
|
@ -1,23 +0,0 @@
|
||||
# $FreeBSD$
|
||||
# Autogenerated - do NOT edit!
|
||||
|
||||
DEP_RELDIR := ${_PARSEDIR:S,${SRCTOP}/,,}
|
||||
|
||||
DIRDEPS = \
|
||||
gnu/lib/csu \
|
||||
gnu/lib/libgcc \
|
||||
gnu/usr.bin/cc/cc_tools \
|
||||
gnu/usr.bin/cc/libiberty \
|
||||
include \
|
||||
include/xlocale \
|
||||
lib/${CSU_DIR} \
|
||||
lib/libc \
|
||||
lib/libc_nonshared \
|
||||
lib/libcompiler_rt \
|
||||
|
||||
|
||||
.include <dirdeps.mk>
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# local dependencies - needed for -jN in clean tree
|
||||
.endif
|
@ -120,6 +120,7 @@ TESTS= \
|
||||
test_read_format_gtar_gz.c \
|
||||
test_read_format_gtar_lzma.c \
|
||||
test_read_format_gtar_sparse.c \
|
||||
test_read_format_gtar_sparse_skip_entry.c \
|
||||
test_read_format_iso_Z.c \
|
||||
test_read_format_iso_multi_extent.c \
|
||||
test_read_format_iso_xorriso.c \
|
||||
|
@ -36,19 +36,29 @@ __FBSDID("$FreeBSD$");
|
||||
static u_int
|
||||
__vdso_gettc_low(const struct vdso_timehands *th)
|
||||
{
|
||||
uint32_t rv;
|
||||
u_int rv;
|
||||
|
||||
__asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
|
||||
__asm __volatile("lfence; rdtsc; shrd %%cl, %%edx, %0"
|
||||
: "=a" (rv) : "c" (th->th_x86_shift) : "edx");
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static u_int
|
||||
__vdso_rdtsc32(void)
|
||||
{
|
||||
u_int rv;
|
||||
|
||||
__asm __volatile("lfence;rdtsc" : "=a" (rv) : : "edx");
|
||||
return (rv);
|
||||
}
|
||||
|
||||
#pragma weak __vdso_gettc
|
||||
u_int
|
||||
__vdso_gettc(const struct vdso_timehands *th)
|
||||
{
|
||||
|
||||
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
|
||||
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) :
|
||||
__vdso_rdtsc32());
|
||||
}
|
||||
|
||||
#pragma weak __vdso_gettimekeep
|
||||
|
@ -31,24 +31,78 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/time.h>
|
||||
#include <sys/vdso.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/specialreg.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
static int lfence_works = -1;
|
||||
|
||||
static int
|
||||
get_lfence_usage(void)
|
||||
{
|
||||
u_int cpuid_supported, p[4];
|
||||
|
||||
if (lfence_works == -1) {
|
||||
__asm __volatile(
|
||||
" pushfl\n"
|
||||
" popl %%eax\n"
|
||||
" movl %%eax,%%ecx\n"
|
||||
" xorl $0x200000,%%eax\n"
|
||||
" pushl %%eax\n"
|
||||
" popfl\n"
|
||||
" pushfl\n"
|
||||
" popl %%eax\n"
|
||||
" xorl %%eax,%%ecx\n"
|
||||
" je 1f\n"
|
||||
" movl $1,%0\n"
|
||||
" jmp 2f\n"
|
||||
"1: movl $0,%0\n"
|
||||
"2:\n"
|
||||
: "=r" (cpuid_supported) : : "eax", "ecx");
|
||||
if (cpuid_supported) {
|
||||
__asm __volatile(
|
||||
" pushl %%ebx\n"
|
||||
" cpuid\n"
|
||||
" movl %%ebx,%1\n"
|
||||
" popl %%ebx\n"
|
||||
: "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3])
|
||||
: "0" (0x1));
|
||||
lfence_works = (p[3] & CPUID_SSE2) != 0;
|
||||
} else
|
||||
lfence_works = 0;
|
||||
}
|
||||
return (lfence_works);
|
||||
}
|
||||
|
||||
static u_int
|
||||
__vdso_gettc_low(const struct vdso_timehands *th)
|
||||
{
|
||||
uint32_t rv;
|
||||
u_int rv;
|
||||
|
||||
if (get_lfence_usage() == 1)
|
||||
lfence();
|
||||
__asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
|
||||
: "=a" (rv) : "c" (th->th_x86_shift) : "edx");
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static u_int
|
||||
__vdso_rdtsc32(void)
|
||||
{
|
||||
u_int rv;
|
||||
|
||||
if (get_lfence_usage() == 1)
|
||||
lfence();
|
||||
rv = rdtsc32();
|
||||
return (rv);
|
||||
}
|
||||
|
||||
#pragma weak __vdso_gettc
|
||||
u_int
|
||||
__vdso_gettc(const struct vdso_timehands *th)
|
||||
{
|
||||
|
||||
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
|
||||
return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) :
|
||||
__vdso_rdtsc32());
|
||||
}
|
||||
|
||||
#pragma weak __vdso_gettimekeep
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 28, 2014
|
||||
.Dd August 1, 2015
|
||||
.Dt OPEN_MEMSTREAM 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -86,13 +86,13 @@ will contain the start of the memory buffer and the variable referenced by
|
||||
will contain the smaller of the current position and the current buffer length.
|
||||
.Pp
|
||||
After a successful call to
|
||||
.Xr fflush 3,
|
||||
.Xr fflush 3 ,
|
||||
the pointer referenced by
|
||||
.Fa bufp
|
||||
and the variable referenced by
|
||||
.Fa sizep
|
||||
are only valid until the next write operation or a call to
|
||||
.Xr fclose 3.
|
||||
.Xr fclose 3 .
|
||||
.Pp
|
||||
Once a stream is closed,
|
||||
the allocated buffer referenced by
|
||||
|
@ -42,6 +42,15 @@ tc_delta(const struct vdso_timehands *th)
|
||||
th->th_counter_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the absolute or boot-relative time from the
|
||||
* machine-specific fast timecounter and the published timehands
|
||||
* structure read from the shared page.
|
||||
*
|
||||
* The lockless reading scheme is similar to the one used to read the
|
||||
* in-kernel timehands, see sys/kern/kern_tc.c:binuptime(). This code
|
||||
* is based on the kernel implementation.
|
||||
*/
|
||||
static int
|
||||
binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs)
|
||||
{
|
||||
@ -52,27 +61,21 @@ binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs)
|
||||
if (!tk->tk_enabled)
|
||||
return (ENOSYS);
|
||||
|
||||
/*
|
||||
* XXXKIB. The load of tk->tk_current should use
|
||||
* atomic_load_acq_32 to provide load barrier. But
|
||||
* since tk points to r/o mapped page, x86
|
||||
* implementation of atomic_load_acq faults.
|
||||
*/
|
||||
curr = tk->tk_current;
|
||||
rmb();
|
||||
curr = atomic_load_acq_32(&tk->tk_current);
|
||||
th = &tk->tk_th[curr];
|
||||
if (th->th_algo != VDSO_TH_ALGO_1)
|
||||
return (ENOSYS);
|
||||
gen = th->th_gen;
|
||||
gen = atomic_load_acq_32(&th->th_gen);
|
||||
*bt = th->th_offset;
|
||||
bintime_addx(bt, th->th_scale * tc_delta(th));
|
||||
if (abs)
|
||||
bintime_add(bt, &th->th_boottime);
|
||||
|
||||
/*
|
||||
* Barrier for load of both tk->tk_current and th->th_gen.
|
||||
* Ensure that the load of th_offset is completed
|
||||
* before the load of th_gen.
|
||||
*/
|
||||
rmb();
|
||||
atomic_thread_fence_acq();
|
||||
} while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
|
||||
return (0);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 29, 2015
|
||||
.Dd August 4, 2015
|
||||
.Dt KQUEUE 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -288,6 +288,14 @@ Returns when the file pointer is not at the end of file.
|
||||
.Va data
|
||||
contains the offset from current position to end of file,
|
||||
and may be negative.
|
||||
.Pp
|
||||
This behavior is different from
|
||||
.Xr poll 2 ,
|
||||
where read events are triggered for regular files unconditionally.
|
||||
This event can be triggered unconditionally by setting the
|
||||
.Dv NOTE_FILE_POLL
|
||||
flag in
|
||||
.Va fflags .
|
||||
.It "Fifos, Pipes"
|
||||
Returns when the there is data to read;
|
||||
.Va data
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)unlink.2 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 25, 2010
|
||||
.Dd July 28, 2015
|
||||
.Dt UNLINK 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -151,6 +151,9 @@ The
|
||||
.Fa path
|
||||
argument
|
||||
points outside the process's allocated address space.
|
||||
.It Bq Er ENOSPC
|
||||
On file systems supporting copy-on-write or snapshots, there was not enough
|
||||
free space to record metadata for the delete operation of the file.
|
||||
.El
|
||||
.Pp
|
||||
In addition to the errors returned by the
|
||||
|
@ -1,3 +1,9 @@
|
||||
#$FreeBSD$
|
||||
|
||||
SRCS+= _umtx_op_err.S
|
||||
|
||||
# With the current compiler and libthr code, using SSE in libthr
|
||||
# does not provide enough performance improvement to outweigh
|
||||
# the extra context switch cost. This can measurably impact
|
||||
# performance when the application also does not use enough SSE.
|
||||
CFLAGS+=${CFLAGS_NO_SIMD}
|
||||
|
@ -1,3 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= _umtx_op_err.S
|
||||
|
||||
# With the current compiler and libthr code, using SSE in libthr
|
||||
# does not provide enough performance improvement to outweigh
|
||||
# the extra context switch cost. This can measurably impact
|
||||
# performance when the application also does not use enough SSE.
|
||||
CFLAGS+=${CFLAGS_NO_SIMD}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user