Compare commits
No commits in common. "7d182db32fa2e1d7ed689fd27714eae48cd24abf" and "b9a73106ed5de0705a82a23f5b8e56e0fee4a999" have entirely different histories.
7d182db32f
...
b9a73106ed
21
.gitmodules
vendored
21
.gitmodules
vendored
@ -1,21 +0,0 @@
|
|||||||
[submodule "deps/zlib"]
|
|
||||||
path = deps/zlib
|
|
||||||
url = https://github.com/madler/zlib.git
|
|
||||||
[submodule "deps/libsodium"]
|
|
||||||
path = deps/libsodium
|
|
||||||
url = https://github.com/jedisct1/libsodium.git
|
|
||||||
[submodule "deps/quickjs"]
|
|
||||||
path = deps/quickjs
|
|
||||||
url = https://github.com/bellard/quickjs.git
|
|
||||||
[submodule "deps/crypt_blowfish"]
|
|
||||||
path = deps/crypt_blowfish
|
|
||||||
url = https://github.com/openwall/crypt_blowfish.git
|
|
||||||
[submodule "deps/libbacktrace"]
|
|
||||||
path = deps/libbacktrace
|
|
||||||
url = https://github.com/ianlancetaylor/libbacktrace.git
|
|
||||||
[submodule "deps/libuv"]
|
|
||||||
path = deps/libuv
|
|
||||||
url = https://github.com/libuv/libuv.git
|
|
||||||
[submodule "deps/picohttpparser"]
|
|
||||||
path = deps/picohttpparser
|
|
||||||
url = https://github.com/h2o/picohttpparser.git
|
|
@ -857,7 +857,7 @@ dist: release-apk iosrelease-ipa
|
|||||||
@echo [archive] dist/tildefriends-$(VERSION_NUMBER).tar.xz
|
@echo [archive] dist/tildefriends-$(VERSION_NUMBER).tar.xz
|
||||||
@rm -rf out/tildefriends-$(VERSION_NUMBER)
|
@rm -rf out/tildefriends-$(VERSION_NUMBER)
|
||||||
@mkdir -p dist/ out/tildefriends-$(VERSION_NUMBER)
|
@mkdir -p dist/ out/tildefriends-$(VERSION_NUMBER)
|
||||||
@git ls-files --recurse-submodules | tar -c -T- | tar -x -C out/tildefriends-$(VERSION_NUMBER)
|
@git archive HEAD | tar -x -C out/tildefriends-$(VERSION_NUMBER)
|
||||||
@tar \
|
@tar \
|
||||||
--exclude=apps/welcome* \
|
--exclude=apps/welcome* \
|
||||||
--exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \
|
--exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \
|
||||||
|
1
deps/crypt_blowfish
vendored
1
deps/crypt_blowfish
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 3354bb81eea489e972b0a7c63231514ab34f73a0
|
|
29
deps/crypt_blowfish/LINKS
vendored
Normal file
29
deps/crypt_blowfish/LINKS
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
New versions of this package (crypt_blowfish):
|
||||||
|
|
||||||
|
http://www.openwall.com/crypt/
|
||||||
|
|
||||||
|
A paper on the algorithm that explains its design decisions:
|
||||||
|
|
||||||
|
http://www.usenix.org/events/usenix99/provos.html
|
||||||
|
|
||||||
|
Unix Seventh Edition Manual, Volume 2: the password scheme (1978):
|
||||||
|
|
||||||
|
http://plan9.bell-labs.com/7thEdMan/vol2/password
|
||||||
|
|
||||||
|
The Openwall GNU/*/Linux (Owl) tcb suite implementing the alternative
|
||||||
|
password shadowing scheme. This includes a PAM module which
|
||||||
|
supersedes pam_unix and uses the password hashing framework provided
|
||||||
|
with crypt_blowfish when setting new passwords.
|
||||||
|
|
||||||
|
http://www.openwall.com/tcb/
|
||||||
|
|
||||||
|
pam_passwdqc, a password strength checking and policy enforcement
|
||||||
|
module for PAM-aware password changing programs:
|
||||||
|
|
||||||
|
http://www.openwall.com/passwdqc/
|
||||||
|
|
||||||
|
John the Ripper password cracker:
|
||||||
|
|
||||||
|
http://www.openwall.com/john/
|
||||||
|
|
||||||
|
$Owl: Owl/packages/glibc/crypt_blowfish/LINKS,v 1.4 2005/11/16 13:09:47 solar Exp $
|
77
deps/crypt_blowfish/Makefile
vendored
Normal file
77
deps/crypt_blowfish/Makefile
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#
|
||||||
|
# Written and revised by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
# No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
# domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
# in the public domain is deemed null and void, then the software is
|
||||||
|
# Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
# general public under the following terms:
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted.
|
||||||
|
#
|
||||||
|
# There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
#
|
||||||
|
# See crypt_blowfish.c for more information.
|
||||||
|
#
|
||||||
|
|
||||||
|
CC = gcc
|
||||||
|
AS = $(CC)
|
||||||
|
LD = $(CC)
|
||||||
|
RM = rm -f
|
||||||
|
CFLAGS = -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops
|
||||||
|
ASFLAGS = -c
|
||||||
|
LDFLAGS = -s
|
||||||
|
|
||||||
|
BLOWFISH_OBJS = \
|
||||||
|
crypt_blowfish.o x86.o
|
||||||
|
|
||||||
|
CRYPT_OBJS = \
|
||||||
|
$(BLOWFISH_OBJS) crypt_gensalt.o wrapper.o
|
||||||
|
|
||||||
|
TEST_OBJS = \
|
||||||
|
$(BLOWFISH_OBJS) crypt_gensalt.o crypt_test.o
|
||||||
|
|
||||||
|
TEST_THREADS_OBJS = \
|
||||||
|
$(BLOWFISH_OBJS) crypt_gensalt.o crypt_test_threads.o
|
||||||
|
|
||||||
|
EXTRA_MANS = \
|
||||||
|
crypt_r.3 crypt_rn.3 crypt_ra.3 \
|
||||||
|
crypt_gensalt.3 crypt_gensalt_rn.3 crypt_gensalt_ra.3
|
||||||
|
|
||||||
|
all: $(CRYPT_OBJS) man
|
||||||
|
|
||||||
|
check: crypt_test
|
||||||
|
./crypt_test
|
||||||
|
|
||||||
|
crypt_test: $(TEST_OBJS)
|
||||||
|
$(LD) $(LDFLAGS) $(TEST_OBJS) -o $@
|
||||||
|
|
||||||
|
crypt_test.o: wrapper.c ow-crypt.h crypt_blowfish.h crypt_gensalt.h
|
||||||
|
$(CC) -c $(CFLAGS) wrapper.c -DTEST -o $@
|
||||||
|
|
||||||
|
check_threads: crypt_test_threads
|
||||||
|
./crypt_test_threads
|
||||||
|
|
||||||
|
crypt_test_threads: $(TEST_THREADS_OBJS)
|
||||||
|
$(LD) $(LDFLAGS) $(TEST_THREADS_OBJS) -lpthread -o $@
|
||||||
|
|
||||||
|
crypt_test_threads.o: wrapper.c ow-crypt.h crypt_blowfish.h crypt_gensalt.h
|
||||||
|
$(CC) -c $(CFLAGS) wrapper.c -DTEST -DTEST_THREADS=4 -o $@
|
||||||
|
|
||||||
|
man: $(EXTRA_MANS)
|
||||||
|
|
||||||
|
$(EXTRA_MANS):
|
||||||
|
echo '.so man3/crypt.3' > $@
|
||||||
|
|
||||||
|
crypt_blowfish.o: crypt_blowfish.h
|
||||||
|
crypt_gensalt.o: crypt_gensalt.h
|
||||||
|
wrapper.o: crypt.h ow-crypt.h crypt_blowfish.h crypt_gensalt.h
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(CFLAGS) $*.c
|
||||||
|
|
||||||
|
.S.o:
|
||||||
|
$(AS) $(ASFLAGS) $*.S
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) crypt_test crypt_test_threads *.o $(EXTRA_MANS) core
|
30
deps/crypt_blowfish/PERFORMANCE
vendored
Normal file
30
deps/crypt_blowfish/PERFORMANCE
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
These numbers are for 32 iterations ("$2a$05"):
|
||||||
|
|
||||||
|
OpenBSD 3.0 bcrypt(*) crypt_blowfish 0.4.4
|
||||||
|
Pentium III, 840 MHz 99 c/s 121 c/s (+22%)
|
||||||
|
Alpha 21164PC, 533 MHz 55.5 c/s 76.9 c/s (+38%)
|
||||||
|
UltraSparc IIi, 400 MHz 49.9 c/s 52.5 c/s (+5%)
|
||||||
|
Pentium, 120 MHz 8.8 c/s 20.1 c/s (+128%)
|
||||||
|
PA-RISC 7100LC, 80 MHz 8.5 c/s 16.3 c/s (+92%)
|
||||||
|
|
||||||
|
(*) built with -fomit-frame-pointer -funroll-loops, which I don't
|
||||||
|
think happens for libcrypt.
|
||||||
|
|
||||||
|
Starting with version 1.1 released in June 2011, default builds of
|
||||||
|
crypt_blowfish invoke a quick self-test on every hash computation.
|
||||||
|
This has roughly a 4.8% performance impact at "$2a$05", but only a 0.6%
|
||||||
|
impact at a more typical setting of "$2a$08".
|
||||||
|
|
||||||
|
The large speedup for the original Pentium is due to the assembly
|
||||||
|
code and the weird optimizations this processor requires.
|
||||||
|
|
||||||
|
The numbers for password cracking are 2 to 10% higher than those for
|
||||||
|
crypt_blowfish as certain things may be done out of the loop and the
|
||||||
|
code doesn't need to be reentrant.
|
||||||
|
|
||||||
|
Recent versions of John the Ripper (1.6.25-dev and newer) achieve an
|
||||||
|
additional 15% speedup on the Pentium Pro family of processors (which
|
||||||
|
includes Pentium III) with a separate version of the assembly code and
|
||||||
|
run-time CPU detection.
|
||||||
|
|
||||||
|
$Owl: Owl/packages/glibc/crypt_blowfish/PERFORMANCE,v 1.6 2011/06/21 12:09:20 solar Exp $
|
68
deps/crypt_blowfish/README
vendored
Normal file
68
deps/crypt_blowfish/README
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
This is an implementation of a password hashing method, provided via the
|
||||||
|
crypt(3) and a reentrant interface. It is fully compatible with
|
||||||
|
OpenBSD's bcrypt.c for prefix "$2b$", originally by Niels Provos and
|
||||||
|
David Mazieres. (Please refer to the included crypt(3) man page for
|
||||||
|
information on minor compatibility issues for other bcrypt prefixes.)
|
||||||
|
|
||||||
|
I've placed this code in the public domain, with fallback to a
|
||||||
|
permissive license. Please see the comment in crypt_blowfish.c for
|
||||||
|
more information.
|
||||||
|
|
||||||
|
You can use the provided routines in your own packages, or link them
|
||||||
|
into a C library. I've provided hooks for linking into GNU libc, but
|
||||||
|
it shouldn't be too hard to get this into another C library. Note
|
||||||
|
that simply adding this code into your libc is probably not enough to
|
||||||
|
make your system use the new password hashing algorithm. Changes to
|
||||||
|
passwd(1), PAM modules, or whatever else your system uses will likely
|
||||||
|
be needed as well. These are not a part of this package, but see
|
||||||
|
LINKS for a pointer to our tcb suite.
|
||||||
|
|
||||||
|
Instructions on using the routines in one of the two common ways are
|
||||||
|
given below. It is recommended that you test the routines on your
|
||||||
|
system before you start. Type "make check" or "make check_threads"
|
||||||
|
(if you have the POSIX threads library), then "make clean".
|
||||||
|
|
||||||
|
|
||||||
|
1. Using the routines in your programs.
|
||||||
|
|
||||||
|
The available interfaces are in ow-crypt.h, and this is the file you
|
||||||
|
should include. You won't need crypt.h. When linking, add all of the
|
||||||
|
C files and x86.S (you can compile and link it even on a non-x86, it
|
||||||
|
will produce no code in this case).
|
||||||
|
|
||||||
|
|
||||||
|
2. Building the routines into GNU C library.
|
||||||
|
|
||||||
|
For versions 2.13 and 2.14 (and likely other nearby ones), extract the
|
||||||
|
library sources as usual. Apply the patch for glibc 2.14 provided in
|
||||||
|
this package. Enter crypt/ and rename crypt.h to gnu-crypt.h within
|
||||||
|
that directory. Copy the C sources, header, and assembly (x86.S) files
|
||||||
|
from this package in there as well (but be sure you don't overwrite the
|
||||||
|
Makefile). Configure, build, and install the library as usual.
|
||||||
|
|
||||||
|
For versions 2.2 to 2.3.6 (and likely also for some newer ones),
|
||||||
|
extract the library sources and maybe its optional add-ons as usual.
|
||||||
|
Apply the patch for glibc 2.3.6 provided in this package. Enter
|
||||||
|
crypt/ and rename crypt.h to gnu-crypt.h within that directory. Copy
|
||||||
|
the C sources, header, and assembly (x86.S) files from this package in
|
||||||
|
there as well (but be sure you don't overwrite the Makefile).
|
||||||
|
Configure, build, and install the library as usual.
|
||||||
|
|
||||||
|
For versions 2.1 to 2.1.3, extract the library sources and the crypt
|
||||||
|
and linuxthreads add-ons as usual. Apply the patch for glibc 2.1.3
|
||||||
|
provided in this package. Enter crypt/sysdeps/unix/, and rename
|
||||||
|
crypt.h to gnu-crypt.h within that directory. Copy C sources, header,
|
||||||
|
and assembly (x86.S) files from this package in there as well (but be
|
||||||
|
sure you don't overwrite the Makefile). Configure, build, and install
|
||||||
|
the library as usual.
|
||||||
|
|
||||||
|
Programs that want to use the provided interfaces will need to include
|
||||||
|
crypt.h (but not ow-crypt.h directly). By default, prototypes for the
|
||||||
|
new routines aren't defined (but the extra functionality of crypt(3)
|
||||||
|
is indeed available). You need to define _OW_SOURCE to obtain the new
|
||||||
|
routines as well.
|
||||||
|
|
||||||
|
--
|
||||||
|
Solar Designer <solar at openwall.com>
|
||||||
|
|
||||||
|
$Owl: Owl/packages/glibc/crypt_blowfish/README,v 1.10 2014/07/07 15:19:04 solar Exp $
|
575
deps/crypt_blowfish/crypt.3
vendored
Normal file
575
deps/crypt_blowfish/crypt.3
vendored
Normal file
@ -0,0 +1,575 @@
|
|||||||
|
.\" Written and revised by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
.\" No copyright is claimed, and this man page is hereby placed in the public
|
||||||
|
.\" domain. In case this attempt to disclaim copyright and place the man page
|
||||||
|
.\" in the public domain is deemed null and void, then the man page is
|
||||||
|
.\" Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
.\" general public under the following terms:
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted.
|
||||||
|
.\"
|
||||||
|
.\" There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
.\"
|
||||||
|
.\" This manual page in its current form is intended for use on systems
|
||||||
|
.\" based on the GNU C Library with crypt_blowfish patched into libcrypt.
|
||||||
|
.\"
|
||||||
|
.TH CRYPT 3 "July 7, 2014" "Openwall Project" "Library functions"
|
||||||
|
.ad l
|
||||||
|
.\" No macros in NAME to keep makewhatis happy.
|
||||||
|
.SH NAME
|
||||||
|
\fBcrypt\fR, \fBcrypt_r\fR, \fBcrypt_rn\fR, \fBcrypt_ra\fR,
|
||||||
|
\fBcrypt_gensalt\fR, \fBcrypt_gensalt_rn\fR, \fBcrypt_gensalt_ra\fR
|
||||||
|
\- password hashing
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B #define _XOPEN_SOURCE
|
||||||
|
.br
|
||||||
|
.B #include <unistd.h>
|
||||||
|
.sp
|
||||||
|
.in +8
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt(const char *" key ", const char *" setting );
|
||||||
|
.in -8
|
||||||
|
.sp
|
||||||
|
.B #define _GNU_SOURCE
|
||||||
|
.br
|
||||||
|
.B #include <crypt.h>
|
||||||
|
.sp
|
||||||
|
.in +8
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_r(const char *" key ", const char *" setting ", struct crypt_data *" data );
|
||||||
|
.in -8
|
||||||
|
.sp
|
||||||
|
.B #define _OW_SOURCE
|
||||||
|
.br
|
||||||
|
.B #include <crypt.h>
|
||||||
|
.sp
|
||||||
|
.in +8
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_rn(const char *" key ", const char *" setting ", void *" data ", int " size );
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_ra(const char *" key ", const char *" setting ", void **" data ", int *" size );
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_gensalt(const char *" prefix ", unsigned long " count ", const char *" input ", int " size );
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_gensalt_rn(const char *" prefix ", unsigned long " count ", const char *" input ", int " size ", char *" output ", int " output_size );
|
||||||
|
.ti -8
|
||||||
|
.BI "char *crypt_gensalt_ra(const char *" prefix ", unsigned long " count ", const char *" input ", int " size );
|
||||||
|
.ad b
|
||||||
|
.de crypt
|
||||||
|
.BR crypt ,
|
||||||
|
.BR crypt_r ,
|
||||||
|
.BR crypt_rn ", \\$1"
|
||||||
|
.ie "\\$2"" .B crypt_ra
|
||||||
|
.el .BR crypt_ra "\\$2"
|
||||||
|
..
|
||||||
|
.de crypt_gensalt
|
||||||
|
.BR crypt_gensalt ,
|
||||||
|
.BR crypt_gensalt_rn ", \\$1"
|
||||||
|
.ie "\\$2"" .B crypt_gensalt_ra
|
||||||
|
.el .BR crypt_gensalt_ra "\\$2"
|
||||||
|
..
|
||||||
|
.SH DESCRIPTION
|
||||||
|
The
|
||||||
|
.crypt and
|
||||||
|
functions calculate a cryptographic hash function of
|
||||||
|
.I key
|
||||||
|
with one of a number of supported methods as requested with
|
||||||
|
.IR setting ,
|
||||||
|
which is also used to pass a salt and possibly other parameters to
|
||||||
|
the chosen method.
|
||||||
|
The hashing methods are explained below.
|
||||||
|
.PP
|
||||||
|
Unlike
|
||||||
|
.BR crypt ,
|
||||||
|
the functions
|
||||||
|
.BR crypt_r ,
|
||||||
|
.BR crypt_rn " and"
|
||||||
|
.B crypt_ra
|
||||||
|
are reentrant.
|
||||||
|
They place their result and possibly their private data in a
|
||||||
|
.I data
|
||||||
|
area of
|
||||||
|
.I size
|
||||||
|
bytes as passed to them by an application and/or in memory they
|
||||||
|
allocate dynamically. Some hashing algorithms may use the data area to
|
||||||
|
cache precomputed intermediate values across calls. Thus, applications
|
||||||
|
must properly initialize the data area before its first use.
|
||||||
|
.B crypt_r
|
||||||
|
requires that only
|
||||||
|
.I data->initialized
|
||||||
|
be reset to zero;
|
||||||
|
.BR crypt_rn " and " crypt_ra
|
||||||
|
require that either the entire data area is zeroed or, in the case of
|
||||||
|
.BR crypt_ra ,
|
||||||
|
.I *data
|
||||||
|
is NULL. When called with a NULL
|
||||||
|
.I *data
|
||||||
|
or insufficient
|
||||||
|
.I *size
|
||||||
|
for the requested hashing algorithm,
|
||||||
|
.B crypt_ra
|
||||||
|
uses
|
||||||
|
.BR realloc (3)
|
||||||
|
to allocate the required amount of memory dynamically. Thus,
|
||||||
|
.B crypt_ra
|
||||||
|
has the additional requirement that
|
||||||
|
.IR *data ,
|
||||||
|
when non-NULL, must point to an area allocated either with a previous
|
||||||
|
call to
|
||||||
|
.B crypt_ra
|
||||||
|
or with a
|
||||||
|
.BR malloc (3)
|
||||||
|
family call.
|
||||||
|
The memory allocated by
|
||||||
|
.B crypt_ra
|
||||||
|
should be freed with
|
||||||
|
.BR free "(3)."
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.crypt_gensalt and
|
||||||
|
functions compile a string for use as
|
||||||
|
.I setting
|
||||||
|
\- with the given
|
||||||
|
.I prefix
|
||||||
|
(used to choose a hashing method), the iteration
|
||||||
|
.I count
|
||||||
|
(if supported by the chosen method) and up to
|
||||||
|
.I size
|
||||||
|
cryptographically random
|
||||||
|
.I input
|
||||||
|
bytes for use as the actual salt.
|
||||||
|
If
|
||||||
|
.I count
|
||||||
|
is 0, a low default will be picked.
|
||||||
|
The random bytes may be obtained from
|
||||||
|
.BR /dev/urandom .
|
||||||
|
Unlike
|
||||||
|
.BR crypt_gensalt ,
|
||||||
|
the functions
|
||||||
|
.BR crypt_gensalt_rn " and " crypt_gensalt_ra
|
||||||
|
are reentrant.
|
||||||
|
.B crypt_gensalt_rn
|
||||||
|
places its result in the
|
||||||
|
.I output
|
||||||
|
buffer of
|
||||||
|
.I output_size
|
||||||
|
bytes.
|
||||||
|
.B crypt_gensalt_ra
|
||||||
|
allocates memory for its result dynamically. The memory should be
|
||||||
|
freed with
|
||||||
|
.BR free "(3)."
|
||||||
|
.SH RETURN VALUE
|
||||||
|
Upon successful completion, the functions
|
||||||
|
.crypt and
|
||||||
|
return a pointer to a string containing the setting that was actually used
|
||||||
|
and a printable encoding of the hash function value.
|
||||||
|
The entire string is directly usable as
|
||||||
|
.I setting
|
||||||
|
with other calls to
|
||||||
|
.crypt and
|
||||||
|
and as
|
||||||
|
.I prefix
|
||||||
|
with calls to
|
||||||
|
.crypt_gensalt and .
|
||||||
|
.PP
|
||||||
|
The behavior of
|
||||||
|
.B crypt
|
||||||
|
on errors isn't well standardized. Some implementations simply can't fail
|
||||||
|
(unless the process dies, in which case they obviously can't return),
|
||||||
|
others return NULL or a fixed string. Most implementations don't set
|
||||||
|
.IR errno ,
|
||||||
|
but some do. SUSv2 specifies only returning NULL and setting
|
||||||
|
.I errno
|
||||||
|
as a valid behavior, and defines only one possible error
|
||||||
|
.RB "(" ENOSYS ,
|
||||||
|
"The functionality is not supported on this implementation.")
|
||||||
|
Unfortunately, most existing applications aren't prepared to handle
|
||||||
|
NULL returns from
|
||||||
|
.BR crypt .
|
||||||
|
The description below corresponds to this implementation of
|
||||||
|
.BR crypt " and " crypt_r
|
||||||
|
only, and to
|
||||||
|
.BR crypt_rn " and " crypt_ra .
|
||||||
|
The behavior may change to match standards, other implementations or
|
||||||
|
existing applications.
|
||||||
|
.PP
|
||||||
|
.BR crypt " and " crypt_r
|
||||||
|
may only fail (and return) when passed an invalid or unsupported
|
||||||
|
.IR setting ,
|
||||||
|
in which case they return a pointer to a magic string that is
|
||||||
|
shorter than 13 characters and is guaranteed to differ from
|
||||||
|
.IR setting .
|
||||||
|
This behavior is safe for older applications which assume that
|
||||||
|
.B crypt
|
||||||
|
can't fail, when both setting new passwords and authenticating against
|
||||||
|
existing password hashes.
|
||||||
|
.BR crypt_rn " and " crypt_ra
|
||||||
|
return NULL to indicate failure. All four functions set
|
||||||
|
.I errno
|
||||||
|
when they fail.
|
||||||
|
.PP
|
||||||
|
The functions
|
||||||
|
.crypt_gensalt and
|
||||||
|
return a pointer to the compiled string for
|
||||||
|
.IR setting ,
|
||||||
|
or NULL on error in which case
|
||||||
|
.I errno
|
||||||
|
is set.
|
||||||
|
.SH ERRORS
|
||||||
|
.TP
|
||||||
|
.B EINVAL
|
||||||
|
.crypt "" :
|
||||||
|
.I setting
|
||||||
|
is invalid or not supported by this implementation;
|
||||||
|
.sp
|
||||||
|
.crypt_gensalt "" :
|
||||||
|
.I prefix
|
||||||
|
is invalid or not supported by this implementation;
|
||||||
|
.I count
|
||||||
|
is invalid for the requested
|
||||||
|
.IR prefix ;
|
||||||
|
the input
|
||||||
|
.I size
|
||||||
|
is insufficient for the smallest valid salt with the requested
|
||||||
|
.IR prefix ;
|
||||||
|
.I input
|
||||||
|
is NULL.
|
||||||
|
.TP
|
||||||
|
.B ERANGE
|
||||||
|
.BR crypt_rn :
|
||||||
|
the provided data area
|
||||||
|
.I size
|
||||||
|
is insufficient for the requested hashing algorithm;
|
||||||
|
.sp
|
||||||
|
.BR crypt_gensalt_rn :
|
||||||
|
.I output_size
|
||||||
|
is too small to hold the compiled
|
||||||
|
.I setting
|
||||||
|
string.
|
||||||
|
.TP
|
||||||
|
.B ENOMEM
|
||||||
|
.B crypt
|
||||||
|
(original glibc only):
|
||||||
|
failed to allocate memory for the output buffer (which subsequent calls
|
||||||
|
would re-use);
|
||||||
|
.sp
|
||||||
|
.BR crypt_ra :
|
||||||
|
.I *data
|
||||||
|
is NULL or
|
||||||
|
.I *size
|
||||||
|
is insufficient for the requested hashing algorithm and
|
||||||
|
.BR realloc (3)
|
||||||
|
failed;
|
||||||
|
.sp
|
||||||
|
.BR crypt_gensalt_ra :
|
||||||
|
failed to allocate memory for the compiled
|
||||||
|
.I setting
|
||||||
|
string.
|
||||||
|
.TP
|
||||||
|
.B ENOSYS
|
||||||
|
.B crypt
|
||||||
|
(SUSv2):
|
||||||
|
the functionality is not supported on this implementation;
|
||||||
|
.sp
|
||||||
|
.BR crypt ,
|
||||||
|
.B crypt_r
|
||||||
|
(glibc 2.0 to 2.0.1 only):
|
||||||
|
.de no-crypt-add-on
|
||||||
|
the crypt add-on is not compiled in and
|
||||||
|
.I setting
|
||||||
|
requests something other than the MD5-based algorithm.
|
||||||
|
..
|
||||||
|
.no-crypt-add-on
|
||||||
|
.TP
|
||||||
|
.B EOPNOTSUPP
|
||||||
|
.BR crypt ,
|
||||||
|
.B crypt_r
|
||||||
|
(glibc 2.0.2 to 2.1.3 only):
|
||||||
|
.no-crypt-add-on
|
||||||
|
.SH HASHING METHODS
|
||||||
|
The implemented hashing methods are intended specifically for processing
|
||||||
|
user passwords for storage and authentication;
|
||||||
|
they are at best inefficient for most other purposes.
|
||||||
|
.PP
|
||||||
|
It is important to understand that password hashing is not a replacement
|
||||||
|
for strong passwords.
|
||||||
|
It is always possible for an attacker with access to password hashes
|
||||||
|
to try guessing candidate passwords against the hashes.
|
||||||
|
There are, however, certain properties a password hashing method may have
|
||||||
|
which make these key search attacks somewhat harder.
|
||||||
|
.PP
|
||||||
|
All of the hashing methods use salts such that the same
|
||||||
|
.I key
|
||||||
|
may produce many possible hashes.
|
||||||
|
Proper use of salts may defeat a number of attacks, including:
|
||||||
|
.TP
|
||||||
|
1.
|
||||||
|
The ability to try candidate passwords against multiple hashes at the
|
||||||
|
price of one.
|
||||||
|
.TP
|
||||||
|
2.
|
||||||
|
The use of pre-hashed lists of candidate passwords.
|
||||||
|
.TP
|
||||||
|
3.
|
||||||
|
The ability to determine whether two users (or two accounts of one user)
|
||||||
|
have the same or different passwords without actually having to guess
|
||||||
|
one of the passwords.
|
||||||
|
.PP
|
||||||
|
The key search attacks depend on computing hashes of large numbers of
|
||||||
|
candidate passwords.
|
||||||
|
Thus, the computational cost of a good password hashing method must be
|
||||||
|
high \- but of course not too high to render it impractical.
|
||||||
|
.PP
|
||||||
|
All hashing methods implemented within the
|
||||||
|
.crypt and
|
||||||
|
interfaces use multiple iterations of an underlying cryptographic
|
||||||
|
primitive specifically in order to increase the cost of trying a
|
||||||
|
candidate password.
|
||||||
|
Unfortunately, due to hardware improvements, the hashing methods which
|
||||||
|
have a fixed cost become increasingly less secure over time.
|
||||||
|
.PP
|
||||||
|
In addition to salts, modern password hashing methods accept a variable
|
||||||
|
iteration
|
||||||
|
.IR count .
|
||||||
|
This makes it possible to adapt their cost to the hardware improvements
|
||||||
|
while still maintaining compatibility.
|
||||||
|
.PP
|
||||||
|
The following hashing methods are or may be implemented within the
|
||||||
|
described interfaces:
|
||||||
|
.PP
|
||||||
|
.de hash
|
||||||
|
.ad l
|
||||||
|
.TP
|
||||||
|
.I prefix
|
||||||
|
.ie "\\$1"" \{\
|
||||||
|
"" (empty string);
|
||||||
|
.br
|
||||||
|
a string matching ^[./0-9A-Za-z]{2} (see
|
||||||
|
.BR regex (7))
|
||||||
|
.\}
|
||||||
|
.el "\\$1"
|
||||||
|
.TP
|
||||||
|
.B Encoding syntax
|
||||||
|
\\$2
|
||||||
|
.TP
|
||||||
|
.B Maximum password length
|
||||||
|
\\$3 (uses \\$4-bit characters)
|
||||||
|
.TP
|
||||||
|
.B Effective key size
|
||||||
|
.ie "\\$5"" limited by the hash size only
|
||||||
|
.el up to \\$5 bits
|
||||||
|
.TP
|
||||||
|
.B Hash size
|
||||||
|
\\$6 bits
|
||||||
|
.TP
|
||||||
|
.B Salt size
|
||||||
|
\\$7 bits
|
||||||
|
.TP
|
||||||
|
.B Iteration count
|
||||||
|
\\$8
|
||||||
|
.ad b
|
||||||
|
..
|
||||||
|
.ti -2
|
||||||
|
.B Traditional DES-based
|
||||||
|
.br
|
||||||
|
This method is supported by almost all implementations of
|
||||||
|
.BR crypt .
|
||||||
|
Unfortunately, it no longer offers adequate security because of its many
|
||||||
|
limitations.
|
||||||
|
Thus, it should not be used for new passwords unless you absolutely have
|
||||||
|
to be able to migrate the password hashes to other systems.
|
||||||
|
.hash "" "[./0-9A-Za-z]{13}" 8 7 56 64 12 25
|
||||||
|
.PP
|
||||||
|
.ti -2
|
||||||
|
.B Extended BSDI-style DES-based
|
||||||
|
.br
|
||||||
|
This method is used on BSDI and is also available on at least NetBSD,
|
||||||
|
OpenBSD, and FreeBSD due to the use of David Burren's FreeSec library.
|
||||||
|
.hash _ "_[./0-9A-Za-z]{19}" unlimited 7 56 64 24 "1 to 2**24-1 (must be odd)"
|
||||||
|
.PP
|
||||||
|
.ti -2
|
||||||
|
.B FreeBSD-style MD5-based
|
||||||
|
.br
|
||||||
|
This is Poul-Henning Kamp's MD5-based password hashing method originally
|
||||||
|
developed for FreeBSD.
|
||||||
|
It is currently supported on many free Unix-like systems, on Solaris 10
|
||||||
|
and newer, and it is part of the official glibc.
|
||||||
|
Its main disadvantage is the fixed iteration count, which is already
|
||||||
|
too low for the currently available hardware.
|
||||||
|
.hash "$1$" "\e$1\e$[^$]{1,8}\e$[./0-9A-Za-z]{22}" unlimited 8 "" 128 "6 to 48" 1000
|
||||||
|
.PP
|
||||||
|
.ti -2
|
||||||
|
.BR "OpenBSD-style Blowfish-based" " (" bcrypt )
|
||||||
|
.br
|
||||||
|
.B bcrypt
|
||||||
|
was originally developed by Niels Provos and David Mazieres for OpenBSD
|
||||||
|
and is also supported on recent versions of FreeBSD and NetBSD,
|
||||||
|
on Solaris 10 and newer, and on several GNU/*/Linux distributions.
|
||||||
|
It is, however, not part of the official glibc.
|
||||||
|
.PP
|
||||||
|
While both
|
||||||
|
.B bcrypt
|
||||||
|
and the BSDI-style DES-based hashing offer a variable iteration count,
|
||||||
|
.B bcrypt
|
||||||
|
may scale to even faster hardware, doesn't allow for certain optimizations
|
||||||
|
specific to password cracking only, doesn't have the effective key size
|
||||||
|
limitation, and uses 8-bit characters in passwords.
|
||||||
|
.hash "$2b$" "\e$2[abxy]\e$[0-9]{2}\e$[./A-Za-z0-9]{53}" 72 8 "" 184 128 "2**4 to 2**99 (current implementations are limited to 2**31 iterations)"
|
||||||
|
.PP
|
||||||
|
With
|
||||||
|
.BR bcrypt ,
|
||||||
|
the
|
||||||
|
.I count
|
||||||
|
passed to
|
||||||
|
.crypt_gensalt and
|
||||||
|
is the base-2 logarithm of the actual iteration count.
|
||||||
|
.PP
|
||||||
|
.B bcrypt
|
||||||
|
hashes used the "$2a$" prefix since 1997.
|
||||||
|
However, in 2011 an implementation bug was discovered in crypt_blowfish
|
||||||
|
(versions up to 1.0.4 inclusive) affecting handling of password characters with
|
||||||
|
the 8th bit set.
|
||||||
|
Besides fixing the bug,
|
||||||
|
to provide for upgrade strategies for existing systems, two new prefixes were
|
||||||
|
introduced: "$2x$", which fully re-introduces the bug, and "$2y$", which
|
||||||
|
guarantees correct handling of both 7- and 8-bit characters.
|
||||||
|
OpenBSD 5.5 introduced the "$2b$" prefix for behavior that exactly matches
|
||||||
|
crypt_blowfish's "$2y$", and current crypt_blowfish supports it as well.
|
||||||
|
Unfortunately, the behavior of "$2a$" on password characters with the 8th bit
|
||||||
|
set has to be considered system-specific.
|
||||||
|
When generating new password hashes, the "$2b$" or "$2y$" prefix should be used.
|
||||||
|
(If such hashes ever need to be migrated to a system that does not yet support
|
||||||
|
these new prefixes, the prefix in migrated copies of the already-generated
|
||||||
|
hashes may be changed to "$2a$".)
|
||||||
|
.PP
|
||||||
|
.crypt_gensalt and
|
||||||
|
support the "$2b$", "$2y$", and "$2a$" prefixes (the latter for legacy programs
|
||||||
|
or configurations), but not "$2x$" (which must not be used for new hashes).
|
||||||
|
.crypt and
|
||||||
|
support all four of these prefixes.
|
||||||
|
.SH PORTABILITY NOTES
|
||||||
|
Programs using any of these functions on a glibc 2.x system must be
|
||||||
|
linked against
|
||||||
|
.BR libcrypt .
|
||||||
|
However, many Unix-like operating systems and older versions of the
|
||||||
|
GNU C Library include the
|
||||||
|
.BR crypt " function in " libc .
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.BR crypt_r ,
|
||||||
|
.BR crypt_rn ,
|
||||||
|
.BR crypt_ra ,
|
||||||
|
.crypt_gensalt and
|
||||||
|
functions are very non-portable.
|
||||||
|
.PP
|
||||||
|
The set of supported hashing methods is implementation-dependent.
|
||||||
|
.SH CONFORMING TO
|
||||||
|
The
|
||||||
|
.B crypt
|
||||||
|
function conforms to SVID, X/OPEN, and is available on BSD 4.3.
|
||||||
|
The strings returned by
|
||||||
|
.B crypt
|
||||||
|
are not required to be portable among conformant systems.
|
||||||
|
.PP
|
||||||
|
.B crypt_r
|
||||||
|
is a GNU extension.
|
||||||
|
There's also a
|
||||||
|
.B crypt_r
|
||||||
|
function on HP-UX and MKS Toolkit, but the prototypes and semantics differ.
|
||||||
|
.PP
|
||||||
|
.B crypt_gensalt
|
||||||
|
is an Openwall extension.
|
||||||
|
There's also a
|
||||||
|
.B crypt_gensalt
|
||||||
|
function on Solaris 10 and newer, but the prototypes and semantics differ.
|
||||||
|
.PP
|
||||||
|
.BR crypt_rn ,
|
||||||
|
.BR crypt_ra ,
|
||||||
|
.BR crypt_gensalt_rn ,
|
||||||
|
and
|
||||||
|
.B crypt_gensalt_ra
|
||||||
|
are Openwall extensions.
|
||||||
|
.SH HISTORY
|
||||||
|
A rotor-based
|
||||||
|
.B crypt
|
||||||
|
function appeared in Version 6 AT&T UNIX.
|
||||||
|
The "traditional"
|
||||||
|
.B crypt
|
||||||
|
first appeared in Version 7 AT&T UNIX.
|
||||||
|
.PP
|
||||||
|
The
|
||||||
|
.B crypt_r
|
||||||
|
function was introduced during glibc 2.0 development.
|
||||||
|
.SH BUGS
|
||||||
|
The return values of
|
||||||
|
.BR crypt " and " crypt_gensalt
|
||||||
|
point to static buffers that are overwritten by subsequent calls.
|
||||||
|
These functions are not thread-safe.
|
||||||
|
.RB ( crypt
|
||||||
|
on recent versions of Solaris uses thread-specific data and actually is
|
||||||
|
thread-safe.)
|
||||||
|
.PP
|
||||||
|
The strings returned by certain other implementations of
|
||||||
|
.B crypt
|
||||||
|
on error may be stored in read-only locations or only initialized once,
|
||||||
|
which makes it unsafe to always attempt to zero out the buffer normally
|
||||||
|
pointed to by the
|
||||||
|
.B crypt
|
||||||
|
return value as it would otherwise be preferable for security reasons.
|
||||||
|
The problem could be avoided with the use of
|
||||||
|
.BR crypt_r ,
|
||||||
|
.BR crypt_rn ,
|
||||||
|
or
|
||||||
|
.B crypt_ra
|
||||||
|
where the application has full control over output buffers of these functions
|
||||||
|
(and often over some of their private data as well).
|
||||||
|
Unfortunately, the functions aren't (yet?) available on platforms where
|
||||||
|
.B crypt
|
||||||
|
has this undesired property.
|
||||||
|
.PP
|
||||||
|
Applications using the thread-safe
|
||||||
|
.B crypt_r
|
||||||
|
need to allocate address space for the large (over 128 KB)
|
||||||
|
.I struct crypt_data
|
||||||
|
structure. Each thread needs a separate instance of the structure. The
|
||||||
|
.B crypt_r
|
||||||
|
interface makes it impossible to implement a hashing algorithm which
|
||||||
|
would need to keep an even larger amount of private data, without breaking
|
||||||
|
binary compatibility.
|
||||||
|
.B crypt_ra
|
||||||
|
allows for dynamically increasing the allocation size as required by the
|
||||||
|
hashing algorithm that is actually used. Unfortunately,
|
||||||
|
.B crypt_ra
|
||||||
|
is even more non-portable than
|
||||||
|
.BR crypt_r .
|
||||||
|
.PP
|
||||||
|
Multi-threaded applications or library functions which are meant to be
|
||||||
|
thread-safe should use
|
||||||
|
.BR crypt_gensalt_rn " or " crypt_gensalt_ra
|
||||||
|
rather than
|
||||||
|
.BR crypt_gensalt .
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR login (1),
|
||||||
|
.BR passwd (1),
|
||||||
|
.BR crypto (3),
|
||||||
|
.BR encrypt (3),
|
||||||
|
.BR free (3),
|
||||||
|
.BR getpass (3),
|
||||||
|
.BR getpwent (3),
|
||||||
|
.BR malloc (3),
|
||||||
|
.BR realloc (3),
|
||||||
|
.BR shadow (3),
|
||||||
|
.BR passwd (5),
|
||||||
|
.BR shadow (5),
|
||||||
|
.BR regex (7),
|
||||||
|
.BR pam (8)
|
||||||
|
.sp
|
||||||
|
Niels Provos and David Mazieres. A Future-Adaptable Password Scheme.
|
||||||
|
Proceedings of the 1999 USENIX Annual Technical Conference, June 1999.
|
||||||
|
.br
|
||||||
|
http://www.usenix.org/events/usenix99/provos.html
|
||||||
|
.sp
|
||||||
|
Robert Morris and Ken Thompson. Password Security: A Case History.
|
||||||
|
Unix Seventh Edition Manual, Volume 2, April 1978.
|
||||||
|
.br
|
||||||
|
http://plan9.bell-labs.com/7thEdMan/vol2/password
|
24
deps/crypt_blowfish/crypt.h
vendored
Normal file
24
deps/crypt_blowfish/crypt.h
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2002.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2002 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gnu-crypt.h>
|
||||||
|
|
||||||
|
#if defined(_OW_SOURCE) || defined(__USE_OW)
|
||||||
|
#define __SKIP_GNU
|
||||||
|
#undef __SKIP_OW
|
||||||
|
#include <ow-crypt.h>
|
||||||
|
#undef __SKIP_GNU
|
||||||
|
#endif
|
907
deps/crypt_blowfish/crypt_blowfish.c
vendored
Normal file
907
deps/crypt_blowfish/crypt_blowfish.c
vendored
Normal file
@ -0,0 +1,907 @@
|
|||||||
|
/*
|
||||||
|
* The crypt_blowfish homepage is:
|
||||||
|
*
|
||||||
|
* http://www.openwall.com/crypt/
|
||||||
|
*
|
||||||
|
* This code comes from John the Ripper password cracker, with reentrant
|
||||||
|
* and crypt(3) interfaces added, but optimizations specific to password
|
||||||
|
* cracking removed.
|
||||||
|
*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 1998-2014.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 1998-2014 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* It is my intent that you should be able to use this on your system,
|
||||||
|
* as part of a software package, or anywhere else to improve security,
|
||||||
|
* ensure compatibility, or for any other purpose. I would appreciate
|
||||||
|
* it if you give credit where it is due and keep your modifications in
|
||||||
|
* the public domain as well, but I don't require that in order to let
|
||||||
|
* you place this code and any modifications you make under a license
|
||||||
|
* of your choice.
|
||||||
|
*
|
||||||
|
* This implementation is fully compatible with OpenBSD's bcrypt.c for prefix
|
||||||
|
* "$2b$", originally by Niels Provos <provos at citi.umich.edu>, and it uses
|
||||||
|
* some of his ideas. The password hashing algorithm was designed by David
|
||||||
|
* Mazieres <dm at lcs.mit.edu>. For information on the level of
|
||||||
|
* compatibility for bcrypt hash prefixes other than "$2b$", please refer to
|
||||||
|
* the comments in BF_set_key() below and to the included crypt(3) man page.
|
||||||
|
*
|
||||||
|
* There's a paper on the algorithm that explains its design decisions:
|
||||||
|
*
|
||||||
|
* http://www.usenix.org/events/usenix99/provos.html
|
||||||
|
*
|
||||||
|
* Some of the tricks in BF_ROUND might be inspired by Eric Young's
|
||||||
|
* Blowfish library (I can't be sure if I would think of something if I
|
||||||
|
* hadn't seen his code).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef __set_errno
|
||||||
|
#define __set_errno(val) errno = (val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Just to make sure the prototypes match the actual definitions */
|
||||||
|
#include "crypt_blowfish.h"
|
||||||
|
|
||||||
|
#ifdef __i386__
|
||||||
|
#define BF_ASM 1
|
||||||
|
#define BF_SCALE 1
|
||||||
|
#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
|
||||||
|
#define BF_ASM 0
|
||||||
|
#define BF_SCALE 1
|
||||||
|
#else
|
||||||
|
#define BF_ASM 0
|
||||||
|
#define BF_SCALE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned int BF_word;
|
||||||
|
typedef signed int BF_word_signed;
|
||||||
|
|
||||||
|
/* Number of Blowfish rounds, this is also hardcoded into a few places */
|
||||||
|
#define BF_N 16
|
||||||
|
|
||||||
|
typedef BF_word BF_key[BF_N + 2];
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BF_word S[4][0x100];
|
||||||
|
BF_key P;
|
||||||
|
} BF_ctx;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Magic IV for 64 Blowfish encryptions that we do at the end.
|
||||||
|
* The string is "OrpheanBeholderScryDoubt" on big-endian.
|
||||||
|
*/
|
||||||
|
static BF_word BF_magic_w[6] = {
|
||||||
|
0x4F727068, 0x65616E42, 0x65686F6C,
|
||||||
|
0x64657253, 0x63727944, 0x6F756274
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* P-box and S-box tables initialized with digits of Pi.
|
||||||
|
*/
|
||||||
|
static BF_ctx BF_init_state = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
|
||||||
|
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
|
||||||
|
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
|
||||||
|
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
|
||||||
|
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
|
||||||
|
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
|
||||||
|
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
|
||||||
|
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
|
||||||
|
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
|
||||||
|
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
|
||||||
|
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
|
||||||
|
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
|
||||||
|
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
|
||||||
|
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
|
||||||
|
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
|
||||||
|
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
|
||||||
|
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
|
||||||
|
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
|
||||||
|
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
|
||||||
|
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
|
||||||
|
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
|
||||||
|
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
|
||||||
|
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
|
||||||
|
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
|
||||||
|
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
|
||||||
|
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
|
||||||
|
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
|
||||||
|
0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
|
||||||
|
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
|
||||||
|
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
|
||||||
|
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
|
||||||
|
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
|
||||||
|
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
|
||||||
|
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
|
||||||
|
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
|
||||||
|
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
|
||||||
|
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
|
||||||
|
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
|
||||||
|
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
|
||||||
|
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
|
||||||
|
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
|
||||||
|
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
|
||||||
|
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
|
||||||
|
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
|
||||||
|
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
|
||||||
|
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
|
||||||
|
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
|
||||||
|
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
|
||||||
|
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
|
||||||
|
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
|
||||||
|
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
|
||||||
|
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
|
||||||
|
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
|
||||||
|
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
|
||||||
|
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
|
||||||
|
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
|
||||||
|
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
|
||||||
|
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
|
||||||
|
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
|
||||||
|
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
|
||||||
|
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
|
||||||
|
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
|
||||||
|
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
|
||||||
|
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
|
||||||
|
}, {
|
||||||
|
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
|
||||||
|
0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
|
||||||
|
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
|
||||||
|
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
|
||||||
|
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
|
||||||
|
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
|
||||||
|
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
|
||||||
|
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
|
||||||
|
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
|
||||||
|
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
|
||||||
|
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
|
||||||
|
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
|
||||||
|
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
|
||||||
|
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
|
||||||
|
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
|
||||||
|
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
|
||||||
|
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
|
||||||
|
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
|
||||||
|
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
|
||||||
|
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
|
||||||
|
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
|
||||||
|
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
|
||||||
|
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
|
||||||
|
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
|
||||||
|
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
|
||||||
|
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
|
||||||
|
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
|
||||||
|
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
|
||||||
|
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
|
||||||
|
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
|
||||||
|
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
|
||||||
|
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
|
||||||
|
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
|
||||||
|
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
|
||||||
|
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
|
||||||
|
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
|
||||||
|
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
|
||||||
|
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
|
||||||
|
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
|
||||||
|
0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
|
||||||
|
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
|
||||||
|
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
|
||||||
|
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
|
||||||
|
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
|
||||||
|
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
|
||||||
|
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
|
||||||
|
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
|
||||||
|
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
|
||||||
|
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
|
||||||
|
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
|
||||||
|
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
|
||||||
|
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
|
||||||
|
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
|
||||||
|
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
|
||||||
|
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
|
||||||
|
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
|
||||||
|
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
|
||||||
|
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
|
||||||
|
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
|
||||||
|
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
|
||||||
|
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
|
||||||
|
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
|
||||||
|
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
|
||||||
|
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
|
||||||
|
}, {
|
||||||
|
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
|
||||||
|
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
|
||||||
|
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
|
||||||
|
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
|
||||||
|
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
|
||||||
|
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
|
||||||
|
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
|
||||||
|
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
|
||||||
|
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
|
||||||
|
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
|
||||||
|
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
|
||||||
|
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
|
||||||
|
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
|
||||||
|
0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
|
||||||
|
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
|
||||||
|
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
|
||||||
|
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
|
||||||
|
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
|
||||||
|
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
|
||||||
|
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
|
||||||
|
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
|
||||||
|
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
|
||||||
|
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
|
||||||
|
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
|
||||||
|
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
|
||||||
|
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
|
||||||
|
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
|
||||||
|
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
|
||||||
|
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
|
||||||
|
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
|
||||||
|
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
|
||||||
|
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
|
||||||
|
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
|
||||||
|
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
|
||||||
|
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
|
||||||
|
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
|
||||||
|
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
|
||||||
|
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
|
||||||
|
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
|
||||||
|
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
|
||||||
|
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
|
||||||
|
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
|
||||||
|
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
|
||||||
|
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
|
||||||
|
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
|
||||||
|
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
|
||||||
|
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
|
||||||
|
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
|
||||||
|
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
|
||||||
|
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
|
||||||
|
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
|
||||||
|
0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
|
||||||
|
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
|
||||||
|
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
|
||||||
|
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
|
||||||
|
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
|
||||||
|
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
|
||||||
|
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
|
||||||
|
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
|
||||||
|
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
|
||||||
|
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
|
||||||
|
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
|
||||||
|
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
|
||||||
|
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
|
||||||
|
}, {
|
||||||
|
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
|
||||||
|
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
|
||||||
|
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
|
||||||
|
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
|
||||||
|
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
|
||||||
|
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
|
||||||
|
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
|
||||||
|
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
|
||||||
|
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
|
||||||
|
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
|
||||||
|
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
|
||||||
|
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
|
||||||
|
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
|
||||||
|
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
|
||||||
|
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
|
||||||
|
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
|
||||||
|
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
|
||||||
|
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
|
||||||
|
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
|
||||||
|
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
|
||||||
|
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
|
||||||
|
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
|
||||||
|
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
|
||||||
|
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
|
||||||
|
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
|
||||||
|
0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
|
||||||
|
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
|
||||||
|
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
|
||||||
|
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
|
||||||
|
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
|
||||||
|
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
|
||||||
|
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
|
||||||
|
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
|
||||||
|
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
|
||||||
|
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
|
||||||
|
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
|
||||||
|
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
|
||||||
|
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
|
||||||
|
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
|
||||||
|
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
|
||||||
|
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
|
||||||
|
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
|
||||||
|
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
|
||||||
|
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
|
||||||
|
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
|
||||||
|
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
|
||||||
|
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
|
||||||
|
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
|
||||||
|
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
|
||||||
|
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
|
||||||
|
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
|
||||||
|
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
|
||||||
|
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
|
||||||
|
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
|
||||||
|
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
|
||||||
|
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
|
||||||
|
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
|
||||||
|
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
|
||||||
|
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
|
||||||
|
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
|
||||||
|
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
|
||||||
|
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
|
||||||
|
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
|
||||||
|
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
|
||||||
|
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
|
||||||
|
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
|
||||||
|
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
|
||||||
|
0x9216d5d9, 0x8979fb1b
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static unsigned char BF_itoa64[64 + 1] =
|
||||||
|
"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
|
static unsigned char BF_atoi64[0x60] = {
|
||||||
|
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
|
||||||
|
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
|
||||||
|
64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||||
|
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 64, 64, 64, 64, 64,
|
||||||
|
64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
|
||||||
|
43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 64, 64, 64, 64, 64
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BF_safe_atoi64(dst, src) \
|
||||||
|
{ \
|
||||||
|
tmp = (unsigned char)(src); \
|
||||||
|
if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
|
||||||
|
tmp = BF_atoi64[tmp]; \
|
||||||
|
if (tmp > 63) return -1; \
|
||||||
|
(dst) = tmp; \
|
||||||
|
}
|
||||||
|
|
||||||
|
static int BF_decode(BF_word *dst, const char *src, int size)
|
||||||
|
{
|
||||||
|
unsigned char *dptr = (unsigned char *)dst;
|
||||||
|
unsigned char *end = dptr + size;
|
||||||
|
const unsigned char *sptr = (const unsigned char *)src;
|
||||||
|
unsigned int tmp, c1, c2, c3, c4;
|
||||||
|
|
||||||
|
do {
|
||||||
|
BF_safe_atoi64(c1, *sptr++);
|
||||||
|
BF_safe_atoi64(c2, *sptr++);
|
||||||
|
*dptr++ = (c1 << 2) | ((c2 & 0x30) >> 4);
|
||||||
|
if (dptr >= end) break;
|
||||||
|
|
||||||
|
BF_safe_atoi64(c3, *sptr++);
|
||||||
|
*dptr++ = ((c2 & 0x0F) << 4) | ((c3 & 0x3C) >> 2);
|
||||||
|
if (dptr >= end) break;
|
||||||
|
|
||||||
|
BF_safe_atoi64(c4, *sptr++);
|
||||||
|
*dptr++ = ((c3 & 0x03) << 6) | c4;
|
||||||
|
} while (dptr < end);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BF_encode(char *dst, const BF_word *src, int size)
|
||||||
|
{
|
||||||
|
const unsigned char *sptr = (const unsigned char *)src;
|
||||||
|
const unsigned char *end = sptr + size;
|
||||||
|
unsigned char *dptr = (unsigned char *)dst;
|
||||||
|
unsigned int c1, c2;
|
||||||
|
|
||||||
|
do {
|
||||||
|
c1 = *sptr++;
|
||||||
|
*dptr++ = BF_itoa64[c1 >> 2];
|
||||||
|
c1 = (c1 & 0x03) << 4;
|
||||||
|
if (sptr >= end) {
|
||||||
|
*dptr++ = BF_itoa64[c1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
c2 = *sptr++;
|
||||||
|
c1 |= c2 >> 4;
|
||||||
|
*dptr++ = BF_itoa64[c1];
|
||||||
|
c1 = (c2 & 0x0f) << 2;
|
||||||
|
if (sptr >= end) {
|
||||||
|
*dptr++ = BF_itoa64[c1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
c2 = *sptr++;
|
||||||
|
c1 |= c2 >> 6;
|
||||||
|
*dptr++ = BF_itoa64[c1];
|
||||||
|
*dptr++ = BF_itoa64[c2 & 0x3f];
|
||||||
|
} while (sptr < end);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BF_swap(BF_word *x, int count)
|
||||||
|
{
|
||||||
|
static int endianness_check = 1;
|
||||||
|
char *is_little_endian = (char *)&endianness_check;
|
||||||
|
BF_word tmp;
|
||||||
|
|
||||||
|
if (*is_little_endian)
|
||||||
|
do {
|
||||||
|
tmp = *x;
|
||||||
|
tmp = (tmp << 16) | (tmp >> 16);
|
||||||
|
*x++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if BF_SCALE
|
||||||
|
/* Architectures which can shift addresses left by 2 bits with no extra cost */
|
||||||
|
#define BF_ROUND(L, R, N) \
|
||||||
|
tmp1 = L & 0xFF; \
|
||||||
|
tmp2 = L >> 8; \
|
||||||
|
tmp2 &= 0xFF; \
|
||||||
|
tmp3 = L >> 16; \
|
||||||
|
tmp3 &= 0xFF; \
|
||||||
|
tmp4 = L >> 24; \
|
||||||
|
tmp1 = data.ctx.S[3][tmp1]; \
|
||||||
|
tmp2 = data.ctx.S[2][tmp2]; \
|
||||||
|
tmp3 = data.ctx.S[1][tmp3]; \
|
||||||
|
tmp3 += data.ctx.S[0][tmp4]; \
|
||||||
|
tmp3 ^= tmp2; \
|
||||||
|
R ^= data.ctx.P[N + 1]; \
|
||||||
|
tmp3 += tmp1; \
|
||||||
|
R ^= tmp3;
|
||||||
|
#else
|
||||||
|
/* Architectures with no complicated addressing modes supported */
|
||||||
|
#define BF_INDEX(S, i) \
|
||||||
|
(*((BF_word *)(((unsigned char *)S) + (i))))
|
||||||
|
#define BF_ROUND(L, R, N) \
|
||||||
|
tmp1 = L & 0xFF; \
|
||||||
|
tmp1 <<= 2; \
|
||||||
|
tmp2 = L >> 6; \
|
||||||
|
tmp2 &= 0x3FC; \
|
||||||
|
tmp3 = L >> 14; \
|
||||||
|
tmp3 &= 0x3FC; \
|
||||||
|
tmp4 = L >> 22; \
|
||||||
|
tmp4 &= 0x3FC; \
|
||||||
|
tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \
|
||||||
|
tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \
|
||||||
|
tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \
|
||||||
|
tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \
|
||||||
|
tmp3 ^= tmp2; \
|
||||||
|
R ^= data.ctx.P[N + 1]; \
|
||||||
|
tmp3 += tmp1; \
|
||||||
|
R ^= tmp3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encrypt one block, BF_N is hardcoded here.
|
||||||
|
*/
|
||||||
|
#define BF_ENCRYPT \
|
||||||
|
L ^= data.ctx.P[0]; \
|
||||||
|
BF_ROUND(L, R, 0); \
|
||||||
|
BF_ROUND(R, L, 1); \
|
||||||
|
BF_ROUND(L, R, 2); \
|
||||||
|
BF_ROUND(R, L, 3); \
|
||||||
|
BF_ROUND(L, R, 4); \
|
||||||
|
BF_ROUND(R, L, 5); \
|
||||||
|
BF_ROUND(L, R, 6); \
|
||||||
|
BF_ROUND(R, L, 7); \
|
||||||
|
BF_ROUND(L, R, 8); \
|
||||||
|
BF_ROUND(R, L, 9); \
|
||||||
|
BF_ROUND(L, R, 10); \
|
||||||
|
BF_ROUND(R, L, 11); \
|
||||||
|
BF_ROUND(L, R, 12); \
|
||||||
|
BF_ROUND(R, L, 13); \
|
||||||
|
BF_ROUND(L, R, 14); \
|
||||||
|
BF_ROUND(R, L, 15); \
|
||||||
|
tmp4 = R; \
|
||||||
|
R = L; \
|
||||||
|
L = tmp4 ^ data.ctx.P[BF_N + 1];
|
||||||
|
|
||||||
|
#if BF_ASM
|
||||||
|
#define BF_body() \
|
||||||
|
_BF_body_r(&data.ctx);
|
||||||
|
#else
|
||||||
|
#define BF_body() \
|
||||||
|
L = R = 0; \
|
||||||
|
ptr = data.ctx.P; \
|
||||||
|
do { \
|
||||||
|
ptr += 2; \
|
||||||
|
BF_ENCRYPT; \
|
||||||
|
*(ptr - 2) = L; \
|
||||||
|
*(ptr - 1) = R; \
|
||||||
|
} while (ptr < &data.ctx.P[BF_N + 2]); \
|
||||||
|
\
|
||||||
|
ptr = data.ctx.S[0]; \
|
||||||
|
do { \
|
||||||
|
ptr += 2; \
|
||||||
|
BF_ENCRYPT; \
|
||||||
|
*(ptr - 2) = L; \
|
||||||
|
*(ptr - 1) = R; \
|
||||||
|
} while (ptr < &data.ctx.S[3][0xFF]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void BF_set_key(const char *key, BF_key expanded, BF_key initial,
|
||||||
|
unsigned char flags)
|
||||||
|
{
|
||||||
|
const char *ptr = key;
|
||||||
|
unsigned int bug, i, j;
|
||||||
|
BF_word safety, sign, diff, tmp[2];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There was a sign extension bug in older revisions of this function. While
|
||||||
|
* we would have liked to simply fix the bug and move on, we have to provide
|
||||||
|
* a backwards compatibility feature (essentially the bug) for some systems and
|
||||||
|
* a safety measure for some others. The latter is needed because for certain
|
||||||
|
* multiple inputs to the buggy algorithm there exist easily found inputs to
|
||||||
|
* the correct algorithm that produce the same hash. Thus, we optionally
|
||||||
|
* deviate from the correct algorithm just enough to avoid such collisions.
|
||||||
|
* While the bug itself affected the majority of passwords containing
|
||||||
|
* characters with the 8th bit set (although only a percentage of those in a
|
||||||
|
* collision-producing way), the anti-collision safety measure affects
|
||||||
|
* only a subset of passwords containing the '\xff' character (not even all of
|
||||||
|
* those passwords, just some of them). This character is not found in valid
|
||||||
|
* UTF-8 sequences and is rarely used in popular 8-bit character encodings.
|
||||||
|
* Thus, the safety measure is unlikely to cause much annoyance, and is a
|
||||||
|
* reasonable tradeoff to use when authenticating against existing hashes that
|
||||||
|
* are not reliably known to have been computed with the correct algorithm.
|
||||||
|
*
|
||||||
|
* We use an approach that tries to minimize side-channel leaks of password
|
||||||
|
* information - that is, we mostly use fixed-cost bitwise operations instead
|
||||||
|
* of branches or table lookups. (One conditional branch based on password
|
||||||
|
* length remains. It is not part of the bug aftermath, though, and is
|
||||||
|
* difficult and possibly unreasonable to avoid given the use of C strings by
|
||||||
|
* the caller, which results in similar timing leaks anyway.)
|
||||||
|
*
|
||||||
|
* For actual implementation, we set an array index in the variable "bug"
|
||||||
|
* (0 means no bug, 1 means sign extension bug emulation) and a flag in the
|
||||||
|
* variable "safety" (bit 16 is set when the safety measure is requested).
|
||||||
|
* Valid combinations of settings are:
|
||||||
|
*
|
||||||
|
* Prefix "$2a$": bug = 0, safety = 0x10000
|
||||||
|
* Prefix "$2b$": bug = 0, safety = 0
|
||||||
|
* Prefix "$2x$": bug = 1, safety = 0
|
||||||
|
* Prefix "$2y$": bug = 0, safety = 0
|
||||||
|
*/
|
||||||
|
bug = (unsigned int)flags & 1;
|
||||||
|
safety = ((BF_word)flags & 2) << 15;
|
||||||
|
|
||||||
|
sign = diff = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < BF_N + 2; i++) {
|
||||||
|
tmp[0] = tmp[1] = 0;
|
||||||
|
for (j = 0; j < 4; j++) {
|
||||||
|
tmp[0] <<= 8;
|
||||||
|
tmp[0] |= (unsigned char)*ptr; /* correct */
|
||||||
|
tmp[1] <<= 8;
|
||||||
|
tmp[1] |= (BF_word_signed)(signed char)*ptr; /* bug */
|
||||||
|
/*
|
||||||
|
* Sign extension in the first char has no effect - nothing to overwrite yet,
|
||||||
|
* and those extra 24 bits will be fully shifted out of the 32-bit word. For
|
||||||
|
* chars 2, 3, 4 in each four-char block, we set bit 7 of "sign" if sign
|
||||||
|
* extension in tmp[1] occurs. Once this flag is set, it remains set.
|
||||||
|
*/
|
||||||
|
if (j)
|
||||||
|
sign |= tmp[1] & 0x80;
|
||||||
|
if (!*ptr)
|
||||||
|
ptr = key;
|
||||||
|
else
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
diff |= tmp[0] ^ tmp[1]; /* Non-zero on any differences */
|
||||||
|
|
||||||
|
expanded[i] = tmp[bug];
|
||||||
|
initial[i] = BF_init_state.P[i] ^ tmp[bug];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* At this point, "diff" is zero iff the correct and buggy algorithms produced
|
||||||
|
* exactly the same result. If so and if "sign" is non-zero, which indicates
|
||||||
|
* that there was a non-benign sign extension, this means that we have a
|
||||||
|
* collision between the correctly computed hash for this password and a set of
|
||||||
|
* passwords that could be supplied to the buggy algorithm. Our safety measure
|
||||||
|
* is meant to protect from such many-buggy to one-correct collisions, by
|
||||||
|
* deviating from the correct algorithm in such cases. Let's check for this.
|
||||||
|
*/
|
||||||
|
diff |= diff >> 16; /* still zero iff exact match */
|
||||||
|
diff &= 0xffff; /* ditto */
|
||||||
|
diff += 0xffff; /* bit 16 set iff "diff" was non-zero (on non-match) */
|
||||||
|
sign <<= 9; /* move the non-benign sign extension flag to bit 16 */
|
||||||
|
sign &= ~diff & safety; /* action needed? */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have determined that we need to deviate from the correct algorithm,
|
||||||
|
* flip bit 16 in initial expanded key. (The choice of 16 is arbitrary, but
|
||||||
|
* let's stick to it now. It came out of the approach we used above, and it's
|
||||||
|
* not any worse than any other choice we could make.)
|
||||||
|
*
|
||||||
|
* It is crucial that we don't do the same to the expanded key used in the main
|
||||||
|
* Eksblowfish loop. By doing it to only one of these two, we deviate from a
|
||||||
|
* state that could be directly specified by a password to the buggy algorithm
|
||||||
|
* (and to the fully correct one as well, but that's a side-effect).
|
||||||
|
*/
|
||||||
|
initial[0] ^= sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const unsigned char flags_by_subtype[26] =
|
||||||
|
{2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0};
|
||||||
|
|
||||||
|
static char *BF_crypt(const char *key, const char *setting,
|
||||||
|
char *output, int size,
|
||||||
|
BF_word min)
|
||||||
|
{
|
||||||
|
#if BF_ASM
|
||||||
|
extern void _BF_body_r(BF_ctx *ctx);
|
||||||
|
#endif
|
||||||
|
struct {
|
||||||
|
BF_ctx ctx;
|
||||||
|
BF_key expanded_key;
|
||||||
|
union {
|
||||||
|
BF_word salt[4];
|
||||||
|
BF_word output[6];
|
||||||
|
} binary;
|
||||||
|
} data;
|
||||||
|
BF_word L, R;
|
||||||
|
BF_word tmp1, tmp2, tmp3, tmp4;
|
||||||
|
BF_word *ptr;
|
||||||
|
BF_word count;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (size < 7 + 22 + 31 + 1) {
|
||||||
|
__set_errno(ERANGE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setting[0] != '$' ||
|
||||||
|
setting[1] != '2' ||
|
||||||
|
setting[2] < 'a' || setting[2] > 'z' ||
|
||||||
|
!flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a'] ||
|
||||||
|
setting[3] != '$' ||
|
||||||
|
setting[4] < '0' || setting[4] > '3' ||
|
||||||
|
setting[5] < '0' || setting[5] > '9' ||
|
||||||
|
(setting[4] == '3' && setting[5] > '1') ||
|
||||||
|
setting[6] != '$') {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = (BF_word)1 << ((setting[4] - '0') * 10 + (setting[5] - '0'));
|
||||||
|
if (count < min || BF_decode(data.binary.salt, &setting[7], 16)) {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
BF_swap(data.binary.salt, 4);
|
||||||
|
|
||||||
|
BF_set_key(key, data.expanded_key, data.ctx.P,
|
||||||
|
flags_by_subtype[(unsigned int)(unsigned char)setting[2] - 'a']);
|
||||||
|
|
||||||
|
memcpy(data.ctx.S, BF_init_state.S, sizeof(data.ctx.S));
|
||||||
|
|
||||||
|
L = R = 0;
|
||||||
|
for (i = 0; i < BF_N + 2; i += 2) {
|
||||||
|
L ^= data.binary.salt[i & 2];
|
||||||
|
R ^= data.binary.salt[(i & 2) + 1];
|
||||||
|
BF_ENCRYPT;
|
||||||
|
data.ctx.P[i] = L;
|
||||||
|
data.ctx.P[i + 1] = R;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = data.ctx.S[0];
|
||||||
|
do {
|
||||||
|
ptr += 4;
|
||||||
|
L ^= data.binary.salt[(BF_N + 2) & 3];
|
||||||
|
R ^= data.binary.salt[(BF_N + 3) & 3];
|
||||||
|
BF_ENCRYPT;
|
||||||
|
*(ptr - 4) = L;
|
||||||
|
*(ptr - 3) = R;
|
||||||
|
|
||||||
|
L ^= data.binary.salt[(BF_N + 4) & 3];
|
||||||
|
R ^= data.binary.salt[(BF_N + 5) & 3];
|
||||||
|
BF_ENCRYPT;
|
||||||
|
*(ptr - 2) = L;
|
||||||
|
*(ptr - 1) = R;
|
||||||
|
} while (ptr < &data.ctx.S[3][0xFF]);
|
||||||
|
|
||||||
|
do {
|
||||||
|
int done;
|
||||||
|
|
||||||
|
for (i = 0; i < BF_N + 2; i += 2) {
|
||||||
|
data.ctx.P[i] ^= data.expanded_key[i];
|
||||||
|
data.ctx.P[i + 1] ^= data.expanded_key[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
done = 0;
|
||||||
|
do {
|
||||||
|
BF_body();
|
||||||
|
if (done)
|
||||||
|
break;
|
||||||
|
done = 1;
|
||||||
|
|
||||||
|
tmp1 = data.binary.salt[0];
|
||||||
|
tmp2 = data.binary.salt[1];
|
||||||
|
tmp3 = data.binary.salt[2];
|
||||||
|
tmp4 = data.binary.salt[3];
|
||||||
|
for (i = 0; i < BF_N; i += 4) {
|
||||||
|
data.ctx.P[i] ^= tmp1;
|
||||||
|
data.ctx.P[i + 1] ^= tmp2;
|
||||||
|
data.ctx.P[i + 2] ^= tmp3;
|
||||||
|
data.ctx.P[i + 3] ^= tmp4;
|
||||||
|
}
|
||||||
|
data.ctx.P[16] ^= tmp1;
|
||||||
|
data.ctx.P[17] ^= tmp2;
|
||||||
|
} while (1);
|
||||||
|
} while (--count);
|
||||||
|
|
||||||
|
for (i = 0; i < 6; i += 2) {
|
||||||
|
L = BF_magic_w[i];
|
||||||
|
R = BF_magic_w[i + 1];
|
||||||
|
|
||||||
|
count = 64;
|
||||||
|
do {
|
||||||
|
BF_ENCRYPT;
|
||||||
|
} while (--count);
|
||||||
|
|
||||||
|
data.binary.output[i] = L;
|
||||||
|
data.binary.output[i + 1] = R;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(output, setting, 7 + 22 - 1);
|
||||||
|
output[7 + 22 - 1] = BF_itoa64[(int)
|
||||||
|
BF_atoi64[(int)setting[7 + 22 - 1] - 0x20] & 0x30];
|
||||||
|
|
||||||
|
/* This has to be bug-compatible with the original implementation, so
|
||||||
|
* only encode 23 of the 24 bytes. :-) */
|
||||||
|
BF_swap(data.binary.output, 6);
|
||||||
|
BF_encode(&output[7 + 22], data.binary.output, 23);
|
||||||
|
output[7 + 22 + 31] = '\0';
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _crypt_output_magic(const char *setting, char *output, int size)
|
||||||
|
{
|
||||||
|
if (size < 3)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
output[0] = '*';
|
||||||
|
output[1] = '0';
|
||||||
|
output[2] = '\0';
|
||||||
|
|
||||||
|
if (setting[0] == '*' && setting[1] == '0')
|
||||||
|
output[1] = '1';
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Please preserve the runtime self-test. It serves two purposes at once:
|
||||||
|
*
|
||||||
|
* 1. We really can't afford the risk of producing incompatible hashes e.g.
|
||||||
|
* when there's something like gcc bug 26587 again, whereas an application or
|
||||||
|
* library integrating this code might not also integrate our external tests or
|
||||||
|
* it might not run them after every build. Even if it does, the miscompile
|
||||||
|
* might only occur on the production build, but not on a testing build (such
|
||||||
|
* as because of different optimization settings). It is painful to recover
|
||||||
|
* from incorrectly-computed hashes - merely fixing whatever broke is not
|
||||||
|
* enough. Thus, a proactive measure like this self-test is needed.
|
||||||
|
*
|
||||||
|
* 2. We don't want to leave sensitive data from our actual password hash
|
||||||
|
* computation on the stack or in registers. Previous revisions of the code
|
||||||
|
* would do explicit cleanups, but simply running the self-test after hash
|
||||||
|
* computation is more reliable.
|
||||||
|
*
|
||||||
|
* The performance cost of this quick self-test is around 0.6% at the "$2a$08"
|
||||||
|
* setting.
|
||||||
|
*/
|
||||||
|
char *_crypt_blowfish_rn(const char *key, const char *setting,
|
||||||
|
char *output, int size)
|
||||||
|
{
|
||||||
|
const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8";
|
||||||
|
const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu";
|
||||||
|
static const char * const test_hashes[2] =
|
||||||
|
{"i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55", /* 'a', 'b', 'y' */
|
||||||
|
"VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55"}; /* 'x' */
|
||||||
|
const char *test_hash = test_hashes[0];
|
||||||
|
char *retval;
|
||||||
|
const char *p;
|
||||||
|
int save_errno, ok;
|
||||||
|
struct {
|
||||||
|
char s[7 + 22 + 1];
|
||||||
|
char o[7 + 22 + 31 + 1 + 1 + 1];
|
||||||
|
} buf;
|
||||||
|
|
||||||
|
/* Hash the supplied password */
|
||||||
|
_crypt_output_magic(setting, output, size);
|
||||||
|
retval = BF_crypt(key, setting, output, size, 16);
|
||||||
|
save_errno = errno;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Do a quick self-test. It is important that we make both calls to BF_crypt()
|
||||||
|
* from the same scope such that they likely use the same stack locations,
|
||||||
|
* which makes the second call overwrite the first call's sensitive data on the
|
||||||
|
* stack and makes it more likely that any alignment related issues would be
|
||||||
|
* detected by the self-test.
|
||||||
|
*/
|
||||||
|
memcpy(buf.s, test_setting, sizeof(buf.s));
|
||||||
|
if (retval) {
|
||||||
|
unsigned int flags = flags_by_subtype[
|
||||||
|
(unsigned int)(unsigned char)setting[2] - 'a'];
|
||||||
|
test_hash = test_hashes[flags & 1];
|
||||||
|
buf.s[2] = setting[2];
|
||||||
|
}
|
||||||
|
memset(buf.o, 0x55, sizeof(buf.o));
|
||||||
|
buf.o[sizeof(buf.o) - 1] = 0;
|
||||||
|
p = BF_crypt(test_key, buf.s, buf.o, sizeof(buf.o) - (1 + 1), 1);
|
||||||
|
|
||||||
|
ok = (p == buf.o &&
|
||||||
|
!memcmp(p, buf.s, 7 + 22) &&
|
||||||
|
!memcmp(p + (7 + 22), test_hash, 31 + 1 + 1 + 1));
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *k = "\xff\xa3" "34" "\xff\xff\xff\xa3" "345";
|
||||||
|
BF_key ae, ai, ye, yi;
|
||||||
|
BF_set_key(k, ae, ai, 2); /* $2a$ */
|
||||||
|
BF_set_key(k, ye, yi, 4); /* $2y$ */
|
||||||
|
ai[0] ^= 0x10000; /* undo the safety (for comparison) */
|
||||||
|
ok = ok && ai[0] == 0xdb9c59bc && ye[17] == 0x33343500 &&
|
||||||
|
!memcmp(ae, ye, sizeof(ae)) &&
|
||||||
|
!memcmp(ai, yi, sizeof(ai));
|
||||||
|
}
|
||||||
|
|
||||||
|
__set_errno(save_errno);
|
||||||
|
if (ok)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
/* Should not happen */
|
||||||
|
_crypt_output_magic(setting, output, size);
|
||||||
|
__set_errno(EINVAL); /* pretend we don't support this hash type */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size)
|
||||||
|
{
|
||||||
|
if (size < 16 || output_size < 7 + 22 + 1 ||
|
||||||
|
(count && (count < 4 || count > 31)) ||
|
||||||
|
prefix[0] != '$' || prefix[1] != '2' ||
|
||||||
|
(prefix[2] != 'a' && prefix[2] != 'b' && prefix[2] != 'y')) {
|
||||||
|
if (output_size > 0) output[0] = '\0';
|
||||||
|
__set_errno((output_size < 7 + 22 + 1) ? ERANGE : EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count) count = 5;
|
||||||
|
|
||||||
|
output[0] = '$';
|
||||||
|
output[1] = '2';
|
||||||
|
output[2] = prefix[2];
|
||||||
|
output[3] = '$';
|
||||||
|
output[4] = '0' + count / 10;
|
||||||
|
output[5] = '0' + count % 10;
|
||||||
|
output[6] = '$';
|
||||||
|
|
||||||
|
BF_encode(&output[7], (const BF_word *)input, 16);
|
||||||
|
output[7 + 22] = '\0';
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
27
deps/crypt_blowfish/crypt_blowfish.h
vendored
Normal file
27
deps/crypt_blowfish/crypt_blowfish.h
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CRYPT_BLOWFISH_H
|
||||||
|
#define _CRYPT_BLOWFISH_H
|
||||||
|
|
||||||
|
extern int _crypt_output_magic(const char *setting, char *output, int size);
|
||||||
|
extern char *_crypt_blowfish_rn(const char *key, const char *setting,
|
||||||
|
char *output, int size);
|
||||||
|
extern char *_crypt_gensalt_blowfish_rn(const char *prefix,
|
||||||
|
unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size);
|
||||||
|
|
||||||
|
#endif
|
124
deps/crypt_blowfish/crypt_gensalt.c
vendored
Normal file
124
deps/crypt_blowfish/crypt_gensalt.c
vendored
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*
|
||||||
|
* This file contains salt generation functions for the traditional and
|
||||||
|
* other common crypt(3) algorithms, except for bcrypt which is defined
|
||||||
|
* entirely in crypt_blowfish.c.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef __set_errno
|
||||||
|
#define __set_errno(val) errno = (val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Just to make sure the prototypes match the actual definitions */
|
||||||
|
#include "crypt_gensalt.h"
|
||||||
|
|
||||||
|
unsigned char _crypt_itoa64[64 + 1] =
|
||||||
|
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
char *_crypt_gensalt_traditional_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size)
|
||||||
|
{
|
||||||
|
(void) prefix;
|
||||||
|
|
||||||
|
if (size < 2 || output_size < 2 + 1 || (count && count != 25)) {
|
||||||
|
if (output_size > 0) output[0] = '\0';
|
||||||
|
__set_errno((output_size < 2 + 1) ? ERANGE : EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
output[0] = _crypt_itoa64[(unsigned int)input[0] & 0x3f];
|
||||||
|
output[1] = _crypt_itoa64[(unsigned int)input[1] & 0x3f];
|
||||||
|
output[2] = '\0';
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *_crypt_gensalt_extended_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size)
|
||||||
|
{
|
||||||
|
unsigned long value;
|
||||||
|
|
||||||
|
(void) prefix;
|
||||||
|
|
||||||
|
/* Even iteration counts make it easier to detect weak DES keys from a look
|
||||||
|
* at the hash, so they should be avoided */
|
||||||
|
if (size < 3 || output_size < 1 + 4 + 4 + 1 ||
|
||||||
|
(count && (count > 0xffffff || !(count & 1)))) {
|
||||||
|
if (output_size > 0) output[0] = '\0';
|
||||||
|
__set_errno((output_size < 1 + 4 + 4 + 1) ? ERANGE : EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count) count = 725;
|
||||||
|
|
||||||
|
output[0] = '_';
|
||||||
|
output[1] = _crypt_itoa64[count & 0x3f];
|
||||||
|
output[2] = _crypt_itoa64[(count >> 6) & 0x3f];
|
||||||
|
output[3] = _crypt_itoa64[(count >> 12) & 0x3f];
|
||||||
|
output[4] = _crypt_itoa64[(count >> 18) & 0x3f];
|
||||||
|
value = (unsigned long)(unsigned char)input[0] |
|
||||||
|
((unsigned long)(unsigned char)input[1] << 8) |
|
||||||
|
((unsigned long)(unsigned char)input[2] << 16);
|
||||||
|
output[5] = _crypt_itoa64[value & 0x3f];
|
||||||
|
output[6] = _crypt_itoa64[(value >> 6) & 0x3f];
|
||||||
|
output[7] = _crypt_itoa64[(value >> 12) & 0x3f];
|
||||||
|
output[8] = _crypt_itoa64[(value >> 18) & 0x3f];
|
||||||
|
output[9] = '\0';
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *_crypt_gensalt_md5_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size)
|
||||||
|
{
|
||||||
|
unsigned long value;
|
||||||
|
|
||||||
|
(void) prefix;
|
||||||
|
|
||||||
|
if (size < 3 || output_size < 3 + 4 + 1 || (count && count != 1000)) {
|
||||||
|
if (output_size > 0) output[0] = '\0';
|
||||||
|
__set_errno((output_size < 3 + 4 + 1) ? ERANGE : EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
output[0] = '$';
|
||||||
|
output[1] = '1';
|
||||||
|
output[2] = '$';
|
||||||
|
value = (unsigned long)(unsigned char)input[0] |
|
||||||
|
((unsigned long)(unsigned char)input[1] << 8) |
|
||||||
|
((unsigned long)(unsigned char)input[2] << 16);
|
||||||
|
output[3] = _crypt_itoa64[value & 0x3f];
|
||||||
|
output[4] = _crypt_itoa64[(value >> 6) & 0x3f];
|
||||||
|
output[5] = _crypt_itoa64[(value >> 12) & 0x3f];
|
||||||
|
output[6] = _crypt_itoa64[(value >> 18) & 0x3f];
|
||||||
|
output[7] = '\0';
|
||||||
|
|
||||||
|
if (size >= 6 && output_size >= 3 + 4 + 4 + 1) {
|
||||||
|
value = (unsigned long)(unsigned char)input[3] |
|
||||||
|
((unsigned long)(unsigned char)input[4] << 8) |
|
||||||
|
((unsigned long)(unsigned char)input[5] << 16);
|
||||||
|
output[7] = _crypt_itoa64[value & 0x3f];
|
||||||
|
output[8] = _crypt_itoa64[(value >> 6) & 0x3f];
|
||||||
|
output[9] = _crypt_itoa64[(value >> 12) & 0x3f];
|
||||||
|
output[10] = _crypt_itoa64[(value >> 18) & 0x3f];
|
||||||
|
output[11] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
30
deps/crypt_blowfish/crypt_gensalt.h
vendored
Normal file
30
deps/crypt_blowfish/crypt_gensalt.h
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CRYPT_GENSALT_H
|
||||||
|
#define _CRYPT_GENSALT_H
|
||||||
|
|
||||||
|
extern unsigned char _crypt_itoa64[];
|
||||||
|
extern char *_crypt_gensalt_traditional_rn(const char *prefix,
|
||||||
|
unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size);
|
||||||
|
extern char *_crypt_gensalt_extended_rn(const char *prefix,
|
||||||
|
unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size);
|
||||||
|
extern char *_crypt_gensalt_md5_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size);
|
||||||
|
|
||||||
|
#endif
|
53
deps/crypt_blowfish/glibc-2.1.3-crypt.diff
vendored
Normal file
53
deps/crypt_blowfish/glibc-2.1.3-crypt.diff
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
--- glibc-2.1.3.orig/crypt/sysdeps/unix/Makefile 1997-03-05 00:33:59 +0000
|
||||||
|
+++ glibc-2.1.3/crypt/sysdeps/unix/Makefile 2000-06-11 03:13:41 +0000
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
ifeq ($(subdir),md5-crypt)
|
||||||
|
-libcrypt-routines += crypt crypt_util
|
||||||
|
-dont_distribute += crypt.c crypt_util.c
|
||||||
|
+libcrypt-routines += crypt crypt_util crypt_blowfish x86 crypt_gensalt wrapper
|
||||||
|
+dont_distribute += crypt.c crypt_util.c crypt_blowfish.c x86.S crypt_gensalt.c wrapper.c
|
||||||
|
endif
|
||||||
|
--- glibc-2.1.3.orig/crypt/sysdeps/unix/crypt-entry.c 1998-12-10 12:49:04 +0000
|
||||||
|
+++ glibc-2.1.3/crypt/sysdeps/unix/crypt-entry.c 2000-06-11 03:14:57 +0000
|
||||||
|
@@ -70,7 +70,7 @@ extern struct crypt_data _ufc_foobar;
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *
|
||||||
|
-__crypt_r (key, salt, data)
|
||||||
|
+__des_crypt_r (key, salt, data)
|
||||||
|
const char *key;
|
||||||
|
const char *salt;
|
||||||
|
struct crypt_data * __restrict data;
|
||||||
|
@@ -115,6 +115,7 @@ __crypt_r (key, salt, data)
|
||||||
|
_ufc_output_conversion_r (res[0], res[1], salt, data);
|
||||||
|
return data->crypt_3_buf;
|
||||||
|
}
|
||||||
|
+#if 0
|
||||||
|
weak_alias (__crypt_r, crypt_r)
|
||||||
|
|
||||||
|
char *
|
||||||
|
@@ -147,3 +148,4 @@ __fcrypt (key, salt)
|
||||||
|
return crypt (key, salt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+#endif
|
||||||
|
--- glibc-2.1.3.orig/md5-crypt/Makefile 1998-07-02 22:46:47 +0000
|
||||||
|
+++ glibc-2.1.3/md5-crypt/Makefile 2000-06-11 03:12:34 +0000
|
||||||
|
@@ -21,7 +21,7 @@
|
||||||
|
#
|
||||||
|
subdir := md5-crypt
|
||||||
|
|
||||||
|
-headers := crypt.h
|
||||||
|
+headers := crypt.h gnu-crypt.h ow-crypt.h
|
||||||
|
|
||||||
|
distribute := md5.h
|
||||||
|
|
||||||
|
--- glibc-2.1.3.orig/md5-crypt/Versions 1998-07-02 22:32:07 +0000
|
||||||
|
+++ glibc-2.1.3/md5-crypt/Versions 2000-06-11 09:11:03 +0000
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
libcrypt {
|
||||||
|
GLIBC_2.0 {
|
||||||
|
crypt; crypt_r; encrypt; encrypt_r; fcrypt; setkey; setkey_r;
|
||||||
|
+ crypt_rn; crypt_ra; crypt_gensalt; crypt_gensalt_rn; crypt_gensalt_ra;
|
||||||
|
}
|
||||||
|
}
|
55
deps/crypt_blowfish/glibc-2.14-crypt.diff
vendored
Normal file
55
deps/crypt_blowfish/glibc-2.14-crypt.diff
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
diff -urp glibc-2.14.orig/crypt/Makefile glibc-2.14/crypt/Makefile
|
||||||
|
--- glibc-2.14.orig/crypt/Makefile 2011-05-31 04:12:33 +0000
|
||||||
|
+++ glibc-2.14/crypt/Makefile 2011-07-16 21:40:56 +0000
|
||||||
|
@@ -22,6 +22,7 @@
|
||||||
|
subdir := crypt
|
||||||
|
|
||||||
|
headers := crypt.h
|
||||||
|
+headers += gnu-crypt.h ow-crypt.h
|
||||||
|
|
||||||
|
extra-libs := libcrypt
|
||||||
|
extra-libs-others := $(extra-libs)
|
||||||
|
@@ -29,6 +30,8 @@ extra-libs-others := $(extra-libs)
|
||||||
|
libcrypt-routines := crypt-entry md5-crypt sha256-crypt sha512-crypt crypt \
|
||||||
|
crypt_util
|
||||||
|
|
||||||
|
+libcrypt-routines += crypt_blowfish x86 crypt_gensalt wrapper
|
||||||
|
+
|
||||||
|
tests := cert md5c-test sha256c-test sha512c-test
|
||||||
|
|
||||||
|
distribute := ufc-crypt.h crypt-private.h ufc.c speeds.c README.ufc-crypt \
|
||||||
|
diff -urp glibc-2.14.orig/crypt/Versions glibc-2.14/crypt/Versions
|
||||||
|
--- glibc-2.14.orig/crypt/Versions 2011-05-31 04:12:33 +0000
|
||||||
|
+++ glibc-2.14/crypt/Versions 2011-07-16 21:40:56 +0000
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
libcrypt {
|
||||||
|
GLIBC_2.0 {
|
||||||
|
crypt; crypt_r; encrypt; encrypt_r; fcrypt; setkey; setkey_r;
|
||||||
|
+ crypt_rn; crypt_ra; crypt_gensalt; crypt_gensalt_rn; crypt_gensalt_ra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff -urp glibc-2.14.orig/crypt/crypt-entry.c glibc-2.14/crypt/crypt-entry.c
|
||||||
|
--- glibc-2.14.orig/crypt/crypt-entry.c 2011-05-31 04:12:33 +0000
|
||||||
|
+++ glibc-2.14/crypt/crypt-entry.c 2011-07-16 21:40:56 +0000
|
||||||
|
@@ -82,7 +82,7 @@ extern struct crypt_data _ufc_foobar;
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *
|
||||||
|
-__crypt_r (key, salt, data)
|
||||||
|
+__des_crypt_r (key, salt, data)
|
||||||
|
const char *key;
|
||||||
|
const char *salt;
|
||||||
|
struct crypt_data * __restrict data;
|
||||||
|
@@ -137,6 +137,7 @@ __crypt_r (key, salt, data)
|
||||||
|
_ufc_output_conversion_r (res[0], res[1], salt, data);
|
||||||
|
return data->crypt_3_buf;
|
||||||
|
}
|
||||||
|
+#if 0
|
||||||
|
weak_alias (__crypt_r, crypt_r)
|
||||||
|
|
||||||
|
char *
|
||||||
|
@@ -177,3 +178,4 @@ __fcrypt (key, salt)
|
||||||
|
return crypt (key, salt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+#endif
|
52
deps/crypt_blowfish/glibc-2.3.6-crypt.diff
vendored
Normal file
52
deps/crypt_blowfish/glibc-2.3.6-crypt.diff
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
--- glibc-2.3.6.orig/crypt/Makefile 2001-07-06 04:54:45 +0000
|
||||||
|
+++ glibc-2.3.6/crypt/Makefile 2004-02-27 00:23:48 +0000
|
||||||
|
@@ -21,14 +21,14 @@
|
||||||
|
#
|
||||||
|
subdir := crypt
|
||||||
|
|
||||||
|
-headers := crypt.h
|
||||||
|
+headers := crypt.h gnu-crypt.h ow-crypt.h
|
||||||
|
|
||||||
|
distribute := md5.h
|
||||||
|
|
||||||
|
extra-libs := libcrypt
|
||||||
|
extra-libs-others := $(extra-libs)
|
||||||
|
|
||||||
|
-libcrypt-routines := crypt-entry md5-crypt md5 crypt crypt_util
|
||||||
|
+libcrypt-routines := crypt-entry md5-crypt md5 crypt crypt_util crypt_blowfish x86 crypt_gensalt wrapper
|
||||||
|
|
||||||
|
tests = cert md5test md5c-test
|
||||||
|
|
||||||
|
--- glibc-2.3.6.orig/crypt/Versions 2000-03-04 00:47:30 +0000
|
||||||
|
+++ glibc-2.3.6/crypt/Versions 2004-02-27 00:25:15 +0000
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
libcrypt {
|
||||||
|
GLIBC_2.0 {
|
||||||
|
crypt; crypt_r; encrypt; encrypt_r; fcrypt; setkey; setkey_r;
|
||||||
|
+ crypt_rn; crypt_ra; crypt_gensalt; crypt_gensalt_rn; crypt_gensalt_ra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--- glibc-2.3.6.orig/crypt/crypt-entry.c 2001-07-06 05:18:49 +0000
|
||||||
|
+++ glibc-2.3.6/crypt/crypt-entry.c 2004-02-27 00:12:32 +0000
|
||||||
|
@@ -70,7 +70,7 @@ extern struct crypt_data _ufc_foobar;
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *
|
||||||
|
-__crypt_r (key, salt, data)
|
||||||
|
+__des_crypt_r (key, salt, data)
|
||||||
|
const char *key;
|
||||||
|
const char *salt;
|
||||||
|
struct crypt_data * __restrict data;
|
||||||
|
@@ -115,6 +115,7 @@ __crypt_r (key, salt, data)
|
||||||
|
_ufc_output_conversion_r (res[0], res[1], salt, data);
|
||||||
|
return data->crypt_3_buf;
|
||||||
|
}
|
||||||
|
+#if 0
|
||||||
|
weak_alias (__crypt_r, crypt_r)
|
||||||
|
|
||||||
|
char *
|
||||||
|
@@ -147,3 +148,4 @@ __fcrypt (key, salt)
|
||||||
|
return crypt (key, salt);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
+#endif
|
43
deps/crypt_blowfish/ow-crypt.h
vendored
Normal file
43
deps/crypt_blowfish/ow-crypt.h
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2011.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2011 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _OW_CRYPT_H
|
||||||
|
#define _OW_CRYPT_H
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
#undef __const
|
||||||
|
#define __const const
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SKIP_GNU
|
||||||
|
extern char *crypt(__const char *key, __const char *setting);
|
||||||
|
extern char *crypt_r(__const char *key, __const char *setting, void *data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SKIP_OW
|
||||||
|
extern char *crypt_rn(__const char *key, __const char *setting,
|
||||||
|
void *data, int size);
|
||||||
|
extern char *crypt_ra(__const char *key, __const char *setting,
|
||||||
|
void **data, int *size);
|
||||||
|
extern char *crypt_gensalt(__const char *prefix, unsigned long count,
|
||||||
|
__const char *input, int size);
|
||||||
|
extern char *crypt_gensalt_rn(__const char *prefix, unsigned long count,
|
||||||
|
__const char *input, int size, char *output, int output_size);
|
||||||
|
extern char *crypt_gensalt_ra(__const char *prefix, unsigned long count,
|
||||||
|
__const char *input, int size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
551
deps/crypt_blowfish/wrapper.c
vendored
Normal file
551
deps/crypt_blowfish/wrapper.c
vendored
Normal file
@ -0,0 +1,551 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 2000-2014.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 2000-2014 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef __set_errno
|
||||||
|
#define __set_errno(val) errno = (val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
#ifdef TEST_THREADS
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CRYPT_OUTPUT_SIZE (7 + 22 + 31 + 1)
|
||||||
|
#define CRYPT_GENSALT_OUTPUT_SIZE (7 + 22 + 1)
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && defined(_LIBC)
|
||||||
|
#define __SKIP_GNU
|
||||||
|
#endif
|
||||||
|
#include "ow-crypt.h"
|
||||||
|
|
||||||
|
#include "crypt_blowfish.h"
|
||||||
|
#include "crypt_gensalt.h"
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && defined(_LIBC)
|
||||||
|
/* crypt.h from glibc-crypt-2.1 will define struct crypt_data for us */
|
||||||
|
#include "crypt.h"
|
||||||
|
extern char *__md5_crypt_r(const char *key, const char *salt,
|
||||||
|
char *buffer, int buflen);
|
||||||
|
/* crypt-entry.c needs to be patched to define __des_crypt_r rather than
|
||||||
|
* __crypt_r, and not define crypt_r and crypt at all */
|
||||||
|
extern char *__des_crypt_r(const char *key, const char *salt,
|
||||||
|
struct crypt_data *data);
|
||||||
|
extern struct crypt_data _ufc_foobar;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int _crypt_data_alloc(void **data, int *size, int need)
|
||||||
|
{
|
||||||
|
void *updated;
|
||||||
|
|
||||||
|
if (*data && *size >= need) return 0;
|
||||||
|
|
||||||
|
updated = realloc(*data, need);
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
#ifndef __GLIBC__
|
||||||
|
/* realloc(3) on glibc sets errno, so we don't need to bother */
|
||||||
|
__set_errno(ENOMEM);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && defined(_LIBC)
|
||||||
|
if (need >= sizeof(struct crypt_data))
|
||||||
|
((struct crypt_data *)updated)->initialized = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
*data = updated;
|
||||||
|
*size = need;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *_crypt_retval_magic(char *retval, const char *setting,
|
||||||
|
char *output, int size)
|
||||||
|
{
|
||||||
|
if (retval)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
if (_crypt_output_magic(setting, output, size))
|
||||||
|
return NULL; /* shouldn't happen */
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && defined(_LIBC)
|
||||||
|
/*
|
||||||
|
* Applications may re-use the same instance of struct crypt_data without
|
||||||
|
* resetting the initialized field in order to let crypt_r() skip some of
|
||||||
|
* its initialization code. Thus, it is important that our multiple hashing
|
||||||
|
* algorithms either don't conflict with each other in their use of the
|
||||||
|
* data area or reset the initialized field themselves whenever required.
|
||||||
|
* Currently, the hashing algorithms simply have no conflicts: the first
|
||||||
|
* field of struct crypt_data is the 128-byte large DES key schedule which
|
||||||
|
* __des_crypt_r() calculates each time it is called while the two other
|
||||||
|
* hashing algorithms use less than 128 bytes of the data area.
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *__crypt_rn(__const char *key, __const char *setting,
|
||||||
|
void *data, int size)
|
||||||
|
{
|
||||||
|
if (setting[0] == '$' && setting[1] == '2')
|
||||||
|
return _crypt_blowfish_rn(key, setting, (char *)data, size);
|
||||||
|
if (setting[0] == '$' && setting[1] == '1')
|
||||||
|
return __md5_crypt_r(key, setting, (char *)data, size);
|
||||||
|
if (setting[0] == '$' || setting[0] == '_') {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (size >= sizeof(struct crypt_data))
|
||||||
|
return __des_crypt_r(key, setting, (struct crypt_data *)data);
|
||||||
|
__set_errno(ERANGE);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__crypt_ra(__const char *key, __const char *setting,
|
||||||
|
void **data, int *size)
|
||||||
|
{
|
||||||
|
if (setting[0] == '$' && setting[1] == '2') {
|
||||||
|
if (_crypt_data_alloc(data, size, CRYPT_OUTPUT_SIZE))
|
||||||
|
return NULL;
|
||||||
|
return _crypt_blowfish_rn(key, setting, (char *)*data, *size);
|
||||||
|
}
|
||||||
|
if (setting[0] == '$' && setting[1] == '1') {
|
||||||
|
if (_crypt_data_alloc(data, size, CRYPT_OUTPUT_SIZE))
|
||||||
|
return NULL;
|
||||||
|
return __md5_crypt_r(key, setting, (char *)*data, *size);
|
||||||
|
}
|
||||||
|
if (setting[0] == '$' || setting[0] == '_') {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (_crypt_data_alloc(data, size, sizeof(struct crypt_data)))
|
||||||
|
return NULL;
|
||||||
|
return __des_crypt_r(key, setting, (struct crypt_data *)*data);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__crypt_r(__const char *key, __const char *setting,
|
||||||
|
struct crypt_data *data)
|
||||||
|
{
|
||||||
|
return _crypt_retval_magic(
|
||||||
|
__crypt_rn(key, setting, data, sizeof(*data)),
|
||||||
|
setting, (char *)data, sizeof(*data));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__crypt(__const char *key, __const char *setting)
|
||||||
|
{
|
||||||
|
return _crypt_retval_magic(
|
||||||
|
__crypt_rn(key, setting, &_ufc_foobar, sizeof(_ufc_foobar)),
|
||||||
|
setting, (char *)&_ufc_foobar, sizeof(_ufc_foobar));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
char *crypt_rn(const char *key, const char *setting, void *data, int size)
|
||||||
|
{
|
||||||
|
return _crypt_blowfish_rn(key, setting, (char *)data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *crypt_ra(const char *key, const char *setting,
|
||||||
|
void **data, int *size)
|
||||||
|
{
|
||||||
|
if (_crypt_data_alloc(data, size, CRYPT_OUTPUT_SIZE))
|
||||||
|
return NULL;
|
||||||
|
return _crypt_blowfish_rn(key, setting, (char *)*data, *size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *crypt_r(const char *key, const char *setting, void *data)
|
||||||
|
{
|
||||||
|
return _crypt_retval_magic(
|
||||||
|
crypt_rn(key, setting, data, CRYPT_OUTPUT_SIZE),
|
||||||
|
setting, (char *)data, CRYPT_OUTPUT_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *crypt(const char *key, const char *setting)
|
||||||
|
{
|
||||||
|
static char output[CRYPT_OUTPUT_SIZE];
|
||||||
|
|
||||||
|
return _crypt_retval_magic(
|
||||||
|
crypt_rn(key, setting, output, sizeof(output)),
|
||||||
|
setting, output, sizeof(output));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __crypt_gensalt_rn crypt_gensalt_rn
|
||||||
|
#define __crypt_gensalt_ra crypt_gensalt_ra
|
||||||
|
#define __crypt_gensalt crypt_gensalt
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *__crypt_gensalt_rn(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size, char *output, int output_size)
|
||||||
|
{
|
||||||
|
char *(*use)(const char *_prefix, unsigned long _count,
|
||||||
|
const char *_input, int _size,
|
||||||
|
char *_output, int _output_size);
|
||||||
|
|
||||||
|
/* This may be supported on some platforms in the future */
|
||||||
|
if (!input) {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncmp(prefix, "$2a$", 4) || !strncmp(prefix, "$2b$", 4) ||
|
||||||
|
!strncmp(prefix, "$2y$", 4))
|
||||||
|
use = _crypt_gensalt_blowfish_rn;
|
||||||
|
else
|
||||||
|
if (!strncmp(prefix, "$1$", 3))
|
||||||
|
use = _crypt_gensalt_md5_rn;
|
||||||
|
else
|
||||||
|
if (prefix[0] == '_')
|
||||||
|
use = _crypt_gensalt_extended_rn;
|
||||||
|
else
|
||||||
|
if (!prefix[0] ||
|
||||||
|
(prefix[0] && prefix[1] &&
|
||||||
|
memchr(_crypt_itoa64, prefix[0], 64) &&
|
||||||
|
memchr(_crypt_itoa64, prefix[1], 64)))
|
||||||
|
use = _crypt_gensalt_traditional_rn;
|
||||||
|
else {
|
||||||
|
__set_errno(EINVAL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return use(prefix, count, input, size, output, output_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__crypt_gensalt_ra(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size)
|
||||||
|
{
|
||||||
|
char output[CRYPT_GENSALT_OUTPUT_SIZE];
|
||||||
|
char *retval;
|
||||||
|
|
||||||
|
retval = __crypt_gensalt_rn(prefix, count,
|
||||||
|
input, size, output, sizeof(output));
|
||||||
|
|
||||||
|
if (retval) {
|
||||||
|
retval = strdup(retval);
|
||||||
|
#ifndef __GLIBC__
|
||||||
|
/* strdup(3) on glibc sets errno, so we don't need to bother */
|
||||||
|
if (!retval)
|
||||||
|
__set_errno(ENOMEM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *__crypt_gensalt(const char *prefix, unsigned long count,
|
||||||
|
const char *input, int size)
|
||||||
|
{
|
||||||
|
static char output[CRYPT_GENSALT_OUTPUT_SIZE];
|
||||||
|
|
||||||
|
return __crypt_gensalt_rn(prefix, count,
|
||||||
|
input, size, output, sizeof(output));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && defined(_LIBC)
|
||||||
|
weak_alias(__crypt_rn, crypt_rn)
|
||||||
|
weak_alias(__crypt_ra, crypt_ra)
|
||||||
|
weak_alias(__crypt_r, crypt_r)
|
||||||
|
weak_alias(__crypt, crypt)
|
||||||
|
weak_alias(__crypt_gensalt_rn, crypt_gensalt_rn)
|
||||||
|
weak_alias(__crypt_gensalt_ra, crypt_gensalt_ra)
|
||||||
|
weak_alias(__crypt_gensalt, crypt_gensalt)
|
||||||
|
weak_alias(crypt, fcrypt)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST
|
||||||
|
static const char *tests[][3] = {
|
||||||
|
{"$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW",
|
||||||
|
"U*U"},
|
||||||
|
{"$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK",
|
||||||
|
"U*U*"},
|
||||||
|
{"$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a",
|
||||||
|
"U*U*U"},
|
||||||
|
{"$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui",
|
||||||
|
"0123456789abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
"chars after 72 are ignored"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e",
|
||||||
|
"\xa3"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e",
|
||||||
|
"\xff\xff\xa3"},
|
||||||
|
{"$2y$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e",
|
||||||
|
"\xff\xff\xa3"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.nqd1wy.pTMdcvrRWxyiGL2eMz.2a85.",
|
||||||
|
"\xff\xff\xa3"},
|
||||||
|
{"$2b$05$/OK.fbVrR/bpIqNJ5ianF.CE5elHaaO4EbggVDjb8P19RukzXSM3e",
|
||||||
|
"\xff\xff\xa3"},
|
||||||
|
{"$2y$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq",
|
||||||
|
"\xa3"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq",
|
||||||
|
"\xa3"},
|
||||||
|
{"$2b$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq",
|
||||||
|
"\xa3"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.o./n25XVfn6oAPaUvHe.Csk4zRfsYPi",
|
||||||
|
"1\xa3" "345"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.o./n25XVfn6oAPaUvHe.Csk4zRfsYPi",
|
||||||
|
"\xff\xa3" "345"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.o./n25XVfn6oAPaUvHe.Csk4zRfsYPi",
|
||||||
|
"\xff\xa3" "34" "\xff\xff\xff\xa3" "345"},
|
||||||
|
{"$2y$05$/OK.fbVrR/bpIqNJ5ianF.o./n25XVfn6oAPaUvHe.Csk4zRfsYPi",
|
||||||
|
"\xff\xa3" "34" "\xff\xff\xff\xa3" "345"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.ZC1JEJ8Z4gPfpe1JOr/oyPXTWl9EFd.",
|
||||||
|
"\xff\xa3" "34" "\xff\xff\xff\xa3" "345"},
|
||||||
|
{"$2y$05$/OK.fbVrR/bpIqNJ5ianF.nRht2l/HRhr6zmCp9vYUvvsqynflf9e",
|
||||||
|
"\xff\xa3" "345"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.nRht2l/HRhr6zmCp9vYUvvsqynflf9e",
|
||||||
|
"\xff\xa3" "345"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.6IflQkJytoRVc1yuaNtHfiuq.FRlSIS",
|
||||||
|
"\xa3" "ab"},
|
||||||
|
{"$2x$05$/OK.fbVrR/bpIqNJ5ianF.6IflQkJytoRVc1yuaNtHfiuq.FRlSIS",
|
||||||
|
"\xa3" "ab"},
|
||||||
|
{"$2y$05$/OK.fbVrR/bpIqNJ5ianF.6IflQkJytoRVc1yuaNtHfiuq.FRlSIS",
|
||||||
|
"\xa3" "ab"},
|
||||||
|
{"$2x$05$6bNw2HLQYeqHYyBfLMsv/OiwqTymGIGzFsA4hOTWebfehXHNprcAS",
|
||||||
|
"\xd1\x91"},
|
||||||
|
{"$2x$05$6bNw2HLQYeqHYyBfLMsv/O9LIGgn8OMzuDoHfof8AQimSGfcSWxnS",
|
||||||
|
"\xd0\xc1\xd2\xcf\xcc\xd8"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6",
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
|
||||||
|
"chars after 72 are ignored as usual"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.R9xrDjiycxMbQE2bp.vgqlYpW5wx2yy",
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"
|
||||||
|
"\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55\xaa\x55"},
|
||||||
|
{"$2a$05$/OK.fbVrR/bpIqNJ5ianF.9tQZzcJfm3uj2NvJ/n5xkhpqLrMpWCe",
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"
|
||||||
|
"\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff\x55\xaa\xff"},
|
||||||
|
{"$2a$05$CCCCCCCCCCCCCCCCCCCCC.7uG0VCzI2bS7j6ymqJi9CdcdxiRTWNy",
|
||||||
|
""},
|
||||||
|
{"*0", "", "$2a$03$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*0", "", "$2a$32$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*0", "", "$2c$05$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*0", "", "$2z$05$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*0", "", "$2`$05$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*0", "", "$2{$05$CCCCCCCCCCCCCCCCCCCCC."},
|
||||||
|
{"*1", "", "*0"},
|
||||||
|
{NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define which tests[0]
|
||||||
|
|
||||||
|
static volatile sig_atomic_t running;
|
||||||
|
|
||||||
|
static void handle_timer(int signum)
|
||||||
|
{
|
||||||
|
(void) signum;
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *run(void *arg)
|
||||||
|
{
|
||||||
|
unsigned long count = 0;
|
||||||
|
int i = 0;
|
||||||
|
void *data = NULL;
|
||||||
|
int size = 0x12345678;
|
||||||
|
|
||||||
|
do {
|
||||||
|
const char *hash = tests[i][0];
|
||||||
|
const char *key = tests[i][1];
|
||||||
|
const char *setting = tests[i][2];
|
||||||
|
|
||||||
|
if (!tests[++i][0])
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
if (setting && strlen(hash) < 30) /* not for benchmark */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(crypt_ra(key, hash, &data, &size), hash)) {
|
||||||
|
printf("%d: FAILED (crypt_ra/%d/%lu)\n",
|
||||||
|
(int)((char *)arg - (char *)0), i, count);
|
||||||
|
free(data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
} while (running);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
return count + (char *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
struct itimerval it;
|
||||||
|
struct tms buf;
|
||||||
|
clock_t clk_tck, start_real, start_virtual, end_real, end_virtual;
|
||||||
|
unsigned long count;
|
||||||
|
void *data;
|
||||||
|
int size;
|
||||||
|
char *setting1, *setting2;
|
||||||
|
int i;
|
||||||
|
#ifdef TEST_THREADS
|
||||||
|
pthread_t t[TEST_THREADS];
|
||||||
|
void *t_retval;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
data = NULL;
|
||||||
|
size = 0x12345678;
|
||||||
|
|
||||||
|
for (i = 0; tests[i][0]; i++) {
|
||||||
|
const char *hash = tests[i][0];
|
||||||
|
const char *key = tests[i][1];
|
||||||
|
const char *setting = tests[i][2];
|
||||||
|
const char *p;
|
||||||
|
int ok = !setting || strlen(hash) >= 30;
|
||||||
|
int o_size;
|
||||||
|
char s_buf[30], o_buf[61];
|
||||||
|
if (!setting) {
|
||||||
|
memcpy(s_buf, hash, sizeof(s_buf) - 1);
|
||||||
|
s_buf[sizeof(s_buf) - 1] = 0;
|
||||||
|
setting = s_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
__set_errno(0);
|
||||||
|
p = crypt(key, setting);
|
||||||
|
if ((!ok && !errno) || strcmp(p, hash)) {
|
||||||
|
printf("FAILED (crypt/%d)\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok && strcmp(crypt(key, hash), hash)) {
|
||||||
|
printf("FAILED (crypt/%d)\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (o_size = -1; o_size <= (int)sizeof(o_buf); o_size++) {
|
||||||
|
int ok_n = ok && o_size == (int)sizeof(o_buf);
|
||||||
|
const char *x = "abc";
|
||||||
|
strcpy(o_buf, x);
|
||||||
|
if (o_size >= 3) {
|
||||||
|
x = "*0";
|
||||||
|
if (setting[0] == '*' && setting[1] == '0')
|
||||||
|
x = "*1";
|
||||||
|
}
|
||||||
|
__set_errno(0);
|
||||||
|
p = crypt_rn(key, setting, o_buf, o_size);
|
||||||
|
if ((ok_n && (!p || strcmp(p, hash))) ||
|
||||||
|
(!ok_n && (!errno || p || strcmp(o_buf, x)))) {
|
||||||
|
printf("FAILED (crypt_rn/%d)\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__set_errno(0);
|
||||||
|
p = crypt_ra(key, setting, &data, &size);
|
||||||
|
if ((ok && (!p || strcmp(p, hash))) ||
|
||||||
|
(!ok && (!errno || p || strcmp((char *)data, hash)))) {
|
||||||
|
printf("FAILED (crypt_ra/%d)\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setting1 = crypt_gensalt(which[0], 12, data, size);
|
||||||
|
if (!setting1 || strncmp(setting1, "$2a$12$", 7)) {
|
||||||
|
puts("FAILED (crypt_gensalt)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
setting2 = crypt_gensalt_ra(setting1, 12, data, size);
|
||||||
|
if (strcmp(setting1, setting2)) {
|
||||||
|
puts("FAILED (crypt_gensalt_ra/1)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*(char *)data)++;
|
||||||
|
setting1 = crypt_gensalt_ra(setting2, 12, data, size);
|
||||||
|
if (!strcmp(setting1, setting2)) {
|
||||||
|
puts("FAILED (crypt_gensalt_ra/2)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(setting1);
|
||||||
|
free(setting2);
|
||||||
|
free(data);
|
||||||
|
|
||||||
|
#if defined(_SC_CLK_TCK) || !defined(CLK_TCK)
|
||||||
|
clk_tck = sysconf(_SC_CLK_TCK);
|
||||||
|
#else
|
||||||
|
clk_tck = CLK_TCK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
running = 1;
|
||||||
|
signal(SIGALRM, handle_timer);
|
||||||
|
|
||||||
|
memset(&it, 0, sizeof(it));
|
||||||
|
it.it_value.tv_sec = 5;
|
||||||
|
setitimer(ITIMER_REAL, &it, NULL);
|
||||||
|
|
||||||
|
start_real = times(&buf);
|
||||||
|
start_virtual = buf.tms_utime + buf.tms_stime;
|
||||||
|
|
||||||
|
count = (char *)run((char *)0) - (char *)0;
|
||||||
|
|
||||||
|
end_real = times(&buf);
|
||||||
|
end_virtual = buf.tms_utime + buf.tms_stime;
|
||||||
|
if (end_virtual == start_virtual) end_virtual++;
|
||||||
|
|
||||||
|
printf("%.1f c/s real, %.1f c/s virtual\n",
|
||||||
|
(float)count * clk_tck / (end_real - start_real),
|
||||||
|
(float)count * clk_tck / (end_virtual - start_virtual));
|
||||||
|
|
||||||
|
#ifdef TEST_THREADS
|
||||||
|
running = 1;
|
||||||
|
it.it_value.tv_sec = 60;
|
||||||
|
setitimer(ITIMER_REAL, &it, NULL);
|
||||||
|
start_real = times(&buf);
|
||||||
|
|
||||||
|
for (i = 0; i < TEST_THREADS; i++)
|
||||||
|
if (pthread_create(&t[i], NULL, run, i + (char *)0)) {
|
||||||
|
perror("pthread_create");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < TEST_THREADS; i++) {
|
||||||
|
if (pthread_join(t[i], &t_retval)) {
|
||||||
|
perror("pthread_join");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!t_retval) continue;
|
||||||
|
count = (char *)t_retval - (char *)0;
|
||||||
|
end_real = times(&buf);
|
||||||
|
printf("%d: %.1f c/s real\n", i,
|
||||||
|
(float)count * clk_tck / (end_real - start_real));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
203
deps/crypt_blowfish/x86.S
vendored
Normal file
203
deps/crypt_blowfish/x86.S
vendored
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* Written by Solar Designer <solar at openwall.com> in 1998-2010.
|
||||||
|
* No copyright is claimed, and the software is hereby placed in the public
|
||||||
|
* domain. In case this attempt to disclaim copyright and place the software
|
||||||
|
* in the public domain is deemed null and void, then the software is
|
||||||
|
* Copyright (c) 1998-2010 Solar Designer and it is hereby released to the
|
||||||
|
* general public under the following terms:
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted.
|
||||||
|
*
|
||||||
|
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||||
|
*
|
||||||
|
* See crypt_blowfish.c for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __i386__
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__) && !defined(__ELF__)
|
||||||
|
#define UNDERSCORES
|
||||||
|
#define ALIGN_LOG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||||
|
#define UNDERSCORES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __DJGPP__
|
||||||
|
#define UNDERSCORES
|
||||||
|
#define ALIGN_LOG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef UNDERSCORES
|
||||||
|
#define _BF_body_r __BF_body_r
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ALIGN_LOG
|
||||||
|
#define DO_ALIGN(log) .align (log)
|
||||||
|
#elif defined(DUMBAS)
|
||||||
|
#define DO_ALIGN(log) .align 1 << log
|
||||||
|
#else
|
||||||
|
#define DO_ALIGN(log) .align (1 << (log))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BF_FRAME 0x200
|
||||||
|
#define ctx %esp
|
||||||
|
|
||||||
|
#define BF_ptr (ctx)
|
||||||
|
|
||||||
|
#define S(N, r) N+BF_FRAME(ctx,r,4)
|
||||||
|
#ifdef DUMBAS
|
||||||
|
#define P(N) 0x1000+N+N+N+N+BF_FRAME(ctx)
|
||||||
|
#else
|
||||||
|
#define P(N) 0x1000+4*N+BF_FRAME(ctx)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This version of the assembly code is optimized primarily for the original
|
||||||
|
* Intel Pentium but is also careful to avoid partial register stalls on the
|
||||||
|
* Pentium Pro family of processors (tested up to Pentium III Coppermine).
|
||||||
|
*
|
||||||
|
* It is possible to do 15% faster on the Pentium Pro family and probably on
|
||||||
|
* many non-Intel x86 processors, but, unfortunately, that would make things
|
||||||
|
* twice slower for the original Pentium.
|
||||||
|
*
|
||||||
|
* An additional 2% speedup may be achieved with non-reentrant code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define L %esi
|
||||||
|
#define R %edi
|
||||||
|
#define tmp1 %eax
|
||||||
|
#define tmp1_lo %al
|
||||||
|
#define tmp2 %ecx
|
||||||
|
#define tmp2_hi %ch
|
||||||
|
#define tmp3 %edx
|
||||||
|
#define tmp3_lo %dl
|
||||||
|
#define tmp4 %ebx
|
||||||
|
#define tmp4_hi %bh
|
||||||
|
#define tmp5 %ebp
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
||||||
|
#define BF_ROUND(L, R, N) \
|
||||||
|
xorl L,tmp2; \
|
||||||
|
xorl tmp1,tmp1; \
|
||||||
|
movl tmp2,L; \
|
||||||
|
shrl $16,tmp2; \
|
||||||
|
movl L,tmp4; \
|
||||||
|
movb tmp2_hi,tmp1_lo; \
|
||||||
|
andl $0xFF,tmp2; \
|
||||||
|
movb tmp4_hi,tmp3_lo; \
|
||||||
|
andl $0xFF,tmp4; \
|
||||||
|
movl S(0,tmp1),tmp1; \
|
||||||
|
movl S(0x400,tmp2),tmp5; \
|
||||||
|
addl tmp5,tmp1; \
|
||||||
|
movl S(0x800,tmp3),tmp5; \
|
||||||
|
xorl tmp5,tmp1; \
|
||||||
|
movl S(0xC00,tmp4),tmp5; \
|
||||||
|
addl tmp1,tmp5; \
|
||||||
|
movl 4+P(N),tmp2; \
|
||||||
|
xorl tmp5,R
|
||||||
|
|
||||||
|
#define BF_ENCRYPT_START \
|
||||||
|
BF_ROUND(L, R, 0); \
|
||||||
|
BF_ROUND(R, L, 1); \
|
||||||
|
BF_ROUND(L, R, 2); \
|
||||||
|
BF_ROUND(R, L, 3); \
|
||||||
|
BF_ROUND(L, R, 4); \
|
||||||
|
BF_ROUND(R, L, 5); \
|
||||||
|
BF_ROUND(L, R, 6); \
|
||||||
|
BF_ROUND(R, L, 7); \
|
||||||
|
BF_ROUND(L, R, 8); \
|
||||||
|
BF_ROUND(R, L, 9); \
|
||||||
|
BF_ROUND(L, R, 10); \
|
||||||
|
BF_ROUND(R, L, 11); \
|
||||||
|
BF_ROUND(L, R, 12); \
|
||||||
|
BF_ROUND(R, L, 13); \
|
||||||
|
BF_ROUND(L, R, 14); \
|
||||||
|
BF_ROUND(R, L, 15); \
|
||||||
|
movl BF_ptr,tmp5; \
|
||||||
|
xorl L,tmp2; \
|
||||||
|
movl P(17),L
|
||||||
|
|
||||||
|
#define BF_ENCRYPT_END \
|
||||||
|
xorl R,L; \
|
||||||
|
movl tmp2,R
|
||||||
|
|
||||||
|
DO_ALIGN(5)
|
||||||
|
.globl _BF_body_r
|
||||||
|
_BF_body_r:
|
||||||
|
movl 4(%esp),%eax
|
||||||
|
pushl %ebp
|
||||||
|
pushl %ebx
|
||||||
|
pushl %esi
|
||||||
|
pushl %edi
|
||||||
|
subl $BF_FRAME-8,%eax
|
||||||
|
xorl L,L
|
||||||
|
cmpl %esp,%eax
|
||||||
|
ja BF_die
|
||||||
|
xchgl %eax,%esp
|
||||||
|
xorl R,R
|
||||||
|
pushl %eax
|
||||||
|
leal 0x1000+BF_FRAME-4(ctx),%eax
|
||||||
|
movl 0x1000+BF_FRAME-4(ctx),tmp2
|
||||||
|
pushl %eax
|
||||||
|
xorl tmp3,tmp3
|
||||||
|
BF_loop_P:
|
||||||
|
BF_ENCRYPT_START
|
||||||
|
addl $8,tmp5
|
||||||
|
BF_ENCRYPT_END
|
||||||
|
leal 0x1000+18*4+BF_FRAME(ctx),tmp1
|
||||||
|
movl tmp5,BF_ptr
|
||||||
|
cmpl tmp5,tmp1
|
||||||
|
movl L,-8(tmp5)
|
||||||
|
movl R,-4(tmp5)
|
||||||
|
movl P(0),tmp2
|
||||||
|
ja BF_loop_P
|
||||||
|
leal BF_FRAME(ctx),tmp5
|
||||||
|
xorl tmp3,tmp3
|
||||||
|
movl tmp5,BF_ptr
|
||||||
|
BF_loop_S:
|
||||||
|
BF_ENCRYPT_START
|
||||||
|
BF_ENCRYPT_END
|
||||||
|
movl P(0),tmp2
|
||||||
|
movl L,(tmp5)
|
||||||
|
movl R,4(tmp5)
|
||||||
|
BF_ENCRYPT_START
|
||||||
|
BF_ENCRYPT_END
|
||||||
|
movl P(0),tmp2
|
||||||
|
movl L,8(tmp5)
|
||||||
|
movl R,12(tmp5)
|
||||||
|
BF_ENCRYPT_START
|
||||||
|
BF_ENCRYPT_END
|
||||||
|
movl P(0),tmp2
|
||||||
|
movl L,16(tmp5)
|
||||||
|
movl R,20(tmp5)
|
||||||
|
BF_ENCRYPT_START
|
||||||
|
addl $32,tmp5
|
||||||
|
BF_ENCRYPT_END
|
||||||
|
leal 0x1000+BF_FRAME(ctx),tmp1
|
||||||
|
movl tmp5,BF_ptr
|
||||||
|
cmpl tmp5,tmp1
|
||||||
|
movl P(0),tmp2
|
||||||
|
movl L,-8(tmp5)
|
||||||
|
movl R,-4(tmp5)
|
||||||
|
ja BF_loop_S
|
||||||
|
movl 4(%esp),%esp
|
||||||
|
popl %edi
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
popl %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
BF_die:
|
||||||
|
/* Oops, need to re-compile with a larger BF_FRAME. */
|
||||||
|
hlt
|
||||||
|
jmp BF_die
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ELF__) && defined(__linux__)
|
||||||
|
.section .note.GNU-stack,"",@progbits
|
||||||
|
#endif
|
1
deps/libbacktrace
vendored
1
deps/libbacktrace
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 7ead8c1ea2f4aeafe9c5b9ef8a9461a9ba781aa8
|
|
5
deps/libbacktrace/.gitignore
vendored
Normal file
5
deps/libbacktrace/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*~
|
||||||
|
*.o
|
||||||
|
*.lo
|
||||||
|
*.a
|
||||||
|
*.la
|
9286
deps/libbacktrace/Isaac.Newton-Opticks.txt
vendored
Normal file
9286
deps/libbacktrace/Isaac.Newton-Opticks.txt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
29
deps/libbacktrace/LICENSE
vendored
Normal file
29
deps/libbacktrace/LICENSE
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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) 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.
|
623
deps/libbacktrace/Makefile.am
vendored
Normal file
623
deps/libbacktrace/Makefile.am
vendored
Normal file
@ -0,0 +1,623 @@
|
|||||||
|
# Makefile.am -- Backtrace Makefile.
|
||||||
|
# Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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) 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.
|
||||||
|
|
||||||
|
ACLOCAL_AMFLAGS = -I config
|
||||||
|
|
||||||
|
AM_CPPFLAGS =
|
||||||
|
|
||||||
|
AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
|
||||||
|
|
||||||
|
include_HEADERS = backtrace.h backtrace-supported.h
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libbacktrace.la
|
||||||
|
|
||||||
|
libbacktrace_la_SOURCES = \
|
||||||
|
backtrace.h \
|
||||||
|
atomic.c \
|
||||||
|
dwarf.c \
|
||||||
|
fileline.c \
|
||||||
|
internal.h \
|
||||||
|
posix.c \
|
||||||
|
print.c \
|
||||||
|
sort.c \
|
||||||
|
state.c
|
||||||
|
|
||||||
|
BACKTRACE_FILES = \
|
||||||
|
backtrace.c \
|
||||||
|
simple.c \
|
||||||
|
nounwind.c
|
||||||
|
|
||||||
|
FORMAT_FILES = \
|
||||||
|
elf.c \
|
||||||
|
macho.c \
|
||||||
|
pecoff.c \
|
||||||
|
unknown.c \
|
||||||
|
xcoff.c
|
||||||
|
|
||||||
|
VIEW_FILES = \
|
||||||
|
read.c \
|
||||||
|
mmapio.c
|
||||||
|
|
||||||
|
ALLOC_FILES = \
|
||||||
|
alloc.c \
|
||||||
|
mmap.c
|
||||||
|
|
||||||
|
EXTRA_libbacktrace_la_SOURCES = \
|
||||||
|
$(BACKTRACE_FILES) \
|
||||||
|
$(FORMAT_FILES) \
|
||||||
|
$(VIEW_FILES) \
|
||||||
|
$(ALLOC_FILES)
|
||||||
|
|
||||||
|
libbacktrace_la_LIBADD = \
|
||||||
|
$(BACKTRACE_FILE) \
|
||||||
|
$(FORMAT_FILE) \
|
||||||
|
$(VIEW_FILE) \
|
||||||
|
$(ALLOC_FILE)
|
||||||
|
|
||||||
|
libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
|
||||||
|
|
||||||
|
# Testsuite.
|
||||||
|
|
||||||
|
# Add a test to this variable if you want it to be built as a program,
|
||||||
|
# with SOURCES, etc.
|
||||||
|
check_PROGRAMS =
|
||||||
|
|
||||||
|
# Add a test to this variable if you want it to be run.
|
||||||
|
TESTS =
|
||||||
|
|
||||||
|
# Add a test to this variable if you want it to be built as a Makefile
|
||||||
|
# target and run.
|
||||||
|
MAKETESTS =
|
||||||
|
|
||||||
|
# Add a test to this variable if you want it to be built as a program,
|
||||||
|
# with SOURCES, etc., and run.
|
||||||
|
BUILDTESTS =
|
||||||
|
|
||||||
|
# Add a file to this variable if you want it to be built for testing.
|
||||||
|
check_DATA =
|
||||||
|
|
||||||
|
# Flags to use when compiling test programs.
|
||||||
|
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
|
||||||
|
%.dSYM: %
|
||||||
|
$(DSYMUTIL) $<
|
||||||
|
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if NATIVE
|
||||||
|
check_LTLIBRARIES = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
|
||||||
|
libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
|
||||||
|
|
||||||
|
libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
|
||||||
|
|
||||||
|
check_LTLIBRARIES += libbacktrace_noformat.la
|
||||||
|
|
||||||
|
libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
|
||||||
|
libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
|
||||||
|
|
||||||
|
libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
|
||||||
|
|
||||||
|
if HAVE_ELF
|
||||||
|
if HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
|
||||||
|
|
||||||
|
check_LTLIBRARIES += libbacktrace_elf_for_test.la
|
||||||
|
|
||||||
|
libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
|
||||||
|
libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
|
||||||
|
$(VIEW_FILE) $(ALLOC_FILE)
|
||||||
|
|
||||||
|
elf_for_test.c: elf.c
|
||||||
|
SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
|
||||||
|
REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
|
||||||
|
$(SED) "s%$$SEARCH%$$REPLACE%" \
|
||||||
|
$< \
|
||||||
|
> $@.tmp
|
||||||
|
mv $@.tmp $@
|
||||||
|
|
||||||
|
endif HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
endif HAVE_ELF
|
||||||
|
|
||||||
|
elf_%.c: elf.c
|
||||||
|
SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \
|
||||||
|
REPLACE='#undef BACKTRACE_ELF_SIZE\
|
||||||
|
#define BACKTRACE_ELF_SIZE'; \
|
||||||
|
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
|
||||||
|
$< \
|
||||||
|
> $@.tmp
|
||||||
|
mv $@.tmp $@
|
||||||
|
|
||||||
|
xcoff_%.c: xcoff.c
|
||||||
|
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
|
||||||
|
REPLACE='#undef BACKTRACE_XCOFF_SIZE\
|
||||||
|
#define BACKTRACE_XCOFF_SIZE'; \
|
||||||
|
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
|
||||||
|
$< \
|
||||||
|
> $@.tmp
|
||||||
|
mv $@.tmp $@
|
||||||
|
|
||||||
|
test_elf_32_SOURCES = test_format.c testlib.c
|
||||||
|
test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_elf_32
|
||||||
|
|
||||||
|
test_elf_64_SOURCES = test_format.c testlib.c
|
||||||
|
test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_elf_64
|
||||||
|
|
||||||
|
test_macho_SOURCES = test_format.c testlib.c
|
||||||
|
test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_macho_LDADD = libbacktrace_noformat.la macho.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_macho
|
||||||
|
|
||||||
|
test_xcoff_32_SOURCES = test_format.c testlib.c
|
||||||
|
test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_xcoff_32
|
||||||
|
|
||||||
|
test_xcoff_64_SOURCES = test_format.c testlib.c
|
||||||
|
test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_xcoff_64
|
||||||
|
|
||||||
|
test_pecoff_SOURCES = test_format.c testlib.c
|
||||||
|
test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_pecoff
|
||||||
|
|
||||||
|
test_unknown_SOURCES = test_format.c testlib.c
|
||||||
|
test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
|
||||||
|
|
||||||
|
BUILDTESTS += test_unknown
|
||||||
|
|
||||||
|
unittest_SOURCES = unittest.c testlib.c
|
||||||
|
unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
unittest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += unittest
|
||||||
|
|
||||||
|
unittest_alloc_SOURCES = $(unittest_SOURCES)
|
||||||
|
unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
unittest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
BUILDTESTS += unittest_alloc
|
||||||
|
|
||||||
|
check_LTLIBRARIES += libbacktrace_instrumented_alloc.la
|
||||||
|
|
||||||
|
libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
|
||||||
|
libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \
|
||||||
|
read.lo instrumented_alloc.lo
|
||||||
|
|
||||||
|
libbacktrace_instrumented_alloc_la_DEPENDENCIES = \
|
||||||
|
$(libbacktrace_instrumented_alloc_la_LIBADD)
|
||||||
|
|
||||||
|
instrumented_alloc.lo: alloc.c
|
||||||
|
|
||||||
|
allocfail_SOURCES = allocfail.c testlib.c
|
||||||
|
allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
allocfail_LDADD = libbacktrace_instrumented_alloc.la
|
||||||
|
|
||||||
|
check_PROGRAMS += allocfail
|
||||||
|
|
||||||
|
allocfail.sh: allocfail
|
||||||
|
|
||||||
|
TESTS += allocfail.sh
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += allocfail.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if HAVE_ELF
|
||||||
|
if HAVE_BUILDID
|
||||||
|
if HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
b2test_SOURCES = $(btest_SOURCES)
|
||||||
|
b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
b2test_LDFLAGS = -Wl,--build-id
|
||||||
|
b2test_LDADD = libbacktrace_elf_for_test.la
|
||||||
|
|
||||||
|
check_PROGRAMS += b2test
|
||||||
|
MAKETESTS += b2test_buildid
|
||||||
|
|
||||||
|
if HAVE_DWZ
|
||||||
|
|
||||||
|
b3test_SOURCES = $(btest_SOURCES)
|
||||||
|
b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
b3test_LDFLAGS = -Wl,--build-id
|
||||||
|
b3test_LDADD = libbacktrace_elf_for_test.la
|
||||||
|
|
||||||
|
check_PROGRAMS += b3test
|
||||||
|
MAKETESTS += b3test_dwz_buildid
|
||||||
|
|
||||||
|
endif HAVE_DWZ
|
||||||
|
|
||||||
|
endif HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
endif HAVE_BUILDID
|
||||||
|
endif HAVE_ELF
|
||||||
|
|
||||||
|
btest_SOURCES = btest.c testlib.c
|
||||||
|
btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
|
||||||
|
btest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += btest
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += btest.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if HAVE_ELF
|
||||||
|
|
||||||
|
btest_lto_SOURCES = btest.c testlib.c
|
||||||
|
btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
|
||||||
|
btest_lto_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += btest_lto
|
||||||
|
|
||||||
|
endif HAVE_ELF
|
||||||
|
|
||||||
|
btest_alloc_SOURCES = $(btest_SOURCES)
|
||||||
|
btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
btest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
BUILDTESTS += btest_alloc
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += btest_alloc.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if HAVE_DWZ
|
||||||
|
|
||||||
|
%_dwz: %
|
||||||
|
rm -f $@ $@_common.debug
|
||||||
|
cp $< $@_1
|
||||||
|
cp $< $@_2
|
||||||
|
if $(DWZ) -m $@_common.debug $@_1 $@_2; then \
|
||||||
|
rm -f $@_2; \
|
||||||
|
mv $@_1 $@; \
|
||||||
|
else \
|
||||||
|
echo "Ignoring dwz errors, assuming that test passes"; \
|
||||||
|
cp $< $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
MAKETESTS += btest_dwz
|
||||||
|
|
||||||
|
if HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
MAKETESTS += btest_dwz_gnudebuglink
|
||||||
|
|
||||||
|
endif HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
endif HAVE_DWZ
|
||||||
|
|
||||||
|
stest_SOURCES = stest.c
|
||||||
|
stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
stest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += stest
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += stest.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
stest_alloc_SOURCES = $(stest_SOURCES)
|
||||||
|
stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
stest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
BUILDTESTS += stest_alloc
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += stest_alloc.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if HAVE_ELF
|
||||||
|
|
||||||
|
ztest_SOURCES = ztest.c testlib.c
|
||||||
|
ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
||||||
|
ztest_LDADD = libbacktrace.la
|
||||||
|
ztest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
if HAVE_ZLIB
|
||||||
|
ztest_LDADD += -lz
|
||||||
|
ztest_alloc_LDADD += -lz
|
||||||
|
endif
|
||||||
|
ztest_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
|
||||||
|
BUILDTESTS += ztest
|
||||||
|
|
||||||
|
ztest_alloc_SOURCES = $(ztest_SOURCES)
|
||||||
|
ztest_alloc_CFLAGS = $(ztest_CFLAGS)
|
||||||
|
|
||||||
|
BUILDTESTS += ztest_alloc
|
||||||
|
|
||||||
|
zstdtest_SOURCES = zstdtest.c testlib.c
|
||||||
|
zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
||||||
|
zstdtest_LDADD = libbacktrace.la
|
||||||
|
zstdtest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
if HAVE_ZSTD
|
||||||
|
zstdtest_LDADD += -lzstd
|
||||||
|
zstdtest_alloc_LDADD += -lzstd
|
||||||
|
endif
|
||||||
|
zstdtest_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
zstdtest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
|
||||||
|
BUILDTESTS += zstdtest
|
||||||
|
|
||||||
|
zstdtest_alloc_SOURCES = $(zstdtest_SOURCES)
|
||||||
|
zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS)
|
||||||
|
|
||||||
|
BUILDTESTS += zstdtest_alloc
|
||||||
|
|
||||||
|
endif HAVE_ELF
|
||||||
|
|
||||||
|
edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
||||||
|
edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
edtest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += edtest
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += edtest.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
edtest_alloc_SOURCES = $(edtest_SOURCES)
|
||||||
|
edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
edtest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += edtest_alloc.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
BUILDTESTS += edtest_alloc
|
||||||
|
|
||||||
|
edtest2_build.c: gen_edtest2_build; @true
|
||||||
|
gen_edtest2_build: $(srcdir)/edtest2.c
|
||||||
|
cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
|
||||||
|
$(SHELL) $(srcdir)/move-if-change tmp-edtest2_build.c edtest2_build.c
|
||||||
|
echo timestamp > $@
|
||||||
|
|
||||||
|
if HAVE_PTHREAD
|
||||||
|
|
||||||
|
BUILDTESTS += ttest
|
||||||
|
|
||||||
|
ttest_SOURCES = ttest.c testlib.c
|
||||||
|
ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
|
||||||
|
ttest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += ttest.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
BUILDTESTS += ttest_alloc
|
||||||
|
|
||||||
|
ttest_alloc_SOURCES = $(ttest_SOURCES)
|
||||||
|
ttest_alloc_CFLAGS = $(ttest_CFLAGS)
|
||||||
|
ttest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += ttest_alloc.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
endif HAVE_PTHREAD
|
||||||
|
|
||||||
|
if HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
MAKETESTS += btest_gnudebuglink
|
||||||
|
|
||||||
|
%_gnudebuglink: %
|
||||||
|
$(OBJCOPY) --only-keep-debug $< $@.debug
|
||||||
|
$(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
|
||||||
|
|
||||||
|
endif HAVE_OBJCOPY_DEBUGLINK
|
||||||
|
|
||||||
|
%_buildid: %
|
||||||
|
./install-debuginfo-for-buildid.sh \
|
||||||
|
"$(TEST_BUILD_ID_DIR)" \
|
||||||
|
$<
|
||||||
|
$(OBJCOPY) --strip-debug $< $@
|
||||||
|
|
||||||
|
if HAVE_COMPRESSED_DEBUG
|
||||||
|
|
||||||
|
ctestg_SOURCES = btest.c testlib.c
|
||||||
|
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
|
||||||
|
ctestg_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
ctesta_SOURCES = btest.c testlib.c
|
||||||
|
ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
|
||||||
|
ctesta_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += ctestg ctesta
|
||||||
|
|
||||||
|
if HAVE_COMPRESSED_DEBUG_ZSTD
|
||||||
|
|
||||||
|
ctestzstd_SOURCES = btest.c testlib.c
|
||||||
|
ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
||||||
|
ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd
|
||||||
|
ctestzstd_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += ctestzstd
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ctestg_alloc_SOURCES = $(ctestg_SOURCES)
|
||||||
|
ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
|
||||||
|
ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
|
||||||
|
ctestg_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
ctesta_alloc_SOURCES = $(ctesta_SOURCES)
|
||||||
|
ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
|
||||||
|
ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
|
||||||
|
ctesta_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
BUILDTESTS += ctestg_alloc ctesta_alloc
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
if HAVE_DWARF5
|
||||||
|
|
||||||
|
dwarf5_SOURCES = btest.c testlib.c
|
||||||
|
dwarf5_CFLAGS = $(libbacktrace_TEST_CFLAGS) -gdwarf-5
|
||||||
|
dwarf5_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += dwarf5
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += dwarf5.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
|
||||||
|
dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
|
||||||
|
dwarf5_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
BUILDTESTS += dwarf5_alloc
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += dwarf5_alloc.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
mtest_SOURCES = mtest.c testlib.c
|
||||||
|
mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
|
||||||
|
mtest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
BUILDTESTS += mtest
|
||||||
|
|
||||||
|
if USE_DSYMUTIL
|
||||||
|
check_DATA += mtest.dSYM
|
||||||
|
endif USE_DSYMUTIL
|
||||||
|
|
||||||
|
if HAVE_MINIDEBUG
|
||||||
|
|
||||||
|
MAKETESTS += mtest_minidebug
|
||||||
|
|
||||||
|
%_minidebug: %
|
||||||
|
$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
|
||||||
|
$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
|
||||||
|
$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
|
||||||
|
$(OBJCOPY) --only-keep-debug $< $<.dbg
|
||||||
|
$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
|
||||||
|
$(OBJCOPY) --strip-all --remove-section ..comment $< $<.strip
|
||||||
|
rm -f $<.mdbg.xz
|
||||||
|
$(XZ) $<.mdbg
|
||||||
|
$(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg.xz $<.strip
|
||||||
|
mv $<.strip $@
|
||||||
|
|
||||||
|
endif HAVE_MINIDEBUG
|
||||||
|
|
||||||
|
endif NATIVE
|
||||||
|
|
||||||
|
if HAVE_ELF
|
||||||
|
|
||||||
|
xztest_SOURCES = xztest.c testlib.c
|
||||||
|
xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
||||||
|
xztest_LDADD = libbacktrace.la
|
||||||
|
|
||||||
|
xztest_alloc_SOURCES = $(xztest_SOURCES)
|
||||||
|
xztest_alloc_CFLAGS = $(xztest_CFLAGS)
|
||||||
|
xztest_alloc_LDADD = libbacktrace_alloc.la
|
||||||
|
|
||||||
|
if HAVE_LIBLZMA
|
||||||
|
xztest_LDADD += -llzma
|
||||||
|
xztest_alloc_LDADD += -llzma
|
||||||
|
endif
|
||||||
|
|
||||||
|
xztest_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
xztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
|
||||||
|
|
||||||
|
BUILDTESTS += xztest xztest_alloc
|
||||||
|
|
||||||
|
endif HAVE_ELF
|
||||||
|
|
||||||
|
check_PROGRAMS += $(BUILDTESTS)
|
||||||
|
|
||||||
|
TESTS += $(MAKETESTS) $(BUILDTESTS)
|
||||||
|
|
||||||
|
CLEANFILES = \
|
||||||
|
$(MAKETESTS) $(BUILDTESTS) *.debug elf_for_test.c edtest2_build.c \
|
||||||
|
gen_edtest2_build \
|
||||||
|
*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip
|
||||||
|
|
||||||
|
clean-local:
|
||||||
|
-rm -rf usr
|
||||||
|
|
||||||
|
# We can't use automake's automatic dependency tracking, because it
|
||||||
|
# breaks when using bootstrap-lean. Automatic dependency tracking
|
||||||
|
# with GCC bootstrap will cause some of the objects to depend on
|
||||||
|
# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When
|
||||||
|
# using bootstrap-lean, prev-gcc is removed after each stage. When
|
||||||
|
# running "make install", those header files will be gone, causing the
|
||||||
|
# library to be rebuilt at install time. That may not succeed.
|
||||||
|
|
||||||
|
# These manual dependencies do not include dependencies on unwind.h,
|
||||||
|
# even though that is part of GCC, because where to find it depends on
|
||||||
|
# whether we are being built as a host library or a target library.
|
||||||
|
|
||||||
|
alloc.lo: config.h backtrace.h internal.h
|
||||||
|
backtrace.lo: config.h backtrace.h internal.h
|
||||||
|
btest.lo: filenames.h backtrace.h backtrace-supported.h
|
||||||
|
dwarf.lo: config.h filenames.h backtrace.h internal.h
|
||||||
|
elf.lo: config.h backtrace.h internal.h
|
||||||
|
fileline.lo: config.h backtrace.h internal.h
|
||||||
|
macho.lo: config.h backtrace.h internal.h
|
||||||
|
mmap.lo: config.h backtrace.h internal.h
|
||||||
|
mmapio.lo: config.h backtrace.h internal.h
|
||||||
|
mtest.lo: backtrace.h backtrace-supported.h
|
||||||
|
nounwind.lo: config.h internal.h
|
||||||
|
pecoff.lo: config.h backtrace.h internal.h
|
||||||
|
posix.lo: config.h backtrace.h internal.h
|
||||||
|
print.lo: config.h backtrace.h internal.h
|
||||||
|
read.lo: config.h backtrace.h internal.h
|
||||||
|
simple.lo: config.h backtrace.h internal.h
|
||||||
|
sort.lo: config.h backtrace.h internal.h
|
||||||
|
stest.lo: config.h backtrace.h internal.h
|
||||||
|
state.lo: config.h backtrace.h backtrace-supported.h internal.h
|
||||||
|
unknown.lo: config.h backtrace.h internal.h
|
||||||
|
xcoff.lo: config.h backtrace.h internal.h
|
||||||
|
xztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
|
||||||
|
ztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h
|
||||||
|
|
2666
deps/libbacktrace/Makefile.in
vendored
Normal file
2666
deps/libbacktrace/Makefile.in
vendored
Normal file
File diff suppressed because it is too large
Load Diff
36
deps/libbacktrace/README.md
vendored
Normal file
36
deps/libbacktrace/README.md
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# libbacktrace
|
||||||
|
A C library that may be linked into a C/C++ program to produce symbolic backtraces
|
||||||
|
|
||||||
|
Initially written by Ian Lance Taylor <iant@golang.org>.
|
||||||
|
|
||||||
|
This is version 1.0.
|
||||||
|
It is likely that this will always be version 1.0.
|
||||||
|
|
||||||
|
The libbacktrace library may be linked into a program or library and
|
||||||
|
used to produce symbolic backtraces.
|
||||||
|
Sample uses would be to print a detailed backtrace when an error
|
||||||
|
occurs or to gather detailed profiling information.
|
||||||
|
In general the functions provided by this library are async-signal-safe,
|
||||||
|
meaning that they may be safely called from a signal handler.
|
||||||
|
|
||||||
|
The libbacktrace library is provided under a BSD license.
|
||||||
|
See the source files for the exact license text.
|
||||||
|
|
||||||
|
The public functions are declared and documented in the header file
|
||||||
|
backtrace.h, which should be #include'd by a user of the library.
|
||||||
|
|
||||||
|
Building libbacktrace will generate a file backtrace-supported.h,
|
||||||
|
which a user of the library may use to determine whether backtraces
|
||||||
|
will work.
|
||||||
|
See the source file backtrace-supported.h.in for the macros that it
|
||||||
|
defines.
|
||||||
|
|
||||||
|
As of October 2020, libbacktrace supports ELF, PE/COFF, Mach-O, and
|
||||||
|
XCOFF executables with DWARF debugging information.
|
||||||
|
In other words, it supports GNU/Linux, *BSD, macOS, Windows, and AIX.
|
||||||
|
The library is written to make it straightforward to add support for
|
||||||
|
other object file and debugging formats.
|
||||||
|
|
||||||
|
The library relies on the C++ unwind API defined at
|
||||||
|
https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
|
||||||
|
This API is provided by GCC and clang.
|
864
deps/libbacktrace/aclocal.m4
vendored
Normal file
864
deps/libbacktrace/aclocal.m4
vendored
Normal file
@ -0,0 +1,864 @@
|
|||||||
|
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||||
|
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||||
|
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||||
|
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
|
||||||
|
[m4_warning([this file was generated for autoconf 2.69.
|
||||||
|
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||||
|
If you have problems, you may need to regenerate the build system entirely.
|
||||||
|
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||||
|
|
||||||
|
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_AUTOMAKE_VERSION(VERSION)
|
||||||
|
# ----------------------------
|
||||||
|
# Automake X.Y traces this macro to ensure aclocal.m4 has been
|
||||||
|
# generated from the m4 files accompanying Automake X.Y.
|
||||||
|
# (This private macro should not be called outside this file.)
|
||||||
|
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||||
|
[am__api_version='1.15'
|
||||||
|
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||||
|
dnl require some minimum version. Point them to the right macro.
|
||||||
|
m4_if([$1], [1.15.1], [],
|
||||||
|
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# _AM_AUTOCONF_VERSION(VERSION)
|
||||||
|
# -----------------------------
|
||||||
|
# aclocal traces this macro to find the Autoconf version.
|
||||||
|
# This is a private macro too. Using m4_define simplifies
|
||||||
|
# the logic in aclocal, which can simply ignore this definition.
|
||||||
|
m4_define([_AM_AUTOCONF_VERSION], [])
|
||||||
|
|
||||||
|
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||||
|
# -------------------------------
|
||||||
|
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||||
|
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||||
|
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||||
|
[AM_AUTOMAKE_VERSION([1.15.1])dnl
|
||||||
|
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||||
|
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||||
|
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||||
|
|
||||||
|
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
|
||||||
|
# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
|
||||||
|
# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
|
||||||
|
#
|
||||||
|
# Of course, Automake must honor this variable whenever it calls a
|
||||||
|
# tool from the auxiliary directory. The problem is that $srcdir (and
|
||||||
|
# therefore $ac_aux_dir as well) can be either absolute or relative,
|
||||||
|
# depending on how configure is run. This is pretty annoying, since
|
||||||
|
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
|
||||||
|
# source directory, any form will work fine, but in subdirectories a
|
||||||
|
# relative path needs to be adjusted first.
|
||||||
|
#
|
||||||
|
# $ac_aux_dir/missing
|
||||||
|
# fails when called from a subdirectory if $ac_aux_dir is relative
|
||||||
|
# $top_srcdir/$ac_aux_dir/missing
|
||||||
|
# fails if $ac_aux_dir is absolute,
|
||||||
|
# fails when called from a subdirectory in a VPATH build with
|
||||||
|
# a relative $ac_aux_dir
|
||||||
|
#
|
||||||
|
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
|
||||||
|
# are both prefixed by $srcdir. In an in-source build this is usually
|
||||||
|
# harmless because $srcdir is '.', but things will broke when you
|
||||||
|
# start a VPATH build or use an absolute $srcdir.
|
||||||
|
#
|
||||||
|
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
|
||||||
|
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
|
||||||
|
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
|
||||||
|
# and then we would define $MISSING as
|
||||||
|
# MISSING="\${SHELL} $am_aux_dir/missing"
|
||||||
|
# This will work as long as MISSING is not called from configure, because
|
||||||
|
# unfortunately $(top_srcdir) has no meaning in configure.
|
||||||
|
# However there are other variables, like CC, which are often used in
|
||||||
|
# configure, and could therefore not use this "fixed" $ac_aux_dir.
|
||||||
|
#
|
||||||
|
# Another solution, used here, is to always expand $ac_aux_dir to an
|
||||||
|
# absolute PATH. The drawback is that using absolute paths prevent a
|
||||||
|
# configured tree to be moved without reconfiguration.
|
||||||
|
|
||||||
|
AC_DEFUN([AM_AUX_DIR_EXPAND],
|
||||||
|
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
|
||||||
|
# Expand $ac_aux_dir to an absolute path.
|
||||||
|
am_aux_dir=`cd "$ac_aux_dir" && pwd`
|
||||||
|
])
|
||||||
|
|
||||||
|
# AM_CONDITIONAL -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||||
|
# -------------------------------------
|
||||||
|
# Define a conditional.
|
||||||
|
AC_DEFUN([AM_CONDITIONAL],
|
||||||
|
[AC_PREREQ([2.52])dnl
|
||||||
|
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
|
||||||
|
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
|
||||||
|
AC_SUBST([$1_TRUE])dnl
|
||||||
|
AC_SUBST([$1_FALSE])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
|
||||||
|
m4_define([_AM_COND_VALUE_$1], [$2])dnl
|
||||||
|
if $2; then
|
||||||
|
$1_TRUE=
|
||||||
|
$1_FALSE='#'
|
||||||
|
else
|
||||||
|
$1_TRUE='#'
|
||||||
|
$1_FALSE=
|
||||||
|
fi
|
||||||
|
AC_CONFIG_COMMANDS_PRE(
|
||||||
|
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
|
||||||
|
AC_MSG_ERROR([[conditional "$1" was never defined.
|
||||||
|
Usually this means the macro was only invoked conditionally.]])
|
||||||
|
fi])])
|
||||||
|
|
||||||
|
# Do all the work for Automake. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This macro actually does too much. Some checks are only needed if
|
||||||
|
# your package does certain things. But this isn't really a big deal.
|
||||||
|
|
||||||
|
dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
|
||||||
|
m4_define([AC_PROG_CC],
|
||||||
|
m4_defn([AC_PROG_CC])
|
||||||
|
[_AM_PROG_CC_C_O
|
||||||
|
])
|
||||||
|
|
||||||
|
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
|
||||||
|
# AM_INIT_AUTOMAKE([OPTIONS])
|
||||||
|
# -----------------------------------------------
|
||||||
|
# The call with PACKAGE and VERSION arguments is the old style
|
||||||
|
# call (pre autoconf-2.50), which is being phased out. PACKAGE
|
||||||
|
# and VERSION should now be passed to AC_INIT and removed from
|
||||||
|
# the call to AM_INIT_AUTOMAKE.
|
||||||
|
# We support both call styles for the transition. After
|
||||||
|
# the next Automake release, Autoconf can make the AC_INIT
|
||||||
|
# arguments mandatory, and then we can depend on a new Autoconf
|
||||||
|
# release and drop the old call support.
|
||||||
|
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||||
|
[AC_PREREQ([2.65])dnl
|
||||||
|
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||||
|
dnl the ones we care about.
|
||||||
|
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||||
|
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_INSTALL])dnl
|
||||||
|
if test "`cd $srcdir && pwd`" != "`pwd`"; then
|
||||||
|
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
|
||||||
|
# is not polluted with repeated "-I."
|
||||||
|
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
|
||||||
|
# test to see if srcdir already configured
|
||||||
|
if test -f $srcdir/config.status; then
|
||||||
|
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# test whether we have cygpath
|
||||||
|
if test -z "$CYGPATH_W"; then
|
||||||
|
if (cygpath --version) >/dev/null 2>/dev/null; then
|
||||||
|
CYGPATH_W='cygpath -w'
|
||||||
|
else
|
||||||
|
CYGPATH_W=echo
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_SUBST([CYGPATH_W])
|
||||||
|
|
||||||
|
# Define the identity of the package.
|
||||||
|
dnl Distinguish between old-style and new-style calls.
|
||||||
|
m4_ifval([$2],
|
||||||
|
[AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: two- and three-arguments forms are deprecated.])
|
||||||
|
m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||||
|
AC_SUBST([PACKAGE], [$1])dnl
|
||||||
|
AC_SUBST([VERSION], [$2])],
|
||||||
|
[_AM_SET_OPTIONS([$1])dnl
|
||||||
|
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||||
|
m4_if(
|
||||||
|
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
|
||||||
|
[ok:ok],,
|
||||||
|
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||||
|
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||||
|
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
|
||||||
|
|
||||||
|
_AM_IF_OPTION([no-define],,
|
||||||
|
[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
|
||||||
|
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
|
||||||
|
|
||||||
|
# Some tools Automake needs.
|
||||||
|
AC_REQUIRE([AM_SANITY_CHECK])dnl
|
||||||
|
AC_REQUIRE([AC_ARG_PROGRAM])dnl
|
||||||
|
AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
|
||||||
|
AM_MISSING_PROG([AUTOCONF], [autoconf])
|
||||||
|
AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
|
||||||
|
AM_MISSING_PROG([AUTOHEADER], [autoheader])
|
||||||
|
AM_MISSING_PROG([MAKEINFO], [makeinfo])
|
||||||
|
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||||
|
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||||
|
# For better backward compatibility. To be removed once Automake 1.9.x
|
||||||
|
# dies out for good. For more background, see:
|
||||||
|
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
|
||||||
|
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
|
||||||
|
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
|
||||||
|
# We need awk for the "check" target (and possibly the TAP driver). The
|
||||||
|
# system "awk" is bad on some platforms.
|
||||||
|
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||||
|
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||||
|
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
|
||||||
|
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||||
|
[_AM_PROG_TAR([v7])])])
|
||||||
|
_AM_IF_OPTION([no-dependencies],,
|
||||||
|
[AC_PROVIDE_IFELSE([AC_PROG_CC],
|
||||||
|
[_AM_DEPENDENCIES([CC])],
|
||||||
|
[m4_define([AC_PROG_CC],
|
||||||
|
m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
|
||||||
|
AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
||||||
|
[_AM_DEPENDENCIES([CXX])],
|
||||||
|
[m4_define([AC_PROG_CXX],
|
||||||
|
m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
|
||||||
|
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
|
||||||
|
[_AM_DEPENDENCIES([OBJC])],
|
||||||
|
[m4_define([AC_PROG_OBJC],
|
||||||
|
m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
|
||||||
|
AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
|
||||||
|
[_AM_DEPENDENCIES([OBJCXX])],
|
||||||
|
[m4_define([AC_PROG_OBJCXX],
|
||||||
|
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
|
||||||
|
])
|
||||||
|
AC_REQUIRE([AM_SILENT_RULES])dnl
|
||||||
|
dnl The testsuite driver may need to know about EXEEXT, so add the
|
||||||
|
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
|
||||||
|
dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
|
||||||
|
AC_CONFIG_COMMANDS_PRE(dnl
|
||||||
|
[m4_provide_if([_AM_COMPILER_EXEEXT],
|
||||||
|
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
|
||||||
|
|
||||||
|
# POSIX will say in a future version that running "rm -f" with no argument
|
||||||
|
# is OK; and we want to be able to make that assumption in our Makefile
|
||||||
|
# recipes. So use an aggressive probe to check that the usage we want is
|
||||||
|
# actually supported "in the wild" to an acceptable degree.
|
||||||
|
# See automake bug#10828.
|
||||||
|
# To make any issue more visible, cause the running configure to be aborted
|
||||||
|
# by default if the 'rm' program in use doesn't match our expectations; the
|
||||||
|
# user can still override this though.
|
||||||
|
if rm -f && rm -fr && rm -rf; then : OK; else
|
||||||
|
cat >&2 <<'END'
|
||||||
|
Oops!
|
||||||
|
|
||||||
|
Your 'rm' program seems unable to run without file operands specified
|
||||||
|
on the command line, even when the '-f' option is present. This is contrary
|
||||||
|
to the behaviour of most rm programs out there, and not conforming with
|
||||||
|
the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
|
||||||
|
|
||||||
|
Please tell bug-automake@gnu.org about your system, including the value
|
||||||
|
of your $PATH and any error possibly output before this message. This
|
||||||
|
can help us improve future automake versions.
|
||||||
|
|
||||||
|
END
|
||||||
|
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
|
||||||
|
echo 'Configuration will proceed anyway, since you have set the' >&2
|
||||||
|
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
|
||||||
|
echo >&2
|
||||||
|
else
|
||||||
|
cat >&2 <<'END'
|
||||||
|
Aborting the configuration process, to ensure you take notice of the issue.
|
||||||
|
|
||||||
|
You can download and install GNU coreutils to get an 'rm' implementation
|
||||||
|
that behaves properly: <http://www.gnu.org/software/coreutils/>.
|
||||||
|
|
||||||
|
If you want to complete the configuration process using your problematic
|
||||||
|
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
|
||||||
|
to "yes", and re-run configure.
|
||||||
|
|
||||||
|
END
|
||||||
|
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
dnl The trailing newline in this macro's definition is deliberate, for
|
||||||
|
dnl backward compatibility and to allow trailing 'dnl'-style comments
|
||||||
|
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
|
||||||
|
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
|
||||||
|
dnl mangled by Autoconf and run in a shell conditional statement.
|
||||||
|
m4_define([_AC_COMPILER_EXEEXT],
|
||||||
|
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
|
||||||
|
|
||||||
|
# When config.status generates a header, we must update the stamp-h file.
|
||||||
|
# This file resides in the same directory as the config header
|
||||||
|
# that is generated. The stamp files are numbered to have different names.
|
||||||
|
|
||||||
|
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
|
||||||
|
# loop where config.status creates the headers, so we can generate
|
||||||
|
# our stamp files there.
|
||||||
|
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
|
||||||
|
[# Compute $1's index in $config_headers.
|
||||||
|
_am_arg=$1
|
||||||
|
_am_stamp_count=1
|
||||||
|
for _am_header in $config_headers :; do
|
||||||
|
case $_am_header in
|
||||||
|
$_am_arg | $_am_arg:* )
|
||||||
|
break ;;
|
||||||
|
* )
|
||||||
|
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_PROG_INSTALL_SH
|
||||||
|
# ------------------
|
||||||
|
# Define $install_sh.
|
||||||
|
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||||
|
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||||
|
if test x"${install_sh+set}" != xset; then
|
||||||
|
case $am_aux_dir in
|
||||||
|
*\ * | *\ *)
|
||||||
|
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||||
|
*)
|
||||||
|
install_sh="\${SHELL} $am_aux_dir/install-sh"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
AC_SUBST([install_sh])])
|
||||||
|
|
||||||
|
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||||
|
# From Jim Meyering
|
||||||
|
|
||||||
|
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_MAINTAINER_MODE([DEFAULT-MODE])
|
||||||
|
# ----------------------------------
|
||||||
|
# Control maintainer-specific portions of Makefiles.
|
||||||
|
# Default is to disable them, unless 'enable' is passed literally.
|
||||||
|
# For symmetry, 'disable' may be passed as well. Anyway, the user
|
||||||
|
# can override the default with the --enable/--disable switch.
|
||||||
|
AC_DEFUN([AM_MAINTAINER_MODE],
|
||||||
|
[m4_case(m4_default([$1], [disable]),
|
||||||
|
[enable], [m4_define([am_maintainer_other], [disable])],
|
||||||
|
[disable], [m4_define([am_maintainer_other], [enable])],
|
||||||
|
[m4_define([am_maintainer_other], [enable])
|
||||||
|
m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
|
||||||
|
AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||||
|
dnl maintainer-mode's default is 'disable' unless 'enable' is passed
|
||||||
|
AC_ARG_ENABLE([maintainer-mode],
|
||||||
|
[AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
|
||||||
|
am_maintainer_other[ make rules and dependencies not useful
|
||||||
|
(and sometimes confusing) to the casual installer])],
|
||||||
|
[USE_MAINTAINER_MODE=$enableval],
|
||||||
|
[USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
|
||||||
|
AC_MSG_RESULT([$USE_MAINTAINER_MODE])
|
||||||
|
AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
|
||||||
|
MAINT=$MAINTAINER_MODE_TRUE
|
||||||
|
AC_SUBST([MAINT])dnl
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||||
|
# ------------------------------
|
||||||
|
AC_DEFUN([AM_MISSING_PROG],
|
||||||
|
[AC_REQUIRE([AM_MISSING_HAS_RUN])
|
||||||
|
$1=${$1-"${am_missing_run}$2"}
|
||||||
|
AC_SUBST($1)])
|
||||||
|
|
||||||
|
# AM_MISSING_HAS_RUN
|
||||||
|
# ------------------
|
||||||
|
# Define MISSING if not defined so far and test if it is modern enough.
|
||||||
|
# If it is, set am_missing_run to use it, otherwise, to nothing.
|
||||||
|
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||||
|
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||||
|
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||||
|
if test x"${MISSING+set}" != xset; then
|
||||||
|
case $am_aux_dir in
|
||||||
|
*\ * | *\ *)
|
||||||
|
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||||
|
*)
|
||||||
|
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
# Use eval to expand $SHELL
|
||||||
|
if eval "$MISSING --is-lightweight"; then
|
||||||
|
am_missing_run="$MISSING "
|
||||||
|
else
|
||||||
|
am_missing_run=
|
||||||
|
AC_MSG_WARN(['missing' script is too old or missing])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
# Helper functions for option handling. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# _AM_MANGLE_OPTION(NAME)
|
||||||
|
# -----------------------
|
||||||
|
AC_DEFUN([_AM_MANGLE_OPTION],
|
||||||
|
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
# _AM_SET_OPTION(NAME)
|
||||||
|
# --------------------
|
||||||
|
# Set option NAME. Presently that only means defining a flag for this option.
|
||||||
|
AC_DEFUN([_AM_SET_OPTION],
|
||||||
|
[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
|
||||||
|
|
||||||
|
# _AM_SET_OPTIONS(OPTIONS)
|
||||||
|
# ------------------------
|
||||||
|
# OPTIONS is a space-separated list of Automake options.
|
||||||
|
AC_DEFUN([_AM_SET_OPTIONS],
|
||||||
|
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||||
|
|
||||||
|
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
|
||||||
|
# -------------------------------------------
|
||||||
|
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||||
|
AC_DEFUN([_AM_IF_OPTION],
|
||||||
|
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# _AM_PROG_CC_C_O
|
||||||
|
# ---------------
|
||||||
|
# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
|
||||||
|
# to automatically call this.
|
||||||
|
AC_DEFUN([_AM_PROG_CC_C_O],
|
||||||
|
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||||
|
AC_REQUIRE_AUX_FILE([compile])dnl
|
||||||
|
AC_LANG_PUSH([C])dnl
|
||||||
|
AC_CACHE_CHECK(
|
||||||
|
[whether $CC understands -c and -o together],
|
||||||
|
[am_cv_prog_cc_c_o],
|
||||||
|
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
|
||||||
|
# Make sure it works both with $CC and with simple cc.
|
||||||
|
# Following AC_PROG_CC_C_O, we do the test twice because some
|
||||||
|
# compilers refuse to overwrite an existing .o file with -o,
|
||||||
|
# though they will create one.
|
||||||
|
am_cv_prog_cc_c_o=yes
|
||||||
|
for am_i in 1 2; do
|
||||||
|
if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
|
||||||
|
&& test -f conftest2.$ac_objext; then
|
||||||
|
: OK
|
||||||
|
else
|
||||||
|
am_cv_prog_cc_c_o=no
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm -f core conftest*
|
||||||
|
unset am_i])
|
||||||
|
if test "$am_cv_prog_cc_c_o" != yes; then
|
||||||
|
# Losing compiler, so override with the script.
|
||||||
|
# FIXME: It is wrong to rewrite CC.
|
||||||
|
# But if we don't then we get into trouble of one sort or another.
|
||||||
|
# A longer-term fix would be to have automake use am__CC in this case,
|
||||||
|
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
|
||||||
|
CC="$am_aux_dir/compile $CC"
|
||||||
|
fi
|
||||||
|
AC_LANG_POP([C])])
|
||||||
|
|
||||||
|
# For backward compatibility.
|
||||||
|
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_RUN_LOG(COMMAND)
|
||||||
|
# -------------------
|
||||||
|
# Run COMMAND, save the exit status in ac_status, and log it.
|
||||||
|
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
|
||||||
|
AC_DEFUN([AM_RUN_LOG],
|
||||||
|
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
|
||||||
|
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
|
||||||
|
ac_status=$?
|
||||||
|
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
|
||||||
|
(exit $ac_status); }])
|
||||||
|
|
||||||
|
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_SANITY_CHECK
|
||||||
|
# ---------------
|
||||||
|
AC_DEFUN([AM_SANITY_CHECK],
|
||||||
|
[AC_MSG_CHECKING([whether build environment is sane])
|
||||||
|
# Reject unsafe characters in $srcdir or the absolute working directory
|
||||||
|
# name. Accept space and tab only in the latter.
|
||||||
|
am_lf='
|
||||||
|
'
|
||||||
|
case `pwd` in
|
||||||
|
*[[\\\"\#\$\&\'\`$am_lf]]*)
|
||||||
|
AC_MSG_ERROR([unsafe absolute working directory name]);;
|
||||||
|
esac
|
||||||
|
case $srcdir in
|
||||||
|
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
|
||||||
|
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Do 'set' in a subshell so we don't clobber the current shell's
|
||||||
|
# arguments. Must try -L first in case configure is actually a
|
||||||
|
# symlink; some systems play weird games with the mod time of symlinks
|
||||||
|
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||||
|
# directory).
|
||||||
|
if (
|
||||||
|
am_has_slept=no
|
||||||
|
for am_try in 1 2; do
|
||||||
|
echo "timestamp, slept: $am_has_slept" > conftest.file
|
||||||
|
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
|
||||||
|
if test "$[*]" = "X"; then
|
||||||
|
# -L didn't work.
|
||||||
|
set X `ls -t "$srcdir/configure" conftest.file`
|
||||||
|
fi
|
||||||
|
if test "$[*]" != "X $srcdir/configure conftest.file" \
|
||||||
|
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
|
||||||
|
|
||||||
|
# If neither matched, then we have a broken ls. This can happen
|
||||||
|
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||||
|
# broken ls alias from the environment. This has actually
|
||||||
|
# happened. Such a system could not be considered "sane".
|
||||||
|
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||||
|
alias in your environment])
|
||||||
|
fi
|
||||||
|
if test "$[2]" = conftest.file || test $am_try -eq 2; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
# Just in case.
|
||||||
|
sleep 1
|
||||||
|
am_has_slept=yes
|
||||||
|
done
|
||||||
|
test "$[2]" = conftest.file
|
||||||
|
)
|
||||||
|
then
|
||||||
|
# Ok.
|
||||||
|
:
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||||
|
Check your system clock])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
# If we didn't sleep, we still need to ensure time stamps of config.status and
|
||||||
|
# generated files are strictly newer.
|
||||||
|
am_sleep_pid=
|
||||||
|
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
|
||||||
|
( sleep 1 ) &
|
||||||
|
am_sleep_pid=$!
|
||||||
|
fi
|
||||||
|
AC_CONFIG_COMMANDS_PRE(
|
||||||
|
[AC_MSG_CHECKING([that generated files are newer than configure])
|
||||||
|
if test -n "$am_sleep_pid"; then
|
||||||
|
# Hide warnings about reused PIDs.
|
||||||
|
wait $am_sleep_pid 2>/dev/null
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT([done])])
|
||||||
|
rm -f conftest.file
|
||||||
|
])
|
||||||
|
|
||||||
|
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_SILENT_RULES([DEFAULT])
|
||||||
|
# --------------------------
|
||||||
|
# Enable less verbose build rules; with the default set to DEFAULT
|
||||||
|
# ("yes" being less verbose, "no" or empty being verbose).
|
||||||
|
AC_DEFUN([AM_SILENT_RULES],
|
||||||
|
[AC_ARG_ENABLE([silent-rules], [dnl
|
||||||
|
AS_HELP_STRING(
|
||||||
|
[--enable-silent-rules],
|
||||||
|
[less verbose build output (undo: "make V=1")])
|
||||||
|
AS_HELP_STRING(
|
||||||
|
[--disable-silent-rules],
|
||||||
|
[verbose build output (undo: "make V=0")])dnl
|
||||||
|
])
|
||||||
|
case $enable_silent_rules in @%:@ (((
|
||||||
|
yes) AM_DEFAULT_VERBOSITY=0;;
|
||||||
|
no) AM_DEFAULT_VERBOSITY=1;;
|
||||||
|
*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
|
||||||
|
esac
|
||||||
|
dnl
|
||||||
|
dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
|
||||||
|
dnl do not support nested variable expansions.
|
||||||
|
dnl See automake bug#9928 and bug#10237.
|
||||||
|
am_make=${MAKE-make}
|
||||||
|
AC_CACHE_CHECK([whether $am_make supports nested variables],
|
||||||
|
[am_cv_make_support_nested_variables],
|
||||||
|
[if AS_ECHO([['TRUE=$(BAR$(V))
|
||||||
|
BAR0=false
|
||||||
|
BAR1=true
|
||||||
|
V=1
|
||||||
|
am__doit:
|
||||||
|
@$(TRUE)
|
||||||
|
.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
|
||||||
|
am_cv_make_support_nested_variables=yes
|
||||||
|
else
|
||||||
|
am_cv_make_support_nested_variables=no
|
||||||
|
fi])
|
||||||
|
if test $am_cv_make_support_nested_variables = yes; then
|
||||||
|
dnl Using '$V' instead of '$(V)' breaks IRIX make.
|
||||||
|
AM_V='$(V)'
|
||||||
|
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
|
||||||
|
else
|
||||||
|
AM_V=$AM_DEFAULT_VERBOSITY
|
||||||
|
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
|
||||||
|
fi
|
||||||
|
AC_SUBST([AM_V])dnl
|
||||||
|
AM_SUBST_NOTMAKE([AM_V])dnl
|
||||||
|
AC_SUBST([AM_DEFAULT_V])dnl
|
||||||
|
AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
|
||||||
|
AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
|
||||||
|
AM_BACKSLASH='\'
|
||||||
|
AC_SUBST([AM_BACKSLASH])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_PROG_INSTALL_STRIP
|
||||||
|
# ---------------------
|
||||||
|
# One issue with vendor 'install' (even GNU) is that you can't
|
||||||
|
# specify the program used to strip binaries. This is especially
|
||||||
|
# annoying in cross-compiling environments, where the build's strip
|
||||||
|
# is unlikely to handle the host's binaries.
|
||||||
|
# Fortunately install-sh will honor a STRIPPROG variable, so we
|
||||||
|
# always use install-sh in "make install-strip", and initialize
|
||||||
|
# STRIPPROG with the value of the STRIP variable (set by the user).
|
||||||
|
AC_DEFUN([AM_PROG_INSTALL_STRIP],
|
||||||
|
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||||
|
# Installed binaries are usually stripped using 'strip' when the user
|
||||||
|
# run "make install-strip". However 'strip' might not be the right
|
||||||
|
# tool to use in cross-compilation environments, therefore Automake
|
||||||
|
# will honor the 'STRIP' environment variable to overrule this program.
|
||||||
|
dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
|
||||||
|
if test "$cross_compiling" != no; then
|
||||||
|
AC_CHECK_TOOL([STRIP], [strip], :)
|
||||||
|
fi
|
||||||
|
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||||
|
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||||
|
|
||||||
|
# Copyright (C) 2006-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# _AM_SUBST_NOTMAKE(VARIABLE)
|
||||||
|
# ---------------------------
|
||||||
|
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
|
||||||
|
# This macro is traced by Automake.
|
||||||
|
AC_DEFUN([_AM_SUBST_NOTMAKE])
|
||||||
|
|
||||||
|
# AM_SUBST_NOTMAKE(VARIABLE)
|
||||||
|
# --------------------------
|
||||||
|
# Public sister of _AM_SUBST_NOTMAKE.
|
||||||
|
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||||
|
|
||||||
|
# Check how to create a tarball. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2004-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# _AM_PROG_TAR(FORMAT)
|
||||||
|
# --------------------
|
||||||
|
# Check how to create a tarball in format FORMAT.
|
||||||
|
# FORMAT should be one of 'v7', 'ustar', or 'pax'.
|
||||||
|
#
|
||||||
|
# Substitute a variable $(am__tar) that is a command
|
||||||
|
# writing to stdout a FORMAT-tarball containing the directory
|
||||||
|
# $tardir.
|
||||||
|
# tardir=directory && $(am__tar) > result.tar
|
||||||
|
#
|
||||||
|
# Substitute a variable $(am__untar) that extract such
|
||||||
|
# a tarball read from stdin.
|
||||||
|
# $(am__untar) < result.tar
|
||||||
|
#
|
||||||
|
AC_DEFUN([_AM_PROG_TAR],
|
||||||
|
[# Always define AMTAR for backward compatibility. Yes, it's still used
|
||||||
|
# in the wild :-( We should find a proper way to deprecate it ...
|
||||||
|
AC_SUBST([AMTAR], ['$${TAR-tar}'])
|
||||||
|
|
||||||
|
# We'll loop over all known methods to create a tar archive until one works.
|
||||||
|
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
|
||||||
|
|
||||||
|
m4_if([$1], [v7],
|
||||||
|
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
|
||||||
|
|
||||||
|
[m4_case([$1],
|
||||||
|
[ustar],
|
||||||
|
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
|
||||||
|
# There is notably a 21 bits limit for the UID and the GID. In fact,
|
||||||
|
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
|
||||||
|
# and bug#13588).
|
||||||
|
am_max_uid=2097151 # 2^21 - 1
|
||||||
|
am_max_gid=$am_max_uid
|
||||||
|
# The $UID and $GID variables are not portable, so we need to resort
|
||||||
|
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
|
||||||
|
# below are definitely unexpected, so allow the users to see them
|
||||||
|
# (that is, avoid stderr redirection).
|
||||||
|
am_uid=`id -u || echo unknown`
|
||||||
|
am_gid=`id -g || echo unknown`
|
||||||
|
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
|
||||||
|
if test $am_uid -le $am_max_uid; then
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
_am_tools=none
|
||||||
|
fi
|
||||||
|
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
|
||||||
|
if test $am_gid -le $am_max_gid; then
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
_am_tools=none
|
||||||
|
fi],
|
||||||
|
|
||||||
|
[pax],
|
||||||
|
[],
|
||||||
|
|
||||||
|
[m4_fatal([Unknown tar format])])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([how to create a $1 tar archive])
|
||||||
|
|
||||||
|
# Go ahead even if we have the value already cached. We do so because we
|
||||||
|
# need to set the values for the 'am__tar' and 'am__untar' variables.
|
||||||
|
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
|
||||||
|
|
||||||
|
for _am_tool in $_am_tools; do
|
||||||
|
case $_am_tool in
|
||||||
|
gnutar)
|
||||||
|
for _am_tar in tar gnutar gtar; do
|
||||||
|
AM_RUN_LOG([$_am_tar --version]) && break
|
||||||
|
done
|
||||||
|
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
|
||||||
|
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
|
||||||
|
am__untar="$_am_tar -xf -"
|
||||||
|
;;
|
||||||
|
plaintar)
|
||||||
|
# Must skip GNU tar: if it does not support --format= it doesn't create
|
||||||
|
# ustar tarball either.
|
||||||
|
(tar --version) >/dev/null 2>&1 && continue
|
||||||
|
am__tar='tar chf - "$$tardir"'
|
||||||
|
am__tar_='tar chf - "$tardir"'
|
||||||
|
am__untar='tar xf -'
|
||||||
|
;;
|
||||||
|
pax)
|
||||||
|
am__tar='pax -L -x $1 -w "$$tardir"'
|
||||||
|
am__tar_='pax -L -x $1 -w "$tardir"'
|
||||||
|
am__untar='pax -r'
|
||||||
|
;;
|
||||||
|
cpio)
|
||||||
|
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
|
||||||
|
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
|
||||||
|
am__untar='cpio -i -H $1 -d'
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
am__tar=false
|
||||||
|
am__tar_=false
|
||||||
|
am__untar=false
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If the value was cached, stop now. We just wanted to have am__tar
|
||||||
|
# and am__untar set.
|
||||||
|
test -n "${am_cv_prog_tar_$1}" && break
|
||||||
|
|
||||||
|
# tar/untar a dummy directory, and stop if the command works.
|
||||||
|
rm -rf conftest.dir
|
||||||
|
mkdir conftest.dir
|
||||||
|
echo GrepMe > conftest.dir/file
|
||||||
|
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
|
||||||
|
rm -rf conftest.dir
|
||||||
|
if test -s conftest.tar; then
|
||||||
|
AM_RUN_LOG([$am__untar <conftest.tar])
|
||||||
|
AM_RUN_LOG([cat conftest.dir/file])
|
||||||
|
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm -rf conftest.dir
|
||||||
|
|
||||||
|
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
|
||||||
|
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
|
||||||
|
|
||||||
|
AC_SUBST([am__tar])
|
||||||
|
AC_SUBST([am__untar])
|
||||||
|
]) # _AM_PROG_TAR
|
||||||
|
|
||||||
|
m4_include([config/lead-dot.m4])
|
||||||
|
m4_include([config/libtool.m4])
|
||||||
|
m4_include([config/ltoptions.m4])
|
||||||
|
m4_include([config/ltsugar.m4])
|
||||||
|
m4_include([config/ltversion.m4])
|
||||||
|
m4_include([config/lt~obsolete.m4])
|
||||||
|
m4_include([config/multi.m4])
|
||||||
|
m4_include([config/override.m4])
|
||||||
|
m4_include([config/unwind_ipinfo.m4])
|
||||||
|
m4_include([config/warnings.m4])
|
167
deps/libbacktrace/alloc.c
vendored
Normal file
167
deps/libbacktrace/alloc.c
vendored
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/* alloc.c -- Memory allocation without mmap.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Allocation routines to use on systems that do not support anonymous
|
||||||
|
mmap. This implementation just uses malloc, which means that the
|
||||||
|
backtrace functions may not be safely invoked from a signal
|
||||||
|
handler. */
|
||||||
|
|
||||||
|
/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't
|
||||||
|
report an error. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_alloc (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
size_t size, backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
ret = malloc (size);
|
||||||
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
if (error_callback)
|
||||||
|
error_callback (data, "malloc", errno);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_free (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
void *p, size_t size ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
free (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grow VEC by SIZE bytes. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_vector_grow (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
size_t size, backtrace_error_callback error_callback,
|
||||||
|
void *data, struct backtrace_vector *vec)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if (size > vec->alc)
|
||||||
|
{
|
||||||
|
size_t alc;
|
||||||
|
void *base;
|
||||||
|
|
||||||
|
if (vec->size == 0)
|
||||||
|
alc = 32 * size;
|
||||||
|
else if (vec->size >= 4096)
|
||||||
|
alc = vec->size + 4096;
|
||||||
|
else
|
||||||
|
alc = 2 * vec->size;
|
||||||
|
|
||||||
|
if (alc < vec->size + size)
|
||||||
|
alc = vec->size + size;
|
||||||
|
|
||||||
|
base = realloc (vec->base, alc);
|
||||||
|
if (base == NULL)
|
||||||
|
{
|
||||||
|
error_callback (data, "realloc", errno);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec->base = base;
|
||||||
|
vec->alc = alc - vec->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (char *) vec->base + vec->size;
|
||||||
|
vec->size += size;
|
||||||
|
vec->alc -= size;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finish the current allocation on VEC. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_vector_finish (struct backtrace_state *state,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
/* With this allocator we call realloc in backtrace_vector_grow,
|
||||||
|
which means we can't easily reuse the memory here. So just
|
||||||
|
release it. */
|
||||||
|
if (!backtrace_vector_release (state, vec, error_callback, data))
|
||||||
|
return NULL;
|
||||||
|
ret = vec->base;
|
||||||
|
vec->base = NULL;
|
||||||
|
vec->size = 0;
|
||||||
|
vec->alc = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release any extra space allocated for VEC. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_vector_release (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
vec->alc = 0;
|
||||||
|
|
||||||
|
if (vec->size == 0)
|
||||||
|
{
|
||||||
|
/* As of C17, realloc with size 0 is marked as an obsolescent feature, use
|
||||||
|
free instead. */
|
||||||
|
free (vec->base);
|
||||||
|
vec->base = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec->base = realloc (vec->base, vec->size);
|
||||||
|
if (vec->base == NULL)
|
||||||
|
{
|
||||||
|
error_callback (data, "realloc", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
136
deps/libbacktrace/allocfail.c
vendored
Normal file
136
deps/libbacktrace/allocfail.c
vendored
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/* allocfail.c -- Test for libbacktrace library
|
||||||
|
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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 <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
extern uint64_t get_nr_allocs (void);
|
||||||
|
extern void set_fail_at_alloc (uint64_t);
|
||||||
|
extern int at_fail_alloc_p (void);
|
||||||
|
|
||||||
|
static int test1 (void) __attribute__ ((noinline, unused));
|
||||||
|
static int f2 (int) __attribute__ ((noinline));
|
||||||
|
static int f3 (int, int) __attribute__ ((noinline));
|
||||||
|
|
||||||
|
static unsigned callback_errors = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback_full (void *vdata ATTRIBUTE_UNUSED,
|
||||||
|
const char *msg ATTRIBUTE_UNUSED,
|
||||||
|
int errnum ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
if (at_fail_alloc_p ())
|
||||||
|
{
|
||||||
|
set_fail_at_alloc (0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callback_errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
callback_full (void *vdata ATTRIBUTE_UNUSED, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||||
|
const char *filename ATTRIBUTE_UNUSED,
|
||||||
|
int lineno ATTRIBUTE_UNUSED,
|
||||||
|
const char *function ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
return f2 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f2 (int f1line)
|
||||||
|
{
|
||||||
|
return f3 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f3 (int f1line ATTRIBUTE_UNUSED, int f2line ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = backtrace_full (state, 0, callback_full, error_callback_full, NULL);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: unexpected return value %d\n", i);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback_errors)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Run all the tests. */
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
uint64_t fail_at = 0;
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
fail_at = atoi (argv[1]);
|
||||||
|
set_fail_at_alloc (fail_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_full, NULL);
|
||||||
|
if (state == NULL)
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
|
||||||
|
#if BACKTRACE_SUPPORTED
|
||||||
|
test1 ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (argc == 1)
|
||||||
|
fprintf (stderr, "%llu\n", (long long unsigned) get_nr_allocs ());
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
104
deps/libbacktrace/allocfail.sh
vendored
Executable file
104
deps/libbacktrace/allocfail.sh
vendored
Executable file
@ -0,0 +1,104 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# allocfail.sh -- Test for libbacktrace library.
|
||||||
|
# Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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) 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.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ ! -f ./allocfail ]; then
|
||||||
|
# Hard failure.
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
|
|
||||||
|
allocs=$(./allocfail 2>&1)
|
||||||
|
if [ "$allocs" = "" ]; then
|
||||||
|
# Hard failure.
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This generates the following output:
|
||||||
|
# ...
|
||||||
|
# $ allocfail.sh
|
||||||
|
# allocs: 80495
|
||||||
|
# Status changed to 0 at 1
|
||||||
|
# Status changed to 1 at 3
|
||||||
|
# Status changed to 0 at 11
|
||||||
|
# Status changed to 1 at 12
|
||||||
|
# Status changed to 0 at 845
|
||||||
|
# ...
|
||||||
|
#
|
||||||
|
# We have status 0 for an allocation failure at:
|
||||||
|
# - 1 because backtrace_create_state handles failure robustly
|
||||||
|
# - 2 because the fail switches backtrace_full to !can_alloc mode.
|
||||||
|
# - 11 because failure of elf_open_debugfile_by_buildid does not generate an
|
||||||
|
# error callback beyond the one for the allocation failure itself.
|
||||||
|
|
||||||
|
echo "allocs: $allocs"
|
||||||
|
|
||||||
|
step=1
|
||||||
|
i=1
|
||||||
|
passes=0
|
||||||
|
prev_status=-1
|
||||||
|
while [ $i -le $allocs ]; do
|
||||||
|
if ./allocfail $i >/dev/null 2>&1; status=$?; then
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
if [ $status -gt 1 ]; then
|
||||||
|
echo "Unallowed fail found: $i"
|
||||||
|
# Failure.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The test-case would run too long if we would excercise all allocs.
|
||||||
|
# So, run with step 1 initially, and increase the step once we have 10
|
||||||
|
# subsequent passes, and drop back to step 1 once we encounter another
|
||||||
|
# failure. This takes ~2.6 seconds on an i7-6600U CPU @ 2.60GHz.
|
||||||
|
if [ $status -eq 0 ]; then
|
||||||
|
passes=$(($passes + 1))
|
||||||
|
if [ $passes -ge 10 ]; then
|
||||||
|
step=$((step * 10))
|
||||||
|
passes=0
|
||||||
|
fi
|
||||||
|
elif [ $status -eq 1 ]; then
|
||||||
|
passes=0
|
||||||
|
step=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $status -ne $prev_status ]; then
|
||||||
|
echo "Status changed to $status at $i"
|
||||||
|
fi
|
||||||
|
prev_status=$status
|
||||||
|
|
||||||
|
i=$(($i + $step))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Success.
|
||||||
|
exit 0
|
113
deps/libbacktrace/atomic.c
vendored
Normal file
113
deps/libbacktrace/atomic.c
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* atomic.c -- Support for atomic functions if not present.
|
||||||
|
Copyright (C) 2013-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* This file holds implementations of the atomic functions that are
|
||||||
|
used if the host compiler has the sync functions but not the atomic
|
||||||
|
functions, as is true of versions of GCC before 4.7. */
|
||||||
|
|
||||||
|
#if !defined (HAVE_ATOMIC_FUNCTIONS) && defined (HAVE_SYNC_FUNCTIONS)
|
||||||
|
|
||||||
|
/* Do an atomic load of a pointer. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_atomic_load_pointer (void *arg)
|
||||||
|
{
|
||||||
|
void **pp;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
pp = (void **) arg;
|
||||||
|
p = *pp;
|
||||||
|
while (!__sync_bool_compare_and_swap (pp, p, p))
|
||||||
|
p = *pp;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do an atomic load of an int. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_atomic_load_int (int *p)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = *p;
|
||||||
|
while (!__sync_bool_compare_and_swap (p, i, i))
|
||||||
|
i = *p;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do an atomic store of a pointer. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_atomic_store_pointer (void *arg, void *p)
|
||||||
|
{
|
||||||
|
void **pp;
|
||||||
|
void *old;
|
||||||
|
|
||||||
|
pp = (void **) arg;
|
||||||
|
old = *pp;
|
||||||
|
while (!__sync_bool_compare_and_swap (pp, old, p))
|
||||||
|
old = *pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do an atomic store of a size_t value. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_atomic_store_size_t (size_t *p, size_t v)
|
||||||
|
{
|
||||||
|
size_t old;
|
||||||
|
|
||||||
|
old = *p;
|
||||||
|
while (!__sync_bool_compare_and_swap (p, old, v))
|
||||||
|
old = *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do an atomic store of a int value. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_atomic_store_int (int *p, int v)
|
||||||
|
{
|
||||||
|
size_t old;
|
||||||
|
|
||||||
|
old = *p;
|
||||||
|
while (!__sync_bool_compare_and_swap (p, old, v))
|
||||||
|
old = *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
66
deps/libbacktrace/backtrace-supported.h.in
vendored
Normal file
66
deps/libbacktrace/backtrace-supported.h.in
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* backtrace-supported.h.in -- Whether stack backtrace is supported.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* The file backtrace-supported.h.in is used by configure to generate
|
||||||
|
the file backtrace-supported.h. The file backtrace-supported.h may
|
||||||
|
be #include'd to see whether the backtrace library will be able to
|
||||||
|
get a backtrace and produce symbolic information. */
|
||||||
|
|
||||||
|
|
||||||
|
/* BACKTRACE_SUPPORTED will be #define'd as 1 if the backtrace library
|
||||||
|
should work, 0 if it will not. Libraries may #include this to make
|
||||||
|
other arrangements. */
|
||||||
|
|
||||||
|
#define BACKTRACE_SUPPORTED @BACKTRACE_SUPPORTED@
|
||||||
|
|
||||||
|
/* BACKTRACE_USES_MALLOC will be #define'd as 1 if the backtrace
|
||||||
|
library will call malloc as it works, 0 if it will call mmap
|
||||||
|
instead. This may be used to determine whether it is safe to call
|
||||||
|
the backtrace functions from a signal handler. In general this
|
||||||
|
only applies to calls like backtrace and backtrace_pcinfo. It does
|
||||||
|
not apply to backtrace_simple, which never calls malloc. It does
|
||||||
|
not apply to backtrace_print, which always calls fprintf and
|
||||||
|
therefore malloc. */
|
||||||
|
|
||||||
|
#define BACKTRACE_USES_MALLOC @BACKTRACE_USES_MALLOC@
|
||||||
|
|
||||||
|
/* BACKTRACE_SUPPORTS_THREADS will be #define'd as 1 if the backtrace
|
||||||
|
library is configured with threading support, 0 if not. If this is
|
||||||
|
0, the threaded parameter to backtrace_create_state must be passed
|
||||||
|
as 0. */
|
||||||
|
|
||||||
|
#define BACKTRACE_SUPPORTS_THREADS @BACKTRACE_SUPPORTS_THREADS@
|
||||||
|
|
||||||
|
/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo
|
||||||
|
will work for variables. It will always work for functions. */
|
||||||
|
|
||||||
|
#define BACKTRACE_SUPPORTS_DATA @BACKTRACE_SUPPORTS_DATA@
|
129
deps/libbacktrace/backtrace.c
vendored
Normal file
129
deps/libbacktrace/backtrace.c
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/* backtrace.c -- Entry point for stack backtrace library.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "unwind.h"
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* The main backtrace_full routine. */
|
||||||
|
|
||||||
|
/* Data passed through _Unwind_Backtrace. */
|
||||||
|
|
||||||
|
struct backtrace_data
|
||||||
|
{
|
||||||
|
/* Number of frames to skip. */
|
||||||
|
int skip;
|
||||||
|
/* Library state. */
|
||||||
|
struct backtrace_state *state;
|
||||||
|
/* Callback routine. */
|
||||||
|
backtrace_full_callback callback;
|
||||||
|
/* Error callback routine. */
|
||||||
|
backtrace_error_callback error_callback;
|
||||||
|
/* Data to pass to callback routines. */
|
||||||
|
void *data;
|
||||||
|
/* Value to return from backtrace_full. */
|
||||||
|
int ret;
|
||||||
|
/* Whether there is any memory available. */
|
||||||
|
int can_alloc;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Unwind library callback routine. This is passed to
|
||||||
|
_Unwind_Backtrace. */
|
||||||
|
|
||||||
|
static _Unwind_Reason_Code
|
||||||
|
unwind (struct _Unwind_Context *context, void *vdata)
|
||||||
|
{
|
||||||
|
struct backtrace_data *bdata = (struct backtrace_data *) vdata;
|
||||||
|
uintptr_t pc;
|
||||||
|
int ip_before_insn = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_GETIPINFO
|
||||||
|
pc = _Unwind_GetIPInfo (context, &ip_before_insn);
|
||||||
|
#else
|
||||||
|
pc = _Unwind_GetIP (context);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (bdata->skip > 0)
|
||||||
|
{
|
||||||
|
--bdata->skip;
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip_before_insn)
|
||||||
|
--pc;
|
||||||
|
|
||||||
|
if (!bdata->can_alloc)
|
||||||
|
bdata->ret = bdata->callback (bdata->data, pc, NULL, 0, NULL);
|
||||||
|
else
|
||||||
|
bdata->ret = backtrace_pcinfo (bdata->state, pc, bdata->callback,
|
||||||
|
bdata->error_callback, bdata->data);
|
||||||
|
if (bdata->ret != 0)
|
||||||
|
return _URC_END_OF_STACK;
|
||||||
|
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a stack backtrace. */
|
||||||
|
|
||||||
|
int __attribute__((noinline))
|
||||||
|
backtrace_full (struct backtrace_state *state, int skip,
|
||||||
|
backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
struct backtrace_data bdata;
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
bdata.skip = skip + 1;
|
||||||
|
bdata.state = state;
|
||||||
|
bdata.callback = callback;
|
||||||
|
bdata.error_callback = error_callback;
|
||||||
|
bdata.data = data;
|
||||||
|
bdata.ret = 0;
|
||||||
|
|
||||||
|
/* If we can't allocate any memory at all, don't try to produce
|
||||||
|
file/line information. */
|
||||||
|
p = backtrace_alloc (state, 4096, NULL, NULL);
|
||||||
|
if (p == NULL)
|
||||||
|
bdata.can_alloc = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backtrace_free (state, p, 4096, NULL, NULL);
|
||||||
|
bdata.can_alloc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_Unwind_Backtrace (unwind, &bdata);
|
||||||
|
return bdata.ret;
|
||||||
|
}
|
189
deps/libbacktrace/backtrace.h
vendored
Normal file
189
deps/libbacktrace/backtrace.h
vendored
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
/* backtrace.h -- Public header file for stack backtrace library.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
#ifndef BACKTRACE_H
|
||||||
|
#define BACKTRACE_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The backtrace state. This struct is intentionally not defined in
|
||||||
|
the public interface. */
|
||||||
|
|
||||||
|
struct backtrace_state;
|
||||||
|
|
||||||
|
/* The type of the error callback argument to backtrace functions.
|
||||||
|
This function, if not NULL, will be called for certain error cases.
|
||||||
|
The DATA argument is passed to the function that calls this one.
|
||||||
|
The MSG argument is an error message. The ERRNUM argument, if
|
||||||
|
greater than 0, holds an errno value. The MSG buffer may become
|
||||||
|
invalid after this function returns.
|
||||||
|
|
||||||
|
As a special case, the ERRNUM argument will be passed as -1 if no
|
||||||
|
debug info can be found for the executable, or if the debug info
|
||||||
|
exists but has an unsupported version, but the function requires
|
||||||
|
debug info (e.g., backtrace_full, backtrace_pcinfo). The MSG in
|
||||||
|
this case will be something along the lines of "no debug info".
|
||||||
|
Similarly, ERRNUM will be passed as -1 if there is no symbol table,
|
||||||
|
but the function requires a symbol table (e.g., backtrace_syminfo).
|
||||||
|
This may be used as a signal that some other approach should be
|
||||||
|
tried. */
|
||||||
|
|
||||||
|
typedef void (*backtrace_error_callback) (void *data, const char *msg,
|
||||||
|
int errnum);
|
||||||
|
|
||||||
|
/* Create state information for the backtrace routines. This must be
|
||||||
|
called before any of the other routines, and its return value must
|
||||||
|
be passed to all of the other routines. FILENAME is the path name
|
||||||
|
of the executable file; if it is NULL the library will try
|
||||||
|
system-specific path names. If not NULL, FILENAME must point to a
|
||||||
|
permanent buffer. If THREADED is non-zero the state may be
|
||||||
|
accessed by multiple threads simultaneously, and the library will
|
||||||
|
use appropriate atomic operations. If THREADED is zero the state
|
||||||
|
may only be accessed by one thread at a time. This returns a state
|
||||||
|
pointer on success, NULL on error. If an error occurs, this will
|
||||||
|
call the ERROR_CALLBACK routine.
|
||||||
|
|
||||||
|
Calling this function allocates resources that cannot be freed.
|
||||||
|
There is no backtrace_free_state function. The state is used to
|
||||||
|
cache information that is expensive to recompute. Programs are
|
||||||
|
expected to call this function at most once and to save the return
|
||||||
|
value for all later calls to backtrace functions. */
|
||||||
|
|
||||||
|
extern struct backtrace_state *backtrace_create_state (
|
||||||
|
const char *filename, int threaded,
|
||||||
|
backtrace_error_callback error_callback, void *data);
|
||||||
|
|
||||||
|
/* The type of the callback argument to the backtrace_full function.
|
||||||
|
DATA is the argument passed to backtrace_full. PC is the program
|
||||||
|
counter. FILENAME is the name of the file containing PC, or NULL
|
||||||
|
if not available. LINENO is the line number in FILENAME containing
|
||||||
|
PC, or 0 if not available. FUNCTION is the name of the function
|
||||||
|
containing PC, or NULL if not available. This should return 0 to
|
||||||
|
continuing tracing. The FILENAME and FUNCTION buffers may become
|
||||||
|
invalid after this function returns. */
|
||||||
|
|
||||||
|
typedef int (*backtrace_full_callback) (void *data, uintptr_t pc,
|
||||||
|
const char *filename, int lineno,
|
||||||
|
const char *function);
|
||||||
|
|
||||||
|
/* Get a full stack backtrace. SKIP is the number of frames to skip;
|
||||||
|
passing 0 will start the trace with the function calling
|
||||||
|
backtrace_full. DATA is passed to the callback routine. If any
|
||||||
|
call to CALLBACK returns a non-zero value, the stack backtrace
|
||||||
|
stops, and backtrace returns that value; this may be used to limit
|
||||||
|
the number of stack frames desired. If all calls to CALLBACK
|
||||||
|
return 0, backtrace returns 0. The backtrace_full function will
|
||||||
|
make at least one call to either CALLBACK or ERROR_CALLBACK. This
|
||||||
|
function requires debug info for the executable. */
|
||||||
|
|
||||||
|
extern int backtrace_full (struct backtrace_state *state, int skip,
|
||||||
|
backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* The type of the callback argument to the backtrace_simple function.
|
||||||
|
DATA is the argument passed to simple_backtrace. PC is the program
|
||||||
|
counter. This should return 0 to continue tracing. */
|
||||||
|
|
||||||
|
typedef int (*backtrace_simple_callback) (void *data, uintptr_t pc);
|
||||||
|
|
||||||
|
/* Get a simple backtrace. SKIP is the number of frames to skip, as
|
||||||
|
in backtrace. DATA is passed to the callback routine. If any call
|
||||||
|
to CALLBACK returns a non-zero value, the stack backtrace stops,
|
||||||
|
and backtrace_simple returns that value. Otherwise
|
||||||
|
backtrace_simple returns 0. The backtrace_simple function will
|
||||||
|
make at least one call to either CALLBACK or ERROR_CALLBACK. This
|
||||||
|
function does not require any debug info for the executable. */
|
||||||
|
|
||||||
|
extern int backtrace_simple (struct backtrace_state *state, int skip,
|
||||||
|
backtrace_simple_callback callback,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Print the current backtrace in a user readable format to a FILE.
|
||||||
|
SKIP is the number of frames to skip, as in backtrace_full. Any
|
||||||
|
error messages are printed to stderr. This function requires debug
|
||||||
|
info for the executable. */
|
||||||
|
|
||||||
|
extern void backtrace_print (struct backtrace_state *state, int skip, FILE *);
|
||||||
|
|
||||||
|
/* Given PC, a program counter in the current program, call the
|
||||||
|
callback function with filename, line number, and function name
|
||||||
|
information. This will normally call the callback function exactly
|
||||||
|
once. However, if the PC happens to describe an inlined call, and
|
||||||
|
the debugging information contains the necessary information, then
|
||||||
|
this may call the callback function multiple times. This will make
|
||||||
|
at least one call to either CALLBACK or ERROR_CALLBACK. This
|
||||||
|
returns the first non-zero value returned by CALLBACK, or 0. */
|
||||||
|
|
||||||
|
extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc,
|
||||||
|
backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* The type of the callback argument to backtrace_syminfo. DATA and
|
||||||
|
PC are the arguments passed to backtrace_syminfo. SYMNAME is the
|
||||||
|
name of the symbol for the corresponding code. SYMVAL is the
|
||||||
|
value and SYMSIZE is the size of the symbol. SYMNAME will be NULL
|
||||||
|
if no error occurred but the symbol could not be found. */
|
||||||
|
|
||||||
|
typedef void (*backtrace_syminfo_callback) (void *data, uintptr_t pc,
|
||||||
|
const char *symname,
|
||||||
|
uintptr_t symval,
|
||||||
|
uintptr_t symsize);
|
||||||
|
|
||||||
|
/* Given ADDR, an address or program counter in the current program,
|
||||||
|
call the callback information with the symbol name and value
|
||||||
|
describing the function or variable in which ADDR may be found.
|
||||||
|
This will call either CALLBACK or ERROR_CALLBACK exactly once.
|
||||||
|
This returns 1 on success, 0 on failure. This function requires
|
||||||
|
the symbol table but does not require the debug info. Note that if
|
||||||
|
the symbol table is present but ADDR could not be found in the
|
||||||
|
table, CALLBACK will be called with a NULL SYMNAME argument.
|
||||||
|
Returns 1 on success, 0 on error. */
|
||||||
|
|
||||||
|
extern int backtrace_syminfo (struct backtrace_state *state, uintptr_t addr,
|
||||||
|
backtrace_syminfo_callback callback,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* End extern "C". */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
501
deps/libbacktrace/btest.c
vendored
Normal file
501
deps/libbacktrace/btest.c
vendored
Normal file
@ -0,0 +1,501 @@
|
|||||||
|
/* btest.c -- Test for libbacktrace library
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* This program tests the externally visible interfaces of the
|
||||||
|
libbacktrace library. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
/* Test the backtrace function with non-inlined functions. */
|
||||||
|
|
||||||
|
static int test1 (void) __attribute__ ((noinline, noclone, unused));
|
||||||
|
static int f2 (int) __attribute__ ((noinline, noclone));
|
||||||
|
static int f3 (int, int) __attribute__ ((noinline, noclone));
|
||||||
|
|
||||||
|
static int
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
/* Returning a value here and elsewhere avoids a tailcall which
|
||||||
|
would mess up the backtrace. */
|
||||||
|
return f2 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f2 (int f1line)
|
||||||
|
{
|
||||||
|
return f3 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f3 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.all = &all[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_full (state, 0, callback_one, error_callback_one, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index < 3)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test1: not enough frames; got %zu, expected at least 3\n",
|
||||||
|
data.index);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test1", 0, all, f3line, "f3", "btest.c", &data.failed);
|
||||||
|
check ("test1", 1, all, f2line, "f2", "btest.c", &data.failed);
|
||||||
|
check ("test1", 2, all, f1line, "test1", "btest.c", &data.failed);
|
||||||
|
|
||||||
|
printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the backtrace function with inlined functions. */
|
||||||
|
|
||||||
|
static inline int test2 (void) __attribute__ ((always_inline, unused));
|
||||||
|
static inline int f12 (int) __attribute__ ((always_inline));
|
||||||
|
static inline int f13 (int, int) __attribute__ ((always_inline));
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
test2 (void)
|
||||||
|
{
|
||||||
|
return f12 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
f12 (int f1line)
|
||||||
|
{
|
||||||
|
return f13 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
f13 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.all = &all[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_full (state, 0, callback_one, error_callback_one, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test2: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test2", 0, all, f3line, "f13", "btest.c", &data.failed);
|
||||||
|
check ("test2", 1, all, f2line, "f12", "btest.c", &data.failed);
|
||||||
|
check ("test2", 2, all, f1line, "test2", "btest.c", &data.failed);
|
||||||
|
|
||||||
|
printf ("%s: backtrace_full inline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the backtrace_simple function with non-inlined functions. */
|
||||||
|
|
||||||
|
static int test3 (void) __attribute__ ((noinline, noclone, unused));
|
||||||
|
static int f22 (int) __attribute__ ((noinline, noclone));
|
||||||
|
static int f23 (int, int) __attribute__ ((noinline, noclone));
|
||||||
|
|
||||||
|
static int
|
||||||
|
test3 (void)
|
||||||
|
{
|
||||||
|
return f22 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f22 (int f1line)
|
||||||
|
{
|
||||||
|
return f23 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f23 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
uintptr_t addrs[20];
|
||||||
|
struct sdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.addrs = &addrs[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_simple (state, 0, callback_two, error_callback_two, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test3: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.failed)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata bdata;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
bdata.all = &all[0];
|
||||||
|
bdata.index = 0;
|
||||||
|
bdata.max = 20;
|
||||||
|
bdata.failed = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
i = backtrace_pcinfo (state, addrs[j], callback_one,
|
||||||
|
error_callback_one, &bdata);
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test3: unexpected return value "
|
||||||
|
"from backtrace_pcinfo %d\n"),
|
||||||
|
i);
|
||||||
|
bdata.failed = 1;
|
||||||
|
}
|
||||||
|
if (!bdata.failed && bdata.index != (size_t) (j + 1))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("wrong number of calls from backtrace_pcinfo "
|
||||||
|
"got %u expected %d\n"),
|
||||||
|
(unsigned int) bdata.index, j + 1);
|
||||||
|
bdata.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test3", 0, all, f3line, "f23", "btest.c", &bdata.failed);
|
||||||
|
check ("test3", 1, all, f2line, "f22", "btest.c", &bdata.failed);
|
||||||
|
check ("test3", 2, all, f1line, "test3", "btest.c", &bdata.failed);
|
||||||
|
|
||||||
|
if (bdata.failed)
|
||||||
|
data.failed = 1;
|
||||||
|
|
||||||
|
for (j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
struct symdata symdata;
|
||||||
|
|
||||||
|
symdata.name = NULL;
|
||||||
|
symdata.val = 0;
|
||||||
|
symdata.size = 0;
|
||||||
|
symdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_syminfo (state, addrs[j], callback_three,
|
||||||
|
error_callback_three, &symdata);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test3: [%d]: unexpected return value "
|
||||||
|
"from backtrace_syminfo %d\n"),
|
||||||
|
j, i);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!symdata.failed)
|
||||||
|
{
|
||||||
|
const char *expected;
|
||||||
|
|
||||||
|
switch (j)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
expected = "f23";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
expected = "f22";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
expected = "test3";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symdata.name == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
/* Use strncmp, not strcmp, because GCC might create a
|
||||||
|
clone. */
|
||||||
|
else if (strncmp (symdata.name, expected, strlen (expected))
|
||||||
|
!= 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test3: [%d]: unexpected syminfo name "
|
||||||
|
"got %s expected %s\n"),
|
||||||
|
j, symdata.name, expected);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symdata.failed)
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the backtrace_simple function with inlined functions. */
|
||||||
|
|
||||||
|
static inline int test4 (void) __attribute__ ((always_inline, unused));
|
||||||
|
static inline int f32 (int) __attribute__ ((always_inline));
|
||||||
|
static inline int f33 (int, int) __attribute__ ((always_inline));
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
test4 (void)
|
||||||
|
{
|
||||||
|
return f32 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
f32 (int f1line)
|
||||||
|
{
|
||||||
|
return f33 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
f33 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
uintptr_t addrs[20];
|
||||||
|
struct sdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.addrs = &addrs[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_simple (state, 0, callback_two, error_callback_two, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test3: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.failed)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata bdata;
|
||||||
|
|
||||||
|
bdata.all = &all[0];
|
||||||
|
bdata.index = 0;
|
||||||
|
bdata.max = 20;
|
||||||
|
bdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_pcinfo (state, addrs[0], callback_one, error_callback_one,
|
||||||
|
&bdata);
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test4: unexpected return value "
|
||||||
|
"from backtrace_pcinfo %d\n"),
|
||||||
|
i);
|
||||||
|
bdata.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test4", 0, all, f3line, "f33", "btest.c", &bdata.failed);
|
||||||
|
check ("test4", 1, all, f2line, "f32", "btest.c", &bdata.failed);
|
||||||
|
check ("test4", 2, all, f1line, "test4", "btest.c", &bdata.failed);
|
||||||
|
|
||||||
|
if (bdata.failed)
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_simple inline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test5 (void) __attribute__ ((unused));
|
||||||
|
|
||||||
|
int global = 1;
|
||||||
|
|
||||||
|
static int
|
||||||
|
test5 (void)
|
||||||
|
{
|
||||||
|
struct symdata symdata;
|
||||||
|
int i;
|
||||||
|
uintptr_t addr = (uintptr_t) &global;
|
||||||
|
|
||||||
|
if (sizeof (global) > 1)
|
||||||
|
addr += 1;
|
||||||
|
|
||||||
|
symdata.name = NULL;
|
||||||
|
symdata.val = 0;
|
||||||
|
symdata.size = 0;
|
||||||
|
symdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_syminfo (state, addr, callback_three,
|
||||||
|
error_callback_three, &symdata);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected return value from backtrace_syminfo %d\n",
|
||||||
|
i);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!symdata.failed)
|
||||||
|
{
|
||||||
|
if (symdata.name == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test5: NULL syminfo name\n");
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (!(strncmp (symdata.name, "global", 6) == 0
|
||||||
|
&& (symdata.name[6] == '\0'|| symdata.name[6] == '.')))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo name got %s expected %s\n",
|
||||||
|
symdata.name, "global");
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (symdata.val != (uintptr_t) &global)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo value got %lx expected %lx\n",
|
||||||
|
(unsigned long) symdata.val,
|
||||||
|
(unsigned long) (uintptr_t) &global);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (symdata.size != sizeof (global))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo size got %lx expected %lx\n",
|
||||||
|
(unsigned long) symdata.size,
|
||||||
|
(unsigned long) sizeof (global));
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_syminfo variable\n",
|
||||||
|
symdata.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (symdata.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check that are no files left open. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_open_files (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 3; i < 10; i++)
|
||||||
|
{
|
||||||
|
if (close (i) == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"ERROR: descriptor %d still open after tests complete\n",
|
||||||
|
i);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Run all the tests. */
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
#if BACKTRACE_SUPPORTED
|
||||||
|
test1 ();
|
||||||
|
test2 ();
|
||||||
|
test3 ();
|
||||||
|
test4 ();
|
||||||
|
#if BACKTRACE_SUPPORTS_DATA
|
||||||
|
test5 ();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
check_open_files ();
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
348
deps/libbacktrace/compile
vendored
Executable file
348
deps/libbacktrace/compile
vendored
Executable file
@ -0,0 +1,348 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
|
||||||
|
scriptversion=2016-01-11.22; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
|
||||||
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# This file is maintained in Automake, please report
|
||||||
|
# bugs to <bug-automake@gnu.org> or send patches to
|
||||||
|
# <automake-patches@gnu.org>.
|
||||||
|
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
|
||||||
|
# We need space, tab and new line, in precisely that order. Quoting is
|
||||||
|
# there to prevent tools from complaining about whitespace usage.
|
||||||
|
IFS=" "" $nl"
|
||||||
|
|
||||||
|
file_conv=
|
||||||
|
|
||||||
|
# func_file_conv build_file lazy
|
||||||
|
# Convert a $build file to $host form and store it in $file
|
||||||
|
# Currently only supports Windows hosts. If the determined conversion
|
||||||
|
# type is listed in (the comma separated) LAZY, no conversion will
|
||||||
|
# take place.
|
||||||
|
func_file_conv ()
|
||||||
|
{
|
||||||
|
file=$1
|
||||||
|
case $file in
|
||||||
|
/ | /[!/]*) # absolute file, and not a UNC file
|
||||||
|
if test -z "$file_conv"; then
|
||||||
|
# lazily determine how to convert abs files
|
||||||
|
case `uname -s` in
|
||||||
|
MINGW*)
|
||||||
|
file_conv=mingw
|
||||||
|
;;
|
||||||
|
CYGWIN*)
|
||||||
|
file_conv=cygwin
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
file_conv=wine
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
case $file_conv/,$2, in
|
||||||
|
*,$file_conv,*)
|
||||||
|
;;
|
||||||
|
mingw/*)
|
||||||
|
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||||
|
;;
|
||||||
|
cygwin/*)
|
||||||
|
file=`cygpath -m "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
wine/*)
|
||||||
|
file=`winepath -w "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashL linkdir
|
||||||
|
# Make cl look for libraries in LINKDIR
|
||||||
|
func_cl_dashL ()
|
||||||
|
{
|
||||||
|
func_file_conv "$1"
|
||||||
|
if test -z "$lib_path"; then
|
||||||
|
lib_path=$file
|
||||||
|
else
|
||||||
|
lib_path="$lib_path;$file"
|
||||||
|
fi
|
||||||
|
linker_opts="$linker_opts -LIBPATH:$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashl library
|
||||||
|
# Do a library search-path lookup for cl
|
||||||
|
func_cl_dashl ()
|
||||||
|
{
|
||||||
|
lib=$1
|
||||||
|
found=no
|
||||||
|
save_IFS=$IFS
|
||||||
|
IFS=';'
|
||||||
|
for dir in $lib_path $LIB
|
||||||
|
do
|
||||||
|
IFS=$save_IFS
|
||||||
|
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.dll.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/$lib.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/lib$lib.a"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/lib$lib.a
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$save_IFS
|
||||||
|
|
||||||
|
if test "$found" != yes; then
|
||||||
|
lib=$lib.lib
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_wrapper cl arg...
|
||||||
|
# Adjust compile command to suit cl
|
||||||
|
func_cl_wrapper ()
|
||||||
|
{
|
||||||
|
# Assume a capable shell
|
||||||
|
lib_path=
|
||||||
|
shared=:
|
||||||
|
linker_opts=
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.[oO][bB][jJ])
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fo"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fe"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
-I)
|
||||||
|
eat=1
|
||||||
|
func_file_conv "$2" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-I*)
|
||||||
|
func_file_conv "${1#-I}" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashl "$2"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l*)
|
||||||
|
func_cl_dashl "${1#-l}"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-L)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashL "$2"
|
||||||
|
;;
|
||||||
|
-L*)
|
||||||
|
func_cl_dashL "${1#-L}"
|
||||||
|
;;
|
||||||
|
-static)
|
||||||
|
shared=false
|
||||||
|
;;
|
||||||
|
-Wl,*)
|
||||||
|
arg=${1#-Wl,}
|
||||||
|
save_ifs="$IFS"; IFS=','
|
||||||
|
for flag in $arg; do
|
||||||
|
IFS="$save_ifs"
|
||||||
|
linker_opts="$linker_opts $flag"
|
||||||
|
done
|
||||||
|
IFS="$save_ifs"
|
||||||
|
;;
|
||||||
|
-Xlinker)
|
||||||
|
eat=1
|
||||||
|
linker_opts="$linker_opts $2"
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||||
|
func_file_conv "$1"
|
||||||
|
set x "$@" -Tp"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||||
|
func_file_conv "$1" mingw
|
||||||
|
set x "$@" "$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if test -n "$linker_opts"; then
|
||||||
|
linker_opts="-link$linker_opts"
|
||||||
|
fi
|
||||||
|
exec "$@" $linker_opts
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
eat=
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
'')
|
||||||
|
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||||
|
exit 1;
|
||||||
|
;;
|
||||||
|
-h | --h*)
|
||||||
|
cat <<\EOF
|
||||||
|
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||||
|
|
||||||
|
Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||||
|
arguments, and rename the output as expected.
|
||||||
|
|
||||||
|
If you are trying to build a whole package this is not the
|
||||||
|
right script to run: please start by reading the file 'INSTALL'.
|
||||||
|
|
||||||
|
Report bugs to <bug-automake@gnu.org>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "compile $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||||
|
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||||
|
func_cl_wrapper "$@" # Doesn't return...
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
ofile=
|
||||||
|
cfile=
|
||||||
|
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
# So we strip '-o arg' only if arg is an object.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.obj)
|
||||||
|
ofile=$2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" -o "$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*.c)
|
||||||
|
cfile=$1
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z "$ofile" || test -z "$cfile"; then
|
||||||
|
# If no '-o' option was seen then we might have been invoked from a
|
||||||
|
# pattern rule where we don't need one. That is ok -- this is a
|
||||||
|
# normal compilation that the losing compiler can handle. If no
|
||||||
|
# '.c' file was seen then we are probably linking. That is also
|
||||||
|
# ok.
|
||||||
|
exec "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Name of file we expect compiler to create.
|
||||||
|
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||||
|
|
||||||
|
# Create the lock directory.
|
||||||
|
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||||
|
# that we are using for the .o file. Also, base the name on the expected
|
||||||
|
# object file name, since that is what matters with a parallel build.
|
||||||
|
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||||
|
while true; do
|
||||||
|
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
# FIXME: race condition here if user kills between mkdir and trap.
|
||||||
|
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||||
|
|
||||||
|
# Run the compile.
|
||||||
|
"$@"
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if test -f "$cofile"; then
|
||||||
|
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||||
|
elif test -f "${cofile}bj"; then
|
||||||
|
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmdir "$lockdir"
|
||||||
|
exit $ret
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC0"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
1700
deps/libbacktrace/config.guess
vendored
Executable file
1700
deps/libbacktrace/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
179
deps/libbacktrace/config.h.in
vendored
Normal file
179
deps/libbacktrace/config.h.in
vendored
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
|
/* ELF size: 32 or 64 */
|
||||||
|
#undef BACKTRACE_ELF_SIZE
|
||||||
|
|
||||||
|
/* XCOFF size: 32 or 64 */
|
||||||
|
#undef BACKTRACE_XCOFF_SIZE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the __atomic functions */
|
||||||
|
#undef HAVE_ATOMIC_FUNCTIONS
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `clock_gettime' function. */
|
||||||
|
#undef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `getpagesize', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_GETPAGESIZE
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_STRNLEN
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `_pgmptr', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL__PGMPTR
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define if dl_iterate_phdr is available. */
|
||||||
|
#undef HAVE_DL_ITERATE_PHDR
|
||||||
|
|
||||||
|
/* Define to 1 if you have the fcntl function */
|
||||||
|
#undef HAVE_FCNTL
|
||||||
|
|
||||||
|
/* Define if getexecname is available. */
|
||||||
|
#undef HAVE_GETEXECNAME
|
||||||
|
|
||||||
|
/* Define if _Unwind_GetIPInfo is available. */
|
||||||
|
#undef HAVE_GETIPINFO
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.
|
||||||
|
*/
|
||||||
|
#undef HAVE_KERN_PROC
|
||||||
|
|
||||||
|
/* Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in
|
||||||
|
<sys/sysctl.h>. */
|
||||||
|
#undef HAVE_KERN_PROC_ARGS
|
||||||
|
|
||||||
|
/* Define if -llzma is available. */
|
||||||
|
#undef HAVE_LIBLZMA
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <link.h> header file. */
|
||||||
|
#undef HAVE_LINK_H
|
||||||
|
|
||||||
|
/* Define if AIX loadquery is available. */
|
||||||
|
#undef HAVE_LOADQUERY
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `lstat' function. */
|
||||||
|
#undef HAVE_LSTAT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <mach-o/dyld.h> header file. */
|
||||||
|
#undef HAVE_MACH_O_DYLD_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `readlink' function. */
|
||||||
|
#undef HAVE_READLINK
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#undef HAVE_STRING_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the __sync functions */
|
||||||
|
#undef HAVE_SYNC_FUNCTIONS
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/ldr.h> header file. */
|
||||||
|
#undef HAVE_SYS_LDR_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/link.h> header file. */
|
||||||
|
#undef HAVE_SYS_LINK_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||||
|
#undef HAVE_SYS_MMAN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define if -lz is available. */
|
||||||
|
#undef HAVE_ZLIB
|
||||||
|
|
||||||
|
/* Define if -lzstd is available. */
|
||||||
|
#undef HAVE_ZSTD
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
#undef LT_OBJDIR
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#undef PACKAGE_NAME
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#undef PACKAGE_STRING
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#undef PACKAGE_TARNAME
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#undef PACKAGE_URL
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* Enable extensions on AIX 3, Interix. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
# undef _ALL_SOURCE
|
||||||
|
#endif
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# undef _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
/* Enable threading extensions on Solaris. */
|
||||||
|
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||||
|
# undef _POSIX_PTHREAD_SEMANTICS
|
||||||
|
#endif
|
||||||
|
/* Enable extensions on HP NonStop. */
|
||||||
|
#ifndef _TANDEM_SOURCE
|
||||||
|
# undef _TANDEM_SOURCE
|
||||||
|
#endif
|
||||||
|
/* Enable general extensions on Solaris. */
|
||||||
|
#ifndef __EXTENSIONS__
|
||||||
|
# undef __EXTENSIONS__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||||
|
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||||
|
# define _DARWIN_USE_64_BIT_INODE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
#undef _FILE_OFFSET_BITS
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
#undef _LARGE_FILES
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
#undef _MINIX
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
#undef _POSIX_1_SOURCE
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
#undef _POSIX_SOURCE
|
1885
deps/libbacktrace/config.sub
vendored
Executable file
1885
deps/libbacktrace/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
38
deps/libbacktrace/config/enable.m4
vendored
Normal file
38
deps/libbacktrace/config/enable.m4
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
dnl ----------------------------------------------------------------------
|
||||||
|
dnl This whole bit snagged from libstdc++-v3.
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl GCC_ENABLE
|
||||||
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
|
||||||
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
|
||||||
|
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
|
||||||
|
dnl
|
||||||
|
dnl See docs/html/17_intro/configury.html#enable for documentation.
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([GCC_ENABLE],[dnl
|
||||||
|
m4_define([_g_switch],[--enable-$1])dnl
|
||||||
|
m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
|
||||||
|
AC_ARG_ENABLE($1,_g_help,
|
||||||
|
m4_bmatch([$5],
|
||||||
|
[^permit ],
|
||||||
|
[[
|
||||||
|
case "$enableval" in
|
||||||
|
m4_bpatsubst([$5],[permit ])) ;;
|
||||||
|
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
|
||||||
|
dnl Idea for future: generate a URL pointing to
|
||||||
|
dnl "onlinedocs/configopts.html#whatever"
|
||||||
|
esac
|
||||||
|
]],
|
||||||
|
[^$],
|
||||||
|
[[
|
||||||
|
case "$enableval" in
|
||||||
|
yes|no) ;;
|
||||||
|
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
|
||||||
|
esac
|
||||||
|
]],
|
||||||
|
[[$5]]),
|
||||||
|
[enable_]m4_bpatsubst([$1],-,_)[=][$2])
|
||||||
|
m4_undefine([_g_switch])dnl
|
||||||
|
m4_undefine([_g_help])dnl
|
||||||
|
])
|
||||||
|
|
31
deps/libbacktrace/config/lead-dot.m4
vendored
Normal file
31
deps/libbacktrace/config/lead-dot.m4
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# -*- Autoconf -*-
|
||||||
|
# Copyright (C) 2003, 2009 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; see the file COPYING3. If not see
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# serial 1
|
||||||
|
|
||||||
|
# Check whether the underlying file-system supports filenames
|
||||||
|
# with a leading dot. For instance MS-DOS doesn't.
|
||||||
|
AC_DEFUN([AM_SET_LEADING_DOT],
|
||||||
|
[rm -rf .tst 2>/dev/null
|
||||||
|
mkdir .tst 2>/dev/null
|
||||||
|
if test -d .tst; then
|
||||||
|
am__leading_dot=.
|
||||||
|
else
|
||||||
|
am__leading_dot=_
|
||||||
|
fi
|
||||||
|
rmdir .tst 2>/dev/null
|
||||||
|
AC_SUBST([am__leading_dot])])
|
7436
deps/libbacktrace/config/libtool.m4
vendored
Normal file
7436
deps/libbacktrace/config/libtool.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
369
deps/libbacktrace/config/ltoptions.m4
vendored
Normal file
369
deps/libbacktrace/config/ltoptions.m4
vendored
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
# Helper functions for option handling. -*- Autoconf -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
|
# Written by Gary V. Vaughan, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 6 ltoptions.m4
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
|
||||||
|
# ------------------------------------------
|
||||||
|
m4_define([_LT_MANGLE_OPTION],
|
||||||
|
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
|
||||||
|
# ---------------------------------------
|
||||||
|
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
|
||||||
|
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
|
||||||
|
# saved as a flag.
|
||||||
|
m4_define([_LT_SET_OPTION],
|
||||||
|
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||||
|
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||||
|
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||||
|
[m4_warning([Unknown $1 option `$2'])])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||||
|
m4_define([_LT_IF_OPTION],
|
||||||
|
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
|
||||||
|
# are set.
|
||||||
|
m4_define([_LT_UNLESS_OPTIONS],
|
||||||
|
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||||
|
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
|
||||||
|
[m4_define([$0_found])])])[]dnl
|
||||||
|
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
|
||||||
|
])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
|
||||||
|
# ----------------------------------------
|
||||||
|
# OPTION-LIST is a space-separated list of Libtool options associated
|
||||||
|
# with MACRO-NAME. If any OPTION has a matching handler declared with
|
||||||
|
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
|
||||||
|
# the unknown option and exit.
|
||||||
|
m4_defun([_LT_SET_OPTIONS],
|
||||||
|
[# Set options
|
||||||
|
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||||
|
[_LT_SET_OPTION([$1], _LT_Option)])
|
||||||
|
|
||||||
|
m4_if([$1],[LT_INIT],[
|
||||||
|
dnl
|
||||||
|
dnl Simply set some default values (i.e off) if boolean options were not
|
||||||
|
dnl specified:
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
|
||||||
|
])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
|
||||||
|
])
|
||||||
|
dnl
|
||||||
|
dnl If no reference was made to various pairs of opposing options, then
|
||||||
|
dnl we run the default mode handler for the pair. For example, if neither
|
||||||
|
dnl `shared' nor `disable-shared' was passed, we enable building of shared
|
||||||
|
dnl archives by default:
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||||
|
[_LT_ENABLE_FAST_INSTALL])
|
||||||
|
])
|
||||||
|
])# _LT_SET_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------------------- ##
|
||||||
|
## Macros to handle LT_INIT options. ##
|
||||||
|
## --------------------------------- ##
|
||||||
|
|
||||||
|
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
|
||||||
|
# -----------------------------------------
|
||||||
|
m4_define([_LT_MANGLE_DEFUN],
|
||||||
|
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
|
||||||
|
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
|
||||||
|
# -----------------------------------------------
|
||||||
|
m4_define([LT_OPTION_DEFINE],
|
||||||
|
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
|
||||||
|
])# LT_OPTION_DEFINE
|
||||||
|
|
||||||
|
|
||||||
|
# dlopen
|
||||||
|
# ------
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `dlopen' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
|
||||||
|
|
||||||
|
|
||||||
|
# win32-dll
|
||||||
|
# ---------
|
||||||
|
# Declare package support for building win32 dll's.
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
|
||||||
|
[enable_win32_dll=yes
|
||||||
|
|
||||||
|
case $host in
|
||||||
|
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
|
||||||
|
AC_CHECK_TOOL(AS, as, false)
|
||||||
|
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||||
|
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
test -z "$AS" && AS=as
|
||||||
|
_LT_DECL([], [AS], [1], [Assembler program])dnl
|
||||||
|
|
||||||
|
test -z "$DLLTOOL" && DLLTOOL=dlltool
|
||||||
|
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
|
||||||
|
|
||||||
|
test -z "$OBJDUMP" && OBJDUMP=objdump
|
||||||
|
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
|
||||||
|
])# win32-dll
|
||||||
|
|
||||||
|
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||||
|
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||||
|
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `win32-dll' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_SHARED([DEFAULT])
|
||||||
|
# ----------------------------
|
||||||
|
# implement the --enable-shared flag, and supports the `shared' and
|
||||||
|
# `disable-shared' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_SHARED],
|
||||||
|
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([shared],
|
||||||
|
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
|
||||||
|
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_shared=yes ;;
|
||||||
|
no) enable_shared=no ;;
|
||||||
|
*)
|
||||||
|
enable_shared=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_shared=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([build_libtool_libs], [enable_shared], [0],
|
||||||
|
[Whether or not to build shared libraries])
|
||||||
|
])# _LT_ENABLE_SHARED
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AC_DEFUN([AC_ENABLE_SHARED],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AC_DISABLE_SHARED],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-shared])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
|
||||||
|
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_STATIC([DEFAULT])
|
||||||
|
# ----------------------------
|
||||||
|
# implement the --enable-static flag, and support the `static' and
|
||||||
|
# `disable-static' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_STATIC],
|
||||||
|
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([static],
|
||||||
|
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
|
||||||
|
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_static=yes ;;
|
||||||
|
no) enable_static=no ;;
|
||||||
|
*)
|
||||||
|
enable_static=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_static=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([build_old_libs], [enable_static], [0],
|
||||||
|
[Whether or not to build static libraries])
|
||||||
|
])# _LT_ENABLE_STATIC
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AC_DEFUN([AC_ENABLE_STATIC],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AC_DISABLE_STATIC],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-static])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
|
||||||
|
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||||
|
# ----------------------------------
|
||||||
|
# implement the --enable-fast-install flag, and support the `fast-install'
|
||||||
|
# and `disable-fast-install' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||||
|
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([fast-install],
|
||||||
|
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
|
||||||
|
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_fast_install=yes ;;
|
||||||
|
no) enable_fast_install=no ;;
|
||||||
|
*)
|
||||||
|
enable_fast_install=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_fast_install=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([fast_install], [enable_fast_install], [0],
|
||||||
|
[Whether or not to optimize for fast installation])dnl
|
||||||
|
])# _LT_ENABLE_FAST_INSTALL
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||||
|
the `fast-install' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||||
|
the `disable-fast-install' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_WITH_PIC([MODE])
|
||||||
|
# --------------------
|
||||||
|
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
|
||||||
|
# LT_INIT options.
|
||||||
|
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
|
||||||
|
m4_define([_LT_WITH_PIC],
|
||||||
|
[AC_ARG_WITH([pic],
|
||||||
|
[AS_HELP_STRING([--with-pic],
|
||||||
|
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
|
||||||
|
[pic_mode="$withval"],
|
||||||
|
[pic_mode=default])
|
||||||
|
|
||||||
|
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
|
||||||
|
|
||||||
|
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||||
|
])# _LT_WITH_PIC
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
|
||||||
|
|
||||||
|
# Old name:
|
||||||
|
AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `pic-only' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## LTDL_INIT Options ##
|
||||||
|
## ----------------- ##
|
||||||
|
|
||||||
|
m4_define([_LTDL_MODE], [])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
|
||||||
|
[m4_define([_LTDL_MODE], [nonrecursive])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
|
||||||
|
[m4_define([_LTDL_MODE], [recursive])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
|
||||||
|
[m4_define([_LTDL_MODE], [subproject])])
|
||||||
|
|
||||||
|
m4_define([_LTDL_TYPE], [])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [installable],
|
||||||
|
[m4_define([_LTDL_TYPE], [installable])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
|
||||||
|
[m4_define([_LTDL_TYPE], [convenience])])
|
123
deps/libbacktrace/config/ltsugar.m4
vendored
Normal file
123
deps/libbacktrace/config/ltsugar.m4
vendored
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||||
|
# Written by Gary V. Vaughan, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 6 ltsugar.m4
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_join(SEP, ARG1, [ARG2...])
|
||||||
|
# -----------------------------
|
||||||
|
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
||||||
|
# associated separator.
|
||||||
|
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
||||||
|
# versions in m4sugar had bugs.
|
||||||
|
m4_define([lt_join],
|
||||||
|
[m4_if([$#], [1], [],
|
||||||
|
[$#], [2], [[$2]],
|
||||||
|
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
||||||
|
m4_define([_lt_join],
|
||||||
|
[m4_if([$#$2], [2], [],
|
||||||
|
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_car(LIST)
|
||||||
|
# lt_cdr(LIST)
|
||||||
|
# ------------
|
||||||
|
# Manipulate m4 lists.
|
||||||
|
# These macros are necessary as long as will still need to support
|
||||||
|
# Autoconf-2.59 which quotes differently.
|
||||||
|
m4_define([lt_car], [[$1]])
|
||||||
|
m4_define([lt_cdr],
|
||||||
|
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||||
|
[$#], 1, [],
|
||||||
|
[m4_dquote(m4_shift($@))])])
|
||||||
|
m4_define([lt_unquote], $1)
|
||||||
|
|
||||||
|
|
||||||
|
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||||
|
# ------------------------------------------
|
||||||
|
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
||||||
|
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||||
|
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||||
|
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||||
|
# than defined and empty).
|
||||||
|
#
|
||||||
|
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
||||||
|
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
||||||
|
m4_define([lt_append],
|
||||||
|
[m4_define([$1],
|
||||||
|
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Produce a SEP delimited list of all paired combinations of elements of
|
||||||
|
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
||||||
|
# has the form PREFIXmINFIXSUFFIXn.
|
||||||
|
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
||||||
|
m4_define([lt_combine],
|
||||||
|
[m4_if(m4_eval([$# > 3]), [1],
|
||||||
|
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
||||||
|
[[m4_foreach([_Lt_prefix], [$2],
|
||||||
|
[m4_foreach([_Lt_suffix],
|
||||||
|
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
||||||
|
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
||||||
|
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
||||||
|
m4_define([lt_if_append_uniq],
|
||||||
|
[m4_ifdef([$1],
|
||||||
|
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
||||||
|
[lt_append([$1], [$2], [$3])$4],
|
||||||
|
[$5])],
|
||||||
|
[lt_append([$1], [$2], [$3])$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_add(DICT, KEY, VALUE)
|
||||||
|
# -----------------------------
|
||||||
|
m4_define([lt_dict_add],
|
||||||
|
[m4_define([$1($2)], [$3])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
||||||
|
# --------------------------------------------
|
||||||
|
m4_define([lt_dict_add_subkey],
|
||||||
|
[m4_define([$1($2:$3)], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
||||||
|
# ----------------------------------
|
||||||
|
m4_define([lt_dict_fetch],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
||||||
|
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
m4_define([lt_if_dict_fetch],
|
||||||
|
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
||||||
|
[$5],
|
||||||
|
[$6])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
m4_define([lt_dict_filter],
|
||||||
|
[m4_if([$5], [], [],
|
||||||
|
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
||||||
|
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
||||||
|
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
||||||
|
])
|
23
deps/libbacktrace/config/ltversion.m4
vendored
Normal file
23
deps/libbacktrace/config/ltversion.m4
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||||
|
# Written by Scott James Remnant, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# Generated from ltversion.in.
|
||||||
|
|
||||||
|
# serial 3134 ltversion.m4
|
||||||
|
# This file is part of GNU Libtool
|
||||||
|
|
||||||
|
m4_define([LT_PACKAGE_VERSION], [2.2.7a])
|
||||||
|
m4_define([LT_PACKAGE_REVISION], [1.3134])
|
||||||
|
|
||||||
|
AC_DEFUN([LTVERSION_VERSION],
|
||||||
|
[macro_version='2.2.7a'
|
||||||
|
macro_revision='1.3134'
|
||||||
|
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||||
|
_LT_DECL(, macro_revision, 0)
|
||||||
|
])
|
98
deps/libbacktrace/config/lt~obsolete.m4
vendored
Normal file
98
deps/libbacktrace/config/lt~obsolete.m4
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||||
|
# Written by Scott James Remnant, 2004.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 4 lt~obsolete.m4
|
||||||
|
|
||||||
|
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||||
|
#
|
||||||
|
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
||||||
|
# which have later been changed to m4_define as they aren't part of the
|
||||||
|
# exported API, or moved to Autoconf or Automake where they belong.
|
||||||
|
#
|
||||||
|
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
||||||
|
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
||||||
|
# using a macro with the same name in our local m4/libtool.m4 it'll
|
||||||
|
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
||||||
|
# and doesn't know about Autoconf macros at all.)
|
||||||
|
#
|
||||||
|
# So we provide this file, which has a silly filename so it's always
|
||||||
|
# included after everything else. This provides aclocal with the
|
||||||
|
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||||
|
# because those macros already exist, or will be overwritten later.
|
||||||
|
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||||
|
#
|
||||||
|
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||||
|
# Yes, that means every name once taken will need to remain here until
|
||||||
|
# we give up compatibility with versions before 1.7, at which point
|
||||||
|
# we need to keep only those names which we still refer to.
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
||||||
|
|
||||||
|
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
||||||
|
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
||||||
|
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
||||||
|
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
||||||
|
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
||||||
|
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
||||||
|
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
||||||
|
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
||||||
|
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
||||||
|
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
||||||
|
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
||||||
|
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
||||||
|
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
||||||
|
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
||||||
|
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
||||||
|
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
||||||
|
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
||||||
|
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
||||||
|
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
||||||
|
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
||||||
|
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
||||||
|
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
||||||
|
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
||||||
|
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
||||||
|
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
||||||
|
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
||||||
|
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
||||||
|
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
||||||
|
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
||||||
|
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
||||||
|
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
||||||
|
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
||||||
|
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
68
deps/libbacktrace/config/multi.m4
vendored
Normal file
68
deps/libbacktrace/config/multi.m4
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
## -*- Autoconf -*-
|
||||||
|
# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2008
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 6
|
||||||
|
|
||||||
|
# AM_ENABLE_MULTILIB([MAKEFILE], [REL-TO-TOP-SRCDIR])
|
||||||
|
# ---------------------------------------------------
|
||||||
|
# Add --enable-multilib to configure.
|
||||||
|
AC_DEFUN([AM_ENABLE_MULTILIB],
|
||||||
|
[# Default to --enable-multilib
|
||||||
|
AC_ARG_ENABLE(multilib,
|
||||||
|
[ --enable-multilib build many library versions (default)],
|
||||||
|
[case "$enableval" in
|
||||||
|
yes) multilib=yes ;;
|
||||||
|
no) multilib=no ;;
|
||||||
|
*) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
|
||||||
|
esac],
|
||||||
|
[multilib=yes])
|
||||||
|
|
||||||
|
# We may get other options which we leave undocumented:
|
||||||
|
# --with-target-subdir, --with-multisrctop, --with-multisubdir
|
||||||
|
# See config-ml.in if you want the gory details.
|
||||||
|
|
||||||
|
if test "$srcdir" = "."; then
|
||||||
|
if test "$with_target_subdir" != "."; then
|
||||||
|
multi_basedir="$srcdir/$with_multisrctop../$2"
|
||||||
|
else
|
||||||
|
multi_basedir="$srcdir/$with_multisrctop$2"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
multi_basedir="$srcdir/$2"
|
||||||
|
fi
|
||||||
|
AC_SUBST(multi_basedir)
|
||||||
|
|
||||||
|
# Even if the default multilib is not a cross compilation,
|
||||||
|
# it may be that some of the other multilibs are.
|
||||||
|
if test $cross_compiling = no && test $multilib = yes \
|
||||||
|
&& test "x${with_multisubdir}" != x ; then
|
||||||
|
cross_compiling=maybe
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_OUTPUT_COMMANDS([
|
||||||
|
# Only add multilib support code if we just rebuilt the top-level
|
||||||
|
# Makefile.
|
||||||
|
case " $CONFIG_FILES " in
|
||||||
|
*" ]m4_default([$1],Makefile)[ "*)
|
||||||
|
ac_file=]m4_default([$1],Makefile)[ . ${multi_basedir}/config-ml.in
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[
|
||||||
|
srcdir="$srcdir"
|
||||||
|
host="$host"
|
||||||
|
target="$target"
|
||||||
|
with_multisubdir="$with_multisubdir"
|
||||||
|
with_multisrctop="$with_multisrctop"
|
||||||
|
with_target_subdir="$with_target_subdir"
|
||||||
|
ac_configure_args="${multilib_arg} ${ac_configure_args}"
|
||||||
|
multi_basedir="$multi_basedir"
|
||||||
|
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
|
||||||
|
CC="$CC"
|
||||||
|
CXX="$CXX"
|
||||||
|
GFORTRAN="$GFORTRAN"
|
||||||
|
GDC="$GDC"])])dnl
|
117
deps/libbacktrace/config/override.m4
vendored
Normal file
117
deps/libbacktrace/config/override.m4
vendored
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
dnl Fix Autoconf bugs by overriding broken internal Autoconf
|
||||||
|
dnl macros with backports of fixes from newer releases.
|
||||||
|
dnl
|
||||||
|
dnl The override bits of this file should be a no-op for the newest
|
||||||
|
dnl Autoconf version, which means they can be removed once the complete
|
||||||
|
dnl tree has moved to a new enough Autoconf version.
|
||||||
|
dnl
|
||||||
|
dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired
|
||||||
|
dnl Autoconf version is used. It should be kept for consistency.
|
||||||
|
|
||||||
|
dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
|
||||||
|
ifdef([m4_PACKAGE_VERSION], [
|
||||||
|
|
||||||
|
dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
|
||||||
|
|
||||||
|
m4_ifndef([m4_copy_force],
|
||||||
|
[m4_define([m4_copy_force],
|
||||||
|
[m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
|
||||||
|
|
||||||
|
m4_ifndef([m4_rename_force],
|
||||||
|
[m4_define([m4_rename_force],
|
||||||
|
[m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
|
||||||
|
|
||||||
|
dnl AC_DEFUN a commonly used macro so this file is picked up.
|
||||||
|
m4_copy([AC_PREREQ], [_AC_PREREQ])
|
||||||
|
AC_DEFUN([AC_PREREQ], [frob])
|
||||||
|
m4_copy_force([_AC_PREREQ], [AC_PREREQ])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Ensure exactly this Autoconf version is used
|
||||||
|
m4_ifndef([_GCC_AUTOCONF_VERSION],
|
||||||
|
[m4_define([_GCC_AUTOCONF_VERSION], [2.69])])
|
||||||
|
|
||||||
|
dnl Test for the exact version when AC_INIT is expanded.
|
||||||
|
dnl This allows to update the tree in steps (for testing)
|
||||||
|
dnl by putting
|
||||||
|
dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
|
||||||
|
dnl in configure.ac before AC_INIT,
|
||||||
|
dnl without rewriting this file.
|
||||||
|
dnl Or for updating the whole tree at once with the definition above.
|
||||||
|
AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
|
||||||
|
[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
|
||||||
|
m4_defn([m4_PACKAGE_VERSION]), [],
|
||||||
|
[m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
|
||||||
|
])
|
||||||
|
dnl don't do this for libbacktrace
|
||||||
|
dnl m4_define([AC_INIT], m4_defn([AC_INIT])[
|
||||||
|
dnl _GCC_AUTOCONF_VERSION_CHECK
|
||||||
|
dnl ])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Ensure we do not use a buggy M4.
|
||||||
|
m4_if(m4_index([..wi.d.], [.d.]), [-1],
|
||||||
|
[m4_fatal(m4_do([m4 with buggy strstr detected. Please install
|
||||||
|
GNU M4 1.4.16 or newer and set the M4 environment variable]))])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Fix 2.64 cross compile detection for AVR and RTEMS
|
||||||
|
dnl by not trying to compile fopen.
|
||||||
|
m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
|
||||||
|
[m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
|
||||||
|
[m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
|
||||||
|
|
||||||
|
m4_version_prereq([2.66],, [
|
||||||
|
dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
|
||||||
|
|
||||||
|
# _AC_CHECK_DECL_BODY
|
||||||
|
# -------------------
|
||||||
|
# Shell function body for AC_CHECK_DECL.
|
||||||
|
m4_define([_AC_CHECK_DECL_BODY],
|
||||||
|
[ AS_LINENO_PUSH([$[]1])
|
||||||
|
[as_decl_name=`echo $][2|sed 's/ *(.*//'`]
|
||||||
|
[as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
|
||||||
|
AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
|
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
|
||||||
|
[@%:@ifndef $[]as_decl_name
|
||||||
|
@%:@ifdef __cplusplus
|
||||||
|
(void) $[]as_decl_use;
|
||||||
|
@%:@else
|
||||||
|
(void) $[]as_decl_name;
|
||||||
|
@%:@endif
|
||||||
|
@%:@endif
|
||||||
|
])],
|
||||||
|
[AS_VAR_SET([$[]3], [yes])],
|
||||||
|
[AS_VAR_SET([$[]3], [no])])])
|
||||||
|
AS_LINENO_POP
|
||||||
|
])# _AC_CHECK_DECL_BODY
|
||||||
|
|
||||||
|
# _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
|
||||||
|
# INCLUDES)
|
||||||
|
# -------------------------------------------------------------
|
||||||
|
# Helper to AC_CHECK_DECLS, which generates the check for a single
|
||||||
|
# SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
|
||||||
|
# ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
|
||||||
|
m4_define([_AC_CHECK_DECLS],
|
||||||
|
[AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
|
||||||
|
[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
|
||||||
|
[$ac_have_decl],
|
||||||
|
[Define to 1 if you have the declaration of `$1',
|
||||||
|
and to 0 if you don't.])]dnl
|
||||||
|
[m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl If flex/lex are not found, the top level configure sets LEX to
|
||||||
|
dnl "/path_to/missing flex". When AC_PROG_LEX tries to find the flex
|
||||||
|
dnl output file, it calls $LEX to do so, but the current lightweight
|
||||||
|
dnl "missing" won't create a file. This results in an error.
|
||||||
|
dnl Avoid calling the bulk of AC_PROG_LEX when $LEX is "missing".
|
||||||
|
AC_DEFUN_ONCE([AC_PROG_LEX],
|
||||||
|
[AC_CHECK_PROGS(LEX, flex lex, :)
|
||||||
|
case "$LEX" in
|
||||||
|
:|*"missing "*) ;;
|
||||||
|
*) _AC_PROG_LEX_YYTEXT_DECL ;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
])
|
37
deps/libbacktrace/config/unwind_ipinfo.m4
vendored
Normal file
37
deps/libbacktrace/config/unwind_ipinfo.m4
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
dnl
|
||||||
|
dnl Check whether _Unwind_GetIPInfo is available without doing a link
|
||||||
|
dnl test so we can use this with libstdc++-v3 and libjava. Need to
|
||||||
|
dnl use $target to set defaults because automatic checking is not possible
|
||||||
|
dnl without a link test (and maybe even with a link test).
|
||||||
|
dnl
|
||||||
|
|
||||||
|
AC_DEFUN([GCC_CHECK_UNWIND_GETIPINFO], [
|
||||||
|
AC_ARG_WITH(system-libunwind,
|
||||||
|
[ --with-system-libunwind use installed libunwind])
|
||||||
|
# If system-libunwind was not specifically set, pick a default setting.
|
||||||
|
if test x$with_system_libunwind = x; then
|
||||||
|
case ${target} in
|
||||||
|
ia64-*-hpux*) with_system_libunwind=yes ;;
|
||||||
|
*) with_system_libunwind=no ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
# Based on system-libunwind and target, do we have ipinfo?
|
||||||
|
if test x$with_system_libunwind = xyes; then
|
||||||
|
case ${target} in
|
||||||
|
ia64-*-*) have_unwind_getipinfo=no ;;
|
||||||
|
*) have_unwind_getipinfo=yes ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# Darwin before version 9 does not have _Unwind_GetIPInfo.
|
||||||
|
changequote(,)
|
||||||
|
case ${target} in
|
||||||
|
*-*-darwin[3-8]|*-*-darwin[3-8].*) have_unwind_getipinfo=no ;;
|
||||||
|
*) have_unwind_getipinfo=yes ;;
|
||||||
|
esac
|
||||||
|
changequote([,])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$have_unwind_getipinfo = xyes; then
|
||||||
|
AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
|
||||||
|
fi
|
||||||
|
])
|
227
deps/libbacktrace/config/warnings.m4
vendored
Normal file
227
deps/libbacktrace/config/warnings.m4
vendored
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
# Autoconf include file defining macros related to compile-time warnings.
|
||||||
|
|
||||||
|
# Copyright 2004, 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
#This file is part of GCC.
|
||||||
|
|
||||||
|
#GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
#the terms of the GNU General Public License as published by the Free
|
||||||
|
#Software Foundation; either version 3, or (at your option) any later
|
||||||
|
#version.
|
||||||
|
|
||||||
|
#GCC is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
#for more details.
|
||||||
|
|
||||||
|
#You should have received a copy of the GNU General Public License
|
||||||
|
#along with GCC; see the file COPYING3. If not see
|
||||||
|
#<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS])
|
||||||
|
# Sets @VARIABLE@ to the subset of the given options which the
|
||||||
|
# compiler accepts.
|
||||||
|
AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
|
||||||
|
[AC_REQUIRE([AC_PROG_CC])dnl
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
for real_option in $1; do
|
||||||
|
# Do the check with the no- prefix removed since gcc silently
|
||||||
|
# accepts any -Wno-* option on purpose
|
||||||
|
case $real_option in
|
||||||
|
-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
|
||||||
|
*) option=$real_option ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
|
||||||
|
AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
|
||||||
|
[CFLAGS="$option"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
|
||||||
|
[AS_VAR_SET(acx_Woption, yes)],
|
||||||
|
[AS_VAR_SET(acx_Woption, no)])
|
||||||
|
])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_Woption) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }$real_option"])
|
||||||
|
AS_VAR_POPDEF([acx_Woption])dnl
|
||||||
|
done
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C)
|
||||||
|
])# ACX_PROG_CC_WARNING_OPTS
|
||||||
|
|
||||||
|
# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
|
||||||
|
# Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
|
||||||
|
# and accepts all of those options simultaneously, otherwise to nothing.
|
||||||
|
AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
|
||||||
|
[AC_REQUIRE([AC_PROG_CC])dnl
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
# Do the check with the no- prefix removed from the warning options
|
||||||
|
# since gcc silently accepts any -Wno-* option on purpose
|
||||||
|
m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
|
||||||
|
AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
|
||||||
|
AS_IF([test "$GCC" = yes],
|
||||||
|
[AC_CACHE_CHECK([whether $CC supports -pedantic ]acx_Woptions, acx_Pedantic,
|
||||||
|
[save_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="-pedantic acx_Woptions"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
|
||||||
|
[AS_VAR_SET(acx_Pedantic, yes)],
|
||||||
|
[AS_VAR_SET(acx_Pedantic, no)])
|
||||||
|
CFLAGS="$save_CFLAGS"])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
|
||||||
|
])
|
||||||
|
AS_VAR_POPDEF([acx_Pedantic])dnl
|
||||||
|
m4_popdef([acx_Woptions])dnl
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C)
|
||||||
|
])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
|
||||||
|
|
||||||
|
# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
|
||||||
|
# sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
|
||||||
|
# --enable-werror-always was given on the command line, otherwise
|
||||||
|
# to nothing.
|
||||||
|
# If the argument is the word "manual" instead of a version number,
|
||||||
|
# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
|
||||||
|
# appeared on the configure command line.
|
||||||
|
AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
|
||||||
|
[AC_REQUIRE([AC_PROG_CC])dnl
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
AC_ARG_ENABLE(werror-always,
|
||||||
|
AS_HELP_STRING([--enable-werror-always],
|
||||||
|
[enable -Werror despite compiler version]),
|
||||||
|
[], [enable_werror_always=no])
|
||||||
|
AS_IF([test $enable_werror_always = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
|
||||||
|
m4_if($1, [manual],,
|
||||||
|
[AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
|
||||||
|
AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
|
||||||
|
[set fnord `echo $1 | tr '.' ' '`
|
||||||
|
shift
|
||||||
|
AC_PREPROC_IFELSE(
|
||||||
|
[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
|
||||||
|
< [$]1 * 10000 + [$]2 * 100 + [$]3
|
||||||
|
#error insufficient
|
||||||
|
#endif],
|
||||||
|
[AS_VAR_SET(acx_GCCvers, yes)],
|
||||||
|
[AS_VAR_SET(acx_GCCvers, no)])])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
|
||||||
|
AS_VAR_POPDEF([acx_GCCvers])])
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C)
|
||||||
|
])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
|
||||||
|
|
||||||
|
# ACX_PROG_CXX_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CXXFLAGS])
|
||||||
|
# Sets @VARIABLE@ to the subset of the given options which the
|
||||||
|
# compiler accepts.
|
||||||
|
AC_DEFUN([ACX_PROG_CXX_WARNING_OPTS],
|
||||||
|
[AC_REQUIRE([AC_PROG_CXX])dnl
|
||||||
|
AC_LANG_PUSH(C++)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WARN_CXXFLAGS])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
save_CXXFLAGS="$CXXFLAGS"
|
||||||
|
for real_option in $1; do
|
||||||
|
# Do the check with the no- prefix removed since gcc silently
|
||||||
|
# accepts any -Wno-* option on purpose
|
||||||
|
case $real_option in
|
||||||
|
-Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
|
||||||
|
*) option=$real_option ;;
|
||||||
|
esac
|
||||||
|
AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
|
||||||
|
AC_CACHE_CHECK([whether $CXX supports $option], acx_Woption,
|
||||||
|
[CXXFLAGS="$option"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
|
||||||
|
[AS_VAR_SET(acx_Woption, yes)],
|
||||||
|
[AS_VAR_SET(acx_Woption, no)])
|
||||||
|
])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_Woption) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }$real_option"])
|
||||||
|
AS_VAR_POPDEF([acx_Woption])dnl
|
||||||
|
done
|
||||||
|
CXXFLAGS="$save_CXXFLAGS"
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C++)
|
||||||
|
])# ACX_PROG_CXX_WARNING_OPTS
|
||||||
|
|
||||||
|
# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
|
||||||
|
# Append to VARIABLE "-pedantic" + the argument, if the compiler is G++
|
||||||
|
# and accepts all of those options simultaneously, otherwise to nothing.
|
||||||
|
AC_DEFUN([ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC],
|
||||||
|
[AC_REQUIRE([AC_PROG_CXX])dnl
|
||||||
|
AC_LANG_PUSH(C++)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
# Do the check with the no- prefix removed from the warning options
|
||||||
|
# since gcc silently accepts any -Wno-* option on purpose
|
||||||
|
m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
|
||||||
|
AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
|
||||||
|
AS_IF([test "$GXX" = yes],
|
||||||
|
[AC_CACHE_CHECK([whether $CXX supports -pedantic ]acx_Woptions, acx_Pedantic,
|
||||||
|
[save_CXXFLAGS="$CXXFLAGS"
|
||||||
|
CXXFLAGS="-pedantic acx_Woptions"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
|
||||||
|
[AS_VAR_SET(acx_Pedantic, yes)],
|
||||||
|
[AS_VAR_SET(acx_Pedantic, no)])
|
||||||
|
CXXFLAGS="$save_CXXFLAGS"])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
|
||||||
|
])
|
||||||
|
AS_VAR_POPDEF([acx_Pedantic])dnl
|
||||||
|
m4_popdef([acx_Woptions])dnl
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C++)
|
||||||
|
])# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC
|
||||||
|
|
||||||
|
# ACX_PROG_CXX_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
|
||||||
|
# sets @VARIABLE@ to "-Werror" if the compiler is G++ >=x.y.z, or if
|
||||||
|
# --enable-werror-always was given on the command line, otherwise
|
||||||
|
# to nothing.
|
||||||
|
# If the argument is the word "manual" instead of a version number,
|
||||||
|
# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
|
||||||
|
# appeared on the configure command line.
|
||||||
|
AC_DEFUN([ACX_PROG_CXX_WARNINGS_ARE_ERRORS],
|
||||||
|
[AC_REQUIRE([AC_PROG_CXX])dnl
|
||||||
|
AC_LANG_PUSH(C++)
|
||||||
|
m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
|
||||||
|
AC_SUBST(acx_Var)dnl
|
||||||
|
m4_expand_once([acx_Var=
|
||||||
|
],m4_quote(acx_Var=))dnl
|
||||||
|
AC_ARG_ENABLE(werror-always,
|
||||||
|
AS_HELP_STRING([--enable-werror-always],
|
||||||
|
[enable -Werror despite compiler version]),
|
||||||
|
[], [enable_werror_always=no])
|
||||||
|
AS_IF([test $enable_werror_always = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
|
||||||
|
m4_if($1, [manual],,
|
||||||
|
[AS_VAR_PUSHDEF([acx_GXXvers], [acx_cv_prog_cxx_gxx_$1_or_newer])dnl
|
||||||
|
AC_CACHE_CHECK([whether $CXX is G++ >=$1], acx_GXXvers,
|
||||||
|
[set fnord `echo $1 | tr '.' ' '`
|
||||||
|
shift
|
||||||
|
AC_PREPROC_IFELSE(
|
||||||
|
[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
|
||||||
|
< [$]1 * 10000 + [$]2 * 100 + [$]3
|
||||||
|
#error insufficient
|
||||||
|
#endif],
|
||||||
|
[AS_VAR_SET(acx_GXXvers, yes)],
|
||||||
|
[AS_VAR_SET(acx_GXXvers, no)])])
|
||||||
|
AS_IF([test AS_VAR_GET(acx_GXXvers) = yes],
|
||||||
|
[acx_Var="$acx_Var${acx_Var:+ }-Werror"])
|
||||||
|
AS_VAR_POPDEF([acx_GXXvers])])
|
||||||
|
m4_popdef([acx_Var])dnl
|
||||||
|
AC_LANG_POP(C++)
|
||||||
|
])# ACX_PROG_CXX_WARNINGS_ARE_ERRORS
|
15727
deps/libbacktrace/configure
vendored
Executable file
15727
deps/libbacktrace/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
611
deps/libbacktrace/configure.ac
vendored
Normal file
611
deps/libbacktrace/configure.ac
vendored
Normal file
@ -0,0 +1,611 @@
|
|||||||
|
# configure.ac -- Backtrace configure script.
|
||||||
|
# Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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) 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.
|
||||||
|
|
||||||
|
AC_PREREQ(2.69)
|
||||||
|
AC_INIT(package-unused, version-unused,, libbacktrace)
|
||||||
|
AC_CONFIG_SRCDIR(backtrace.h)
|
||||||
|
AC_CONFIG_HEADER(config.h)
|
||||||
|
AC_CONFIG_MACRO_DIR(config)
|
||||||
|
|
||||||
|
# with_target_subdir is used when configured as part of a GCC tree.
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
AM_ENABLE_MULTILIB(, ..)
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CANONICAL_SYSTEM
|
||||||
|
target_alias=${target_alias-$host_alias}
|
||||||
|
|
||||||
|
AC_USE_SYSTEM_EXTENSIONS
|
||||||
|
|
||||||
|
# Default to not building a shared library.
|
||||||
|
AC_DISABLE_SHARED
|
||||||
|
|
||||||
|
libtool_VERSION=1:0:0
|
||||||
|
AC_SUBST(libtool_VERSION)
|
||||||
|
|
||||||
|
# 1.11.1: Require that version of automake.
|
||||||
|
# foreign: Don't require README, INSTALL, NEWS, etc.
|
||||||
|
# no-define: Don't define PACKAGE and VERSION.
|
||||||
|
# no-dependencies: Don't generate automatic dependencies.
|
||||||
|
# (because it breaks when using bootstrap-lean, since some of the
|
||||||
|
# headers are gone at "make install" time).
|
||||||
|
# -Wall: Issue all automake warnings.
|
||||||
|
# -Wno-portability: Don't warn about constructs supported by GNU make.
|
||||||
|
# (because GCC requires GNU make anyhow).
|
||||||
|
AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability])
|
||||||
|
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
|
AC_ARG_WITH(target-subdir,
|
||||||
|
[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
|
||||||
|
|
||||||
|
# We must force CC to /not/ be precious variables; otherwise
|
||||||
|
# the wrong, non-multilib-adjusted value will be used in multilibs.
|
||||||
|
# As a side effect, we have to subst CFLAGS ourselves.
|
||||||
|
m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS])
|
||||||
|
m4_define([_AC_ARG_VAR_PRECIOUS],[])
|
||||||
|
AC_PROG_CC
|
||||||
|
m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||||
|
|
||||||
|
AC_SUBST(CFLAGS)
|
||||||
|
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
|
||||||
|
AC_PROG_AWK
|
||||||
|
case "$AWK" in
|
||||||
|
"") AC_MSG_ERROR([can't build without awk]) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
AC_CHECK_PROG(DWZ, dwz, dwz)
|
||||||
|
AM_CONDITIONAL(HAVE_DWZ, test "$DWZ" != "")
|
||||||
|
|
||||||
|
LT_INIT
|
||||||
|
AM_PROG_LIBTOOL
|
||||||
|
|
||||||
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
|
backtrace_supported=yes
|
||||||
|
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
# We are compiling a GCC library. We can assume that the unwind
|
||||||
|
# library exists.
|
||||||
|
BACKTRACE_FILE="backtrace.lo simple.lo"
|
||||||
|
else
|
||||||
|
AC_CHECK_HEADER([unwind.h],
|
||||||
|
[AC_CHECK_FUNC([_Unwind_Backtrace],
|
||||||
|
[BACKTRACE_FILE="backtrace.lo simple.lo"],
|
||||||
|
[BACKTRACE_FILE="nounwind.lo"
|
||||||
|
backtrace_supported=no])],
|
||||||
|
[BACKTRACE_FILE="nounwind.lo"
|
||||||
|
backtrace_supported=no])
|
||||||
|
fi
|
||||||
|
AC_SUBST(BACKTRACE_FILE)
|
||||||
|
|
||||||
|
EXTRA_FLAGS=
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
|
||||||
|
else
|
||||||
|
AC_CACHE_CHECK([for -funwind-tables option],
|
||||||
|
[libbacktrace_cv_c_unwind_tables],
|
||||||
|
[CFLAGS_hold="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS -funwind-tables"
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])],
|
||||||
|
[libbacktrace_cv_c_unwind_tables=yes],
|
||||||
|
[libbacktrace_cv_c_unwind_tables=no])
|
||||||
|
CFLAGS="$CFLAGS_hold"])
|
||||||
|
if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
|
||||||
|
EXTRA_FLAGS=-funwind-tables
|
||||||
|
fi
|
||||||
|
AC_CACHE_CHECK([for -frandom-seed=string option],
|
||||||
|
[libbacktrace_cv_c_random_seed_string],
|
||||||
|
[CFLAGS_hold="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([], [return 0;])],
|
||||||
|
[libbacktrace_cv_c_random_seed_string=yes],
|
||||||
|
[libbacktrace_cv_c_random_seed_string=no])
|
||||||
|
CFLAGS="$CFLAGS_hold"])
|
||||||
|
if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
|
||||||
|
EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_SUBST(EXTRA_FLAGS)
|
||||||
|
|
||||||
|
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
|
||||||
|
-Wmissing-prototypes -Wold-style-definition \
|
||||||
|
-Wmissing-format-attribute -Wcast-qual],
|
||||||
|
[WARN_FLAGS])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([werror],
|
||||||
|
[AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
|
||||||
|
AS_IF([test "x$enable_werror" != "xno" && test -n "${with_target_subdir}"],
|
||||||
|
[WARN_FLAGS="$WARN_FLAGS -Werror"])
|
||||||
|
|
||||||
|
AC_SUBST(WARN_FLAGS)
|
||||||
|
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
GCC_CHECK_UNWIND_GETIPINFO
|
||||||
|
else
|
||||||
|
ac_save_CFFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
|
||||||
|
AC_MSG_CHECKING([for _Unwind_GetIPInfo])
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[#include "unwind.h"
|
||||||
|
struct _Unwind_Context *context;
|
||||||
|
int ip_before_insn = 0;],
|
||||||
|
[return _Unwind_GetIPInfo (context, &ip_before_insn);])],
|
||||||
|
[have_unwind_getipinfo=yes], [have_unwind_getipinfo=no])
|
||||||
|
CFLAGS="$ac_save_CFLAGS"
|
||||||
|
AC_MSG_RESULT([$have_unwind_getipinfo])
|
||||||
|
if test "$have_unwind_getipinfo" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enable --enable-host-shared.
|
||||||
|
AC_ARG_ENABLE(host-shared,
|
||||||
|
[AS_HELP_STRING([--enable-host-shared],
|
||||||
|
[build host code as shared libraries])],
|
||||||
|
[PIC_FLAG=-fPIC], [PIC_FLAG=])
|
||||||
|
AC_SUBST(PIC_FLAG)
|
||||||
|
|
||||||
|
# Test for __sync support.
|
||||||
|
AC_CACHE_CHECK([__sync extensions],
|
||||||
|
[libbacktrace_cv_sys_sync],
|
||||||
|
[if test -n "${with_target_subdir}"; then
|
||||||
|
case "${host}" in
|
||||||
|
hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
|
||||||
|
*) libbacktrace_cv_sys_sync=yes ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([int i;],
|
||||||
|
[__sync_bool_compare_and_swap (&i, i, i);
|
||||||
|
__sync_lock_test_and_set (&i, 1);
|
||||||
|
__sync_lock_release (&i);])],
|
||||||
|
[libbacktrace_cv_sys_sync=yes],
|
||||||
|
[libbacktrace_cv_sys_sync=no])
|
||||||
|
fi])
|
||||||
|
BACKTRACE_SUPPORTS_THREADS=0
|
||||||
|
if test "$libbacktrace_cv_sys_sync" = "yes"; then
|
||||||
|
BACKTRACE_SUPPORTS_THREADS=1
|
||||||
|
AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
|
||||||
|
[Define to 1 if you have the __sync functions])
|
||||||
|
fi
|
||||||
|
AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
|
||||||
|
|
||||||
|
# Test for __atomic support.
|
||||||
|
AC_CACHE_CHECK([__atomic extensions],
|
||||||
|
[libbacktrace_cv_sys_atomic],
|
||||||
|
[if test -n "${with_target_subdir}"; then
|
||||||
|
libbacktrace_cv_sys_atomic=yes
|
||||||
|
else
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([int i;],
|
||||||
|
[__atomic_load_n (&i, __ATOMIC_ACQUIRE);
|
||||||
|
__atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
|
||||||
|
[libbacktrace_cv_sys_atomic=yes],
|
||||||
|
[libbacktrace_cv_sys_atomic=no])
|
||||||
|
fi])
|
||||||
|
if test "$libbacktrace_cv_sys_atomic" = "yes"; then
|
||||||
|
AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
|
||||||
|
[Define to 1 if you have the __atomic functions])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The library needs to be able to read the executable itself. Compile
|
||||||
|
# a file to determine the executable format. The awk script
|
||||||
|
# filetype.awk prints out the file type.
|
||||||
|
AC_CACHE_CHECK([output filetype],
|
||||||
|
[libbacktrace_cv_sys_filetype],
|
||||||
|
[filetype=
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([int i;], [int j;])],
|
||||||
|
[filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`],
|
||||||
|
[AC_MSG_FAILURE([compiler failed])])
|
||||||
|
libbacktrace_cv_sys_filetype=$filetype])
|
||||||
|
|
||||||
|
# Match the file type to decide what files to compile.
|
||||||
|
FORMAT_FILE=
|
||||||
|
backtrace_supports_data=yes
|
||||||
|
case "$libbacktrace_cv_sys_filetype" in
|
||||||
|
elf*) FORMAT_FILE="elf.lo" ;;
|
||||||
|
macho) FORMAT_FILE="macho.lo" ;;
|
||||||
|
pecoff) FORMAT_FILE="pecoff.lo"
|
||||||
|
backtrace_supports_data=no
|
||||||
|
;;
|
||||||
|
xcoff*) FORMAT_FILE="xcoff.lo"
|
||||||
|
backtrace_supports_data=no
|
||||||
|
;;
|
||||||
|
*) AC_MSG_WARN([could not determine output file type])
|
||||||
|
FORMAT_FILE="unknown.lo"
|
||||||
|
backtrace_supported=no
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_SUBST(FORMAT_FILE)
|
||||||
|
|
||||||
|
# ELF defines.
|
||||||
|
elfsize=
|
||||||
|
case "$libbacktrace_cv_sys_filetype" in
|
||||||
|
elf32) elfsize=32 ;;
|
||||||
|
elf64) elfsize=64 ;;
|
||||||
|
*) elfsize=unused
|
||||||
|
esac
|
||||||
|
AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
|
||||||
|
AM_CONDITIONAL(HAVE_ELF, test "$FORMAT_FILE" = "elf.lo")
|
||||||
|
|
||||||
|
# XCOFF defines.
|
||||||
|
xcoffsize=
|
||||||
|
case "$libbacktrace_cv_sys_filetype" in
|
||||||
|
xcoff32) xcoffsize=32 ;;
|
||||||
|
xcoff64) xcoffsize=64 ;;
|
||||||
|
*) xcoffsize=unused
|
||||||
|
esac
|
||||||
|
AC_DEFINE_UNQUOTED([BACKTRACE_XCOFF_SIZE], [$xcoffsize], [XCOFF size: 32 or 64])
|
||||||
|
|
||||||
|
BACKTRACE_SUPPORTED=0
|
||||||
|
if test "$backtrace_supported" = "yes"; then
|
||||||
|
BACKTRACE_SUPPORTED=1
|
||||||
|
fi
|
||||||
|
AC_SUBST(BACKTRACE_SUPPORTED)
|
||||||
|
|
||||||
|
BACKTRACE_SUPPORTS_DATA=0
|
||||||
|
if test "$backtrace_supports_data" = "yes"; then
|
||||||
|
BACKTRACE_SUPPORTS_DATA=1
|
||||||
|
fi
|
||||||
|
AC_SUBST(BACKTRACE_SUPPORTS_DATA)
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(sys/mman.h)
|
||||||
|
if test "$ac_cv_header_sys_mman_h" = "no"; then
|
||||||
|
have_mmap=no
|
||||||
|
else
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
# When built as a GCC target library, we can't do a link test. We
|
||||||
|
# simply assume that if we have mman.h, we have mmap.
|
||||||
|
have_mmap=yes
|
||||||
|
case "${host}" in
|
||||||
|
spu-*-*|*-*-msdosdjgpp)
|
||||||
|
# The SPU does not have mmap, but it has a sys/mman.h header file
|
||||||
|
# containing "mmap_eaddr" and the mmap flags, confusing the test.
|
||||||
|
# DJGPP also has sys/man.h, but no mmap
|
||||||
|
have_mmap=no ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$have_mmap" = "no"; then
|
||||||
|
VIEW_FILE=read.lo
|
||||||
|
ALLOC_FILE=alloc.lo
|
||||||
|
else
|
||||||
|
VIEW_FILE=mmapio.lo
|
||||||
|
AC_PREPROC_IFELSE([AC_LANG_SOURCE([
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
|
||||||
|
#error no MAP_ANONYMOUS
|
||||||
|
#endif
|
||||||
|
])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
|
||||||
|
fi
|
||||||
|
AC_SUBST(VIEW_FILE)
|
||||||
|
AC_SUBST(ALLOC_FILE)
|
||||||
|
|
||||||
|
BACKTRACE_USES_MALLOC=0
|
||||||
|
if test "$ALLOC_FILE" = "alloc.lo"; then
|
||||||
|
BACKTRACE_USES_MALLOC=1
|
||||||
|
fi
|
||||||
|
AC_SUBST(BACKTRACE_USES_MALLOC)
|
||||||
|
|
||||||
|
# Check for dl_iterate_phdr.
|
||||||
|
AC_CHECK_HEADERS(link.h sys/link.h)
|
||||||
|
if test "$ac_cv_header_link_h" = "no" -a "$ac_cv_header_sys_link_h" = "no"; then
|
||||||
|
have_dl_iterate_phdr=no
|
||||||
|
else
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
link_h=link.h
|
||||||
|
if test "$ac_cv_header_link_h" = "no"; then
|
||||||
|
link_h=sys/link.h
|
||||||
|
fi
|
||||||
|
# When built as a GCC target library, we can't do a link test.
|
||||||
|
AC_EGREP_HEADER([dl_iterate_phdr], [$link_h], [have_dl_iterate_phdr=yes],
|
||||||
|
[have_dl_iterate_phdr=no])
|
||||||
|
case "${host}" in
|
||||||
|
*-*-solaris2.10*)
|
||||||
|
# Avoid dl_iterate_phdr on Solaris 10, where it is in the
|
||||||
|
# header file but is only in -ldl.
|
||||||
|
have_dl_iterate_phdr=no ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes],
|
||||||
|
[have_dl_iterate_phdr=no])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$have_dl_iterate_phdr" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for header file for Mach-O image functions.
|
||||||
|
AC_CHECK_HEADERS(mach-o/dyld.h)
|
||||||
|
|
||||||
|
# Check for loadquery.
|
||||||
|
AC_CHECK_HEADERS(sys/ldr.h)
|
||||||
|
if test "$ac_cv_header_sys_ldr_h" = "no"; then
|
||||||
|
have_loadquery=no
|
||||||
|
else
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
# When built as a GCC target library, we can't do a link test.
|
||||||
|
AC_EGREP_HEADER([loadquery], [sys/ldr.h], [have_loadquery=yes],
|
||||||
|
[have_loadquery=no])
|
||||||
|
else
|
||||||
|
AC_CHECK_FUNC([loadquery], [have_loadquery=yes],
|
||||||
|
[have_loadquery=no])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "$have_loadquery" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_LOADQUERY, 1, [Define if AIX loadquery is available.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the fcntl function.
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
case "${host}" in
|
||||||
|
*-*-mingw*) have_fcntl=no ;;
|
||||||
|
spu-*-*) have_fcntl=no ;;
|
||||||
|
*) have_fcntl=yes ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
|
||||||
|
fi
|
||||||
|
if test "$have_fcntl" = "yes"; then
|
||||||
|
AC_DEFINE([HAVE_FCNTL], 1,
|
||||||
|
[Define to 1 if you have the fcntl function])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_DECLS([strnlen, getpagesize])
|
||||||
|
AC_CHECK_FUNCS(lstat readlink)
|
||||||
|
|
||||||
|
# Check for getexecname function.
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
case "${host}" in
|
||||||
|
*-*-solaris2*) have_getexecname=yes ;;
|
||||||
|
*) have_getexecname=no ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
|
||||||
|
fi
|
||||||
|
if test "$have_getexecname" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for _pgmptr variable, contains the executable filename on windows
|
||||||
|
AC_CHECK_DECLS([_pgmptr])
|
||||||
|
|
||||||
|
# Check for sysctl definitions.
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for KERN_PROC],
|
||||||
|
[libbacktrace_cv_proc],
|
||||||
|
[AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
], [int mib0 = CTL_KERN; int mib1 = KERN_PROC; int mib2 = KERN_PROC_PATHNAME;])],
|
||||||
|
[libbacktrace_cv_proc=yes],
|
||||||
|
[libbacktrace_cv_proc=no])])
|
||||||
|
if test "$libbacktrace_cv_proc" = "yes"; then
|
||||||
|
AC_DEFINE([HAVE_KERN_PROC], 1,
|
||||||
|
[Define to 1 if you have KERN_PROC and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for KERN_PROG_ARGS],
|
||||||
|
[libbacktrace_cv_procargs],
|
||||||
|
[AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
], [int mib0 = CTL_KERN; int mib1 = KERN_PROC_ARGS; int mib2 = KERN_PROC_PATHNAME;])],
|
||||||
|
[libbacktrace_cv_procargs=yes],
|
||||||
|
[libbacktrace_cv_procargs=no])])
|
||||||
|
if test "$libbacktrace_cv_procargs" = "yes"; then
|
||||||
|
AC_DEFINE([HAVE_KERN_PROC_ARGS], 1,
|
||||||
|
[Define to 1 if you have KERN_PROCARGS and KERN_PROC_PATHNAME in <sys/sysctl.h>.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for the clock_gettime function.
|
||||||
|
AC_CHECK_FUNCS(clock_gettime)
|
||||||
|
clock_gettime_link=
|
||||||
|
# At least for glibc, clock_gettime is in librt. But don't
|
||||||
|
# pull that in if it still doesn't give us the function we want. This
|
||||||
|
# test is copied from libgomp, and modified to not link in -lrt as
|
||||||
|
# we're using this for test timing only.
|
||||||
|
if test "$ac_cv_func_clock_gettime" = no; then
|
||||||
|
AC_CHECK_LIB(rt, clock_gettime,
|
||||||
|
[CLOCK_GETTIME_LINK=-lrt
|
||||||
|
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
|
||||||
|
[Define to 1 if you have the `clock_gettime' function.])])
|
||||||
|
fi
|
||||||
|
AC_SUBST(CLOCK_GETTIME_LINK)
|
||||||
|
|
||||||
|
dnl Test whether the compiler supports the -pthread option.
|
||||||
|
AC_CACHE_CHECK([whether -pthread is supported],
|
||||||
|
[libgo_cv_lib_pthread],
|
||||||
|
[CFLAGS_hold=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS -pthread"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])],
|
||||||
|
[libgo_cv_lib_pthread=yes],
|
||||||
|
[libgo_cv_lib_pthread=no])
|
||||||
|
CFLAGS=$CFLAGS_hold])
|
||||||
|
PTHREAD_CFLAGS=
|
||||||
|
if test "$libgo_cv_lib_pthread" = yes; then
|
||||||
|
PTHREAD_CFLAGS=-pthread
|
||||||
|
fi
|
||||||
|
AC_SUBST(PTHREAD_CFLAGS)
|
||||||
|
|
||||||
|
AM_CONDITIONAL(HAVE_PTHREAD, test "$libgo_cv_lib_pthread" = yes)
|
||||||
|
|
||||||
|
dnl Test whether the compiler and the linker support the -gdwarf-5 option.
|
||||||
|
AC_CACHE_CHECK([whether -gdwarf-5 is supported],
|
||||||
|
[libbacktrace_cv_lib_dwarf5],
|
||||||
|
[CFLAGS_hold=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS -gdwarf-5"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;], [return 0;])],
|
||||||
|
[libbacktrace_cv_lib_dwarf5=yes],
|
||||||
|
[libbacktrace_cv_lib_dwarf5=no])
|
||||||
|
CFLAGS=$CFLAGS_hold])
|
||||||
|
AM_CONDITIONAL(HAVE_DWARF5, test "$libbacktrace_cv_lib_dwarf5" = yes)
|
||||||
|
|
||||||
|
AC_CHECK_LIB([z], [compress],
|
||||||
|
[AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
|
||||||
|
AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
|
||||||
|
|
||||||
|
dnl Test whether the linker supports the --build-id option.
|
||||||
|
AC_CACHE_CHECK([whether --build-id is supported],
|
||||||
|
[libbacktrace_cv_ld_buildid],
|
||||||
|
[LDFLAGS_hold=$LDFLAGS
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--build-id"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
||||||
|
[libbacktrace_cv_ld_buildid=yes],
|
||||||
|
[libbacktrace_cv_ld_buildid=no])
|
||||||
|
LDFLAGS=$LDFLAGS_hold])
|
||||||
|
AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
|
||||||
|
|
||||||
|
dnl Test whether the linker supports the --compress-debug-sections option.
|
||||||
|
AC_CACHE_CHECK([whether --compress-debug-sections is supported],
|
||||||
|
[libgo_cv_ld_compress],
|
||||||
|
[LDFLAGS_hold=$LDFLAGS
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zlib-gnu"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
||||||
|
[libgo_cv_ld_compress=yes],
|
||||||
|
[libgo_cv_ld_compress=no])
|
||||||
|
LDFLAGS=$LDFLAGS_hold])
|
||||||
|
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG, test "$libgo_cv_ld_compress" = yes)
|
||||||
|
|
||||||
|
AC_CHECK_LIB([zstd], [ZSTD_compress],
|
||||||
|
[AC_DEFINE(HAVE_ZSTD, 1, [Define if -lzstd is available.])])
|
||||||
|
AM_CONDITIONAL(HAVE_ZSTD, test "$ac_cv_lib_zstd_ZSTD_compress" = yes)
|
||||||
|
|
||||||
|
dnl Test whether the linker supports --compress-debug-sections=zstd option.
|
||||||
|
AC_CACHE_CHECK([whether --compress-debug-sections=zstd is supported],
|
||||||
|
[libgo_cv_ld_compress_zstd],
|
||||||
|
[LDFLAGS_hold=$LDFLAGS
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--compress-debug-sections=zstd"
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
|
||||||
|
[libgo_cv_ld_compress_zstd=yes],
|
||||||
|
[libgo_cv_ld_compress_zstd=no])
|
||||||
|
LDFLAGS=$LDFLAGS_hold])
|
||||||
|
AM_CONDITIONAL(HAVE_COMPRESSED_DEBUG_ZSTD, test "$libgo_cv_ld_compress_zstd" = yes)
|
||||||
|
|
||||||
|
AC_ARG_VAR(OBJCOPY, [location of objcopy])
|
||||||
|
AC_CHECK_PROG(OBJCOPY, objcopy, objcopy,)
|
||||||
|
AC_CHECK_PROG(READELF, readelf, readelf)
|
||||||
|
AC_CACHE_CHECK([whether objcopy supports debuglink],
|
||||||
|
[libbacktrace_cv_objcopy_debuglink],
|
||||||
|
[if test -n "${with_target_subdir}"; then
|
||||||
|
libbacktrace_cv_objcopy_debuglink=no
|
||||||
|
elif ! test -n "${OBJCOPY}"; then
|
||||||
|
libbacktrace_cv_objcopy_debuglink=no
|
||||||
|
elif ${OBJCOPY} --help | grep add-gnu-debuglink >/dev/null 2>&1; then
|
||||||
|
libbacktrace_cv_objcopy_debuglink=yes
|
||||||
|
else
|
||||||
|
libbacktrace_cv_objcopy_debuglink=no
|
||||||
|
fi])
|
||||||
|
AM_CONDITIONAL(HAVE_OBJCOPY_DEBUGLINK, test "$libbacktrace_cv_objcopy_debuglink" = yes)
|
||||||
|
|
||||||
|
AC_ARG_VAR(DSYMUTIL, [location of dsymutil])
|
||||||
|
AC_CHECK_PROG(DSYMUTIL, dsymutil, dsymutil)
|
||||||
|
AM_CONDITIONAL(USE_DSYMUTIL, test -n "${DSYMUTIL}" -a "$FORMAT_FILE" = "macho.lo")
|
||||||
|
|
||||||
|
AC_ARG_VAR(NM, [location of nm])
|
||||||
|
AC_CHECK_PROG(NM, nm, nm)
|
||||||
|
|
||||||
|
AC_CHECK_PROG(XZ, xz, xz)
|
||||||
|
AM_CONDITIONAL(HAVE_XZ, test "$XZ" != "")
|
||||||
|
AC_CHECK_PROG(COMM, comm, comm)
|
||||||
|
AM_CONDITIONAL(HAVE_COMM, test "$COMM" != "")
|
||||||
|
|
||||||
|
AM_CONDITIONAL(HAVE_MINIDEBUG,
|
||||||
|
test "${with_target_subdir}" = "" -a "$FORMAT_FILE" = "elf.lo" -a "${OBJCOPY}" != "" -a "${NM}" != "" -a "${XZ}" != "" -a "${COMM}" != "")
|
||||||
|
|
||||||
|
AC_CHECK_LIB([lzma], [lzma_auto_decoder],
|
||||||
|
[AC_DEFINE(HAVE_LIBLZMA, 1, [Define if -llzma is available.])])
|
||||||
|
AM_CONDITIONAL(HAVE_LIBLZMA, test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes)
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([whether tests can run],
|
||||||
|
[libbacktrace_cv_sys_native],
|
||||||
|
[AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
|
||||||
|
[libbacktrace_cv_sys_native=yes],
|
||||||
|
[libbacktrace_cv_sys_native=no],
|
||||||
|
[libbacktrace_cv_sys_native=no])])
|
||||||
|
AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes")
|
||||||
|
|
||||||
|
if test "${multilib}" = "yes"; then
|
||||||
|
multilib_arg="--enable-multilib"
|
||||||
|
else
|
||||||
|
multilib_arg=
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CONFIG_FILES(Makefile backtrace-supported.h)
|
||||||
|
AC_CONFIG_FILES(install-debuginfo-for-buildid.sh, chmod +x install-debuginfo-for-buildid.sh)
|
||||||
|
|
||||||
|
# We need multilib support, but only if configuring for the target.
|
||||||
|
AC_CONFIG_COMMANDS([default],
|
||||||
|
[if test -n "$CONFIG_FILES"; then
|
||||||
|
if test -n "${with_target_subdir}"; then
|
||||||
|
# Multilibs need MULTISUBDIR defined correctly in certain makefiles so
|
||||||
|
# that multilib installs will end up installed in the correct place.
|
||||||
|
# The testsuite needs it for multilib-aware ABI baseline files.
|
||||||
|
# To work around this not being passed down from config-ml.in ->
|
||||||
|
# srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
|
||||||
|
# append it here. Only modify Makefiles that have just been created.
|
||||||
|
#
|
||||||
|
# Also, get rid of this simulated-VPATH thing that automake does.
|
||||||
|
cat > vpsed << \_EOF
|
||||||
|
s!`test -f '$<' || echo '$(srcdir)/'`!!
|
||||||
|
_EOF
|
||||||
|
for i in $SUBDIRS; do
|
||||||
|
case $CONFIG_FILES in
|
||||||
|
*${i}/Makefile*)
|
||||||
|
#echo "Adding MULTISUBDIR to $i/Makefile"
|
||||||
|
sed -f vpsed $i/Makefile > tmp
|
||||||
|
grep '^MULTISUBDIR =' Makefile >> tmp
|
||||||
|
mv tmp $i/Makefile
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
rm vpsed
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
],
|
||||||
|
[
|
||||||
|
# Variables needed in config.status (file generation) which aren't already
|
||||||
|
# passed by autoconf.
|
||||||
|
SUBDIRS="$SUBDIRS"
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
4402
deps/libbacktrace/dwarf.c
vendored
Normal file
4402
deps/libbacktrace/dwarf.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
120
deps/libbacktrace/edtest.c
vendored
Normal file
120
deps/libbacktrace/edtest.c
vendored
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* edtest.c -- Test for libbacktrace storage allocation stress handling
|
||||||
|
Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
static int test1 (void) __attribute__ ((noinline, noclone, unused));
|
||||||
|
extern int f2 (int);
|
||||||
|
extern int f3 (int, int);
|
||||||
|
|
||||||
|
static int
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
/* Returning a value here and elsewhere avoids a tailcall which
|
||||||
|
would mess up the backtrace. */
|
||||||
|
return f2 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
f3 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.all = &all[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_full (state, 0, callback_one, error_callback_one, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index < 3)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test1: not enough frames; got %zu, expected at least 3\n",
|
||||||
|
data.index);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test1", 0, all, f3line, "f3", "edtest.c", &data.failed);
|
||||||
|
check ("test1", 1, all, f2line, "f2", "edtest2_build.c", &data.failed);
|
||||||
|
check ("test1", 2, all, f1line, "test1", "edtest.c", &data.failed);
|
||||||
|
|
||||||
|
printf ("%s: backtrace_full alloc stress\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
// Grab the storage allocation lock prior to doing anything interesting.
|
||||||
|
// The intent here is to insure that the backtrace_alloc code is forced
|
||||||
|
// to always call mmap() for new memory as opposed to reusing previously
|
||||||
|
// allocated memory from the free list. Doing things this way helps
|
||||||
|
// simulate what you might see in a multithreaded program in which there
|
||||||
|
// are racing calls to the allocator.
|
||||||
|
struct backtrace_state *state_internal =
|
||||||
|
(struct backtrace_state *) state;
|
||||||
|
state_internal->lock_alloc = 1;
|
||||||
|
|
||||||
|
// Kick off the test
|
||||||
|
test1();
|
||||||
|
|
||||||
|
exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
43
deps/libbacktrace/edtest2.c
vendored
Normal file
43
deps/libbacktrace/edtest2.c
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* edtest2.c -- Test for libbacktrace storage allocation stress handling (p2)
|
||||||
|
Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* This file intentionally written without any #include's
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int f3(int, int);
|
||||||
|
extern int f2(int);
|
||||||
|
|
||||||
|
int f2(int x)
|
||||||
|
{
|
||||||
|
/* Returning a value here and elsewhere avoids a tailcall which
|
||||||
|
would mess up the backtrace. */
|
||||||
|
return f3(x, __LINE__) + 3;
|
||||||
|
}
|
7443
deps/libbacktrace/elf.c
vendored
Normal file
7443
deps/libbacktrace/elf.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
361
deps/libbacktrace/fileline.c
vendored
Normal file
361
deps/libbacktrace/fileline.c
vendored
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
/* fileline.c -- Get file and line number information in a backtrace.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if defined (HAVE_KERN_PROC_ARGS) || defined (HAVE_KERN_PROC)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_MACH_O_DYLD_H
|
||||||
|
#include <mach-o/dyld.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_GETEXECNAME
|
||||||
|
#define getexecname() NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined (HAVE_KERN_PROC_ARGS) && !defined (HAVE_KERN_PROC)
|
||||||
|
|
||||||
|
#define sysctl_exec_name1(state, error_callback, data) NULL
|
||||||
|
#define sysctl_exec_name2(state, error_callback, data) NULL
|
||||||
|
|
||||||
|
#else /* defined (HAVE_KERN_PROC_ARGS) || |defined (HAVE_KERN_PROC) */
|
||||||
|
|
||||||
|
static char *
|
||||||
|
sysctl_exec_name (struct backtrace_state *state,
|
||||||
|
int mib0, int mib1, int mib2, int mib3,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
int mib[4];
|
||||||
|
size_t len;
|
||||||
|
char *name;
|
||||||
|
size_t rlen;
|
||||||
|
|
||||||
|
mib[0] = mib0;
|
||||||
|
mib[1] = mib1;
|
||||||
|
mib[2] = mib2;
|
||||||
|
mib[3] = mib3;
|
||||||
|
|
||||||
|
if (sysctl (mib, 4, NULL, &len, NULL, 0) < 0)
|
||||||
|
return NULL;
|
||||||
|
name = (char *) backtrace_alloc (state, len, error_callback, data);
|
||||||
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
rlen = len;
|
||||||
|
if (sysctl (mib, 4, name, &rlen, NULL, 0) < 0)
|
||||||
|
{
|
||||||
|
backtrace_free (state, name, len, error_callback, data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_KERN_PROC_ARGS
|
||||||
|
|
||||||
|
static char *
|
||||||
|
sysctl_exec_name1 (struct backtrace_state *state,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
/* This variant is used on NetBSD. */
|
||||||
|
return sysctl_exec_name (state, CTL_KERN, KERN_PROC_ARGS, -1,
|
||||||
|
KERN_PROC_PATHNAME, error_callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define sysctl_exec_name1(state, error_callback, data) NULL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_KERN_PROC
|
||||||
|
|
||||||
|
static char *
|
||||||
|
sysctl_exec_name2 (struct backtrace_state *state,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
/* This variant is used on FreeBSD. */
|
||||||
|
return sysctl_exec_name (state, CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
|
||||||
|
error_callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define sysctl_exec_name2(state, error_callback, data) NULL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* defined (HAVE_KERN_PROC_ARGS) || |defined (HAVE_KERN_PROC) */
|
||||||
|
|
||||||
|
#ifdef HAVE_MACH_O_DYLD_H
|
||||||
|
|
||||||
|
static char *
|
||||||
|
macho_get_executable_path (struct backtrace_state *state,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
uint32_t len;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
if (_NSGetExecutablePath (NULL, &len) == 0)
|
||||||
|
return NULL;
|
||||||
|
name = (char *) backtrace_alloc (state, len, error_callback, data);
|
||||||
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (_NSGetExecutablePath (name, &len) != 0)
|
||||||
|
{
|
||||||
|
backtrace_free (state, name, len, error_callback, data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* !defined (HAVE_MACH_O_DYLD_H) */
|
||||||
|
|
||||||
|
#define macho_get_executable_path(state, error_callback, data) NULL
|
||||||
|
|
||||||
|
#endif /* !defined (HAVE_MACH_O_DYLD_H) */
|
||||||
|
|
||||||
|
#if HAVE_DECL__PGMPTR
|
||||||
|
|
||||||
|
#define windows_executable_filename() _pgmptr
|
||||||
|
|
||||||
|
#else /* !HAVE_DECL__PGMPTR */
|
||||||
|
|
||||||
|
#define windows_executable_filename() NULL
|
||||||
|
|
||||||
|
#endif /* !HAVE_DECL__PGMPTR */
|
||||||
|
|
||||||
|
/* Initialize the fileline information from the executable. Returns 1
|
||||||
|
on success, 0 on failure. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
fileline_initialize (struct backtrace_state *state,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
int failed;
|
||||||
|
fileline fileline_fn;
|
||||||
|
int pass;
|
||||||
|
int called_error_callback;
|
||||||
|
int descriptor;
|
||||||
|
const char *filename;
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
failed = state->fileline_initialization_failed;
|
||||||
|
else
|
||||||
|
failed = backtrace_atomic_load_int (&state->fileline_initialization_failed);
|
||||||
|
|
||||||
|
if (failed)
|
||||||
|
{
|
||||||
|
error_callback (data, "failed to read executable information", -1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
fileline_fn = state->fileline_fn;
|
||||||
|
else
|
||||||
|
fileline_fn = backtrace_atomic_load_pointer (&state->fileline_fn);
|
||||||
|
if (fileline_fn != NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* We have not initialized the information. Do it now. */
|
||||||
|
|
||||||
|
descriptor = -1;
|
||||||
|
called_error_callback = 0;
|
||||||
|
for (pass = 0; pass < 9; ++pass)
|
||||||
|
{
|
||||||
|
int does_not_exist;
|
||||||
|
|
||||||
|
switch (pass)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
filename = state->filename;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
filename = getexecname ();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
/* Test this before /proc/self/exe, as the latter exists but points
|
||||||
|
to the wine binary (and thus doesn't work). */
|
||||||
|
filename = windows_executable_filename ();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
filename = "/proc/self/exe";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
filename = "/proc/curproc/file";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
snprintf (buf, sizeof (buf), "/proc/%ld/object/a.out",
|
||||||
|
(long) getpid ());
|
||||||
|
filename = buf;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
filename = sysctl_exec_name1 (state, error_callback, data);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
filename = sysctl_exec_name2 (state, error_callback, data);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
filename = macho_get_executable_path (state, error_callback, data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
descriptor = backtrace_open (filename, error_callback, data,
|
||||||
|
&does_not_exist);
|
||||||
|
if (descriptor < 0 && !does_not_exist)
|
||||||
|
{
|
||||||
|
called_error_callback = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (descriptor >= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descriptor < 0)
|
||||||
|
{
|
||||||
|
if (!called_error_callback)
|
||||||
|
{
|
||||||
|
if (state->filename != NULL)
|
||||||
|
error_callback (data, state->filename, ENOENT);
|
||||||
|
else
|
||||||
|
error_callback (data,
|
||||||
|
"libbacktrace could not find executable to open",
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!failed)
|
||||||
|
{
|
||||||
|
if (!backtrace_initialize (state, filename, descriptor, error_callback,
|
||||||
|
data, &fileline_fn))
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed)
|
||||||
|
{
|
||||||
|
if (!state->threaded)
|
||||||
|
state->fileline_initialization_failed = 1;
|
||||||
|
else
|
||||||
|
backtrace_atomic_store_int (&state->fileline_initialization_failed, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
state->fileline_fn = fileline_fn;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backtrace_atomic_store_pointer (&state->fileline_fn, fileline_fn);
|
||||||
|
|
||||||
|
/* Note that if two threads initialize at once, one of the data
|
||||||
|
sets may be leaked. */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Given a PC, find the file name, line number, and function name. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc,
|
||||||
|
backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
if (!fileline_initialize (state, error_callback, data))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (state->fileline_initialization_failed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return state->fileline_fn (state, pc, callback, error_callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Given a PC, find the symbol for it, and its value. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_syminfo (struct backtrace_state *state, uintptr_t pc,
|
||||||
|
backtrace_syminfo_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
if (!fileline_initialize (state, error_callback, data))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (state->fileline_initialization_failed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
state->syminfo_fn (state, pc, callback, error_callback, data);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A backtrace_syminfo_callback that can call into a
|
||||||
|
backtrace_full_callback, used when we have a symbol table but no
|
||||||
|
debug info. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_syminfo_to_full_callback (void *data, uintptr_t pc,
|
||||||
|
const char *symname,
|
||||||
|
uintptr_t symval ATTRIBUTE_UNUSED,
|
||||||
|
uintptr_t symsize ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
struct backtrace_call_full *bdata = (struct backtrace_call_full *) data;
|
||||||
|
|
||||||
|
bdata->ret = bdata->full_callback (bdata->full_data, pc, NULL, 0, symname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An error callback that corresponds to
|
||||||
|
backtrace_syminfo_to_full_callback. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_syminfo_to_full_error_callback (void *data, const char *msg,
|
||||||
|
int errnum)
|
||||||
|
{
|
||||||
|
struct backtrace_call_full *bdata = (struct backtrace_call_full *) data;
|
||||||
|
|
||||||
|
bdata->full_error_callback (bdata->full_data, msg, errnum);
|
||||||
|
}
|
52
deps/libbacktrace/filenames.h
vendored
Normal file
52
deps/libbacktrace/filenames.h
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* btest.c -- Filename header for libbacktrace library
|
||||||
|
Copyright (C) 2012-2018 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
#ifndef GCC_VERSION
|
||||||
|
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (GCC_VERSION < 2007)
|
||||||
|
# define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
|
||||||
|
# define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
|
||||||
|
# define HAS_DRIVE_SPEC(f) ((f)[0] != '\0' && (f)[1] == ':')
|
||||||
|
# define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || HAS_DRIVE_SPEC(f))
|
||||||
|
#else
|
||||||
|
# define IS_DIR_SEPARATOR(c) ((c) == '/')
|
||||||
|
# define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
|
||||||
|
#endif
|
13
deps/libbacktrace/filetype.awk
vendored
Normal file
13
deps/libbacktrace/filetype.awk
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# An awk script to determine the type of a file.
|
||||||
|
/^\177ELF\001/ { if (NR == 1) { print "elf32"; exit } }
|
||||||
|
/^\177ELF\002/ { if (NR == 1) { print "elf64"; exit } }
|
||||||
|
/^\114\001/ { if (NR == 1) { print "pecoff"; exit } }
|
||||||
|
/^\144\206/ { if (NR == 1) { print "pecoff"; exit } }
|
||||||
|
/^\001\337/ { if (NR == 1) { print "xcoff32"; exit } }
|
||||||
|
/^\001\367/ { if (NR == 1) { print "xcoff64"; exit } }
|
||||||
|
/^\376\355\372\316/ { if (NR == 1) { print "macho"; exit } }
|
||||||
|
/^\316\372\355\376/ { if (NR == 1) { print "macho"; exit } }
|
||||||
|
/^\376\355\372\317/ { if (NR == 1) { print "macho"; exit } }
|
||||||
|
/^\317\372\355\376/ { if (NR == 1) { print "macho"; exit } }
|
||||||
|
/^\312\376\272\276/ { if (NR == 1) { print "macho"; exit } }
|
||||||
|
/^\276\272\376\312/ { if (NR == 1) { print "macho"; exit } }
|
65
deps/libbacktrace/install-debuginfo-for-buildid.sh.in
vendored
Normal file
65
deps/libbacktrace/install-debuginfo-for-buildid.sh.in
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# install-debug-info-for-buildid.sh -- Helper script for libbacktrace library
|
||||||
|
# testing.
|
||||||
|
# Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# 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) 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.
|
||||||
|
|
||||||
|
# Extract build-id from src, and copy debug info of src to
|
||||||
|
# $build_id_dir/aa/bb...zz.debug.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sed=@SED@
|
||||||
|
awk=@AWK@
|
||||||
|
grep=@GREP@
|
||||||
|
objcopy=@OBJCOPY@
|
||||||
|
readelf=@READELF@
|
||||||
|
mkdir_p="@MKDIR_P@"
|
||||||
|
|
||||||
|
build_id_dir="$1"
|
||||||
|
src="$2"
|
||||||
|
|
||||||
|
buildid=$($readelf -n $src \
|
||||||
|
| $grep "Build ID" \
|
||||||
|
| $awk '{print $3}')
|
||||||
|
|
||||||
|
prefix=$(echo $buildid \
|
||||||
|
| $sed 's/^\(.\{2\}\).*/\1/')
|
||||||
|
|
||||||
|
remainder=$(echo $buildid \
|
||||||
|
| $sed 's/^.\{2\}//')
|
||||||
|
|
||||||
|
dir=$build_id_dir/$prefix
|
||||||
|
dst=$dir/$remainder.debug
|
||||||
|
|
||||||
|
$mkdir_p $dir
|
||||||
|
|
||||||
|
$objcopy --only-keep-debug $src $dst
|
501
deps/libbacktrace/install-sh
vendored
Executable file
501
deps/libbacktrace/install-sh
vendored
Executable file
@ -0,0 +1,501 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
|
||||||
|
scriptversion=2013-12-25.23; # UTC
|
||||||
|
|
||||||
|
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||||
|
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||||
|
# following copyright and license.
|
||||||
|
#
|
||||||
|
# Copyright (C) 1994 X Consortium
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to
|
||||||
|
# deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
# sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||||
|
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# Except as contained in this notice, the name of the X Consortium shall not
|
||||||
|
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||||
|
# ings in this Software without prior written authorization from the X Consor-
|
||||||
|
# tium.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# FSF changes to this file are in the public domain.
|
||||||
|
#
|
||||||
|
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||||
|
# 'make' implicit rules from creating a file called install from it
|
||||||
|
# when there is no Makefile.
|
||||||
|
#
|
||||||
|
# This script is compatible with the BSD install script, but was written
|
||||||
|
# from scratch.
|
||||||
|
|
||||||
|
tab=' '
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
IFS=" $tab$nl"
|
||||||
|
|
||||||
|
# Set DOITPROG to "echo" to test this script.
|
||||||
|
|
||||||
|
doit=${DOITPROG-}
|
||||||
|
doit_exec=${doit:-exec}
|
||||||
|
|
||||||
|
# Put in absolute file names if you don't have them in your path;
|
||||||
|
# or use environment vars.
|
||||||
|
|
||||||
|
chgrpprog=${CHGRPPROG-chgrp}
|
||||||
|
chmodprog=${CHMODPROG-chmod}
|
||||||
|
chownprog=${CHOWNPROG-chown}
|
||||||
|
cmpprog=${CMPPROG-cmp}
|
||||||
|
cpprog=${CPPROG-cp}
|
||||||
|
mkdirprog=${MKDIRPROG-mkdir}
|
||||||
|
mvprog=${MVPROG-mv}
|
||||||
|
rmprog=${RMPROG-rm}
|
||||||
|
stripprog=${STRIPPROG-strip}
|
||||||
|
|
||||||
|
posix_mkdir=
|
||||||
|
|
||||||
|
# Desired mode of installed file.
|
||||||
|
mode=0755
|
||||||
|
|
||||||
|
chgrpcmd=
|
||||||
|
chmodcmd=$chmodprog
|
||||||
|
chowncmd=
|
||||||
|
mvcmd=$mvprog
|
||||||
|
rmcmd="$rmprog -f"
|
||||||
|
stripcmd=
|
||||||
|
|
||||||
|
src=
|
||||||
|
dst=
|
||||||
|
dir_arg=
|
||||||
|
dst_arg=
|
||||||
|
|
||||||
|
copy_on_change=false
|
||||||
|
is_target_a_directory=possibly
|
||||||
|
|
||||||
|
usage="\
|
||||||
|
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||||
|
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||||
|
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||||
|
or: $0 [OPTION]... -d DIRECTORIES...
|
||||||
|
|
||||||
|
In the 1st form, copy SRCFILE to DSTFILE.
|
||||||
|
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||||
|
In the 4th, create DIRECTORIES.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--help display this help and exit.
|
||||||
|
--version display version info and exit.
|
||||||
|
|
||||||
|
-c (ignored)
|
||||||
|
-C install only if different (preserve the last data modification time)
|
||||||
|
-d create directories instead of installing files.
|
||||||
|
-g GROUP $chgrpprog installed files to GROUP.
|
||||||
|
-m MODE $chmodprog installed files to MODE.
|
||||||
|
-o USER $chownprog installed files to USER.
|
||||||
|
-s $stripprog installed files.
|
||||||
|
-t DIRECTORY install into DIRECTORY.
|
||||||
|
-T report an error if DSTFILE is a directory.
|
||||||
|
|
||||||
|
Environment variables override the default commands:
|
||||||
|
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||||
|
RMPROG STRIPPROG
|
||||||
|
"
|
||||||
|
|
||||||
|
while test $# -ne 0; do
|
||||||
|
case $1 in
|
||||||
|
-c) ;;
|
||||||
|
|
||||||
|
-C) copy_on_change=true;;
|
||||||
|
|
||||||
|
-d) dir_arg=true;;
|
||||||
|
|
||||||
|
-g) chgrpcmd="$chgrpprog $2"
|
||||||
|
shift;;
|
||||||
|
|
||||||
|
--help) echo "$usage"; exit $?;;
|
||||||
|
|
||||||
|
-m) mode=$2
|
||||||
|
case $mode in
|
||||||
|
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
|
||||||
|
echo "$0: invalid mode: $mode" >&2
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
shift;;
|
||||||
|
|
||||||
|
-o) chowncmd="$chownprog $2"
|
||||||
|
shift;;
|
||||||
|
|
||||||
|
-s) stripcmd=$stripprog;;
|
||||||
|
|
||||||
|
-t)
|
||||||
|
is_target_a_directory=always
|
||||||
|
dst_arg=$2
|
||||||
|
# Protect names problematic for 'test' and other utilities.
|
||||||
|
case $dst_arg in
|
||||||
|
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||||
|
esac
|
||||||
|
shift;;
|
||||||
|
|
||||||
|
-T) is_target_a_directory=never;;
|
||||||
|
|
||||||
|
--version) echo "$0 $scriptversion"; exit $?;;
|
||||||
|
|
||||||
|
--) shift
|
||||||
|
break;;
|
||||||
|
|
||||||
|
-*) echo "$0: invalid option: $1" >&2
|
||||||
|
exit 1;;
|
||||||
|
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# We allow the use of options -d and -T together, by making -d
|
||||||
|
# take the precedence; this is for compatibility with GNU install.
|
||||||
|
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
if test -n "$dst_arg"; then
|
||||||
|
echo "$0: target directory not allowed when installing a directory." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||||
|
# When -d is used, all remaining arguments are directories to create.
|
||||||
|
# When -t is used, the destination is already specified.
|
||||||
|
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$dst_arg"; then
|
||||||
|
# $@ is not empty: it contains at least $arg.
|
||||||
|
set fnord "$@" "$dst_arg"
|
||||||
|
shift # fnord
|
||||||
|
fi
|
||||||
|
shift # arg
|
||||||
|
dst_arg=$arg
|
||||||
|
# Protect names problematic for 'test' and other utilities.
|
||||||
|
case $dst_arg in
|
||||||
|
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
if test -z "$dir_arg"; then
|
||||||
|
echo "$0: no input file specified." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# It's OK to call 'install-sh -d' without argument.
|
||||||
|
# This can happen when creating conditional directories.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$dir_arg"; then
|
||||||
|
if test $# -gt 1 || test "$is_target_a_directory" = always; then
|
||||||
|
if test ! -d "$dst_arg"; then
|
||||||
|
echo "$0: $dst_arg: Is not a directory." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$dir_arg"; then
|
||||||
|
do_exit='(exit $ret); exit $ret'
|
||||||
|
trap "ret=129; $do_exit" 1
|
||||||
|
trap "ret=130; $do_exit" 2
|
||||||
|
trap "ret=141; $do_exit" 13
|
||||||
|
trap "ret=143; $do_exit" 15
|
||||||
|
|
||||||
|
# Set umask so as not to create temps with too-generous modes.
|
||||||
|
# However, 'strip' requires both read and write access to temps.
|
||||||
|
case $mode in
|
||||||
|
# Optimize common cases.
|
||||||
|
*644) cp_umask=133;;
|
||||||
|
*755) cp_umask=22;;
|
||||||
|
|
||||||
|
*[0-7])
|
||||||
|
if test -z "$stripcmd"; then
|
||||||
|
u_plus_rw=
|
||||||
|
else
|
||||||
|
u_plus_rw='% 200'
|
||||||
|
fi
|
||||||
|
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||||
|
*)
|
||||||
|
if test -z "$stripcmd"; then
|
||||||
|
u_plus_rw=
|
||||||
|
else
|
||||||
|
u_plus_rw=,u+rw
|
||||||
|
fi
|
||||||
|
cp_umask=$mode$u_plus_rw;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
for src
|
||||||
|
do
|
||||||
|
# Protect names problematic for 'test' and other utilities.
|
||||||
|
case $src in
|
||||||
|
-* | [=\(\)!]) src=./$src;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
dst=$src
|
||||||
|
dstdir=$dst
|
||||||
|
test -d "$dstdir"
|
||||||
|
dstdir_status=$?
|
||||||
|
else
|
||||||
|
|
||||||
|
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||||
|
# might cause directories to be created, which would be especially bad
|
||||||
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
if test ! -f "$src" && test ! -d "$src"; then
|
||||||
|
echo "$0: $src does not exist." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$dst_arg"; then
|
||||||
|
echo "$0: no destination specified." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
dst=$dst_arg
|
||||||
|
|
||||||
|
# If destination is a directory, append the input filename; won't work
|
||||||
|
# if double slashes aren't ignored.
|
||||||
|
if test -d "$dst"; then
|
||||||
|
if test "$is_target_a_directory" = never; then
|
||||||
|
echo "$0: $dst_arg: Is a directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
dstdir=$dst
|
||||||
|
dst=$dstdir/`basename "$src"`
|
||||||
|
dstdir_status=0
|
||||||
|
else
|
||||||
|
dstdir=`dirname "$dst"`
|
||||||
|
test -d "$dstdir"
|
||||||
|
dstdir_status=$?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
obsolete_mkdir_used=false
|
||||||
|
|
||||||
|
if test $dstdir_status != 0; then
|
||||||
|
case $posix_mkdir in
|
||||||
|
'')
|
||||||
|
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||||
|
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||||
|
umask=`umask`
|
||||||
|
case $stripcmd.$umask in
|
||||||
|
# Optimize common cases.
|
||||||
|
*[2367][2367]) mkdir_umask=$umask;;
|
||||||
|
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||||
|
|
||||||
|
*[0-7])
|
||||||
|
mkdir_umask=`expr $umask + 22 \
|
||||||
|
- $umask % 100 % 40 + $umask % 20 \
|
||||||
|
- $umask % 10 % 4 + $umask % 2
|
||||||
|
`;;
|
||||||
|
*) mkdir_umask=$umask,go-w;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# With -d, create the new directory with the user-specified mode.
|
||||||
|
# Otherwise, rely on $mkdir_umask.
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
mkdir_mode=-m$mode
|
||||||
|
else
|
||||||
|
mkdir_mode=
|
||||||
|
fi
|
||||||
|
|
||||||
|
posix_mkdir=false
|
||||||
|
case $umask in
|
||||||
|
*[123567][0-7][0-7])
|
||||||
|
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||||
|
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||||
|
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||||
|
|
||||||
|
if (umask $mkdir_umask &&
|
||||||
|
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
if test -z "$dir_arg" || {
|
||||||
|
# Check for POSIX incompatibilities with -m.
|
||||||
|
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||||
|
# other-writable bit of parent directory when it shouldn't.
|
||||||
|
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||||
|
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||||
|
case $ls_ld_tmpdir in
|
||||||
|
d????-?r-*) different_mode=700;;
|
||||||
|
d????-?--*) different_mode=755;;
|
||||||
|
*) false;;
|
||||||
|
esac &&
|
||||||
|
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||||
|
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||||
|
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
then posix_mkdir=:
|
||||||
|
fi
|
||||||
|
rmdir "$tmpdir/d" "$tmpdir"
|
||||||
|
else
|
||||||
|
# Remove any dirs left behind by ancient mkdir implementations.
|
||||||
|
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||||
|
fi
|
||||||
|
trap '' 0;;
|
||||||
|
esac;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if
|
||||||
|
$posix_mkdir && (
|
||||||
|
umask $mkdir_umask &&
|
||||||
|
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||||
|
)
|
||||||
|
then :
|
||||||
|
else
|
||||||
|
|
||||||
|
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||||
|
# or it failed possibly due to a race condition. Create the
|
||||||
|
# directory the slow way, step by step, checking for races as we go.
|
||||||
|
|
||||||
|
case $dstdir in
|
||||||
|
/*) prefix='/';;
|
||||||
|
[-=\(\)!]*) prefix='./';;
|
||||||
|
*) prefix='';;
|
||||||
|
esac
|
||||||
|
|
||||||
|
oIFS=$IFS
|
||||||
|
IFS=/
|
||||||
|
set -f
|
||||||
|
set fnord $dstdir
|
||||||
|
shift
|
||||||
|
set +f
|
||||||
|
IFS=$oIFS
|
||||||
|
|
||||||
|
prefixes=
|
||||||
|
|
||||||
|
for d
|
||||||
|
do
|
||||||
|
test X"$d" = X && continue
|
||||||
|
|
||||||
|
prefix=$prefix$d
|
||||||
|
if test -d "$prefix"; then
|
||||||
|
prefixes=
|
||||||
|
else
|
||||||
|
if $posix_mkdir; then
|
||||||
|
(umask=$mkdir_umask &&
|
||||||
|
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||||
|
# Don't fail if two instances are running concurrently.
|
||||||
|
test -d "$prefix" || exit 1
|
||||||
|
else
|
||||||
|
case $prefix in
|
||||||
|
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||||
|
*) qprefix=$prefix;;
|
||||||
|
esac
|
||||||
|
prefixes="$prefixes '$qprefix'"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
prefix=$prefix/
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -n "$prefixes"; then
|
||||||
|
# Don't fail if two instances are running concurrently.
|
||||||
|
(umask $mkdir_umask &&
|
||||||
|
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||||
|
test -d "$dstdir" || exit 1
|
||||||
|
obsolete_mkdir_used=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||||
|
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||||
|
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||||
|
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||||
|
else
|
||||||
|
|
||||||
|
# Make a couple of temp file names in the proper directory.
|
||||||
|
dsttmp=$dstdir/_inst.$$_
|
||||||
|
rmtmp=$dstdir/_rm.$$_
|
||||||
|
|
||||||
|
# Trap to clean up those temp files at exit.
|
||||||
|
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||||
|
|
||||||
|
# Copy the file name to the temp name.
|
||||||
|
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||||
|
|
||||||
|
# and set any options; do chmod last to preserve setuid bits.
|
||||||
|
#
|
||||||
|
# If any of these fail, we abort the whole thing. If we want to
|
||||||
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
|
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||||
|
#
|
||||||
|
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||||
|
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||||
|
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||||
|
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||||
|
|
||||||
|
# If -C, don't bother to copy if it wouldn't change the file.
|
||||||
|
if $copy_on_change &&
|
||||||
|
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||||
|
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||||
|
set -f &&
|
||||||
|
set X $old && old=:$2:$4:$5:$6 &&
|
||||||
|
set X $new && new=:$2:$4:$5:$6 &&
|
||||||
|
set +f &&
|
||||||
|
test "$old" = "$new" &&
|
||||||
|
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
rm -f "$dsttmp"
|
||||||
|
else
|
||||||
|
# Rename the file to the real destination.
|
||||||
|
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||||
|
|
||||||
|
# The rename failed, perhaps because mv can't rename something else
|
||||||
|
# to itself, or perhaps because mv is so ancient that it does not
|
||||||
|
# support -f.
|
||||||
|
{
|
||||||
|
# Now remove or move aside any old file at destination location.
|
||||||
|
# We try this two ways since rm can't unlink itself on some
|
||||||
|
# systems and the destination file might be busy for other
|
||||||
|
# reasons. In this case, the final cleanup might fail but the new
|
||||||
|
# file should still install successfully.
|
||||||
|
{
|
||||||
|
test ! -f "$dst" ||
|
||||||
|
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||||
|
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||||
|
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||||
|
} ||
|
||||||
|
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||||
|
(exit 1); exit 1
|
||||||
|
}
|
||||||
|
} &&
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
$doit $mvcmd "$dsttmp" "$dst"
|
||||||
|
}
|
||||||
|
fi || exit 1
|
||||||
|
|
||||||
|
trap '' 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
114
deps/libbacktrace/instrumented_alloc.c
vendored
Normal file
114
deps/libbacktrace/instrumented_alloc.c
vendored
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* instrumented_alloc.c -- Memory allocation instrumented to fail when
|
||||||
|
requested, for testing purposes.
|
||||||
|
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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 all the header files of alloc here, to make sure they're not
|
||||||
|
processed when including alloc.c below, such that the redefinitions of malloc
|
||||||
|
and realloc are only effective in alloc.c itself. This does not work for
|
||||||
|
config.h, because it's not wrapped in "#ifndef CONFIG_H\n#define CONFIG_H"
|
||||||
|
and "#endif" but that does not seem to be harmful. */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
extern void *instrumented_malloc (size_t size);
|
||||||
|
extern void *instrumented_realloc (void *ptr, size_t size);
|
||||||
|
|
||||||
|
#define malloc instrumented_malloc
|
||||||
|
#define realloc instrumented_realloc
|
||||||
|
#include "alloc.c"
|
||||||
|
#undef malloc
|
||||||
|
#undef realloc
|
||||||
|
|
||||||
|
static uint64_t nr_allocs = 0;
|
||||||
|
static uint64_t fail_at_alloc = 0;
|
||||||
|
|
||||||
|
extern int at_fail_alloc_p (void);
|
||||||
|
extern uint64_t get_nr_allocs (void);
|
||||||
|
extern void set_fail_at_alloc (uint64_t);
|
||||||
|
|
||||||
|
void *
|
||||||
|
instrumented_malloc (size_t size)
|
||||||
|
{
|
||||||
|
void *res;
|
||||||
|
|
||||||
|
if (at_fail_alloc_p ())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
res = malloc (size);
|
||||||
|
if (res != NULL)
|
||||||
|
nr_allocs++;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
instrumented_realloc (void *ptr, size_t size)
|
||||||
|
{
|
||||||
|
void *res;
|
||||||
|
|
||||||
|
if (size != 0)
|
||||||
|
{
|
||||||
|
if (at_fail_alloc_p ())
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = realloc (ptr, size);
|
||||||
|
if (res != NULL)
|
||||||
|
nr_allocs++;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
at_fail_alloc_p (void)
|
||||||
|
{
|
||||||
|
return fail_at_alloc == nr_allocs + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t
|
||||||
|
get_nr_allocs (void)
|
||||||
|
{
|
||||||
|
return nr_allocs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_fail_at_alloc (uint64_t nr)
|
||||||
|
{
|
||||||
|
fail_at_alloc = nr;
|
||||||
|
}
|
389
deps/libbacktrace/internal.h
vendored
Normal file
389
deps/libbacktrace/internal.h
vendored
Normal file
@ -0,0 +1,389 @@
|
|||||||
|
/* internal.h -- Internal header file for stack backtrace library.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
#ifndef BACKTRACE_INTERNAL_H
|
||||||
|
#define BACKTRACE_INTERNAL_H
|
||||||
|
|
||||||
|
/* We assume that <sys/types.h> and "backtrace.h" have already been
|
||||||
|
included. */
|
||||||
|
|
||||||
|
#ifndef GCC_VERSION
|
||||||
|
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (GCC_VERSION < 2007)
|
||||||
|
# define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_MALLOC
|
||||||
|
# if (GCC_VERSION >= 2096)
|
||||||
|
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_MALLOC
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_FALLTHROUGH
|
||||||
|
# if (GCC_VERSION >= 7000)
|
||||||
|
# define ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_FALLTHROUGH
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_SYNC_FUNCTIONS
|
||||||
|
|
||||||
|
/* Define out the sync functions. These should never be called if
|
||||||
|
they are not available. */
|
||||||
|
|
||||||
|
#define __sync_bool_compare_and_swap(A, B, C) (abort(), 1)
|
||||||
|
#define __sync_lock_test_and_set(A, B) (abort(), 0)
|
||||||
|
#define __sync_lock_release(A) abort()
|
||||||
|
|
||||||
|
#endif /* !defined (HAVE_SYNC_FUNCTIONS) */
|
||||||
|
|
||||||
|
#ifdef HAVE_ATOMIC_FUNCTIONS
|
||||||
|
|
||||||
|
/* We have the atomic builtin functions. */
|
||||||
|
|
||||||
|
#define backtrace_atomic_load_pointer(p) \
|
||||||
|
__atomic_load_n ((p), __ATOMIC_ACQUIRE)
|
||||||
|
#define backtrace_atomic_load_int(p) \
|
||||||
|
__atomic_load_n ((p), __ATOMIC_ACQUIRE)
|
||||||
|
#define backtrace_atomic_store_pointer(p, v) \
|
||||||
|
__atomic_store_n ((p), (v), __ATOMIC_RELEASE)
|
||||||
|
#define backtrace_atomic_store_size_t(p, v) \
|
||||||
|
__atomic_store_n ((p), (v), __ATOMIC_RELEASE)
|
||||||
|
#define backtrace_atomic_store_int(p, v) \
|
||||||
|
__atomic_store_n ((p), (v), __ATOMIC_RELEASE)
|
||||||
|
|
||||||
|
#else /* !defined (HAVE_ATOMIC_FUNCTIONS) */
|
||||||
|
#ifdef HAVE_SYNC_FUNCTIONS
|
||||||
|
|
||||||
|
/* We have the sync functions but not the atomic functions. Define
|
||||||
|
the atomic ones in terms of the sync ones. */
|
||||||
|
|
||||||
|
extern void *backtrace_atomic_load_pointer (void *);
|
||||||
|
extern int backtrace_atomic_load_int (int *);
|
||||||
|
extern void backtrace_atomic_store_pointer (void *, void *);
|
||||||
|
extern void backtrace_atomic_store_size_t (size_t *, size_t);
|
||||||
|
extern void backtrace_atomic_store_int (int *, int);
|
||||||
|
|
||||||
|
#else /* !defined (HAVE_SYNC_FUNCTIONS) */
|
||||||
|
|
||||||
|
/* We have neither the sync nor the atomic functions. These will
|
||||||
|
never be called. */
|
||||||
|
|
||||||
|
#define backtrace_atomic_load_pointer(p) (abort(), (void *) NULL)
|
||||||
|
#define backtrace_atomic_load_int(p) (abort(), 0)
|
||||||
|
#define backtrace_atomic_store_pointer(p, v) abort()
|
||||||
|
#define backtrace_atomic_store_size_t(p, v) abort()
|
||||||
|
#define backtrace_atomic_store_int(p, v) abort()
|
||||||
|
|
||||||
|
#endif /* !defined (HAVE_SYNC_FUNCTIONS) */
|
||||||
|
#endif /* !defined (HAVE_ATOMIC_FUNCTIONS) */
|
||||||
|
|
||||||
|
/* The type of the function that collects file/line information. This
|
||||||
|
is like backtrace_pcinfo. */
|
||||||
|
|
||||||
|
typedef int (*fileline) (struct backtrace_state *state, uintptr_t pc,
|
||||||
|
backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data);
|
||||||
|
|
||||||
|
/* The type of the function that collects symbol information. This is
|
||||||
|
like backtrace_syminfo. */
|
||||||
|
|
||||||
|
typedef void (*syminfo) (struct backtrace_state *state, uintptr_t pc,
|
||||||
|
backtrace_syminfo_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data);
|
||||||
|
|
||||||
|
/* What the backtrace state pointer points to. */
|
||||||
|
|
||||||
|
struct backtrace_state
|
||||||
|
{
|
||||||
|
/* The name of the executable. */
|
||||||
|
const char *filename;
|
||||||
|
/* Non-zero if threaded. */
|
||||||
|
int threaded;
|
||||||
|
/* The master lock for fileline_fn, fileline_data, syminfo_fn,
|
||||||
|
syminfo_data, fileline_initialization_failed and everything the
|
||||||
|
data pointers point to. */
|
||||||
|
void *lock;
|
||||||
|
/* The function that returns file/line information. */
|
||||||
|
fileline fileline_fn;
|
||||||
|
/* The data to pass to FILELINE_FN. */
|
||||||
|
void *fileline_data;
|
||||||
|
/* The function that returns symbol information. */
|
||||||
|
syminfo syminfo_fn;
|
||||||
|
/* The data to pass to SYMINFO_FN. */
|
||||||
|
void *syminfo_data;
|
||||||
|
/* Whether initializing the file/line information failed. */
|
||||||
|
int fileline_initialization_failed;
|
||||||
|
/* The lock for the freelist. */
|
||||||
|
int lock_alloc;
|
||||||
|
/* The freelist when using mmap. */
|
||||||
|
struct backtrace_freelist_struct *freelist;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Open a file for reading. Returns -1 on error. If DOES_NOT_EXIST
|
||||||
|
is not NULL, *DOES_NOT_EXIST will be set to 0 normally and set to 1
|
||||||
|
if the file does not exist. If the file does not exist and
|
||||||
|
DOES_NOT_EXIST is not NULL, the function will return -1 and will
|
||||||
|
not call ERROR_CALLBACK. On other errors, or if DOES_NOT_EXIST is
|
||||||
|
NULL, the function will call ERROR_CALLBACK before returning. */
|
||||||
|
extern int backtrace_open (const char *filename,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data,
|
||||||
|
int *does_not_exist);
|
||||||
|
|
||||||
|
/* A view of the contents of a file. This supports mmap when
|
||||||
|
available. A view will remain in memory even after backtrace_close
|
||||||
|
is called on the file descriptor from which the view was
|
||||||
|
obtained. */
|
||||||
|
|
||||||
|
struct backtrace_view
|
||||||
|
{
|
||||||
|
/* The data that the caller requested. */
|
||||||
|
const void *data;
|
||||||
|
/* The base of the view. */
|
||||||
|
void *base;
|
||||||
|
/* The total length of the view. */
|
||||||
|
size_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. Store the
|
||||||
|
result in *VIEW. Returns 1 on success, 0 on error. */
|
||||||
|
extern int backtrace_get_view (struct backtrace_state *state, int descriptor,
|
||||||
|
off_t offset, uint64_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, struct backtrace_view *view);
|
||||||
|
|
||||||
|
/* Release a view created by backtrace_get_view. */
|
||||||
|
extern void backtrace_release_view (struct backtrace_state *state,
|
||||||
|
struct backtrace_view *view,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Close a file opened by backtrace_open. Returns 1 on success, 0 on
|
||||||
|
error. */
|
||||||
|
|
||||||
|
extern int backtrace_close (int descriptor,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Sort without using memory. */
|
||||||
|
|
||||||
|
extern void backtrace_qsort (void *base, size_t count, size_t size,
|
||||||
|
int (*compar) (const void *, const void *));
|
||||||
|
|
||||||
|
/* Allocate memory. This is like malloc. If ERROR_CALLBACK is NULL,
|
||||||
|
this does not report an error, it just returns NULL. */
|
||||||
|
|
||||||
|
extern void *backtrace_alloc (struct backtrace_state *state, size_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data) ATTRIBUTE_MALLOC;
|
||||||
|
|
||||||
|
/* Free memory allocated by backtrace_alloc. If ERROR_CALLBACK is
|
||||||
|
NULL, this does not report an error. */
|
||||||
|
|
||||||
|
extern void backtrace_free (struct backtrace_state *state, void *mem,
|
||||||
|
size_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* A growable vector of some struct. This is used for more efficient
|
||||||
|
allocation when we don't know the final size of some group of data
|
||||||
|
that we want to represent as an array. */
|
||||||
|
|
||||||
|
struct backtrace_vector
|
||||||
|
{
|
||||||
|
/* The base of the vector. */
|
||||||
|
void *base;
|
||||||
|
/* The number of bytes in the vector. */
|
||||||
|
size_t size;
|
||||||
|
/* The number of bytes available at the current allocation. */
|
||||||
|
size_t alc;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Grow VEC by SIZE bytes. Return a pointer to the newly allocated
|
||||||
|
bytes. Note that this may move the entire vector to a new memory
|
||||||
|
location. Returns NULL on failure. */
|
||||||
|
|
||||||
|
extern void *backtrace_vector_grow (struct backtrace_state *state, size_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data,
|
||||||
|
struct backtrace_vector *vec);
|
||||||
|
|
||||||
|
/* Finish the current allocation on VEC. Prepare to start a new
|
||||||
|
allocation. The finished allocation will never be freed. Returns
|
||||||
|
a pointer to the base of the finished entries, or NULL on
|
||||||
|
failure. */
|
||||||
|
|
||||||
|
extern void* backtrace_vector_finish (struct backtrace_state *state,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Release any extra space allocated for VEC. This may change
|
||||||
|
VEC->base. Returns 1 on success, 0 on failure. */
|
||||||
|
|
||||||
|
extern int backtrace_vector_release (struct backtrace_state *state,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
/* Free the space managed by VEC. This will reset VEC. */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
backtrace_vector_free (struct backtrace_state *state,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
vec->alc += vec->size;
|
||||||
|
vec->size = 0;
|
||||||
|
backtrace_vector_release (state, vec, error_callback, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read initial debug data from a descriptor, and set the
|
||||||
|
fileline_data, syminfo_fn, and syminfo_data fields of STATE.
|
||||||
|
Return the fileln_fn field in *FILELN_FN--this is done this way so
|
||||||
|
that the synchronization code is only implemented once. This is
|
||||||
|
called after the descriptor has first been opened. It will close
|
||||||
|
the descriptor if it is no longer needed. Returns 1 on success, 0
|
||||||
|
on error. There will be multiple implementations of this function,
|
||||||
|
for different file formats. Each system will compile the
|
||||||
|
appropriate one. */
|
||||||
|
|
||||||
|
extern int backtrace_initialize (struct backtrace_state *state,
|
||||||
|
const char *filename,
|
||||||
|
int descriptor,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data,
|
||||||
|
fileline *fileline_fn);
|
||||||
|
|
||||||
|
/* An enum for the DWARF sections we care about. */
|
||||||
|
|
||||||
|
enum dwarf_section
|
||||||
|
{
|
||||||
|
DEBUG_INFO,
|
||||||
|
DEBUG_LINE,
|
||||||
|
DEBUG_ABBREV,
|
||||||
|
DEBUG_RANGES,
|
||||||
|
DEBUG_STR,
|
||||||
|
DEBUG_ADDR,
|
||||||
|
DEBUG_STR_OFFSETS,
|
||||||
|
DEBUG_LINE_STR,
|
||||||
|
DEBUG_RNGLISTS,
|
||||||
|
|
||||||
|
DEBUG_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Data for the DWARF sections we care about. */
|
||||||
|
|
||||||
|
struct dwarf_sections
|
||||||
|
{
|
||||||
|
const unsigned char *data[DEBUG_MAX];
|
||||||
|
size_t size[DEBUG_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* DWARF data read from a file, used for .gnu_debugaltlink. */
|
||||||
|
|
||||||
|
struct dwarf_data;
|
||||||
|
|
||||||
|
/* Add file/line information for a DWARF module. */
|
||||||
|
|
||||||
|
extern int backtrace_dwarf_add (struct backtrace_state *state,
|
||||||
|
uintptr_t base_address,
|
||||||
|
const struct dwarf_sections *dwarf_sections,
|
||||||
|
int is_bigendian,
|
||||||
|
struct dwarf_data *fileline_altlink,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, fileline *fileline_fn,
|
||||||
|
struct dwarf_data **fileline_entry);
|
||||||
|
|
||||||
|
/* A data structure to pass to backtrace_syminfo_to_full. */
|
||||||
|
|
||||||
|
struct backtrace_call_full
|
||||||
|
{
|
||||||
|
backtrace_full_callback full_callback;
|
||||||
|
backtrace_error_callback full_error_callback;
|
||||||
|
void *full_data;
|
||||||
|
int ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A backtrace_syminfo_callback that can call into a
|
||||||
|
backtrace_full_callback, used when we have a symbol table but no
|
||||||
|
debug info. */
|
||||||
|
|
||||||
|
extern void backtrace_syminfo_to_full_callback (void *data, uintptr_t pc,
|
||||||
|
const char *symname,
|
||||||
|
uintptr_t symval,
|
||||||
|
uintptr_t symsize);
|
||||||
|
|
||||||
|
/* An error callback that corresponds to
|
||||||
|
backtrace_syminfo_to_full_callback. */
|
||||||
|
|
||||||
|
extern void backtrace_syminfo_to_full_error_callback (void *, const char *,
|
||||||
|
int);
|
||||||
|
|
||||||
|
/* A test-only hook for elf_uncompress_zdebug. */
|
||||||
|
|
||||||
|
extern int backtrace_uncompress_zdebug (struct backtrace_state *,
|
||||||
|
const unsigned char *compressed,
|
||||||
|
size_t compressed_size,
|
||||||
|
backtrace_error_callback, void *data,
|
||||||
|
unsigned char **uncompressed,
|
||||||
|
size_t *uncompressed_size);
|
||||||
|
|
||||||
|
/* A test-only hook for elf_zstd_decompress. */
|
||||||
|
|
||||||
|
extern int backtrace_uncompress_zstd (struct backtrace_state *,
|
||||||
|
const unsigned char *compressed,
|
||||||
|
size_t compressed_size,
|
||||||
|
backtrace_error_callback, void *data,
|
||||||
|
unsigned char *uncompressed,
|
||||||
|
size_t uncompressed_size);
|
||||||
|
|
||||||
|
/* A test-only hook for elf_uncompress_lzma. */
|
||||||
|
|
||||||
|
extern int backtrace_uncompress_lzma (struct backtrace_state *,
|
||||||
|
const unsigned char *compressed,
|
||||||
|
size_t compressed_size,
|
||||||
|
backtrace_error_callback, void *data,
|
||||||
|
unsigned char **uncompressed,
|
||||||
|
size_t *uncompressed_size);
|
||||||
|
|
||||||
|
#endif
|
7436
deps/libbacktrace/libtool.m4
vendored
Normal file
7436
deps/libbacktrace/libtool.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8636
deps/libbacktrace/ltmain.sh
vendored
Normal file
8636
deps/libbacktrace/ltmain.sh
vendored
Normal file
File diff suppressed because it is too large
Load Diff
369
deps/libbacktrace/ltoptions.m4
vendored
Normal file
369
deps/libbacktrace/ltoptions.m4
vendored
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
# Helper functions for option handling. -*- Autoconf -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
|
||||||
|
# Inc.
|
||||||
|
# Written by Gary V. Vaughan, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 6 ltoptions.m4
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
|
||||||
|
# ------------------------------------------
|
||||||
|
m4_define([_LT_MANGLE_OPTION],
|
||||||
|
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
|
||||||
|
# ---------------------------------------
|
||||||
|
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
|
||||||
|
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
|
||||||
|
# saved as a flag.
|
||||||
|
m4_define([_LT_SET_OPTION],
|
||||||
|
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||||
|
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||||
|
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||||
|
[m4_warning([Unknown $1 option `$2'])])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
|
||||||
|
# ------------------------------------------------------------
|
||||||
|
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||||
|
m4_define([_LT_IF_OPTION],
|
||||||
|
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
|
||||||
|
# -------------------------------------------------------
|
||||||
|
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
|
||||||
|
# are set.
|
||||||
|
m4_define([_LT_UNLESS_OPTIONS],
|
||||||
|
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||||
|
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
|
||||||
|
[m4_define([$0_found])])])[]dnl
|
||||||
|
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
|
||||||
|
])[]dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
|
||||||
|
# ----------------------------------------
|
||||||
|
# OPTION-LIST is a space-separated list of Libtool options associated
|
||||||
|
# with MACRO-NAME. If any OPTION has a matching handler declared with
|
||||||
|
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
|
||||||
|
# the unknown option and exit.
|
||||||
|
m4_defun([_LT_SET_OPTIONS],
|
||||||
|
[# Set options
|
||||||
|
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||||
|
[_LT_SET_OPTION([$1], _LT_Option)])
|
||||||
|
|
||||||
|
m4_if([$1],[LT_INIT],[
|
||||||
|
dnl
|
||||||
|
dnl Simply set some default values (i.e off) if boolean options were not
|
||||||
|
dnl specified:
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
|
||||||
|
])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
|
||||||
|
])
|
||||||
|
dnl
|
||||||
|
dnl If no reference was made to various pairs of opposing options, then
|
||||||
|
dnl we run the default mode handler for the pair. For example, if neither
|
||||||
|
dnl `shared' nor `disable-shared' was passed, we enable building of shared
|
||||||
|
dnl archives by default:
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||||
|
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||||
|
[_LT_ENABLE_FAST_INSTALL])
|
||||||
|
])
|
||||||
|
])# _LT_SET_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------------------- ##
|
||||||
|
## Macros to handle LT_INIT options. ##
|
||||||
|
## --------------------------------- ##
|
||||||
|
|
||||||
|
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
|
||||||
|
# -----------------------------------------
|
||||||
|
m4_define([_LT_MANGLE_DEFUN],
|
||||||
|
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
|
||||||
|
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
|
||||||
|
# -----------------------------------------------
|
||||||
|
m4_define([LT_OPTION_DEFINE],
|
||||||
|
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
|
||||||
|
])# LT_OPTION_DEFINE
|
||||||
|
|
||||||
|
|
||||||
|
# dlopen
|
||||||
|
# ------
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `dlopen' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
|
||||||
|
|
||||||
|
|
||||||
|
# win32-dll
|
||||||
|
# ---------
|
||||||
|
# Declare package support for building win32 dll's.
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
|
||||||
|
[enable_win32_dll=yes
|
||||||
|
|
||||||
|
case $host in
|
||||||
|
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
|
||||||
|
AC_CHECK_TOOL(AS, as, false)
|
||||||
|
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||||
|
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
test -z "$AS" && AS=as
|
||||||
|
_LT_DECL([], [AS], [1], [Assembler program])dnl
|
||||||
|
|
||||||
|
test -z "$DLLTOOL" && DLLTOOL=dlltool
|
||||||
|
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
|
||||||
|
|
||||||
|
test -z "$OBJDUMP" && OBJDUMP=objdump
|
||||||
|
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
|
||||||
|
])# win32-dll
|
||||||
|
|
||||||
|
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||||
|
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||||
|
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `win32-dll' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_SHARED([DEFAULT])
|
||||||
|
# ----------------------------
|
||||||
|
# implement the --enable-shared flag, and supports the `shared' and
|
||||||
|
# `disable-shared' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_SHARED],
|
||||||
|
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([shared],
|
||||||
|
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
|
||||||
|
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_shared=yes ;;
|
||||||
|
no) enable_shared=no ;;
|
||||||
|
*)
|
||||||
|
enable_shared=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_shared=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([build_libtool_libs], [enable_shared], [0],
|
||||||
|
[Whether or not to build shared libraries])
|
||||||
|
])# _LT_ENABLE_SHARED
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AC_DEFUN([AC_ENABLE_SHARED],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AC_DISABLE_SHARED],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-shared])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
|
||||||
|
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_STATIC([DEFAULT])
|
||||||
|
# ----------------------------
|
||||||
|
# implement the --enable-static flag, and support the `static' and
|
||||||
|
# `disable-static' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_STATIC],
|
||||||
|
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([static],
|
||||||
|
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
|
||||||
|
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_static=yes ;;
|
||||||
|
no) enable_static=no ;;
|
||||||
|
*)
|
||||||
|
enable_static=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_static=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([build_old_libs], [enable_static], [0],
|
||||||
|
[Whether or not to build static libraries])
|
||||||
|
])# _LT_ENABLE_STATIC
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AC_DEFUN([AC_ENABLE_STATIC],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([AC_DISABLE_STATIC],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-static])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
|
||||||
|
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||||
|
# ----------------------------------
|
||||||
|
# implement the --enable-fast-install flag, and support the `fast-install'
|
||||||
|
# and `disable-fast-install' LT_INIT options.
|
||||||
|
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||||
|
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||||
|
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||||
|
AC_ARG_ENABLE([fast-install],
|
||||||
|
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
|
||||||
|
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
|
||||||
|
[p=${PACKAGE-default}
|
||||||
|
case $enableval in
|
||||||
|
yes) enable_fast_install=yes ;;
|
||||||
|
no) enable_fast_install=no ;;
|
||||||
|
*)
|
||||||
|
enable_fast_install=no
|
||||||
|
# Look at the argument we got. We use all the common list separators.
|
||||||
|
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||||
|
for pkg in $enableval; do
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
if test "X$pkg" = "X$p"; then
|
||||||
|
enable_fast_install=yes
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS="$lt_save_ifs"
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||||
|
|
||||||
|
_LT_DECL([fast_install], [enable_fast_install], [0],
|
||||||
|
[Whether or not to optimize for fast installation])dnl
|
||||||
|
])# _LT_ENABLE_FAST_INSTALL
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
|
||||||
|
|
||||||
|
# Old names:
|
||||||
|
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||||
|
the `fast-install' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||||
|
the `disable-fast-install' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||||
|
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||||
|
|
||||||
|
|
||||||
|
# _LT_WITH_PIC([MODE])
|
||||||
|
# --------------------
|
||||||
|
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
|
||||||
|
# LT_INIT options.
|
||||||
|
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
|
||||||
|
m4_define([_LT_WITH_PIC],
|
||||||
|
[AC_ARG_WITH([pic],
|
||||||
|
[AS_HELP_STRING([--with-pic],
|
||||||
|
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
|
||||||
|
[pic_mode="$withval"],
|
||||||
|
[pic_mode=default])
|
||||||
|
|
||||||
|
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
|
||||||
|
|
||||||
|
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||||
|
])# _LT_WITH_PIC
|
||||||
|
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
|
||||||
|
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
|
||||||
|
|
||||||
|
# Old name:
|
||||||
|
AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||||
|
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||||
|
AC_DIAGNOSE([obsolete],
|
||||||
|
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||||
|
put the `pic-only' option into LT_INIT's first parameter.])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl aclocal-1.4 backwards compatibility:
|
||||||
|
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
|
||||||
|
|
||||||
|
## ----------------- ##
|
||||||
|
## LTDL_INIT Options ##
|
||||||
|
## ----------------- ##
|
||||||
|
|
||||||
|
m4_define([_LTDL_MODE], [])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
|
||||||
|
[m4_define([_LTDL_MODE], [nonrecursive])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
|
||||||
|
[m4_define([_LTDL_MODE], [recursive])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
|
||||||
|
[m4_define([_LTDL_MODE], [subproject])])
|
||||||
|
|
||||||
|
m4_define([_LTDL_TYPE], [])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [installable],
|
||||||
|
[m4_define([_LTDL_TYPE], [installable])])
|
||||||
|
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
|
||||||
|
[m4_define([_LTDL_TYPE], [convenience])])
|
123
deps/libbacktrace/ltsugar.m4
vendored
Normal file
123
deps/libbacktrace/ltsugar.m4
vendored
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||||
|
# Written by Gary V. Vaughan, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 6 ltsugar.m4
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_join(SEP, ARG1, [ARG2...])
|
||||||
|
# -----------------------------
|
||||||
|
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
||||||
|
# associated separator.
|
||||||
|
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
||||||
|
# versions in m4sugar had bugs.
|
||||||
|
m4_define([lt_join],
|
||||||
|
[m4_if([$#], [1], [],
|
||||||
|
[$#], [2], [[$2]],
|
||||||
|
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
||||||
|
m4_define([_lt_join],
|
||||||
|
[m4_if([$#$2], [2], [],
|
||||||
|
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_car(LIST)
|
||||||
|
# lt_cdr(LIST)
|
||||||
|
# ------------
|
||||||
|
# Manipulate m4 lists.
|
||||||
|
# These macros are necessary as long as will still need to support
|
||||||
|
# Autoconf-2.59 which quotes differently.
|
||||||
|
m4_define([lt_car], [[$1]])
|
||||||
|
m4_define([lt_cdr],
|
||||||
|
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||||
|
[$#], 1, [],
|
||||||
|
[m4_dquote(m4_shift($@))])])
|
||||||
|
m4_define([lt_unquote], $1)
|
||||||
|
|
||||||
|
|
||||||
|
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||||
|
# ------------------------------------------
|
||||||
|
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
||||||
|
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||||
|
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||||
|
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||||
|
# than defined and empty).
|
||||||
|
#
|
||||||
|
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
||||||
|
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
||||||
|
m4_define([lt_append],
|
||||||
|
[m4_define([$1],
|
||||||
|
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
||||||
|
# ----------------------------------------------------------
|
||||||
|
# Produce a SEP delimited list of all paired combinations of elements of
|
||||||
|
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
||||||
|
# has the form PREFIXmINFIXSUFFIXn.
|
||||||
|
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
||||||
|
m4_define([lt_combine],
|
||||||
|
[m4_if(m4_eval([$# > 3]), [1],
|
||||||
|
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
||||||
|
[[m4_foreach([_Lt_prefix], [$2],
|
||||||
|
[m4_foreach([_Lt_suffix],
|
||||||
|
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
||||||
|
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
||||||
|
# -----------------------------------------------------------------------
|
||||||
|
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
||||||
|
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
||||||
|
m4_define([lt_if_append_uniq],
|
||||||
|
[m4_ifdef([$1],
|
||||||
|
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
||||||
|
[lt_append([$1], [$2], [$3])$4],
|
||||||
|
[$5])],
|
||||||
|
[lt_append([$1], [$2], [$3])$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_add(DICT, KEY, VALUE)
|
||||||
|
# -----------------------------
|
||||||
|
m4_define([lt_dict_add],
|
||||||
|
[m4_define([$1($2)], [$3])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
||||||
|
# --------------------------------------------
|
||||||
|
m4_define([lt_dict_add_subkey],
|
||||||
|
[m4_define([$1($2:$3)], [$4])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
||||||
|
# ----------------------------------
|
||||||
|
m4_define([lt_dict_fetch],
|
||||||
|
[m4_ifval([$3],
|
||||||
|
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
||||||
|
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
m4_define([lt_if_dict_fetch],
|
||||||
|
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
||||||
|
[$5],
|
||||||
|
[$6])])
|
||||||
|
|
||||||
|
|
||||||
|
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
m4_define([lt_dict_filter],
|
||||||
|
[m4_if([$5], [], [],
|
||||||
|
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
||||||
|
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
||||||
|
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
||||||
|
])
|
23
deps/libbacktrace/ltversion.m4
vendored
Normal file
23
deps/libbacktrace/ltversion.m4
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||||
|
# Written by Scott James Remnant, 2004
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# Generated from ltversion.in.
|
||||||
|
|
||||||
|
# serial 3134 ltversion.m4
|
||||||
|
# This file is part of GNU Libtool
|
||||||
|
|
||||||
|
m4_define([LT_PACKAGE_VERSION], [2.2.7a])
|
||||||
|
m4_define([LT_PACKAGE_REVISION], [1.3134])
|
||||||
|
|
||||||
|
AC_DEFUN([LTVERSION_VERSION],
|
||||||
|
[macro_version='2.2.7a'
|
||||||
|
macro_revision='1.3134'
|
||||||
|
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||||
|
_LT_DECL(, macro_revision, 0)
|
||||||
|
])
|
98
deps/libbacktrace/lt~obsolete.m4
vendored
Normal file
98
deps/libbacktrace/lt~obsolete.m4
vendored
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||||
|
# Written by Scott James Remnant, 2004.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 4 lt~obsolete.m4
|
||||||
|
|
||||||
|
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||||
|
#
|
||||||
|
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
||||||
|
# which have later been changed to m4_define as they aren't part of the
|
||||||
|
# exported API, or moved to Autoconf or Automake where they belong.
|
||||||
|
#
|
||||||
|
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
||||||
|
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
||||||
|
# using a macro with the same name in our local m4/libtool.m4 it'll
|
||||||
|
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
||||||
|
# and doesn't know about Autoconf macros at all.)
|
||||||
|
#
|
||||||
|
# So we provide this file, which has a silly filename so it's always
|
||||||
|
# included after everything else. This provides aclocal with the
|
||||||
|
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||||
|
# because those macros already exist, or will be overwritten later.
|
||||||
|
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||||
|
#
|
||||||
|
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||||
|
# Yes, that means every name once taken will need to remain here until
|
||||||
|
# we give up compatibility with versions before 1.7, at which point
|
||||||
|
# we need to keep only those names which we still refer to.
|
||||||
|
|
||||||
|
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||||
|
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
||||||
|
|
||||||
|
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
||||||
|
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
||||||
|
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
||||||
|
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
||||||
|
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
||||||
|
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
||||||
|
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
||||||
|
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
||||||
|
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
||||||
|
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
||||||
|
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
||||||
|
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
||||||
|
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
||||||
|
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
||||||
|
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
||||||
|
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
||||||
|
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
||||||
|
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
||||||
|
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
||||||
|
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
||||||
|
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
||||||
|
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
||||||
|
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
||||||
|
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
||||||
|
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
||||||
|
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
||||||
|
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
||||||
|
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
||||||
|
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
||||||
|
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
||||||
|
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
||||||
|
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
||||||
|
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
||||||
|
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
||||||
|
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
1355
deps/libbacktrace/macho.c
vendored
Normal file
1355
deps/libbacktrace/macho.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
215
deps/libbacktrace/missing
vendored
Executable file
215
deps/libbacktrace/missing
vendored
Executable file
@ -0,0 +1,215 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Common wrapper for a few potentially missing GNU programs.
|
||||||
|
|
||||||
|
scriptversion=2013-10-28.13; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||||
|
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||||
|
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo 1>&2 "Try '$0 --help' for more information"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
|
||||||
|
--is-lightweight)
|
||||||
|
# Used by our autoconf macros to check whether the available missing
|
||||||
|
# script is modern enough.
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
--run)
|
||||||
|
# Back-compat with the calling convention used by older automake.
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-h|--h|--he|--hel|--help)
|
||||||
|
echo "\
|
||||||
|
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||||
|
|
||||||
|
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
|
||||||
|
to PROGRAM being missing or too old.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help display this help and exit
|
||||||
|
-v, --version output version information and exit
|
||||||
|
|
||||||
|
Supported PROGRAM values:
|
||||||
|
aclocal autoconf autoheader autom4te automake makeinfo
|
||||||
|
bison yacc flex lex help2man
|
||||||
|
|
||||||
|
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
|
||||||
|
'g' are ignored when checking the name.
|
||||||
|
|
||||||
|
Send bug reports to <bug-automake@gnu.org>."
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
|
||||||
|
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||||
|
echo "missing $scriptversion (GNU Automake)"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
|
||||||
|
-*)
|
||||||
|
echo 1>&2 "$0: unknown '$1' option"
|
||||||
|
echo 1>&2 "Try '$0 --help' for more information"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Run the given program, remember its exit status.
|
||||||
|
"$@"; st=$?
|
||||||
|
|
||||||
|
# If it succeeded, we are done.
|
||||||
|
test $st -eq 0 && exit 0
|
||||||
|
|
||||||
|
# Also exit now if we it failed (or wasn't found), and '--version' was
|
||||||
|
# passed; such an option is passed most likely to detect whether the
|
||||||
|
# program is present and works.
|
||||||
|
case $2 in --version|--help) exit $st;; esac
|
||||||
|
|
||||||
|
# Exit code 63 means version mismatch. This often happens when the user
|
||||||
|
# tries to use an ancient version of a tool on a file that requires a
|
||||||
|
# minimum version.
|
||||||
|
if test $st -eq 63; then
|
||||||
|
msg="probably too old"
|
||||||
|
elif test $st -eq 127; then
|
||||||
|
# Program was missing.
|
||||||
|
msg="missing on your system"
|
||||||
|
else
|
||||||
|
# Program was found and executed, but failed. Give up.
|
||||||
|
exit $st
|
||||||
|
fi
|
||||||
|
|
||||||
|
perl_URL=http://www.perl.org/
|
||||||
|
flex_URL=http://flex.sourceforge.net/
|
||||||
|
gnu_software_URL=http://www.gnu.org/software
|
||||||
|
|
||||||
|
program_details ()
|
||||||
|
{
|
||||||
|
case $1 in
|
||||||
|
aclocal|automake)
|
||||||
|
echo "The '$1' program is part of the GNU Automake package:"
|
||||||
|
echo "<$gnu_software_URL/automake>"
|
||||||
|
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
|
||||||
|
echo "<$gnu_software_URL/autoconf>"
|
||||||
|
echo "<$gnu_software_URL/m4/>"
|
||||||
|
echo "<$perl_URL>"
|
||||||
|
;;
|
||||||
|
autoconf|autom4te|autoheader)
|
||||||
|
echo "The '$1' program is part of the GNU Autoconf package:"
|
||||||
|
echo "<$gnu_software_URL/autoconf/>"
|
||||||
|
echo "It also requires GNU m4 and Perl in order to run:"
|
||||||
|
echo "<$gnu_software_URL/m4/>"
|
||||||
|
echo "<$perl_URL>"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
give_advice ()
|
||||||
|
{
|
||||||
|
# Normalize program name to check for.
|
||||||
|
normalized_program=`echo "$1" | sed '
|
||||||
|
s/^gnu-//; t
|
||||||
|
s/^gnu//; t
|
||||||
|
s/^g//; t'`
|
||||||
|
|
||||||
|
printf '%s\n' "'$1' is $msg."
|
||||||
|
|
||||||
|
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
|
||||||
|
case $normalized_program in
|
||||||
|
autoconf*)
|
||||||
|
echo "You should only need it if you modified 'configure.ac',"
|
||||||
|
echo "or m4 files included by it."
|
||||||
|
program_details 'autoconf'
|
||||||
|
;;
|
||||||
|
autoheader*)
|
||||||
|
echo "You should only need it if you modified 'acconfig.h' or"
|
||||||
|
echo "$configure_deps."
|
||||||
|
program_details 'autoheader'
|
||||||
|
;;
|
||||||
|
automake*)
|
||||||
|
echo "You should only need it if you modified 'Makefile.am' or"
|
||||||
|
echo "$configure_deps."
|
||||||
|
program_details 'automake'
|
||||||
|
;;
|
||||||
|
aclocal*)
|
||||||
|
echo "You should only need it if you modified 'acinclude.m4' or"
|
||||||
|
echo "$configure_deps."
|
||||||
|
program_details 'aclocal'
|
||||||
|
;;
|
||||||
|
autom4te*)
|
||||||
|
echo "You might have modified some maintainer files that require"
|
||||||
|
echo "the 'autom4te' program to be rebuilt."
|
||||||
|
program_details 'autom4te'
|
||||||
|
;;
|
||||||
|
bison*|yacc*)
|
||||||
|
echo "You should only need it if you modified a '.y' file."
|
||||||
|
echo "You may want to install the GNU Bison package:"
|
||||||
|
echo "<$gnu_software_URL/bison/>"
|
||||||
|
;;
|
||||||
|
lex*|flex*)
|
||||||
|
echo "You should only need it if you modified a '.l' file."
|
||||||
|
echo "You may want to install the Fast Lexical Analyzer package:"
|
||||||
|
echo "<$flex_URL>"
|
||||||
|
;;
|
||||||
|
help2man*)
|
||||||
|
echo "You should only need it if you modified a dependency" \
|
||||||
|
"of a man page."
|
||||||
|
echo "You may want to install the GNU Help2man package:"
|
||||||
|
echo "<$gnu_software_URL/help2man/>"
|
||||||
|
;;
|
||||||
|
makeinfo*)
|
||||||
|
echo "You should only need it if you modified a '.texi' file, or"
|
||||||
|
echo "any other file indirectly affecting the aspect of the manual."
|
||||||
|
echo "You might want to install the Texinfo package:"
|
||||||
|
echo "<$gnu_software_URL/texinfo/>"
|
||||||
|
echo "The spurious makeinfo call might also be the consequence of"
|
||||||
|
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
|
||||||
|
echo "want to install GNU make:"
|
||||||
|
echo "<$gnu_software_URL/make/>"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "You might have modified some files without having the proper"
|
||||||
|
echo "tools for further handling them. Check the 'README' file, it"
|
||||||
|
echo "often tells you about the needed prerequisites for installing"
|
||||||
|
echo "this package. You may also peek at any GNU archive site, in"
|
||||||
|
echo "case some other package contains this missing '$1' program."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||||
|
-e '2,$s/^/ /' >&2
|
||||||
|
|
||||||
|
# Propagate the correct exit status (expected to be 127 for a program
|
||||||
|
# not found, 63 for a program that failed due to version mismatch).
|
||||||
|
exit $st
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
331
deps/libbacktrace/mmap.c
vendored
Normal file
331
deps/libbacktrace/mmap.c
vendored
Normal file
@ -0,0 +1,331 @@
|
|||||||
|
/* mmap.c -- Memory allocation with mmap.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_DECL_GETPAGESIZE
|
||||||
|
extern int getpagesize (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory allocation on systems that provide anonymous mmap. This
|
||||||
|
permits the backtrace functions to be invoked from a signal
|
||||||
|
handler, assuming that mmap is async-signal safe. */
|
||||||
|
|
||||||
|
#ifndef MAP_ANONYMOUS
|
||||||
|
#define MAP_ANONYMOUS MAP_ANON
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_FAILED
|
||||||
|
#define MAP_FAILED ((void *)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A list of free memory blocks. */
|
||||||
|
|
||||||
|
struct backtrace_freelist_struct
|
||||||
|
{
|
||||||
|
/* Next on list. */
|
||||||
|
struct backtrace_freelist_struct *next;
|
||||||
|
/* Size of this block, including this structure. */
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Free memory allocated by backtrace_alloc. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
backtrace_free_locked (struct backtrace_state *state, void *addr, size_t size)
|
||||||
|
{
|
||||||
|
/* Just leak small blocks. We don't have to be perfect. Don't put
|
||||||
|
more than 16 entries on the free list, to avoid wasting time
|
||||||
|
searching when allocating a block. If we have more than 16
|
||||||
|
entries, leak the smallest entry. */
|
||||||
|
|
||||||
|
if (size >= sizeof (struct backtrace_freelist_struct))
|
||||||
|
{
|
||||||
|
size_t c;
|
||||||
|
struct backtrace_freelist_struct **ppsmall;
|
||||||
|
struct backtrace_freelist_struct **pp;
|
||||||
|
struct backtrace_freelist_struct *p;
|
||||||
|
|
||||||
|
c = 0;
|
||||||
|
ppsmall = NULL;
|
||||||
|
for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next)
|
||||||
|
{
|
||||||
|
if (ppsmall == NULL || (*pp)->size < (*ppsmall)->size)
|
||||||
|
ppsmall = pp;
|
||||||
|
++c;
|
||||||
|
}
|
||||||
|
if (c >= 16)
|
||||||
|
{
|
||||||
|
if (size <= (*ppsmall)->size)
|
||||||
|
return;
|
||||||
|
*ppsmall = (*ppsmall)->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = (struct backtrace_freelist_struct *) addr;
|
||||||
|
p->next = state->freelist;
|
||||||
|
p->size = size;
|
||||||
|
state->freelist = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't
|
||||||
|
report an error. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_alloc (struct backtrace_state *state,
|
||||||
|
size_t size, backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
int locked;
|
||||||
|
struct backtrace_freelist_struct **pp;
|
||||||
|
size_t pagesize;
|
||||||
|
size_t asksize;
|
||||||
|
void *page;
|
||||||
|
|
||||||
|
ret = NULL;
|
||||||
|
|
||||||
|
/* If we can acquire the lock, then see if there is space on the
|
||||||
|
free list. If we can't acquire the lock, drop straight into
|
||||||
|
using mmap. __sync_lock_test_and_set returns the old state of
|
||||||
|
the lock, so we have acquired it if it returns 0. */
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
locked = 1;
|
||||||
|
else
|
||||||
|
locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0;
|
||||||
|
|
||||||
|
if (locked)
|
||||||
|
{
|
||||||
|
for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next)
|
||||||
|
{
|
||||||
|
if ((*pp)->size >= size)
|
||||||
|
{
|
||||||
|
struct backtrace_freelist_struct *p;
|
||||||
|
|
||||||
|
p = *pp;
|
||||||
|
*pp = p->next;
|
||||||
|
|
||||||
|
/* Round for alignment; we assume that no type we care about
|
||||||
|
is more than 8 bytes. */
|
||||||
|
size = (size + 7) & ~ (size_t) 7;
|
||||||
|
if (size < p->size)
|
||||||
|
backtrace_free_locked (state, (char *) p + size,
|
||||||
|
p->size - size);
|
||||||
|
|
||||||
|
ret = (void *) p;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state->threaded)
|
||||||
|
__sync_lock_release (&state->lock_alloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == NULL)
|
||||||
|
{
|
||||||
|
/* Allocate a new page. */
|
||||||
|
|
||||||
|
pagesize = getpagesize ();
|
||||||
|
asksize = (size + pagesize - 1) & ~ (pagesize - 1);
|
||||||
|
page = mmap (NULL, asksize, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
|
if (page == MAP_FAILED)
|
||||||
|
{
|
||||||
|
if (error_callback)
|
||||||
|
error_callback (data, "mmap", errno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = (size + 7) & ~ (size_t) 7;
|
||||||
|
if (size < asksize)
|
||||||
|
backtrace_free (state, (char *) page + size, asksize - size,
|
||||||
|
error_callback, data);
|
||||||
|
|
||||||
|
ret = page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory allocated by backtrace_alloc. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_free (struct backtrace_state *state, void *addr, size_t size,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int locked;
|
||||||
|
|
||||||
|
/* If we are freeing a large aligned block, just release it back to
|
||||||
|
the system. This case arises when growing a vector for a large
|
||||||
|
binary with lots of debug info. Calling munmap here may cause us
|
||||||
|
to call mmap again if there is also a large shared library; we
|
||||||
|
just live with that. */
|
||||||
|
if (size >= 16 * 4096)
|
||||||
|
{
|
||||||
|
size_t pagesize;
|
||||||
|
|
||||||
|
pagesize = getpagesize ();
|
||||||
|
if (((uintptr_t) addr & (pagesize - 1)) == 0
|
||||||
|
&& (size & (pagesize - 1)) == 0)
|
||||||
|
{
|
||||||
|
/* If munmap fails for some reason, just add the block to
|
||||||
|
the freelist. */
|
||||||
|
if (munmap (addr, size) == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we can acquire the lock, add the new space to the free list.
|
||||||
|
If we can't acquire the lock, just leak the memory.
|
||||||
|
__sync_lock_test_and_set returns the old state of the lock, so we
|
||||||
|
have acquired it if it returns 0. */
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
locked = 1;
|
||||||
|
else
|
||||||
|
locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0;
|
||||||
|
|
||||||
|
if (locked)
|
||||||
|
{
|
||||||
|
backtrace_free_locked (state, addr, size);
|
||||||
|
|
||||||
|
if (state->threaded)
|
||||||
|
__sync_lock_release (&state->lock_alloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grow VEC by SIZE bytes. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_vector_grow (struct backtrace_state *state,size_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, struct backtrace_vector *vec)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
if (size > vec->alc)
|
||||||
|
{
|
||||||
|
size_t pagesize;
|
||||||
|
size_t alc;
|
||||||
|
void *base;
|
||||||
|
|
||||||
|
pagesize = getpagesize ();
|
||||||
|
alc = vec->size + size;
|
||||||
|
if (vec->size == 0)
|
||||||
|
alc = 16 * size;
|
||||||
|
else if (alc < pagesize)
|
||||||
|
{
|
||||||
|
alc *= 2;
|
||||||
|
if (alc > pagesize)
|
||||||
|
alc = pagesize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alc *= 2;
|
||||||
|
alc = (alc + pagesize - 1) & ~ (pagesize - 1);
|
||||||
|
}
|
||||||
|
base = backtrace_alloc (state, alc, error_callback, data);
|
||||||
|
if (base == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (vec->base != NULL)
|
||||||
|
{
|
||||||
|
memcpy (base, vec->base, vec->size);
|
||||||
|
backtrace_free (state, vec->base, vec->size + vec->alc,
|
||||||
|
error_callback, data);
|
||||||
|
}
|
||||||
|
vec->base = base;
|
||||||
|
vec->alc = alc - vec->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = (char *) vec->base + vec->size;
|
||||||
|
vec->size += size;
|
||||||
|
vec->alc -= size;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finish the current allocation on VEC. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
backtrace_vector_finish (
|
||||||
|
struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
ret = vec->base;
|
||||||
|
vec->base = (char *) vec->base + vec->size;
|
||||||
|
vec->size = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release any extra space allocated for VEC. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_vector_release (struct backtrace_state *state,
|
||||||
|
struct backtrace_vector *vec,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
size_t alc;
|
||||||
|
size_t aligned;
|
||||||
|
|
||||||
|
/* Make sure that the block that we free is aligned on an 8-byte
|
||||||
|
boundary. */
|
||||||
|
size = vec->size;
|
||||||
|
alc = vec->alc;
|
||||||
|
aligned = (size + 7) & ~ (size_t) 7;
|
||||||
|
alc -= aligned - size;
|
||||||
|
|
||||||
|
backtrace_free (state, (char *) vec->base + aligned, alc,
|
||||||
|
error_callback, data);
|
||||||
|
vec->alc = 0;
|
||||||
|
if (vec->size == 0)
|
||||||
|
vec->base = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
110
deps/libbacktrace/mmapio.c
vendored
Normal file
110
deps/libbacktrace/mmapio.c
vendored
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* mmapio.c -- File views using mmap.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_DECL_GETPAGESIZE
|
||||||
|
extern int getpagesize (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAP_FAILED
|
||||||
|
#define MAP_FAILED ((void *)-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This file implements file views and memory allocation when mmap is
|
||||||
|
available. */
|
||||||
|
|
||||||
|
/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
int descriptor, off_t offset, uint64_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, struct backtrace_view *view)
|
||||||
|
{
|
||||||
|
size_t pagesize;
|
||||||
|
unsigned int inpage;
|
||||||
|
off_t pageoff;
|
||||||
|
void *map;
|
||||||
|
|
||||||
|
if ((uint64_t) (size_t) size != size)
|
||||||
|
{
|
||||||
|
error_callback (data, "file size too large", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pagesize = getpagesize ();
|
||||||
|
inpage = offset % pagesize;
|
||||||
|
pageoff = offset - inpage;
|
||||||
|
|
||||||
|
size += inpage;
|
||||||
|
size = (size + (pagesize - 1)) & ~ (pagesize - 1);
|
||||||
|
|
||||||
|
map = mmap (NULL, size, PROT_READ, MAP_PRIVATE, descriptor, pageoff);
|
||||||
|
if (map == MAP_FAILED)
|
||||||
|
{
|
||||||
|
error_callback (data, "mmap", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->data = (char *) map + inpage;
|
||||||
|
view->base = map;
|
||||||
|
view->len = size;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release a view read by backtrace_get_view. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_release_view (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
struct backtrace_view *view,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
const void *cv;
|
||||||
|
void *v;
|
||||||
|
} const_cast;
|
||||||
|
|
||||||
|
const_cast.cv = view->base;
|
||||||
|
if (munmap (const_cast.v, view->len) < 0)
|
||||||
|
error_callback (data, "munmap", errno);
|
||||||
|
}
|
83
deps/libbacktrace/move-if-change
vendored
Executable file
83
deps/libbacktrace/move-if-change
vendored
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Like mv $1 $2, but if the files are the same, just delete $1.
|
||||||
|
# Status is zero if successful, nonzero otherwise.
|
||||||
|
|
||||||
|
VERSION='2012-01-06 07:23'; # UTC
|
||||||
|
# The definition above must lie within the first 8 lines in order
|
||||||
|
# for the Emacs time-stamp write hook (at end) to update it.
|
||||||
|
# If you change this file with Emacs, please let the write hook
|
||||||
|
# do its job. Otherwise, update this string manually.
|
||||||
|
|
||||||
|
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
usage="usage: $0 SOURCE DEST"
|
||||||
|
|
||||||
|
help="$usage
|
||||||
|
or: $0 OPTION
|
||||||
|
If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
|
||||||
|
|
||||||
|
--help display this help and exit
|
||||||
|
--version output version information and exit
|
||||||
|
|
||||||
|
The variable CMPPROG can be used to specify an alternative to 'cmp'.
|
||||||
|
|
||||||
|
Report bugs to <bug-gnulib@gnu.org>."
|
||||||
|
|
||||||
|
version=`expr "$VERSION" : '\([^ ]*\)'`
|
||||||
|
version="move-if-change (gnulib) $version
|
||||||
|
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||||
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||||
|
This is free software: you are free to change and redistribute it.
|
||||||
|
There is NO WARRANTY, to the extent permitted by law."
|
||||||
|
|
||||||
|
cmpprog=${CMPPROG-cmp}
|
||||||
|
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
case $arg in
|
||||||
|
--help | --hel | --he | --h)
|
||||||
|
exec echo "$help" ;;
|
||||||
|
--version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||||
|
exec echo "$version" ;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break ;;
|
||||||
|
-*)
|
||||||
|
echo "$0: invalid option: $arg" >&2
|
||||||
|
exit 1 ;;
|
||||||
|
*)
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
test $# -eq 2 || { echo "$0: $usage" >&2; exit 1; }
|
||||||
|
|
||||||
|
if test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null; then
|
||||||
|
rm -f -- "$1"
|
||||||
|
else
|
||||||
|
if mv -f -- "$1" "$2"; then :; else
|
||||||
|
# Ignore failure due to a concurrent move-if-change.
|
||||||
|
test -r "$2" && $cmpprog -- "$1" "$2" >/dev/null && rm -f -- "$1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
## Local Variables:
|
||||||
|
## eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
## time-stamp-start: "VERSION='"
|
||||||
|
## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
|
||||||
|
## time-stamp-time-zone: "UTC"
|
||||||
|
## time-stamp-end: "'; # UTC"
|
||||||
|
## End:
|
410
deps/libbacktrace/mtest.c
vendored
Normal file
410
deps/libbacktrace/mtest.c
vendored
Normal file
@ -0,0 +1,410 @@
|
|||||||
|
/* mtest.c -- Minidebug test for libbacktrace library
|
||||||
|
Copyright (C) 2020-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* This program tests using libbacktrace with a program that uses the
|
||||||
|
minidebuginfo format in a .gnu_debugdata section. See
|
||||||
|
https://sourceware.org/gdb/current/onlinedocs/gdb/MiniDebugInfo.html
|
||||||
|
for a bit more information about minidebuginfo. What is relevant
|
||||||
|
for libbacktrace is that we have just a symbol table, with no debug
|
||||||
|
info, so we should be able to do a function backtrace, but we can't
|
||||||
|
do a file/line backtrace. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
static int test1 (void) __attribute__ ((noinline, noclone, unused));
|
||||||
|
static int f2 (int) __attribute__ ((noinline, noclone));
|
||||||
|
static int f3 (int, int) __attribute__ ((noinline, noclone));
|
||||||
|
|
||||||
|
/* Collected PC values. */
|
||||||
|
|
||||||
|
static uintptr_t addrs[20];
|
||||||
|
|
||||||
|
/* The backtrace callback function. This is like callback_one in
|
||||||
|
testlib.c, but it saves the PC also. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
callback_mtest (void *vdata, uintptr_t pc, const char *filename, int lineno,
|
||||||
|
const char *function)
|
||||||
|
{
|
||||||
|
struct bdata *data = (struct bdata *) vdata;
|
||||||
|
|
||||||
|
if (data->index >= sizeof addrs / sizeof addrs[0])
|
||||||
|
{
|
||||||
|
fprintf (stderr, "callback_mtest: callback called too many times\n");
|
||||||
|
data->failed = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
addrs[data->index] = pc;
|
||||||
|
|
||||||
|
return callback_one (vdata, pc, filename, lineno, function);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the backtrace function with non-inlined functions. (We don't
|
||||||
|
test with inlined functions because they won't work with minidebug
|
||||||
|
anyhow.) */
|
||||||
|
|
||||||
|
static int
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
/* Returning a value here and elsewhere avoids a tailcall which
|
||||||
|
would mess up the backtrace. */
|
||||||
|
return f2 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f2 (int f1line)
|
||||||
|
{
|
||||||
|
return f3 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f3 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata data;
|
||||||
|
int i;
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
data.all = &all[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_full (state, 0, callback_mtest, error_callback_one, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index < 3)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test1: not enough frames; got %zu, expected at least 3\n",
|
||||||
|
data.index);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When using minidebug we don't expect the function name here. */
|
||||||
|
|
||||||
|
for (j = 0; j < 3 && j < data.index; j++)
|
||||||
|
{
|
||||||
|
if (all[j].function == NULL)
|
||||||
|
{
|
||||||
|
struct symdata symdata;
|
||||||
|
|
||||||
|
symdata.name = NULL;
|
||||||
|
symdata.val = 0;
|
||||||
|
symdata.size = 0;
|
||||||
|
symdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_syminfo (state, addrs[j], callback_three,
|
||||||
|
error_callback_three, &symdata);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test1: [%zu], unexpected return value from "
|
||||||
|
"backtrace_syminfo %d\n"),
|
||||||
|
j, i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
else if (symdata.name == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [%zu]: syminfo did not find name\n", j);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
all[j].function = strdup (symdata.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index > 0)
|
||||||
|
{
|
||||||
|
if (all[0].function == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [0]: missing function name\n");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp (all[0].function, "f3") != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [0]: got %s expected %s\n",
|
||||||
|
all[0].function, "f3");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index > 1)
|
||||||
|
{
|
||||||
|
if (all[1].function == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [1]: missing function name\n");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp (all[1].function, "f2") != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [1]: got %s expected %s\n",
|
||||||
|
all[0].function, "f2");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index > 2)
|
||||||
|
{
|
||||||
|
if (all[2].function == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [2]: missing function name\n");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
else if (strcmp (all[2].function, "test1") != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: [2]: got %s expected %s\n",
|
||||||
|
all[0].function, "test1");
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the backtrace_simple function with non-inlined functions. */
|
||||||
|
|
||||||
|
static int test3 (void) __attribute__ ((noinline, noclone, unused));
|
||||||
|
static int f22 (int) __attribute__ ((noinline, noclone));
|
||||||
|
static int f23 (int, int) __attribute__ ((noinline, noclone));
|
||||||
|
|
||||||
|
static int
|
||||||
|
test3 (void)
|
||||||
|
{
|
||||||
|
return f22 (__LINE__) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f22 (int f1line)
|
||||||
|
{
|
||||||
|
return f23 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f23 (int f1line __attribute__ ((unused)), int f2line __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
uintptr_t addrs[20];
|
||||||
|
struct sdata data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.addrs = &addrs[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_simple (state, 0, callback_two, error_callback_two, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test3: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!data.failed)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
for (j = 0; j < 3; ++j)
|
||||||
|
{
|
||||||
|
struct symdata symdata;
|
||||||
|
|
||||||
|
symdata.name = NULL;
|
||||||
|
symdata.val = 0;
|
||||||
|
symdata.size = 0;
|
||||||
|
symdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_syminfo (state, addrs[j], callback_three,
|
||||||
|
error_callback_three, &symdata);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test3: [%d]: unexpected return value "
|
||||||
|
"from backtrace_syminfo %d\n"),
|
||||||
|
j, i);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!symdata.failed)
|
||||||
|
{
|
||||||
|
const char *expected;
|
||||||
|
|
||||||
|
switch (j)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
expected = "f23";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
expected = "f22";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
expected = "test3";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symdata.name == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
/* Use strncmp, not strcmp, because GCC might create a
|
||||||
|
clone. */
|
||||||
|
else if (strncmp (symdata.name, expected, strlen (expected))
|
||||||
|
!= 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("test3: [%d]: unexpected syminfo name "
|
||||||
|
"got %s expected %s\n"),
|
||||||
|
j, symdata.name, expected);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symdata.failed)
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (data.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test5 (void) __attribute__ ((unused));
|
||||||
|
|
||||||
|
int global = 1;
|
||||||
|
|
||||||
|
int
|
||||||
|
test5 (void)
|
||||||
|
{
|
||||||
|
struct symdata symdata;
|
||||||
|
int i;
|
||||||
|
uintptr_t addr = (uintptr_t) &global;
|
||||||
|
|
||||||
|
if (sizeof (global) > 1)
|
||||||
|
addr += 1;
|
||||||
|
|
||||||
|
symdata.name = NULL;
|
||||||
|
symdata.val = 0;
|
||||||
|
symdata.size = 0;
|
||||||
|
symdata.failed = 0;
|
||||||
|
|
||||||
|
i = backtrace_syminfo (state, addr, callback_three,
|
||||||
|
error_callback_three, &symdata);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected return value from backtrace_syminfo %d\n",
|
||||||
|
i);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!symdata.failed)
|
||||||
|
{
|
||||||
|
if (symdata.name == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test5: NULL syminfo name\n");
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (!(strncmp (symdata.name, "global", 6) == 0
|
||||||
|
&& (symdata.name[6] == '\0'|| symdata.name[6] == '.')))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo name got %s expected %s\n",
|
||||||
|
symdata.name, "global");
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (symdata.val != (uintptr_t) &global)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo value got %lx expected %lx\n",
|
||||||
|
(unsigned long) symdata.val,
|
||||||
|
(unsigned long) (uintptr_t) &global);
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
else if (symdata.size != sizeof (global))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test5: unexpected syminfo size got %lx expected %lx\n",
|
||||||
|
(unsigned long) symdata.size,
|
||||||
|
(unsigned long) sizeof (global));
|
||||||
|
symdata.failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: backtrace_syminfo variable\n",
|
||||||
|
symdata.failed ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
if (symdata.failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
#if BACKTRACE_SUPPORTED
|
||||||
|
test1 ();
|
||||||
|
test3 ();
|
||||||
|
#if BACKTRACE_SUPPORTS_DATA
|
||||||
|
test5 ();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
66
deps/libbacktrace/nounwind.c
vendored
Normal file
66
deps/libbacktrace/nounwind.c
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* backtrace.c -- Entry point for stack backtrace library.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* This source file is compiled if the unwind library is not
|
||||||
|
available. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_full (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
int skip ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_full_callback callback ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
error_callback (data,
|
||||||
|
"no stack trace because unwind library not available",
|
||||||
|
0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_simple (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
int skip ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_simple_callback callback ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
error_callback (data,
|
||||||
|
"no stack trace because unwind library not available",
|
||||||
|
0);
|
||||||
|
return 0;
|
||||||
|
}
|
935
deps/libbacktrace/pecoff.c
vendored
Normal file
935
deps/libbacktrace/pecoff.c
vendored
Normal file
@ -0,0 +1,935 @@
|
|||||||
|
/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces.
|
||||||
|
Copyright (C) 2015-2021 Free Software Foundation, Inc.
|
||||||
|
Adapted from elf.c by Tristan Gingold, AdaCore.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Coff file header. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t machine;
|
||||||
|
uint16_t number_of_sections;
|
||||||
|
uint32_t time_date_stamp;
|
||||||
|
uint32_t pointer_to_symbol_table;
|
||||||
|
uint32_t number_of_symbols;
|
||||||
|
uint16_t size_of_optional_header;
|
||||||
|
uint16_t characteristics;
|
||||||
|
} b_coff_file_header;
|
||||||
|
|
||||||
|
/* Coff optional header. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t magic;
|
||||||
|
uint8_t major_linker_version;
|
||||||
|
uint8_t minor_linker_version;
|
||||||
|
uint32_t size_of_code;
|
||||||
|
uint32_t size_of_initialized_data;
|
||||||
|
uint32_t size_of_uninitialized_data;
|
||||||
|
uint32_t address_of_entry_point;
|
||||||
|
uint32_t base_of_code;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint32_t base_of_data;
|
||||||
|
uint32_t image_base;
|
||||||
|
} pe;
|
||||||
|
struct {
|
||||||
|
uint64_t image_base;
|
||||||
|
} pep;
|
||||||
|
} u;
|
||||||
|
} b_coff_optional_header;
|
||||||
|
|
||||||
|
/* Values of magic in optional header. */
|
||||||
|
|
||||||
|
#define PE_MAGIC 0x10b /* PE32 executable. */
|
||||||
|
#define PEP_MAGIC 0x20b /* PE32+ executable (for 64bit targets). */
|
||||||
|
|
||||||
|
/* Coff section header. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char name[8];
|
||||||
|
uint32_t virtual_size;
|
||||||
|
uint32_t virtual_address;
|
||||||
|
uint32_t size_of_raw_data;
|
||||||
|
uint32_t pointer_to_raw_data;
|
||||||
|
uint32_t pointer_to_relocations;
|
||||||
|
uint32_t pointer_to_line_numbers;
|
||||||
|
uint16_t number_of_relocations;
|
||||||
|
uint16_t number_of_line_numbers;
|
||||||
|
uint32_t characteristics;
|
||||||
|
} b_coff_section_header;
|
||||||
|
|
||||||
|
/* Coff symbol name. */
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
char short_name[8];
|
||||||
|
struct {
|
||||||
|
unsigned char zeroes[4];
|
||||||
|
unsigned char off[4];
|
||||||
|
} long_name;
|
||||||
|
} b_coff_name;
|
||||||
|
|
||||||
|
/* Coff symbol (external representation which is unaligned). */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
b_coff_name name;
|
||||||
|
unsigned char value[4];
|
||||||
|
unsigned char section_number[2];
|
||||||
|
unsigned char type[2];
|
||||||
|
unsigned char storage_class;
|
||||||
|
unsigned char number_of_aux_symbols;
|
||||||
|
} b_coff_external_symbol;
|
||||||
|
|
||||||
|
/* Symbol types. */
|
||||||
|
|
||||||
|
#define N_TBSHFT 4 /* Shift for the derived type. */
|
||||||
|
#define IMAGE_SYM_DTYPE_FUNCTION 2 /* Function derived type. */
|
||||||
|
|
||||||
|
/* Size of a coff symbol. */
|
||||||
|
|
||||||
|
#define SYM_SZ 18
|
||||||
|
|
||||||
|
/* Coff symbol, internal representation (aligned). */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
uint32_t value;
|
||||||
|
int16_t sec;
|
||||||
|
uint16_t type;
|
||||||
|
uint16_t sc;
|
||||||
|
} b_coff_internal_symbol;
|
||||||
|
|
||||||
|
/* Names of sections, indexed by enum dwarf_section in internal.h. */
|
||||||
|
|
||||||
|
static const char * const debug_section_names[DEBUG_MAX] =
|
||||||
|
{
|
||||||
|
".debug_info",
|
||||||
|
".debug_line",
|
||||||
|
".debug_abbrev",
|
||||||
|
".debug_ranges",
|
||||||
|
".debug_str",
|
||||||
|
".debug_addr",
|
||||||
|
".debug_str_offsets",
|
||||||
|
".debug_line_str",
|
||||||
|
".debug_rnglists"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Information we gather for the sections we care about. */
|
||||||
|
|
||||||
|
struct debug_section_info
|
||||||
|
{
|
||||||
|
/* Section file offset. */
|
||||||
|
off_t offset;
|
||||||
|
/* Section size. */
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Information we keep for an coff symbol. */
|
||||||
|
|
||||||
|
struct coff_symbol
|
||||||
|
{
|
||||||
|
/* The name of the symbol. */
|
||||||
|
const char *name;
|
||||||
|
/* The address of the symbol. */
|
||||||
|
uintptr_t address;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Information to pass to coff_syminfo. */
|
||||||
|
|
||||||
|
struct coff_syminfo_data
|
||||||
|
{
|
||||||
|
/* Symbols for the next module. */
|
||||||
|
struct coff_syminfo_data *next;
|
||||||
|
/* The COFF symbols, sorted by address. */
|
||||||
|
struct coff_symbol *symbols;
|
||||||
|
/* The number of symbols. */
|
||||||
|
size_t count;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A dummy callback function used when we can't find any debug info. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
uintptr_t pc ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_full_callback callback ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
error_callback (data, "no debug info in PE/COFF executable", -1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A dummy callback function used when we can't find a symbol
|
||||||
|
table. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
coff_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
uintptr_t addr ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_syminfo_callback callback ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
error_callback (data, "no symbol table in PE/COFF executable", -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read a potentially unaligned 4 byte word at P, using native endianness. */
|
||||||
|
|
||||||
|
static uint32_t
|
||||||
|
coff_read4 (const unsigned char *p)
|
||||||
|
{
|
||||||
|
uint32_t res;
|
||||||
|
|
||||||
|
memcpy (&res, p, 4);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read a potentially unaligned 2 byte word at P, using native endianness.
|
||||||
|
All 2 byte word in symbols are always aligned, but for coherency all
|
||||||
|
fields are declared as char arrays. */
|
||||||
|
|
||||||
|
static uint16_t
|
||||||
|
coff_read2 (const unsigned char *p)
|
||||||
|
{
|
||||||
|
uint16_t res;
|
||||||
|
|
||||||
|
memcpy (&res, p, sizeof (res));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the length (without the trailing 0) of a COFF short name. */
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
coff_short_name_len (const char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
if (name[i] == 0)
|
||||||
|
return i;
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return true iff COFF short name CNAME is the same as NAME (a NUL-terminated
|
||||||
|
string). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_short_name_eq (const char *name, const char *cname)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if (name[i] != cname[i])
|
||||||
|
return 0;
|
||||||
|
if (name[i] == 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return name[8] == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return true iff NAME is the same as string at offset OFF. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_long_name_eq (const char *name, unsigned int off,
|
||||||
|
struct backtrace_view *str_view)
|
||||||
|
{
|
||||||
|
if (off >= str_view->len)
|
||||||
|
return 0;
|
||||||
|
return strcmp (name, (const char *)str_view->data + off) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compare struct coff_symbol for qsort. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_symbol_compare (const void *v1, const void *v2)
|
||||||
|
{
|
||||||
|
const struct coff_symbol *e1 = (const struct coff_symbol *) v1;
|
||||||
|
const struct coff_symbol *e2 = (const struct coff_symbol *) v2;
|
||||||
|
|
||||||
|
if (e1->address < e2->address)
|
||||||
|
return -1;
|
||||||
|
else if (e1->address > e2->address)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert SYM to internal (and aligned) format ISYM, using string table
|
||||||
|
from STRTAB and STRTAB_SIZE, and number of sections SECTS_NUM.
|
||||||
|
Return -1 in case of error (invalid section number or string index). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_expand_symbol (b_coff_internal_symbol *isym,
|
||||||
|
const b_coff_external_symbol *sym,
|
||||||
|
uint16_t sects_num,
|
||||||
|
const unsigned char *strtab, size_t strtab_size)
|
||||||
|
{
|
||||||
|
isym->type = coff_read2 (sym->type);
|
||||||
|
isym->sec = coff_read2 (sym->section_number);
|
||||||
|
isym->sc = sym->storage_class;
|
||||||
|
|
||||||
|
if (isym->sec > 0 && (uint16_t) isym->sec > sects_num)
|
||||||
|
return -1;
|
||||||
|
if (sym->name.short_name[0] != 0)
|
||||||
|
isym->name = sym->name.short_name;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint32_t off = coff_read4 (sym->name.long_name.off);
|
||||||
|
|
||||||
|
if (off >= strtab_size)
|
||||||
|
return -1;
|
||||||
|
isym->name = (const char *) strtab + off;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return true iff SYM is a defined symbol for a function. Data symbols
|
||||||
|
aren't considered because they aren't easily identified (same type as
|
||||||
|
section names, presence of symbols defined by the linker script). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_is_function_symbol (const b_coff_internal_symbol *isym)
|
||||||
|
{
|
||||||
|
return (isym->type >> N_TBSHFT) == IMAGE_SYM_DTYPE_FUNCTION
|
||||||
|
&& isym->sec > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the symbol table info for coff_syminfo. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_initialize_syminfo (struct backtrace_state *state,
|
||||||
|
uintptr_t base_address, int is_64,
|
||||||
|
const b_coff_section_header *sects, size_t sects_num,
|
||||||
|
const b_coff_external_symbol *syms, size_t syms_size,
|
||||||
|
const unsigned char *strtab, size_t strtab_size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, struct coff_syminfo_data *sdata)
|
||||||
|
{
|
||||||
|
size_t syms_count;
|
||||||
|
char *coff_symstr;
|
||||||
|
size_t coff_symstr_len;
|
||||||
|
size_t coff_symbol_count;
|
||||||
|
size_t coff_symbol_size;
|
||||||
|
struct coff_symbol *coff_symbols;
|
||||||
|
struct coff_symbol *coff_sym;
|
||||||
|
char *coff_str;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
syms_count = syms_size / SYM_SZ;
|
||||||
|
|
||||||
|
/* We only care about function symbols. Count them. Also count size of
|
||||||
|
strings for in-symbol names. */
|
||||||
|
coff_symbol_count = 0;
|
||||||
|
coff_symstr_len = 0;
|
||||||
|
for (i = 0; i < syms_count; ++i)
|
||||||
|
{
|
||||||
|
const b_coff_external_symbol *asym = &syms[i];
|
||||||
|
b_coff_internal_symbol isym;
|
||||||
|
|
||||||
|
if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size) < 0)
|
||||||
|
{
|
||||||
|
error_callback (data, "invalid section or offset in coff symbol", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (coff_is_function_symbol (&isym))
|
||||||
|
{
|
||||||
|
++coff_symbol_count;
|
||||||
|
if (asym->name.short_name[0] != 0)
|
||||||
|
coff_symstr_len += coff_short_name_len (asym->name.short_name) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += asym->number_of_aux_symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
coff_symbol_size = (coff_symbol_count + 1) * sizeof (struct coff_symbol);
|
||||||
|
coff_symbols = ((struct coff_symbol *)
|
||||||
|
backtrace_alloc (state, coff_symbol_size, error_callback,
|
||||||
|
data));
|
||||||
|
if (coff_symbols == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Allocate memory for symbols strings. */
|
||||||
|
if (coff_symstr_len > 0)
|
||||||
|
{
|
||||||
|
coff_symstr = ((char *)
|
||||||
|
backtrace_alloc (state, coff_symstr_len, error_callback,
|
||||||
|
data));
|
||||||
|
if (coff_symstr == NULL)
|
||||||
|
{
|
||||||
|
backtrace_free (state, coff_symbols, coff_symbol_size,
|
||||||
|
error_callback, data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
coff_symstr = NULL;
|
||||||
|
|
||||||
|
/* Copy symbols. */
|
||||||
|
coff_sym = coff_symbols;
|
||||||
|
coff_str = coff_symstr;
|
||||||
|
for (i = 0; i < syms_count; ++i)
|
||||||
|
{
|
||||||
|
const b_coff_external_symbol *asym = &syms[i];
|
||||||
|
b_coff_internal_symbol isym;
|
||||||
|
|
||||||
|
if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size))
|
||||||
|
{
|
||||||
|
/* Should not fail, as it was already tested in the previous
|
||||||
|
loop. */
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
if (coff_is_function_symbol (&isym))
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int16_t secnum;
|
||||||
|
|
||||||
|
if (asym->name.short_name[0] != 0)
|
||||||
|
{
|
||||||
|
size_t len = coff_short_name_len (isym.name);
|
||||||
|
name = coff_str;
|
||||||
|
memcpy (coff_str, isym.name, len);
|
||||||
|
coff_str[len] = 0;
|
||||||
|
coff_str += len + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
name = isym.name;
|
||||||
|
|
||||||
|
if (!is_64)
|
||||||
|
{
|
||||||
|
/* Strip leading '_'. */
|
||||||
|
if (name[0] == '_')
|
||||||
|
name++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Symbol value is section relative, so we need to read the address
|
||||||
|
of its section. */
|
||||||
|
secnum = coff_read2 (asym->section_number);
|
||||||
|
|
||||||
|
coff_sym->name = name;
|
||||||
|
coff_sym->address = (coff_read4 (asym->value)
|
||||||
|
+ sects[secnum - 1].virtual_address
|
||||||
|
+ base_address);
|
||||||
|
coff_sym++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += asym->number_of_aux_symbols;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of symbols marker. */
|
||||||
|
coff_sym->name = NULL;
|
||||||
|
coff_sym->address = -1;
|
||||||
|
|
||||||
|
backtrace_qsort (coff_symbols, coff_symbol_count,
|
||||||
|
sizeof (struct coff_symbol), coff_symbol_compare);
|
||||||
|
|
||||||
|
sdata->next = NULL;
|
||||||
|
sdata->symbols = coff_symbols;
|
||||||
|
sdata->count = coff_symbol_count;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add EDATA to the list in STATE. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
coff_add_syminfo_data (struct backtrace_state *state,
|
||||||
|
struct coff_syminfo_data *sdata)
|
||||||
|
{
|
||||||
|
if (!state->threaded)
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data **pp;
|
||||||
|
|
||||||
|
for (pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
|
||||||
|
*pp != NULL;
|
||||||
|
pp = &(*pp)->next)
|
||||||
|
;
|
||||||
|
*pp = sdata;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data **pp;
|
||||||
|
|
||||||
|
pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data *p;
|
||||||
|
|
||||||
|
p = backtrace_atomic_load_pointer (pp);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pp = &p->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__sync_bool_compare_and_swap (pp, NULL, sdata))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compare an ADDR against an elf_symbol for bsearch. We allocate one
|
||||||
|
extra entry in the array so that this can look safely at the next
|
||||||
|
entry. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_symbol_search (const void *vkey, const void *ventry)
|
||||||
|
{
|
||||||
|
const uintptr_t *key = (const uintptr_t *) vkey;
|
||||||
|
const struct coff_symbol *entry = (const struct coff_symbol *) ventry;
|
||||||
|
uintptr_t addr;
|
||||||
|
|
||||||
|
addr = *key;
|
||||||
|
if (addr < entry->address)
|
||||||
|
return -1;
|
||||||
|
else if (addr >= entry[1].address)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the symbol name and value for an ADDR. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
coff_syminfo (struct backtrace_state *state, uintptr_t addr,
|
||||||
|
backtrace_syminfo_callback callback,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data *sdata;
|
||||||
|
struct coff_symbol *sym = NULL;
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
{
|
||||||
|
for (sdata = (struct coff_syminfo_data *) state->syminfo_data;
|
||||||
|
sdata != NULL;
|
||||||
|
sdata = sdata->next)
|
||||||
|
{
|
||||||
|
sym = ((struct coff_symbol *)
|
||||||
|
bsearch (&addr, sdata->symbols, sdata->count,
|
||||||
|
sizeof (struct coff_symbol), coff_symbol_search));
|
||||||
|
if (sym != NULL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data **pp;
|
||||||
|
|
||||||
|
pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
sdata = backtrace_atomic_load_pointer (pp);
|
||||||
|
if (sdata == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
sym = ((struct coff_symbol *)
|
||||||
|
bsearch (&addr, sdata->symbols, sdata->count,
|
||||||
|
sizeof (struct coff_symbol), coff_symbol_search));
|
||||||
|
if (sym != NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
pp = &sdata->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sym == NULL)
|
||||||
|
callback (data, addr, NULL, 0, 0);
|
||||||
|
else
|
||||||
|
callback (data, addr, sym->name, sym->address, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the backtrace data for one PE/COFF file. Returns 1 on success,
|
||||||
|
0 on failure (in both cases descriptor is closed). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
coff_add (struct backtrace_state *state, int descriptor,
|
||||||
|
backtrace_error_callback error_callback, void *data,
|
||||||
|
fileline *fileline_fn, int *found_sym, int *found_dwarf)
|
||||||
|
{
|
||||||
|
struct backtrace_view fhdr_view;
|
||||||
|
off_t fhdr_off;
|
||||||
|
int magic_ok;
|
||||||
|
b_coff_file_header fhdr;
|
||||||
|
off_t opt_sects_off;
|
||||||
|
size_t opt_sects_size;
|
||||||
|
unsigned int sects_num;
|
||||||
|
struct backtrace_view sects_view;
|
||||||
|
int sects_view_valid;
|
||||||
|
const b_coff_optional_header *opt_hdr;
|
||||||
|
const b_coff_section_header *sects;
|
||||||
|
struct backtrace_view str_view;
|
||||||
|
int str_view_valid;
|
||||||
|
size_t str_size;
|
||||||
|
off_t str_off;
|
||||||
|
struct backtrace_view syms_view;
|
||||||
|
off_t syms_off;
|
||||||
|
size_t syms_size;
|
||||||
|
int syms_view_valid;
|
||||||
|
unsigned int syms_num;
|
||||||
|
unsigned int i;
|
||||||
|
struct debug_section_info sections[DEBUG_MAX];
|
||||||
|
off_t min_offset;
|
||||||
|
off_t max_offset;
|
||||||
|
struct backtrace_view debug_view;
|
||||||
|
int debug_view_valid;
|
||||||
|
int is_64;
|
||||||
|
uintptr_t image_base;
|
||||||
|
struct dwarf_sections dwarf_sections;
|
||||||
|
|
||||||
|
*found_sym = 0;
|
||||||
|
*found_dwarf = 0;
|
||||||
|
|
||||||
|
sects_view_valid = 0;
|
||||||
|
syms_view_valid = 0;
|
||||||
|
str_view_valid = 0;
|
||||||
|
debug_view_valid = 0;
|
||||||
|
|
||||||
|
/* Map the MS-DOS stub (if any) and extract file header offset. */
|
||||||
|
if (!backtrace_get_view (state, descriptor, 0, 0x40, error_callback,
|
||||||
|
data, &fhdr_view))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
{
|
||||||
|
const unsigned char *vptr = fhdr_view.data;
|
||||||
|
|
||||||
|
if (vptr[0] == 'M' && vptr[1] == 'Z')
|
||||||
|
fhdr_off = coff_read4 (vptr + 0x3c);
|
||||||
|
else
|
||||||
|
fhdr_off = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
backtrace_release_view (state, &fhdr_view, error_callback, data);
|
||||||
|
|
||||||
|
/* Map the coff file header. */
|
||||||
|
if (!backtrace_get_view (state, descriptor, fhdr_off,
|
||||||
|
sizeof (b_coff_file_header) + 4,
|
||||||
|
error_callback, data, &fhdr_view))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (fhdr_off != 0)
|
||||||
|
{
|
||||||
|
const char *magic = (const char *) fhdr_view.data;
|
||||||
|
magic_ok = memcmp (magic, "PE\0", 4) == 0;
|
||||||
|
fhdr_off += 4;
|
||||||
|
|
||||||
|
memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy (&fhdr, fhdr_view.data, sizeof fhdr);
|
||||||
|
/* TODO: test fhdr.machine for coff but non-PE platforms. */
|
||||||
|
magic_ok = 0;
|
||||||
|
}
|
||||||
|
backtrace_release_view (state, &fhdr_view, error_callback, data);
|
||||||
|
|
||||||
|
if (!magic_ok)
|
||||||
|
{
|
||||||
|
error_callback (data, "executable file is not COFF", 0);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
sects_num = fhdr.number_of_sections;
|
||||||
|
syms_num = fhdr.number_of_symbols;
|
||||||
|
|
||||||
|
opt_sects_off = fhdr_off + sizeof (fhdr);
|
||||||
|
opt_sects_size = (fhdr.size_of_optional_header
|
||||||
|
+ sects_num * sizeof (b_coff_section_header));
|
||||||
|
|
||||||
|
/* To translate PC to file/line when using DWARF, we need to find
|
||||||
|
the .debug_info and .debug_line sections. */
|
||||||
|
|
||||||
|
/* Read the optional header and the section headers. */
|
||||||
|
|
||||||
|
if (!backtrace_get_view (state, descriptor, opt_sects_off, opt_sects_size,
|
||||||
|
error_callback, data, §s_view))
|
||||||
|
goto fail;
|
||||||
|
sects_view_valid = 1;
|
||||||
|
opt_hdr = (const b_coff_optional_header *) sects_view.data;
|
||||||
|
sects = (const b_coff_section_header *)
|
||||||
|
(sects_view.data + fhdr.size_of_optional_header);
|
||||||
|
|
||||||
|
is_64 = 0;
|
||||||
|
if (fhdr.size_of_optional_header > sizeof (*opt_hdr))
|
||||||
|
{
|
||||||
|
if (opt_hdr->magic == PE_MAGIC)
|
||||||
|
image_base = opt_hdr->u.pe.image_base;
|
||||||
|
else if (opt_hdr->magic == PEP_MAGIC)
|
||||||
|
{
|
||||||
|
image_base = opt_hdr->u.pep.image_base;
|
||||||
|
is_64 = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_callback (data, "bad magic in PE optional header", 0);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
image_base = 0;
|
||||||
|
|
||||||
|
/* Read the symbol table and the string table. */
|
||||||
|
|
||||||
|
if (fhdr.pointer_to_symbol_table == 0)
|
||||||
|
{
|
||||||
|
/* No symbol table, no string table. */
|
||||||
|
str_off = 0;
|
||||||
|
str_size = 0;
|
||||||
|
syms_num = 0;
|
||||||
|
syms_size = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Symbol table is followed by the string table. The string table
|
||||||
|
starts with its length (on 4 bytes).
|
||||||
|
Map the symbol table and the length of the string table. */
|
||||||
|
syms_off = fhdr.pointer_to_symbol_table;
|
||||||
|
syms_size = syms_num * SYM_SZ;
|
||||||
|
|
||||||
|
if (!backtrace_get_view (state, descriptor, syms_off, syms_size + 4,
|
||||||
|
error_callback, data, &syms_view))
|
||||||
|
goto fail;
|
||||||
|
syms_view_valid = 1;
|
||||||
|
|
||||||
|
str_size = coff_read4 (syms_view.data + syms_size);
|
||||||
|
|
||||||
|
str_off = syms_off + syms_size;
|
||||||
|
|
||||||
|
if (str_size > 4)
|
||||||
|
{
|
||||||
|
/* Map string table (including the length word). */
|
||||||
|
|
||||||
|
if (!backtrace_get_view (state, descriptor, str_off, str_size,
|
||||||
|
error_callback, data, &str_view))
|
||||||
|
goto fail;
|
||||||
|
str_view_valid = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (sections, 0, sizeof sections);
|
||||||
|
|
||||||
|
/* Look for the symbol table. */
|
||||||
|
for (i = 0; i < sects_num; ++i)
|
||||||
|
{
|
||||||
|
const b_coff_section_header *s = sects + i;
|
||||||
|
unsigned int str_off;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
if (s->name[0] == '/')
|
||||||
|
{
|
||||||
|
/* Extended section name. */
|
||||||
|
str_off = atoi (s->name + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str_off = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < (int) DEBUG_MAX; ++j)
|
||||||
|
{
|
||||||
|
const char *dbg_name = debug_section_names[j];
|
||||||
|
int match;
|
||||||
|
|
||||||
|
if (str_off != 0)
|
||||||
|
match = coff_long_name_eq (dbg_name, str_off, &str_view);
|
||||||
|
else
|
||||||
|
match = coff_short_name_eq (dbg_name, s->name);
|
||||||
|
if (match)
|
||||||
|
{
|
||||||
|
sections[j].offset = s->pointer_to_raw_data;
|
||||||
|
sections[j].size = s->virtual_size <= s->size_of_raw_data ?
|
||||||
|
s->virtual_size : s->size_of_raw_data;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syms_num != 0)
|
||||||
|
{
|
||||||
|
struct coff_syminfo_data *sdata;
|
||||||
|
|
||||||
|
sdata = ((struct coff_syminfo_data *)
|
||||||
|
backtrace_alloc (state, sizeof *sdata, error_callback, data));
|
||||||
|
if (sdata == NULL)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (!coff_initialize_syminfo (state, image_base, is_64,
|
||||||
|
sects, sects_num,
|
||||||
|
syms_view.data, syms_size,
|
||||||
|
str_view.data, str_size,
|
||||||
|
error_callback, data, sdata))
|
||||||
|
{
|
||||||
|
backtrace_free (state, sdata, sizeof *sdata, error_callback, data);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
*found_sym = 1;
|
||||||
|
|
||||||
|
coff_add_syminfo_data (state, sdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
backtrace_release_view (state, §s_view, error_callback, data);
|
||||||
|
sects_view_valid = 0;
|
||||||
|
if (syms_view_valid)
|
||||||
|
{
|
||||||
|
backtrace_release_view (state, &syms_view, error_callback, data);
|
||||||
|
syms_view_valid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read all the debug sections in a single view, since they are
|
||||||
|
probably adjacent in the file. We never release this view. */
|
||||||
|
|
||||||
|
min_offset = 0;
|
||||||
|
max_offset = 0;
|
||||||
|
for (i = 0; i < (int) DEBUG_MAX; ++i)
|
||||||
|
{
|
||||||
|
off_t end;
|
||||||
|
|
||||||
|
if (sections[i].size == 0)
|
||||||
|
continue;
|
||||||
|
if (min_offset == 0 || sections[i].offset < min_offset)
|
||||||
|
min_offset = sections[i].offset;
|
||||||
|
end = sections[i].offset + sections[i].size;
|
||||||
|
if (end > max_offset)
|
||||||
|
max_offset = end;
|
||||||
|
}
|
||||||
|
if (min_offset == 0 || max_offset == 0)
|
||||||
|
{
|
||||||
|
if (!backtrace_close (descriptor, error_callback, data))
|
||||||
|
goto fail;
|
||||||
|
*fileline_fn = coff_nodebug;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_get_view (state, descriptor, min_offset,
|
||||||
|
max_offset - min_offset,
|
||||||
|
error_callback, data, &debug_view))
|
||||||
|
goto fail;
|
||||||
|
debug_view_valid = 1;
|
||||||
|
|
||||||
|
/* We've read all we need from the executable. */
|
||||||
|
if (!backtrace_close (descriptor, error_callback, data))
|
||||||
|
goto fail;
|
||||||
|
descriptor = -1;
|
||||||
|
|
||||||
|
for (i = 0; i < (int) DEBUG_MAX; ++i)
|
||||||
|
{
|
||||||
|
size_t size = sections[i].size;
|
||||||
|
dwarf_sections.size[i] = size;
|
||||||
|
if (size == 0)
|
||||||
|
dwarf_sections.data[i] = NULL;
|
||||||
|
else
|
||||||
|
dwarf_sections.data[i] = ((const unsigned char *) debug_view.data
|
||||||
|
+ (sections[i].offset - min_offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_dwarf_add (state, /* base_address */ 0, &dwarf_sections,
|
||||||
|
0, /* FIXME: is_bigendian */
|
||||||
|
NULL, /* altlink */
|
||||||
|
error_callback, data, fileline_fn,
|
||||||
|
NULL /* returned fileline_entry */))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
*found_dwarf = 1;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (sects_view_valid)
|
||||||
|
backtrace_release_view (state, §s_view, error_callback, data);
|
||||||
|
if (str_view_valid)
|
||||||
|
backtrace_release_view (state, &str_view, error_callback, data);
|
||||||
|
if (syms_view_valid)
|
||||||
|
backtrace_release_view (state, &syms_view, error_callback, data);
|
||||||
|
if (debug_view_valid)
|
||||||
|
backtrace_release_view (state, &debug_view, error_callback, data);
|
||||||
|
if (descriptor != -1)
|
||||||
|
backtrace_close (descriptor, error_callback, data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the backtrace data we need from an ELF executable. At
|
||||||
|
the ELF level, all we need to do is find the debug info
|
||||||
|
sections. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_initialize (struct backtrace_state *state,
|
||||||
|
const char *filename ATTRIBUTE_UNUSED, int descriptor,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, fileline *fileline_fn)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
int found_sym;
|
||||||
|
int found_dwarf;
|
||||||
|
fileline coff_fileline_fn;
|
||||||
|
|
||||||
|
ret = coff_add (state, descriptor, error_callback, data,
|
||||||
|
&coff_fileline_fn, &found_sym, &found_dwarf);
|
||||||
|
if (!ret)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
{
|
||||||
|
if (found_sym)
|
||||||
|
state->syminfo_fn = coff_syminfo;
|
||||||
|
else if (state->syminfo_fn == NULL)
|
||||||
|
state->syminfo_fn = coff_nosyms;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (found_sym)
|
||||||
|
backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo);
|
||||||
|
else
|
||||||
|
(void) __sync_bool_compare_and_swap (&state->syminfo_fn, NULL,
|
||||||
|
coff_nosyms);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state->threaded)
|
||||||
|
{
|
||||||
|
if (state->fileline_fn == NULL || state->fileline_fn == coff_nodebug)
|
||||||
|
*fileline_fn = coff_fileline_fn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileline current_fn;
|
||||||
|
|
||||||
|
current_fn = backtrace_atomic_load_pointer (&state->fileline_fn);
|
||||||
|
if (current_fn == NULL || current_fn == coff_nodebug)
|
||||||
|
*fileline_fn = coff_fileline_fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
104
deps/libbacktrace/posix.c
vendored
Normal file
104
deps/libbacktrace/posix.c
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/* posix.c -- POSIX file I/O routines for the backtrace library.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_CLOEXEC
|
||||||
|
#define O_CLOEXEC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FD_CLOEXEC
|
||||||
|
#define FD_CLOEXEC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Open a file for reading. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_open (const char *filename, backtrace_error_callback error_callback,
|
||||||
|
void *data, int *does_not_exist)
|
||||||
|
{
|
||||||
|
int descriptor;
|
||||||
|
|
||||||
|
if (does_not_exist != NULL)
|
||||||
|
*does_not_exist = 0;
|
||||||
|
|
||||||
|
descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC));
|
||||||
|
if (descriptor < 0)
|
||||||
|
{
|
||||||
|
/* If DOES_NOT_EXIST is not NULL, then don't call ERROR_CALLBACK
|
||||||
|
if the file does not exist. We treat lacking permission to
|
||||||
|
open the file as the file not existing; this case arises when
|
||||||
|
running the libgo syscall package tests as root. */
|
||||||
|
if (does_not_exist != NULL && (errno == ENOENT || errno == EACCES))
|
||||||
|
*does_not_exist = 1;
|
||||||
|
else
|
||||||
|
error_callback (data, filename, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL
|
||||||
|
/* Set FD_CLOEXEC just in case the kernel does not support
|
||||||
|
O_CLOEXEC. It doesn't matter if this fails for some reason.
|
||||||
|
FIXME: At some point it should be safe to only do this if
|
||||||
|
O_CLOEXEC == 0. */
|
||||||
|
fcntl (descriptor, F_SETFD, FD_CLOEXEC);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close DESCRIPTOR. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_close (int descriptor, backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
if (close (descriptor) < 0)
|
||||||
|
{
|
||||||
|
error_callback (data, "close", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
92
deps/libbacktrace/print.c
vendored
Normal file
92
deps/libbacktrace/print.c
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* print.c -- Print the current backtrace.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Passed to callbacks. */
|
||||||
|
|
||||||
|
struct print_data
|
||||||
|
{
|
||||||
|
struct backtrace_state *state;
|
||||||
|
FILE *f;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Print one level of a backtrace. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
print_callback (void *data, uintptr_t pc, const char *filename, int lineno,
|
||||||
|
const char *function)
|
||||||
|
{
|
||||||
|
struct print_data *pdata = (struct print_data *) data;
|
||||||
|
|
||||||
|
fprintf (pdata->f, "0x%lx %s\n\t%s:%d\n",
|
||||||
|
(unsigned long) pc,
|
||||||
|
function == NULL ? "???" : function,
|
||||||
|
filename == NULL ? "???" : filename,
|
||||||
|
lineno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print errors to stderr. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback (void *data, const char *msg, int errnum)
|
||||||
|
{
|
||||||
|
struct print_data *pdata = (struct print_data *) data;
|
||||||
|
|
||||||
|
if (pdata->state->filename != NULL)
|
||||||
|
fprintf (stderr, "%s: ", pdata->state->filename);
|
||||||
|
fprintf (stderr, "libbacktrace: %s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fputc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a backtrace. */
|
||||||
|
|
||||||
|
void __attribute__((noinline))
|
||||||
|
backtrace_print (struct backtrace_state *state, int skip, FILE *f)
|
||||||
|
{
|
||||||
|
struct print_data data;
|
||||||
|
|
||||||
|
data.state = state;
|
||||||
|
data.f = f;
|
||||||
|
backtrace_full (state, skip + 1, print_callback, error_callback,
|
||||||
|
(void *) &data);
|
||||||
|
}
|
110
deps/libbacktrace/read.c
vendored
Normal file
110
deps/libbacktrace/read.c
vendored
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* read.c -- File views without mmap.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* This file implements file views when mmap is not available. */
|
||||||
|
|
||||||
|
/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_get_view (struct backtrace_state *state, int descriptor,
|
||||||
|
off_t offset, uint64_t size,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data, struct backtrace_view *view)
|
||||||
|
{
|
||||||
|
uint64_t got;
|
||||||
|
ssize_t r;
|
||||||
|
|
||||||
|
if ((uint64_t) (size_t) size != size)
|
||||||
|
{
|
||||||
|
error_callback (data, "file size too large", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lseek (descriptor, offset, SEEK_SET) < 0)
|
||||||
|
{
|
||||||
|
error_callback (data, "lseek", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->base = backtrace_alloc (state, size, error_callback, data);
|
||||||
|
if (view->base == NULL)
|
||||||
|
return 0;
|
||||||
|
view->data = view->base;
|
||||||
|
view->len = size;
|
||||||
|
|
||||||
|
got = 0;
|
||||||
|
while (got < size)
|
||||||
|
{
|
||||||
|
r = read (descriptor, view->base, size - got);
|
||||||
|
if (r < 0)
|
||||||
|
{
|
||||||
|
error_callback (data, "read", errno);
|
||||||
|
free (view->base);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
got += (uint64_t) r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (got < size)
|
||||||
|
{
|
||||||
|
error_callback (data, "file too short", 0);
|
||||||
|
free (view->base);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release a view read by backtrace_get_view. */
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_release_view (struct backtrace_state *state,
|
||||||
|
struct backtrace_view *view,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
backtrace_free (state, view->base, view->len, error_callback, data);
|
||||||
|
view->data = NULL;
|
||||||
|
view->base = NULL;
|
||||||
|
}
|
108
deps/libbacktrace/simple.c
vendored
Normal file
108
deps/libbacktrace/simple.c
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/* simple.c -- The backtrace_simple function.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include "unwind.h"
|
||||||
|
#include "backtrace.h"
|
||||||
|
|
||||||
|
/* The simple_backtrace routine. */
|
||||||
|
|
||||||
|
/* Data passed through _Unwind_Backtrace. */
|
||||||
|
|
||||||
|
struct backtrace_simple_data
|
||||||
|
{
|
||||||
|
/* Number of frames to skip. */
|
||||||
|
int skip;
|
||||||
|
/* Library state. */
|
||||||
|
struct backtrace_state *state;
|
||||||
|
/* Callback routine. */
|
||||||
|
backtrace_simple_callback callback;
|
||||||
|
/* Error callback routine. */
|
||||||
|
backtrace_error_callback error_callback;
|
||||||
|
/* Data to pass to callback routine. */
|
||||||
|
void *data;
|
||||||
|
/* Value to return from backtrace. */
|
||||||
|
int ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Unwind library callback routine. This is passed to
|
||||||
|
_Unwind_Backtrace. */
|
||||||
|
|
||||||
|
static _Unwind_Reason_Code
|
||||||
|
simple_unwind (struct _Unwind_Context *context, void *vdata)
|
||||||
|
{
|
||||||
|
struct backtrace_simple_data *bdata = (struct backtrace_simple_data *) vdata;
|
||||||
|
uintptr_t pc;
|
||||||
|
int ip_before_insn = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_GETIPINFO
|
||||||
|
pc = _Unwind_GetIPInfo (context, &ip_before_insn);
|
||||||
|
#else
|
||||||
|
pc = _Unwind_GetIP (context);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (bdata->skip > 0)
|
||||||
|
{
|
||||||
|
--bdata->skip;
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip_before_insn)
|
||||||
|
--pc;
|
||||||
|
|
||||||
|
bdata->ret = bdata->callback (bdata->data, pc);
|
||||||
|
|
||||||
|
if (bdata->ret != 0)
|
||||||
|
return _URC_END_OF_STACK;
|
||||||
|
|
||||||
|
return _URC_NO_REASON;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get a simple stack backtrace. */
|
||||||
|
|
||||||
|
int __attribute__((noinline))
|
||||||
|
backtrace_simple (struct backtrace_state *state, int skip,
|
||||||
|
backtrace_simple_callback callback,
|
||||||
|
backtrace_error_callback error_callback, void *data)
|
||||||
|
{
|
||||||
|
struct backtrace_simple_data bdata;
|
||||||
|
|
||||||
|
bdata.skip = skip + 1;
|
||||||
|
bdata.state = state;
|
||||||
|
bdata.callback = callback;
|
||||||
|
bdata.error_callback = error_callback;
|
||||||
|
bdata.data = data;
|
||||||
|
bdata.ret = 0;
|
||||||
|
_Unwind_Backtrace (simple_unwind, &bdata);
|
||||||
|
return bdata.ret;
|
||||||
|
}
|
108
deps/libbacktrace/sort.c
vendored
Normal file
108
deps/libbacktrace/sort.c
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/* sort.c -- Sort without allocating memory
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* The GNU glibc version of qsort allocates memory, which we must not
|
||||||
|
do if we are invoked by a signal handler. So provide our own
|
||||||
|
sort. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
swap (char *a, char *b, size_t size)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < size; i++, a++, b++)
|
||||||
|
{
|
||||||
|
char t;
|
||||||
|
|
||||||
|
t = *a;
|
||||||
|
*a = *b;
|
||||||
|
*b = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
backtrace_qsort (void *basearg, size_t count, size_t size,
|
||||||
|
int (*compar) (const void *, const void *))
|
||||||
|
{
|
||||||
|
char *base = (char *) basearg;
|
||||||
|
size_t i;
|
||||||
|
size_t mid;
|
||||||
|
|
||||||
|
tail_recurse:
|
||||||
|
if (count < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* The symbol table and DWARF tables, which is all we use this
|
||||||
|
routine for, tend to be roughly sorted. Pick the middle element
|
||||||
|
in the array as our pivot point, so that we are more likely to
|
||||||
|
cut the array in half for each recursion step. */
|
||||||
|
swap (base, base + (count / 2) * size, size);
|
||||||
|
|
||||||
|
mid = 0;
|
||||||
|
for (i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
if ((*compar) (base, base + i * size) > 0)
|
||||||
|
{
|
||||||
|
++mid;
|
||||||
|
if (i != mid)
|
||||||
|
swap (base + mid * size, base + i * size, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mid > 0)
|
||||||
|
swap (base, base + mid * size, size);
|
||||||
|
|
||||||
|
/* Recurse with the smaller array, loop with the larger one. That
|
||||||
|
ensures that our maximum stack depth is log count. */
|
||||||
|
if (2 * mid < count)
|
||||||
|
{
|
||||||
|
backtrace_qsort (base, mid, size, compar);
|
||||||
|
base += (mid + 1) * size;
|
||||||
|
count -= mid + 1;
|
||||||
|
goto tail_recurse;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
backtrace_qsort (base + (mid + 1) * size, count - (mid + 1),
|
||||||
|
size, compar);
|
||||||
|
count = mid;
|
||||||
|
goto tail_recurse;
|
||||||
|
}
|
||||||
|
}
|
72
deps/libbacktrace/state.c
vendored
Normal file
72
deps/libbacktrace/state.c
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/* state.c -- Create the backtrace state.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Create the backtrace state. This will then be passed to all the
|
||||||
|
other routines. */
|
||||||
|
|
||||||
|
struct backtrace_state *
|
||||||
|
backtrace_create_state (const char *filename, int threaded,
|
||||||
|
backtrace_error_callback error_callback,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
struct backtrace_state init_state;
|
||||||
|
struct backtrace_state *state;
|
||||||
|
|
||||||
|
#ifndef HAVE_SYNC_FUNCTIONS
|
||||||
|
if (threaded)
|
||||||
|
{
|
||||||
|
error_callback (data, "backtrace library does not support threads", 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset (&init_state, 0, sizeof init_state);
|
||||||
|
init_state.filename = filename;
|
||||||
|
init_state.threaded = threaded;
|
||||||
|
|
||||||
|
state = ((struct backtrace_state *)
|
||||||
|
backtrace_alloc (&init_state, sizeof *state, error_callback, data));
|
||||||
|
if (state == NULL)
|
||||||
|
return NULL;
|
||||||
|
*state = init_state;
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
137
deps/libbacktrace/stest.c
vendored
Normal file
137
deps/libbacktrace/stest.c
vendored
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/* stest.c -- Test for libbacktrace internal sort function
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* Test the local qsort implementation. */
|
||||||
|
|
||||||
|
#define MAX 10
|
||||||
|
|
||||||
|
struct test
|
||||||
|
{
|
||||||
|
size_t count;
|
||||||
|
int input[MAX];
|
||||||
|
int output[MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct test tests[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
10,
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
9,
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
10,
|
||||||
|
{ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 },
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
9,
|
||||||
|
{ 9, 8, 7, 6, 5, 4, 3, 2, 1 },
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
10,
|
||||||
|
{ 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 },
|
||||||
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
5,
|
||||||
|
{ 4, 5, 3, 1, 2 },
|
||||||
|
{ 1, 2, 3, 4, 5 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
5,
|
||||||
|
{ 1, 1, 1, 1, 1 },
|
||||||
|
{ 1, 1, 1, 1, 1 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
5,
|
||||||
|
{ 1, 1, 2, 1, 1 },
|
||||||
|
{ 1, 1, 1, 1, 2 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
5,
|
||||||
|
{ 2, 1, 1, 1, 1 },
|
||||||
|
{ 1, 1, 1, 1, 2 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
compare (const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const int *ai = (const int *) a;
|
||||||
|
const int *bi = (const int *) b;
|
||||||
|
|
||||||
|
return *ai - *bi;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
int failures;
|
||||||
|
size_t i;
|
||||||
|
int a[MAX];
|
||||||
|
|
||||||
|
failures = 0;
|
||||||
|
for (i = 0; i < sizeof tests / sizeof tests[0]; i++)
|
||||||
|
{
|
||||||
|
memcpy (a, tests[i].input, tests[i].count * sizeof (int));
|
||||||
|
backtrace_qsort (a, tests[i].count, sizeof (int), compare);
|
||||||
|
if (memcmp (a, tests[i].output, tests[i].count * sizeof (int)) != 0)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
fprintf (stderr, "test %d failed:", (int) i);
|
||||||
|
for (j = 0; j < tests[i].count; j++)
|
||||||
|
fprintf (stderr, " %d", a[j]);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
148
deps/libbacktrace/test-driver
vendored
Executable file
148
deps/libbacktrace/test-driver
vendored
Executable file
@ -0,0 +1,148 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# test-driver - basic testsuite driver script.
|
||||||
|
|
||||||
|
scriptversion=2016-01-11.22; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 2011-2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# This file is maintained in Automake, please report
|
||||||
|
# bugs to <bug-automake@gnu.org> or send patches to
|
||||||
|
# <automake-patches@gnu.org>.
|
||||||
|
|
||||||
|
# Make unconditional expansion of undefined variables an error. This
|
||||||
|
# helps a lot in preventing typo-related bugs.
|
||||||
|
set -u
|
||||||
|
|
||||||
|
usage_error ()
|
||||||
|
{
|
||||||
|
echo "$0: $*" >&2
|
||||||
|
print_usage >&2
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
print_usage ()
|
||||||
|
{
|
||||||
|
cat <<END
|
||||||
|
Usage:
|
||||||
|
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
|
||||||
|
[--expect-failure={yes|no}] [--color-tests={yes|no}]
|
||||||
|
[--enable-hard-errors={yes|no}] [--]
|
||||||
|
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
||||||
|
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
test_name= # Used for reporting.
|
||||||
|
log_file= # Where to save the output of the test script.
|
||||||
|
trs_file= # Where to save the metadata of the test run.
|
||||||
|
expect_failure=no
|
||||||
|
color_tests=no
|
||||||
|
enable_hard_errors=yes
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case $1 in
|
||||||
|
--help) print_usage; exit $?;;
|
||||||
|
--version) echo "test-driver $scriptversion"; exit $?;;
|
||||||
|
--test-name) test_name=$2; shift;;
|
||||||
|
--log-file) log_file=$2; shift;;
|
||||||
|
--trs-file) trs_file=$2; shift;;
|
||||||
|
--color-tests) color_tests=$2; shift;;
|
||||||
|
--expect-failure) expect_failure=$2; shift;;
|
||||||
|
--enable-hard-errors) enable_hard_errors=$2; shift;;
|
||||||
|
--) shift; break;;
|
||||||
|
-*) usage_error "invalid option: '$1'";;
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
missing_opts=
|
||||||
|
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
|
||||||
|
test x"$log_file" = x && missing_opts="$missing_opts --log-file"
|
||||||
|
test x"$trs_file" = x && missing_opts="$missing_opts --trs-file"
|
||||||
|
if test x"$missing_opts" != x; then
|
||||||
|
usage_error "the following mandatory options are missing:$missing_opts"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
usage_error "missing argument"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $color_tests = yes; then
|
||||||
|
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
|
||||||
|
red='[0;31m' # Red.
|
||||||
|
grn='[0;32m' # Green.
|
||||||
|
lgn='[1;32m' # Light green.
|
||||||
|
blu='[1;34m' # Blue.
|
||||||
|
mgn='[0;35m' # Magenta.
|
||||||
|
std='[m' # No color.
|
||||||
|
else
|
||||||
|
red= grn= lgn= blu= mgn= std=
|
||||||
|
fi
|
||||||
|
|
||||||
|
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
|
||||||
|
trap "st=129; $do_exit" 1
|
||||||
|
trap "st=130; $do_exit" 2
|
||||||
|
trap "st=141; $do_exit" 13
|
||||||
|
trap "st=143; $do_exit" 15
|
||||||
|
|
||||||
|
# Test script is run here.
|
||||||
|
"$@" >$log_file 2>&1
|
||||||
|
estatus=$?
|
||||||
|
|
||||||
|
if test $enable_hard_errors = no && test $estatus -eq 99; then
|
||||||
|
tweaked_estatus=1
|
||||||
|
else
|
||||||
|
tweaked_estatus=$estatus
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $tweaked_estatus:$expect_failure in
|
||||||
|
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
|
||||||
|
0:*) col=$grn res=PASS recheck=no gcopy=no;;
|
||||||
|
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
|
||||||
|
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
|
||||||
|
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
|
||||||
|
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Report the test outcome and exit status in the logs, so that one can
|
||||||
|
# know whether the test passed or failed simply by looking at the '.log'
|
||||||
|
# file, without the need of also peaking into the corresponding '.trs'
|
||||||
|
# file (automake bug#11814).
|
||||||
|
echo "$res $test_name (exit status: $estatus)" >>$log_file
|
||||||
|
|
||||||
|
# Report outcome to console.
|
||||||
|
echo "${col}${res}${std}: $test_name"
|
||||||
|
|
||||||
|
# Register the test result, and other relevant metadata.
|
||||||
|
echo ":test-result: $res" > $trs_file
|
||||||
|
echo ":global-test-result: $res" >> $trs_file
|
||||||
|
echo ":recheck: $recheck" >> $trs_file
|
||||||
|
echo ":copy-in-global-log: $gcopy" >> $trs_file
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC0"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
55
deps/libbacktrace/test_format.c
vendored
Normal file
55
deps/libbacktrace/test_format.c
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* test_format.c -- Test for libbacktrace library
|
||||||
|
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* This program tests the externally visible interfaces of the
|
||||||
|
libbacktrace library. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
234
deps/libbacktrace/testlib.c
vendored
Normal file
234
deps/libbacktrace/testlib.c
vendored
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
/* testlib.c -- test functions for libbacktrace library
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
/* The backtrace state. */
|
||||||
|
|
||||||
|
void *state;
|
||||||
|
|
||||||
|
/* The number of failures. */
|
||||||
|
|
||||||
|
int failures;
|
||||||
|
|
||||||
|
/* Return the base name in a path. */
|
||||||
|
|
||||||
|
const char *
|
||||||
|
base (const char *p)
|
||||||
|
{
|
||||||
|
const char *last;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
last = NULL;
|
||||||
|
for (s = p; *s != '\0'; ++s)
|
||||||
|
{
|
||||||
|
if (IS_DIR_SEPARATOR (*s))
|
||||||
|
last = s + 1;
|
||||||
|
}
|
||||||
|
return last != NULL ? last : p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check an entry in a struct info array. */
|
||||||
|
|
||||||
|
void
|
||||||
|
check (const char *name, int index, const struct info *all, int want_lineno,
|
||||||
|
const char *want_function, const char *want_file, int *failed)
|
||||||
|
{
|
||||||
|
if (*failed)
|
||||||
|
return;
|
||||||
|
if (all[index].filename == NULL || all[index].function == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: [%d]: missing file name or function name\n",
|
||||||
|
name, index);
|
||||||
|
*failed = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (strcmp (base (all[index].filename), want_file) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index,
|
||||||
|
all[index].filename, want_file);
|
||||||
|
*failed = 1;
|
||||||
|
}
|
||||||
|
if (all[index].lineno != want_lineno)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: [%d]: got %d expected %d\n", name, index,
|
||||||
|
all[index].lineno, want_lineno);
|
||||||
|
*failed = 1;
|
||||||
|
}
|
||||||
|
if (strcmp (all[index].function, want_function) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index,
|
||||||
|
all[index].function, want_function);
|
||||||
|
*failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The backtrace callback function. */
|
||||||
|
|
||||||
|
int
|
||||||
|
callback_one (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||||
|
const char *filename, int lineno, const char *function)
|
||||||
|
{
|
||||||
|
struct bdata *data = (struct bdata *) vdata;
|
||||||
|
struct info *p;
|
||||||
|
|
||||||
|
if (data->index >= data->max)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "callback_one: callback called too many times\n");
|
||||||
|
data->failed = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = &data->all[data->index];
|
||||||
|
if (filename == NULL)
|
||||||
|
p->filename = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->filename = strdup (filename);
|
||||||
|
assert (p->filename != NULL);
|
||||||
|
}
|
||||||
|
p->lineno = lineno;
|
||||||
|
if (function == NULL)
|
||||||
|
p->function = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p->function = strdup (function);
|
||||||
|
assert (p->function != NULL);
|
||||||
|
}
|
||||||
|
++data->index;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An error callback passed to backtrace. */
|
||||||
|
|
||||||
|
void
|
||||||
|
error_callback_one (void *vdata, const char *msg, int errnum)
|
||||||
|
{
|
||||||
|
struct bdata *data = (struct bdata *) vdata;
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
data->failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The backtrace_simple callback function. */
|
||||||
|
|
||||||
|
int
|
||||||
|
callback_two (void *vdata, uintptr_t pc)
|
||||||
|
{
|
||||||
|
struct sdata *data = (struct sdata *) vdata;
|
||||||
|
|
||||||
|
if (data->index >= data->max)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "callback_two: callback called too many times\n");
|
||||||
|
data->failed = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->addrs[data->index] = pc;
|
||||||
|
++data->index;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* An error callback passed to backtrace_simple. */
|
||||||
|
|
||||||
|
void
|
||||||
|
error_callback_two (void *vdata, const char *msg, int errnum)
|
||||||
|
{
|
||||||
|
struct sdata *data = (struct sdata *) vdata;
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
data->failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The backtrace_syminfo callback function. */
|
||||||
|
|
||||||
|
void
|
||||||
|
callback_three (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED,
|
||||||
|
const char *symname, uintptr_t symval,
|
||||||
|
uintptr_t symsize)
|
||||||
|
{
|
||||||
|
struct symdata *data = (struct symdata *) vdata;
|
||||||
|
|
||||||
|
if (symname == NULL)
|
||||||
|
data->name = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data->name = strdup (symname);
|
||||||
|
assert (data->name != NULL);
|
||||||
|
}
|
||||||
|
data->val = symval;
|
||||||
|
data->size = symsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The backtrace_syminfo error callback function. */
|
||||||
|
|
||||||
|
void
|
||||||
|
error_callback_three (void *vdata, const char *msg, int errnum)
|
||||||
|
{
|
||||||
|
struct symdata *data = (struct symdata *) vdata;
|
||||||
|
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
data->failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The backtrace_create_state error callback function. */
|
||||||
|
|
||||||
|
void
|
||||||
|
error_callback_create (void *data ATTRIBUTE_UNUSED, const char *msg,
|
||||||
|
int errnum)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
110
deps/libbacktrace/testlib.h
vendored
Normal file
110
deps/libbacktrace/testlib.h
vendored
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/* testlib.h -- Header for test functions for libbacktrace library
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
#ifndef LIBBACKTRACE_TESTLIB_H
|
||||||
|
#define LIBBACKTRACE_TESTLIB_H
|
||||||
|
|
||||||
|
/* Portable attribute syntax. Actually some of these tests probably
|
||||||
|
won't work if the attributes are not recognized. */
|
||||||
|
|
||||||
|
#ifndef GCC_VERSION
|
||||||
|
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (GCC_VERSION < 2007)
|
||||||
|
# define __attribute__(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Used to collect backtrace info. */
|
||||||
|
|
||||||
|
struct info
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
int lineno;
|
||||||
|
char *function;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Passed to backtrace callback function. */
|
||||||
|
|
||||||
|
struct bdata
|
||||||
|
{
|
||||||
|
struct info *all;
|
||||||
|
size_t index;
|
||||||
|
size_t max;
|
||||||
|
int failed;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Passed to backtrace_simple callback function. */
|
||||||
|
|
||||||
|
struct sdata
|
||||||
|
{
|
||||||
|
uintptr_t *addrs;
|
||||||
|
size_t index;
|
||||||
|
size_t max;
|
||||||
|
int failed;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Passed to backtrace_syminfo callback function. */
|
||||||
|
|
||||||
|
struct symdata
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
uintptr_t val, size;
|
||||||
|
int failed;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The backtrace state. */
|
||||||
|
|
||||||
|
extern void *state;
|
||||||
|
|
||||||
|
/* The number of failures. */
|
||||||
|
|
||||||
|
extern int failures;
|
||||||
|
|
||||||
|
extern const char *base (const char *p);
|
||||||
|
extern void check (const char *name, int index, const struct info *all,
|
||||||
|
int want_lineno, const char *want_function,
|
||||||
|
const char *want_file, int *failed);
|
||||||
|
extern int callback_one (void *, uintptr_t, const char *, int, const char *);
|
||||||
|
extern void error_callback_one (void *, const char *, int);
|
||||||
|
extern int callback_two (void *, uintptr_t);
|
||||||
|
extern void error_callback_two (void *, const char *, int);
|
||||||
|
extern void callback_three (void *, uintptr_t, const char *, uintptr_t,
|
||||||
|
uintptr_t);
|
||||||
|
extern void error_callback_three (void *, const char *, int);
|
||||||
|
extern void error_callback_create (void *, const char *, int);
|
||||||
|
|
||||||
|
#endif /* !defined(LIBBACKTRACE_TESTLIB_H) */
|
161
deps/libbacktrace/ttest.c
vendored
Normal file
161
deps/libbacktrace/ttest.c
vendored
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
/* ttest.c -- Test for libbacktrace library
|
||||||
|
Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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. */
|
||||||
|
|
||||||
|
/* Test using the libbacktrace library from multiple threads. */
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
static int f2 (int) __attribute__ ((noinline));
|
||||||
|
static int f3 (int, int) __attribute__ ((noinline));
|
||||||
|
|
||||||
|
/* Test that a simple backtrace works. This is called via
|
||||||
|
pthread_create. It returns the number of failures, as void *. */
|
||||||
|
|
||||||
|
static void *
|
||||||
|
test1_thread (void *arg ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
/* Returning a value here and elsewhere avoids a tailcall which
|
||||||
|
would mess up the backtrace. */
|
||||||
|
return (void *) (uintptr_t) (f2 (__LINE__) - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f2 (int f1line)
|
||||||
|
{
|
||||||
|
return f3 (f1line, __LINE__) + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
f3 (int f1line, int f2line)
|
||||||
|
{
|
||||||
|
struct info all[20];
|
||||||
|
struct bdata data;
|
||||||
|
int f3line;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
data.all = &all[0];
|
||||||
|
data.index = 0;
|
||||||
|
data.max = 20;
|
||||||
|
data.failed = 0;
|
||||||
|
|
||||||
|
f3line = __LINE__ + 1;
|
||||||
|
i = backtrace_full (state, 0, callback_one, error_callback_one, &data);
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test1: unexpected return value %d\n", i);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.index < 3)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test1: not enough frames; got %zu, expected at least 3\n",
|
||||||
|
data.index);
|
||||||
|
data.failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
check ("test1", 0, all, f3line, "f3", "ttest.c", &data.failed);
|
||||||
|
check ("test1", 1, all, f2line, "f2", "ttest.c", &data.failed);
|
||||||
|
check ("test1", 2, all, f1line, "test1_thread", "ttest.c", &data.failed);
|
||||||
|
|
||||||
|
return data.failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Run the test with 10 threads simultaneously. */
|
||||||
|
|
||||||
|
#define THREAD_COUNT 10
|
||||||
|
|
||||||
|
static void test1 (void) __attribute__ ((unused));
|
||||||
|
|
||||||
|
static void
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
pthread_t atid[THREAD_COUNT];
|
||||||
|
int i;
|
||||||
|
int errnum;
|
||||||
|
int this_fail;
|
||||||
|
void *ret;
|
||||||
|
|
||||||
|
for (i = 0; i < THREAD_COUNT; i++)
|
||||||
|
{
|
||||||
|
errnum = pthread_create (&atid[i], NULL, test1_thread, NULL);
|
||||||
|
if (errnum != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "pthread_create %d: %s\n", i, strerror (errnum));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this_fail = 0;
|
||||||
|
for (i = 0; i < THREAD_COUNT; i++)
|
||||||
|
{
|
||||||
|
errnum = pthread_join (atid[i], &ret);
|
||||||
|
if (errnum != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "pthread_join %d: %s\n", i, strerror (errnum));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
this_fail += (int) (uintptr_t) ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("%s: threaded backtrace_full noinline\n", this_fail > 0 ? "FAIL" : "PASS");
|
||||||
|
|
||||||
|
failures += this_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
#if BACKTRACE_SUPPORTED
|
||||||
|
#if BACKTRACE_SUPPORTS_THREADS
|
||||||
|
test1 ();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
92
deps/libbacktrace/unittest.c
vendored
Normal file
92
deps/libbacktrace/unittest.c
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* unittest.c -- Test for libbacktrace library
|
||||||
|
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
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) 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 <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "filenames.h"
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
static unsigned count;
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback (void *vdata ATTRIBUTE_UNUSED, const char *msg ATTRIBUTE_UNUSED,
|
||||||
|
int errnum ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test1 (void)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
int failed;
|
||||||
|
|
||||||
|
struct backtrace_vector vec;
|
||||||
|
|
||||||
|
memset (&vec, 0, sizeof vec);
|
||||||
|
|
||||||
|
backtrace_vector_grow (state, 100, error_callback, NULL, &vec);
|
||||||
|
vec.alc += vec.size;
|
||||||
|
vec.size = 0;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
res = backtrace_vector_release (state, &vec, error_callback, NULL);
|
||||||
|
failed = res != 1 || count != 0 || vec.base != NULL;
|
||||||
|
|
||||||
|
printf ("%s: unittest backtrace_vector_release size == 0\n",
|
||||||
|
failed ? "FAIL": "PASS");
|
||||||
|
|
||||||
|
if (failed)
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
return failures;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
test1 ();
|
||||||
|
|
||||||
|
exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
65
deps/libbacktrace/unknown.c
vendored
Normal file
65
deps/libbacktrace/unknown.c
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* unknown.c -- used when backtrace configury does not know file format.
|
||||||
|
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
|
/* A trivial routine that always fails to find fileline data. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
unknown_fileline (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
uintptr_t pc, backtrace_full_callback callback,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data)
|
||||||
|
|
||||||
|
{
|
||||||
|
return callback (data, pc, NULL, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the backtrace data when we don't know how to read the
|
||||||
|
debug info. */
|
||||||
|
|
||||||
|
int
|
||||||
|
backtrace_initialize (struct backtrace_state *state ATTRIBUTE_UNUSED,
|
||||||
|
const char *filename ATTRIBUTE_UNUSED,
|
||||||
|
int descriptor ATTRIBUTE_UNUSED,
|
||||||
|
backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
|
||||||
|
void *data ATTRIBUTE_UNUSED, fileline *fileline_fn)
|
||||||
|
{
|
||||||
|
state->fileline_data = NULL;
|
||||||
|
*fileline_fn = unknown_fileline;
|
||||||
|
return 1;
|
||||||
|
}
|
1606
deps/libbacktrace/xcoff.c
vendored
Normal file
1606
deps/libbacktrace/xcoff.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
508
deps/libbacktrace/xztest.c
vendored
Normal file
508
deps/libbacktrace/xztest.c
vendored
Normal file
@ -0,0 +1,508 @@
|
|||||||
|
/* xztest.c -- Test for libbacktrace LZMA decoder.
|
||||||
|
Copyright (C) 2020-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBLZMA
|
||||||
|
#include <lzma.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
typedef int xclockid_t;
|
||||||
|
|
||||||
|
static int
|
||||||
|
xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED,
|
||||||
|
struct timespec *ts ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define clockid_t xclockid_t
|
||||||
|
#define clock_gettime xclock_gettime
|
||||||
|
#undef CLOCK_REALTIME
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
|
#endif /* !defined(HAVE_CLOCK_GETTIME) */
|
||||||
|
|
||||||
|
#ifdef CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#define LIBLZMA_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#else
|
||||||
|
#define LIBLZMA_CLOCK_GETTIME_ARG CLOCK_REALTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some tests for the local lzma inflation code. */
|
||||||
|
|
||||||
|
struct lzma_test
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
const char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
const char *compressed;
|
||||||
|
size_t compressed_len;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Error callback. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback_compress (void *vdata ATTRIBUTE_UNUSED, const char *msg,
|
||||||
|
int errnum)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct lzma_test tests[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"empty",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x00\x00\x00\x00"
|
||||||
|
"\x1c\xdf\x44\x21\x1f\xb6\xf3\x7d\x01\x00\x00\x00\x00\x04\x59\x5a"),
|
||||||
|
32,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hello",
|
||||||
|
"hello, world\n",
|
||||||
|
0,
|
||||||
|
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21\x01"
|
||||||
|
"\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x0c\x68\x65\x6c\x6c\x6f"
|
||||||
|
"\x2c\x20\x77\x6f\x72\x6c\x64\x0a\x00\x00\x00\x00\x7b\x46\x5a\x81"
|
||||||
|
"\xc9\x12\xb8\xea\x00\x01\x25\x0d\x71\x19\xc4\xb6\x1f\xb6\xf3\x7d"
|
||||||
|
"\x01\x00\x00\x00\x00\x04\x59\x5a"),
|
||||||
|
72,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"goodbye",
|
||||||
|
"goodbye, world",
|
||||||
|
0,
|
||||||
|
("\xfd\x37\x7a\x58\x5a\x00\x00\x04\xe6\xd6\xb4\x46\x02\x00\x21\x01"
|
||||||
|
"\x16\x00\x00\x00\x74\x2f\xe5\xa3\x01\x00\x0d\x67\x6f\x6f\x64\x62"
|
||||||
|
"\x79\x65\x2c\x20\x77\x6f\x72\x6c\x64\x00\x00\x00\xf6\xf8\xa3\x33"
|
||||||
|
"\x8c\x4e\xc9\x68\x00\x01\x26\x0e\x08\x1b\xe0\x04\x1f\xb6\xf3\x7d"
|
||||||
|
"\x01\x00\x00\x00\x00\x04\x59\x5a"),
|
||||||
|
72,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test the hand coded samples. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_samples (struct backtrace_state *state)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof tests / sizeof tests[0]; ++i)
|
||||||
|
{
|
||||||
|
unsigned char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
|
||||||
|
uncompressed = NULL;
|
||||||
|
uncompressed_len = 0;
|
||||||
|
if (!backtrace_uncompress_lzma (state,
|
||||||
|
((const unsigned char *)
|
||||||
|
tests[i].compressed),
|
||||||
|
tests[i].compressed_len,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed, &uncompressed_len))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t v;
|
||||||
|
|
||||||
|
v = tests[i].uncompressed_len;
|
||||||
|
if (v == 0)
|
||||||
|
v = strlen (tests[i].uncompressed);
|
||||||
|
if (uncompressed_len != v)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test %s: got uncompressed length %zu, want %zu\n",
|
||||||
|
tests[i].name, uncompressed_len, v);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else if (memcmp (tests[i].uncompressed, uncompressed, v) != 0)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
fprintf (stderr, "test %s: uncompressed data mismatch\n",
|
||||||
|
tests[i].name);
|
||||||
|
for (j = 0; j < v; ++j)
|
||||||
|
if (tests[i].uncompressed[j] != uncompressed[j])
|
||||||
|
fprintf (stderr, " %zu: got %#x want %#x\n", j,
|
||||||
|
uncompressed[j], tests[i].uncompressed[j]);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf ("PASS: lzma %s\n", tests[i].name);
|
||||||
|
|
||||||
|
backtrace_free (state, uncompressed, uncompressed_len,
|
||||||
|
error_callback_compress, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if HAVE_LIBLZMA
|
||||||
|
|
||||||
|
/* Given a set of TRIALS timings, discard the lowest and highest
|
||||||
|
values and return the mean average of the rest. */
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
average_time (const size_t *times, size_t trials)
|
||||||
|
{
|
||||||
|
size_t imax;
|
||||||
|
size_t max;
|
||||||
|
size_t imin;
|
||||||
|
size_t min;
|
||||||
|
size_t i;
|
||||||
|
size_t sum;
|
||||||
|
|
||||||
|
imin = 0;
|
||||||
|
imax = 0;
|
||||||
|
min = times[0];
|
||||||
|
max = times[0];
|
||||||
|
for (i = 1; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (times[i] < min)
|
||||||
|
{
|
||||||
|
imin = i;
|
||||||
|
min = times[i];
|
||||||
|
}
|
||||||
|
if (times[i] > max)
|
||||||
|
{
|
||||||
|
imax = i;
|
||||||
|
max = times[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (i != imax && i != imin)
|
||||||
|
sum += times[i];
|
||||||
|
}
|
||||||
|
return sum / (trials - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Test a larger text, if available. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_large (struct backtrace_state *state ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
#if HAVE_LIBLZMA
|
||||||
|
unsigned char *orig_buf;
|
||||||
|
size_t orig_bufsize;
|
||||||
|
size_t i;
|
||||||
|
lzma_stream initial_stream = LZMA_STREAM_INIT;
|
||||||
|
lzma_stream stream;
|
||||||
|
unsigned char *compressed_buf;
|
||||||
|
size_t compressed_bufsize;
|
||||||
|
unsigned char *uncompressed_buf;
|
||||||
|
size_t uncompressed_bufsize;
|
||||||
|
unsigned char *spare_buf;
|
||||||
|
int r;
|
||||||
|
clockid_t cid;
|
||||||
|
struct timespec ts1;
|
||||||
|
struct timespec ts2;
|
||||||
|
size_t ctime;
|
||||||
|
size_t ztime;
|
||||||
|
const size_t trials = 16;
|
||||||
|
size_t ctimes[16];
|
||||||
|
size_t ztimes[16];
|
||||||
|
static const char * const names[] = {
|
||||||
|
"Isaac.Newton-Opticks.txt",
|
||||||
|
"../libgo/go/testdata/Isaac.Newton-Opticks.txt",
|
||||||
|
};
|
||||||
|
|
||||||
|
orig_buf = NULL;
|
||||||
|
orig_bufsize = 0;
|
||||||
|
uncompressed_buf = NULL;
|
||||||
|
compressed_buf = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof names / sizeof names[0]; ++i)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *namebuf;
|
||||||
|
FILE *e;
|
||||||
|
struct stat st;
|
||||||
|
char *rbuf;
|
||||||
|
size_t got;
|
||||||
|
|
||||||
|
len = strlen (SRCDIR) + strlen (names[i]) + 2;
|
||||||
|
namebuf = malloc (len);
|
||||||
|
if (namebuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
snprintf (namebuf, len, "%s/%s", SRCDIR, names[i]);
|
||||||
|
e = fopen (namebuf, "r");
|
||||||
|
free (namebuf);
|
||||||
|
if (e == NULL)
|
||||||
|
continue;
|
||||||
|
if (fstat (fileno (e), &st) < 0)
|
||||||
|
{
|
||||||
|
perror ("fstat");
|
||||||
|
fclose (e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rbuf = malloc (st.st_size);
|
||||||
|
if (rbuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
got = fread (rbuf, 1, st.st_size, e);
|
||||||
|
fclose (e);
|
||||||
|
if (got > 0)
|
||||||
|
{
|
||||||
|
orig_buf = (unsigned char *) rbuf;
|
||||||
|
orig_bufsize = got;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free (rbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orig_buf == NULL)
|
||||||
|
{
|
||||||
|
/* We couldn't find an input file. */
|
||||||
|
printf ("UNSUPPORTED: lzma large\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream = initial_stream;
|
||||||
|
r = lzma_easy_encoder (&stream, 6, LZMA_CHECK_CRC32);
|
||||||
|
if (r != LZMA_OK)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma_easy_encoder failed: %d\n", r);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
compressed_bufsize = orig_bufsize + 100;
|
||||||
|
compressed_buf = malloc (compressed_bufsize);
|
||||||
|
if (compressed_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.next_in = orig_buf;
|
||||||
|
stream.avail_in = orig_bufsize;
|
||||||
|
stream.next_out = compressed_buf;
|
||||||
|
stream.avail_out = compressed_bufsize;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
r = lzma_code (&stream, LZMA_FINISH);
|
||||||
|
if (r != LZMA_OK && r != LZMA_STREAM_END)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma_code failed: %d\n", r);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (r != LZMA_STREAM_END);
|
||||||
|
|
||||||
|
compressed_bufsize = stream.total_out;
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_lzma (state, (unsigned char *) compressed_buf,
|
||||||
|
compressed_bufsize,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed_buf, &uncompressed_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma large: backtrace_uncompress_lzma failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uncompressed_bufsize != orig_bufsize)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"lzma large: got uncompressed length %zu, want %zu\n",
|
||||||
|
uncompressed_bufsize, orig_bufsize);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp (uncompressed_buf, orig_buf, uncompressed_bufsize) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma large: uncompressed data mismatch\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("PASS: lzma large\n");
|
||||||
|
|
||||||
|
spare_buf = malloc (orig_bufsize);
|
||||||
|
if (spare_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
cid = LIBLZMA_CLOCK_GETTIME_ARG;
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINVAL)
|
||||||
|
return;
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_lzma (state,
|
||||||
|
(unsigned char *) compressed_buf,
|
||||||
|
compressed_bufsize,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed_buf,
|
||||||
|
&uncompressed_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("lzma large: "
|
||||||
|
"benchmark backtrace_uncompress_lzma failed\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ctime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ctimes[i] = ctime;
|
||||||
|
|
||||||
|
stream = initial_stream;
|
||||||
|
|
||||||
|
r = lzma_auto_decoder (&stream, UINT64_MAX, 0);
|
||||||
|
if (r != LZMA_OK)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma_stream_decoder failed: %d\n", r);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.next_in = compressed_buf;
|
||||||
|
stream.avail_in = compressed_bufsize;
|
||||||
|
stream.next_out = spare_buf;
|
||||||
|
stream.avail_out = orig_bufsize;
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
perror("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
r = lzma_code (&stream, LZMA_FINISH);
|
||||||
|
if (r != LZMA_OK && r != LZMA_STREAM_END)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "lzma_code failed: %d\n", r);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (r != LZMA_STREAM_END);
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ztime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ztime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ztimes[i] = ztime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toss the highest and lowest times and average the rest. */
|
||||||
|
ctime = average_time (ctimes, trials);
|
||||||
|
ztime = average_time (ztimes, trials);
|
||||||
|
|
||||||
|
printf ("backtrace: %zu ns\n", ctime);
|
||||||
|
printf ("liblzma : %zu ns\n", ztime);
|
||||||
|
printf ("ratio : %g\n", (double) ztime / (double) ctime);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
printf ("FAIL: lzma large\n");
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
if (orig_buf != NULL)
|
||||||
|
free (orig_buf);
|
||||||
|
if (compressed_buf != NULL)
|
||||||
|
free (compressed_buf);
|
||||||
|
if (uncompressed_buf != NULL)
|
||||||
|
free (uncompressed_buf);
|
||||||
|
|
||||||
|
#else /* !HAVE_LIBLZMA */
|
||||||
|
|
||||||
|
printf ("UNSUPPORTED: lzma large\n");
|
||||||
|
|
||||||
|
#endif /* !HAVE_LIBLZMA */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
struct backtrace_state *state;
|
||||||
|
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
test_samples (state);
|
||||||
|
test_large (state);
|
||||||
|
|
||||||
|
exit (failures != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
523
deps/libbacktrace/zstdtest.c
vendored
Normal file
523
deps/libbacktrace/zstdtest.c
vendored
Normal file
@ -0,0 +1,523 @@
|
|||||||
|
/* ztest.c -- Test for libbacktrace zstd code.
|
||||||
|
Copyright (C) 2022 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ZSTD
|
||||||
|
#include <zstd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
typedef int xclockid_t;
|
||||||
|
|
||||||
|
static int
|
||||||
|
xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED,
|
||||||
|
struct timespec *ts ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define clockid_t xclockid_t
|
||||||
|
#define clock_gettime xclock_gettime
|
||||||
|
#undef CLOCK_REALTIME
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
|
#endif /* !defined(HAVE_CLOCK_GETTIME) */
|
||||||
|
|
||||||
|
#ifdef CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#define ZSTD_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#else
|
||||||
|
#define ZSTD_CLOCK_GETTIME_ARG CLOCK_REALTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some tests for the local zstd inflation code. */
|
||||||
|
|
||||||
|
struct zstd_test
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
const char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
const char *compressed;
|
||||||
|
size_t compressed_len;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Error callback. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback_compress (void *vdata ATTRIBUTE_UNUSED, const char *msg,
|
||||||
|
int errnum)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct zstd_test tests[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"empty",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
"\x28\xb5\x2f\xfd\x24\x00\x01\x00\x00\x99\xe9\xd8\x51",
|
||||||
|
13,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hello",
|
||||||
|
"hello, world\n",
|
||||||
|
0,
|
||||||
|
("\x28\xb5\x2f\xfd\x24\x0d\x69\x00\x00\x68\x65\x6c\x6c\x6f\x2c\x20"
|
||||||
|
"\x77\x6f\x72\x6c\x64\x0a\x4c\x1f\xf9\xf1"),
|
||||||
|
26,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"goodbye",
|
||||||
|
"goodbye, world",
|
||||||
|
0,
|
||||||
|
("\x28\xb5\x2f\xfd\x24\x0e\x71\x00\x00\x67\x6f\x6f\x64\x62\x79\x65"
|
||||||
|
"\x2c\x20\x77\x6f\x72\x6c\x64\x61\x7b\x4b\x83"),
|
||||||
|
27,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ranges",
|
||||||
|
("\xcc\x11\x00\x00\x00\x00\x00\x00\xd5\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x1c\x14\x00\x00\x00\x00\x00\x00\x72\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x0c\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x29\x14\x00\x00\x00\x00\x00\x00\x4e\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x67\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x5f\x0b\x00\x00\x00\x00\x00\x00\x6c\x0b\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7d\x0b\x00\x00\x00\x00\x00\x00\x7e\x0c\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x38\x0f\x00\x00\x00\x00\x00\x00\x5c\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x83\x0c\x00\x00\x00\x00\x00\x00\xfa\x0c\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xef\x0e\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x14\x0f\x00\x00\x00\x00\x00\x00\x38\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xd8\x0e\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfa\x0c\x00\x00\x00\x00\x00\x00\xea\x0d\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xef\x0e\x00\x00\x00\x00\x00\x00\x14\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x5c\x0f\x00\x00\x00\x00\x00\x00\x9f\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xac\x0f\x00\x00\x00\x00\x00\x00\xdb\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xff\x0f\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x60\x11\x00\x00\x00\x00\x00\x00\xd1\x16\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x40\x0b\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7a\x00\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7a\x00\x00\x00\x00\x00\x00\x00\xa9\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"),
|
||||||
|
672,
|
||||||
|
("\x28\xb5\x2f\xfd\x64\xa0\x01\x2d\x05\x00\xc4\x04\xcc\x11\x00\xd5"
|
||||||
|
"\x13\x00\x1c\x14\x00\x72\x9d\xd5\xfb\x12\x00\x09\x0c\x13\xcb\x13"
|
||||||
|
"\x29\x4e\x67\x5f\x0b\x6c\x0b\x7d\x0b\x7e\x0c\x38\x0f\x5c\x0f\x83"
|
||||||
|
"\x0c\xfa\x0c\xfd\x0d\xef\x0e\x14\x38\x9f\x0f\xac\x0f\xdb\x0f\xff"
|
||||||
|
"\x0f\xd8\x9f\xac\xdb\xff\xea\x5c\x2c\x10\x60\xd1\x16\x40\x0b\x7a"
|
||||||
|
"\x00\xb6\x00\x9f\x01\xa7\x01\xa9\x36\x20\xa0\x83\x14\x34\x63\x4a"
|
||||||
|
"\x21\x70\x8c\x07\x46\x03\x4e\x10\x62\x3c\x06\x4e\xc8\x8c\xb0\x32"
|
||||||
|
"\x2a\x59\xad\xb2\xf1\x02\x82\x7c\x33\xcb\x92\x6f\x32\x4f\x9b\xb0"
|
||||||
|
"\xa2\x30\xf0\xc0\x06\x1e\x98\x99\x2c\x06\x1e\xd8\xc0\x03\x56\xd8"
|
||||||
|
"\xc0\x03\x0f\x6c\xe0\x01\xf1\xf0\xee\x9a\xc6\xc8\x97\x99\xd1\x6c"
|
||||||
|
"\xb4\x21\x45\x3b\x10\xe4\x7b\x99\x4d\x8a\x36\x64\x5c\x77\x08\x02"
|
||||||
|
"\xcb\xe0\xce"),
|
||||||
|
179,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test the hand coded samples. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_samples (struct backtrace_state *state)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof tests / sizeof tests[0]; ++i)
|
||||||
|
{
|
||||||
|
unsigned char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
|
||||||
|
uncompressed_len = tests[i].uncompressed_len;
|
||||||
|
if (uncompressed_len == 0)
|
||||||
|
uncompressed_len = strlen (tests[i].uncompressed);
|
||||||
|
|
||||||
|
uncompressed = (unsigned char *) malloc (uncompressed_len);
|
||||||
|
if (uncompressed == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||||
|
++failures;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_zstd (state,
|
||||||
|
((const unsigned char *)
|
||||||
|
tests[i].compressed),
|
||||||
|
tests[i].compressed_len,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
uncompressed, uncompressed_len))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (memcmp (tests[i].uncompressed, uncompressed, uncompressed_len)
|
||||||
|
!= 0)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
fprintf (stderr, "test %s: uncompressed data mismatch\n",
|
||||||
|
tests[i].name);
|
||||||
|
for (j = 0; j < uncompressed_len; ++j)
|
||||||
|
if (tests[i].uncompressed[j] != uncompressed[j])
|
||||||
|
fprintf (stderr, " %zu: got %#x want %#x\n", j,
|
||||||
|
uncompressed[j], tests[i].uncompressed[j]);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf ("PASS: uncompress %s\n", tests[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
|
free (uncompressed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ZSTD
|
||||||
|
|
||||||
|
/* Given a set of TRIALS timings, discard the lowest and highest
|
||||||
|
values and return the mean average of the rest. */
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
average_time (const size_t *times, size_t trials)
|
||||||
|
{
|
||||||
|
size_t imax;
|
||||||
|
size_t max;
|
||||||
|
size_t imin;
|
||||||
|
size_t min;
|
||||||
|
size_t i;
|
||||||
|
size_t sum;
|
||||||
|
|
||||||
|
imin = 0;
|
||||||
|
imax = 0;
|
||||||
|
min = times[0];
|
||||||
|
max = times[0];
|
||||||
|
for (i = 1; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (times[i] < min)
|
||||||
|
{
|
||||||
|
imin = i;
|
||||||
|
min = times[i];
|
||||||
|
}
|
||||||
|
if (times[i] > max)
|
||||||
|
{
|
||||||
|
imax = i;
|
||||||
|
max = times[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (i != imax && i != imin)
|
||||||
|
sum += times[i];
|
||||||
|
}
|
||||||
|
return sum / (trials - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Test a larger text, if available. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_large (struct backtrace_state *state ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_ZSTD
|
||||||
|
unsigned char *orig_buf;
|
||||||
|
size_t orig_bufsize;
|
||||||
|
size_t i;
|
||||||
|
char *compressed_buf;
|
||||||
|
size_t compressed_bufsize;
|
||||||
|
size_t compressed_size;
|
||||||
|
unsigned char *uncompressed_buf;
|
||||||
|
size_t r;
|
||||||
|
clockid_t cid;
|
||||||
|
struct timespec ts1;
|
||||||
|
struct timespec ts2;
|
||||||
|
size_t ctime;
|
||||||
|
size_t ztime;
|
||||||
|
const size_t trials = 16;
|
||||||
|
size_t ctimes[16];
|
||||||
|
size_t ztimes[16];
|
||||||
|
static const char * const names[] = {
|
||||||
|
"Isaac.Newton-Opticks.txt",
|
||||||
|
"../libgo/go/testdata/Isaac.Newton-Opticks.txt",
|
||||||
|
};
|
||||||
|
|
||||||
|
orig_buf = NULL;
|
||||||
|
orig_bufsize = 0;
|
||||||
|
uncompressed_buf = NULL;
|
||||||
|
compressed_buf = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof names / sizeof names[0]; ++i)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *namebuf;
|
||||||
|
FILE *e;
|
||||||
|
struct stat st;
|
||||||
|
char *rbuf;
|
||||||
|
size_t got;
|
||||||
|
|
||||||
|
len = strlen (SRCDIR) + strlen (names[i]) + 2;
|
||||||
|
namebuf = malloc (len);
|
||||||
|
if (namebuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
snprintf (namebuf, len, "%s/%s", SRCDIR, names[i]);
|
||||||
|
e = fopen (namebuf, "r");
|
||||||
|
free (namebuf);
|
||||||
|
if (e == NULL)
|
||||||
|
continue;
|
||||||
|
if (fstat (fileno (e), &st) < 0)
|
||||||
|
{
|
||||||
|
perror ("fstat");
|
||||||
|
fclose (e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rbuf = malloc (st.st_size);
|
||||||
|
if (rbuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
got = fread (rbuf, 1, st.st_size, e);
|
||||||
|
fclose (e);
|
||||||
|
if (got > 0)
|
||||||
|
{
|
||||||
|
orig_buf = (unsigned char *) rbuf;
|
||||||
|
orig_bufsize = got;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free (rbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orig_buf == NULL)
|
||||||
|
{
|
||||||
|
/* We couldn't find an input file. */
|
||||||
|
printf ("UNSUPPORTED: zstd large\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
compressed_bufsize = ZSTD_compressBound (orig_bufsize);
|
||||||
|
compressed_buf = malloc (compressed_bufsize);
|
||||||
|
if (compressed_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = ZSTD_compress (compressed_buf, compressed_bufsize,
|
||||||
|
orig_buf, orig_bufsize,
|
||||||
|
ZSTD_CLEVEL_DEFAULT);
|
||||||
|
if (ZSTD_isError (r))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "zstd compress failed: %s\n", ZSTD_getErrorName (r));
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
compressed_size = r;
|
||||||
|
|
||||||
|
uncompressed_buf = malloc (orig_bufsize);
|
||||||
|
if (uncompressed_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_zstd (state, (unsigned char *) compressed_buf,
|
||||||
|
compressed_size,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
uncompressed_buf, orig_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "zstd large: backtrace_uncompress_zstd failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp (uncompressed_buf, orig_buf, orig_bufsize) != 0)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
fprintf (stderr, "zstd large: uncompressed data mismatch\n");
|
||||||
|
for (j = 0; j < orig_bufsize; ++j)
|
||||||
|
if (orig_buf[j] != uncompressed_buf[j])
|
||||||
|
fprintf (stderr, " %zu: got %#x want %#x\n", j,
|
||||||
|
uncompressed_buf[j], orig_buf[j]);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("PASS: zstd large\n");
|
||||||
|
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
cid = ZSTD_CLOCK_GETTIME_ARG;
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINVAL)
|
||||||
|
return;
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_zstd (state,
|
||||||
|
(unsigned char *) compressed_buf,
|
||||||
|
compressed_size,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
uncompressed_buf,
|
||||||
|
orig_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("zstd large: "
|
||||||
|
"benchmark backtrace_uncompress_zstd failed\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ctime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ctimes[i] = ctime;
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
perror("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = ZSTD_decompress (uncompressed_buf, orig_bufsize,
|
||||||
|
compressed_buf, compressed_size);
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ZSTD_isError (r))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"zstd large: benchmark zlib uncompress failed: %s\n",
|
||||||
|
ZSTD_getErrorName (r));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ztime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ztime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ztimes[i] = ztime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toss the highest and lowest times and average the rest. */
|
||||||
|
ctime = average_time (ctimes, trials);
|
||||||
|
ztime = average_time (ztimes, trials);
|
||||||
|
|
||||||
|
printf ("backtrace: %zu ns\n", ctime);
|
||||||
|
printf ("zstd : %zu ns\n", ztime);
|
||||||
|
printf ("ratio : %g\n", (double) ztime / (double) ctime);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
printf ("FAIL: zstd large\n");
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
if (orig_buf != NULL)
|
||||||
|
free (orig_buf);
|
||||||
|
if (compressed_buf != NULL)
|
||||||
|
free (compressed_buf);
|
||||||
|
if (uncompressed_buf != NULL)
|
||||||
|
free (uncompressed_buf);
|
||||||
|
|
||||||
|
#else /* !HAVE_ZSTD */
|
||||||
|
|
||||||
|
printf ("UNSUPPORTED: zstd large\n");
|
||||||
|
|
||||||
|
#endif /* !HAVE_ZSTD */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
struct backtrace_state *state;
|
||||||
|
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
test_samples (state);
|
||||||
|
test_large (state);
|
||||||
|
|
||||||
|
exit (failures != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
541
deps/libbacktrace/ztest.c
vendored
Normal file
541
deps/libbacktrace/ztest.c
vendored
Normal file
@ -0,0 +1,541 @@
|
|||||||
|
/* ztest.c -- Test for libbacktrace inflate code.
|
||||||
|
Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor, Google.
|
||||||
|
|
||||||
|
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) 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 "config.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "backtrace.h"
|
||||||
|
#include "backtrace-supported.h"
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "testlib.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
typedef int xclockid_t;
|
||||||
|
|
||||||
|
static int
|
||||||
|
xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED,
|
||||||
|
struct timespec *ts ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define clockid_t xclockid_t
|
||||||
|
#define clock_gettime xclock_gettime
|
||||||
|
#undef CLOCK_REALTIME
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
|
#endif /* !defined(HAVE_CLOCK_GETTIME) */
|
||||||
|
|
||||||
|
#ifdef CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#define ZLIB_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
|
||||||
|
#else
|
||||||
|
#define ZLIB_CLOCK_GETTIME_ARG CLOCK_REALTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Some tests for the local zlib inflation code. */
|
||||||
|
|
||||||
|
struct zlib_test
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
const char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
const char *compressed;
|
||||||
|
size_t compressed_len;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Error callback. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_callback_compress (void *vdata ATTRIBUTE_UNUSED, const char *msg,
|
||||||
|
int errnum)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s", msg);
|
||||||
|
if (errnum > 0)
|
||||||
|
fprintf (stderr, ": %s", strerror (errnum));
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct zlib_test tests[] =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"empty",
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
"\x78\x9c\x03\x00\x00\x00\x00\x01",
|
||||||
|
8,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hello",
|
||||||
|
"hello, world\n",
|
||||||
|
0,
|
||||||
|
("\x78\x9c\xca\x48\xcd\xc9\xc9\xd7\x51\x28\xcf"
|
||||||
|
"\x2f\xca\x49\xe1\x02\x04\x00\x00\xff\xff\x21\xe7\x04\x93"),
|
||||||
|
25,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"goodbye",
|
||||||
|
"goodbye, world",
|
||||||
|
0,
|
||||||
|
("\x78\x9c\x4b\xcf\xcf\x4f\x49\xaa"
|
||||||
|
"\x4c\xd5\x51\x28\xcf\x2f\xca\x49"
|
||||||
|
"\x01\x00\x28\xa5\x05\x5e"),
|
||||||
|
22,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ranges",
|
||||||
|
("\xcc\x11\x00\x00\x00\x00\x00\x00\xd5\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x1c\x14\x00\x00\x00\x00\x00\x00\x72\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x0c\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x29\x14\x00\x00\x00\x00\x00\x00\x4e\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfb\x12\x00\x00\x00\x00\x00\x00\x09\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x67\x13\x00\x00\x00\x00\x00\x00\xcb\x13\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9d\x14\x00\x00\x00\x00\x00\x00\xd5\x14\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x5f\x0b\x00\x00\x00\x00\x00\x00\x6c\x0b\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7d\x0b\x00\x00\x00\x00\x00\x00\x7e\x0c\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x38\x0f\x00\x00\x00\x00\x00\x00\x5c\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x83\x0c\x00\x00\x00\x00\x00\x00\xfa\x0c\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xef\x0e\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x14\x0f\x00\x00\x00\x00\x00\x00\x38\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfd\x0d\x00\x00\x00\x00\x00\x00\xd8\x0e\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x0f\x00\x00\x00\x00\x00\x00\xac\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xdb\x0f\x00\x00\x00\x00\x00\x00\xff\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xfa\x0c\x00\x00\x00\x00\x00\x00\xea\x0d\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xef\x0e\x00\x00\x00\x00\x00\x00\x14\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x5c\x0f\x00\x00\x00\x00\x00\x00\x9f\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xac\x0f\x00\x00\x00\x00\x00\x00\xdb\x0f\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\xff\x0f\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x60\x11\x00\x00\x00\x00\x00\x00\xd1\x16\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x40\x0b\x00\x00\x00\x00\x00\x00\x2c\x10\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7a\x00\x00\x00\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x7a\x00\x00\x00\x00\x00\x00\x00\xa9\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x9f\x01\x00\x00\x00\x00\x00\x00\xa7\x01\x00\x00\x00\x00\x00\x00"
|
||||||
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"),
|
||||||
|
672,
|
||||||
|
("\x78\x9c\x3b\x23\xc8\x00\x06\x57\x85\x21\xb4\x8c\x08\x84\x2e\x82"
|
||||||
|
"\xd2\x73\xa1\xf4\x55\x28\x8d\x0e\x7e\x0b\x41\x68\x4e\xa8\x7e\x1e"
|
||||||
|
"\x28\x7d\x1a\x4a\x6b\x42\xf5\xf9\x91\x69\x5e\x3a\x9a\x79\x84\xf4"
|
||||||
|
"\xc7\x73\x43\xe8\x1c\x28\x5d\x0b\xa5\xeb\x78\x20\xb4\x05\x3f\x84"
|
||||||
|
"\x8e\xe1\xc7\xae\xbf\x19\xaa\xee\x17\x94\xfe\xcb\x0b\xa1\xdf\xf3"
|
||||||
|
"\x41\x68\x11\x7e\x54\x73\xe6\x43\xe9\x35\x50\xfa\x36\x94\xfe\x8f"
|
||||||
|
"\xc3\x7c\x98\x79\x37\xf8\xc8\xd3\x0f\x73\xd7\x2b\x1c\xee\x8a\x21"
|
||||||
|
"\xd2\x5d\x3a\x02\xd8\xcd\x4f\x80\xa6\x87\x8b\x62\x10\xda\x81\x1b"
|
||||||
|
"\xbf\xfa\x2a\x28\xbd\x0d\x4a\xcf\x67\x84\xd0\xcb\x19\xf1\xab\x5f"
|
||||||
|
"\x49\xa4\x7a\x00\x48\x97\x29\xd4"),
|
||||||
|
152,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test the hand coded samples. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_samples (struct backtrace_state *state)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof tests / sizeof tests[0]; ++i)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
size_t v;
|
||||||
|
size_t j;
|
||||||
|
unsigned char *uncompressed;
|
||||||
|
size_t uncompressed_len;
|
||||||
|
|
||||||
|
p = malloc (12 + tests[i].compressed_len);
|
||||||
|
memcpy (p, "ZLIB", 4);
|
||||||
|
v = tests[i].uncompressed_len;
|
||||||
|
if (v == 0)
|
||||||
|
v = strlen (tests[i].uncompressed);
|
||||||
|
for (j = 0; j < 8; ++j)
|
||||||
|
p[j + 4] = (v >> ((7 - j) * 8)) & 0xff;
|
||||||
|
memcpy (p + 12, tests[i].compressed, tests[i].compressed_len);
|
||||||
|
uncompressed = NULL;
|
||||||
|
uncompressed_len = 0;
|
||||||
|
if (!backtrace_uncompress_zdebug (state, (unsigned char *) p,
|
||||||
|
tests[i].compressed_len + 12,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed, &uncompressed_len))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "test %s: uncompress failed\n", tests[i].name);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (uncompressed_len != v)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"test %s: got uncompressed length %zu, want %zu\n",
|
||||||
|
tests[i].name, uncompressed_len, v);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else if (memcmp (tests[i].uncompressed, uncompressed, v) != 0)
|
||||||
|
{
|
||||||
|
size_t j;
|
||||||
|
|
||||||
|
fprintf (stderr, "test %s: uncompressed data mismatch\n",
|
||||||
|
tests[i].name);
|
||||||
|
for (j = 0; j < v; ++j)
|
||||||
|
if (tests[i].uncompressed[j] != uncompressed[j])
|
||||||
|
fprintf (stderr, " %zu: got %#x want %#x\n", j,
|
||||||
|
uncompressed[j], tests[i].uncompressed[j]);
|
||||||
|
++failures;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf ("PASS: inflate %s\n", tests[i].name);
|
||||||
|
|
||||||
|
backtrace_free (state, uncompressed, uncompressed_len,
|
||||||
|
error_callback_compress, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
|
||||||
|
/* Given a set of TRIALS timings, discard the lowest and highest
|
||||||
|
values and return the mean average of the rest. */
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
average_time (const size_t *times, size_t trials)
|
||||||
|
{
|
||||||
|
size_t imax;
|
||||||
|
size_t max;
|
||||||
|
size_t imin;
|
||||||
|
size_t min;
|
||||||
|
size_t i;
|
||||||
|
size_t sum;
|
||||||
|
|
||||||
|
imin = 0;
|
||||||
|
imax = 0;
|
||||||
|
min = times[0];
|
||||||
|
max = times[0];
|
||||||
|
for (i = 1; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (times[i] < min)
|
||||||
|
{
|
||||||
|
imin = i;
|
||||||
|
min = times[i];
|
||||||
|
}
|
||||||
|
if (times[i] > max)
|
||||||
|
{
|
||||||
|
imax = i;
|
||||||
|
max = times[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum = 0;
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
if (i != imax && i != imin)
|
||||||
|
sum += times[i];
|
||||||
|
}
|
||||||
|
return sum / (trials - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Test a larger text, if available. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_large (struct backtrace_state *state ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
unsigned char *orig_buf;
|
||||||
|
size_t orig_bufsize;
|
||||||
|
size_t i;
|
||||||
|
char *compressed_buf;
|
||||||
|
size_t compressed_bufsize;
|
||||||
|
unsigned long compress_sizearg;
|
||||||
|
unsigned char *uncompressed_buf;
|
||||||
|
size_t uncompressed_bufsize;
|
||||||
|
int r;
|
||||||
|
clockid_t cid;
|
||||||
|
struct timespec ts1;
|
||||||
|
struct timespec ts2;
|
||||||
|
size_t ctime;
|
||||||
|
size_t ztime;
|
||||||
|
const size_t trials = 16;
|
||||||
|
size_t ctimes[16];
|
||||||
|
size_t ztimes[16];
|
||||||
|
static const char * const names[] = {
|
||||||
|
"Isaac.Newton-Opticks.txt",
|
||||||
|
"../libgo/go/testdata/Isaac.Newton-Opticks.txt",
|
||||||
|
};
|
||||||
|
|
||||||
|
orig_buf = NULL;
|
||||||
|
orig_bufsize = 0;
|
||||||
|
uncompressed_buf = NULL;
|
||||||
|
compressed_buf = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof names / sizeof names[0]; ++i)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *namebuf;
|
||||||
|
FILE *e;
|
||||||
|
struct stat st;
|
||||||
|
char *rbuf;
|
||||||
|
size_t got;
|
||||||
|
|
||||||
|
len = strlen (SRCDIR) + strlen (names[i]) + 2;
|
||||||
|
namebuf = malloc (len);
|
||||||
|
if (namebuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
snprintf (namebuf, len, "%s/%s", SRCDIR, names[i]);
|
||||||
|
e = fopen (namebuf, "r");
|
||||||
|
free (namebuf);
|
||||||
|
if (e == NULL)
|
||||||
|
continue;
|
||||||
|
if (fstat (fileno (e), &st) < 0)
|
||||||
|
{
|
||||||
|
perror ("fstat");
|
||||||
|
fclose (e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
rbuf = malloc (st.st_size);
|
||||||
|
if (rbuf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
got = fread (rbuf, 1, st.st_size, e);
|
||||||
|
fclose (e);
|
||||||
|
if (got > 0)
|
||||||
|
{
|
||||||
|
orig_buf = (unsigned char *) rbuf;
|
||||||
|
orig_bufsize = got;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free (rbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orig_buf == NULL)
|
||||||
|
{
|
||||||
|
/* We couldn't find an input file. */
|
||||||
|
printf ("UNSUPPORTED: inflate large\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
compressed_bufsize = compressBound (orig_bufsize) + 12;
|
||||||
|
compressed_buf = malloc (compressed_bufsize);
|
||||||
|
if (compressed_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
compress_sizearg = compressed_bufsize - 12;
|
||||||
|
r = compress ((unsigned char *) compressed_buf + 12, &compress_sizearg,
|
||||||
|
orig_buf, orig_bufsize);
|
||||||
|
if (r != Z_OK)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "zlib compress failed: %d\n", r);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
compressed_bufsize = compress_sizearg + 12;
|
||||||
|
|
||||||
|
/* Prepare the header that our library expects. */
|
||||||
|
memcpy (compressed_buf, "ZLIB", 4);
|
||||||
|
for (i = 0; i < 8; ++i)
|
||||||
|
compressed_buf[i + 4] = (orig_bufsize >> ((7 - i) * 8)) & 0xff;
|
||||||
|
|
||||||
|
uncompressed_buf = malloc (orig_bufsize);
|
||||||
|
if (uncompressed_buf == NULL)
|
||||||
|
{
|
||||||
|
perror ("malloc");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
uncompressed_bufsize = orig_bufsize;
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_zdebug (state, (unsigned char *) compressed_buf,
|
||||||
|
compressed_bufsize,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed_buf, &uncompressed_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "inflate large: backtrace_uncompress_zdebug failed\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uncompressed_bufsize != orig_bufsize)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"inflate large: got uncompressed length %zu, want %zu\n",
|
||||||
|
uncompressed_bufsize, orig_bufsize);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp (uncompressed_buf, orig_buf, uncompressed_bufsize) != 0)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "inflate large: uncompressed data mismatch\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("PASS: inflate large\n");
|
||||||
|
|
||||||
|
for (i = 0; i < trials; ++i)
|
||||||
|
{
|
||||||
|
unsigned long uncompress_sizearg;
|
||||||
|
|
||||||
|
cid = ZLIB_CLOCK_GETTIME_ARG;
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
if (errno == EINVAL)
|
||||||
|
return;
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!backtrace_uncompress_zdebug (state,
|
||||||
|
(unsigned char *) compressed_buf,
|
||||||
|
compressed_bufsize,
|
||||||
|
error_callback_compress, NULL,
|
||||||
|
&uncompressed_buf,
|
||||||
|
&uncompressed_bufsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
("inflate large: "
|
||||||
|
"benchmark backtrace_uncompress_zdebug failed\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ctime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ctimes[i] = ctime;
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts1) < 0)
|
||||||
|
{
|
||||||
|
perror("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uncompress_sizearg = uncompressed_bufsize;
|
||||||
|
r = uncompress ((unsigned char *) uncompressed_buf, &uncompress_sizearg,
|
||||||
|
(unsigned char *) compressed_buf + 12,
|
||||||
|
compressed_bufsize - 12);
|
||||||
|
|
||||||
|
if (clock_gettime (cid, &ts2) < 0)
|
||||||
|
{
|
||||||
|
perror ("clock_gettime");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r != Z_OK)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
"inflate large: benchmark zlib uncompress failed: %d\n",
|
||||||
|
r);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ztime = (ts2.tv_sec - ts1.tv_sec) * 1000000000;
|
||||||
|
ztime += ts2.tv_nsec - ts1.tv_nsec;
|
||||||
|
ztimes[i] = ztime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toss the highest and lowest times and average the rest. */
|
||||||
|
ctime = average_time (ctimes, trials);
|
||||||
|
ztime = average_time (ztimes, trials);
|
||||||
|
|
||||||
|
printf ("backtrace: %zu ns\n", ctime);
|
||||||
|
printf ("zlib : %zu ns\n", ztime);
|
||||||
|
printf ("ratio : %g\n", (double) ztime / (double) ctime);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
printf ("FAIL: inflate large\n");
|
||||||
|
++failures;
|
||||||
|
|
||||||
|
if (orig_buf != NULL)
|
||||||
|
free (orig_buf);
|
||||||
|
if (compressed_buf != NULL)
|
||||||
|
free (compressed_buf);
|
||||||
|
if (uncompressed_buf != NULL)
|
||||||
|
free (uncompressed_buf);
|
||||||
|
|
||||||
|
#else /* !HAVE_ZLIB */
|
||||||
|
|
||||||
|
printf ("UNSUPPORTED: inflate large\n");
|
||||||
|
|
||||||
|
#endif /* !HAVE_ZLIB */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc ATTRIBUTE_UNUSED, char **argv)
|
||||||
|
{
|
||||||
|
struct backtrace_state *state;
|
||||||
|
|
||||||
|
state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS,
|
||||||
|
error_callback_create, NULL);
|
||||||
|
|
||||||
|
test_samples (state);
|
||||||
|
test_large (state);
|
||||||
|
|
||||||
|
exit (failures != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||||
|
}
|
1
deps/libsodium
vendored
1
deps/libsodium
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit fb4533b0a941b3a5b1db5687d1b008a5853d1f29
|
|
179
deps/libsodium/.github/workflows/ci.yml
vendored
Normal file
179
deps/libsodium/.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, stable, next]
|
||||||
|
pull_request:
|
||||||
|
branches: [master, stable, next]
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tcc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y build-essential libtool autoconf automake tcc
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Compilation with tcc
|
||||||
|
run: |
|
||||||
|
env CC=tcc CFLAGS='-w' CPPFLAGS="-DDEV_MODE=1" ./configure --prefix=/tmp --disable-dependency-tracking --disable-shared || cat config.log
|
||||||
|
make -j $(nproc) && make check && make install
|
||||||
|
env CC=tcc CPPFLAGS='-I/tmp/include' LDFLAGS='-L/tmp/lib' LD_LIBRARY_PATH='/tmp/lib' ./test/constcheck.sh
|
||||||
|
make uninstall
|
||||||
|
make distclean
|
||||||
|
|
||||||
|
zig:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Compilation with zig
|
||||||
|
run: |
|
||||||
|
zig build
|
||||||
|
zig build -Dtarget=x86_64-linux
|
||||||
|
zig build -Dtarget=aarch64-linux
|
||||||
|
zig build -Dtarget=x86_64-windows
|
||||||
|
zig build -Dtarget=aarch64-windows
|
||||||
|
zig build -Dtarget=x86_64-macos
|
||||||
|
zig build -Dtarget=aarch64-macos
|
||||||
|
zig build -Dtarget=wasm32-wasi
|
||||||
|
zig build -Doptimize=ReleaseFast
|
||||||
|
rm -fr zig-cache zig-out
|
||||||
|
|
||||||
|
regular:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: sudo apt-get install -y build-essential libtool autoconf automake
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: C99 compat check
|
||||||
|
run: |
|
||||||
|
env CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking
|
||||||
|
make -j $(nproc) CFLAGS='-g0' > /dev/null && cp src/libsodium/.libs/libsodium.so lib.so && make clean > /dev/null && make CFLAGS='-g0' CPPFLAGS='-DDEV_MODE=1 -DSODIUM_C99\(X\)=' > /dev/null && cp src/libsodium/.libs/libsodium.so lib-oldc.so && cmp lib.so lib-oldc.so && echo No binary changes && make clean > /dev/null
|
||||||
|
make distcheck
|
||||||
|
make distclean > /dev/null
|
||||||
|
|
||||||
|
- name: Regular compilation
|
||||||
|
run: |
|
||||||
|
env CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking --enable-minimal
|
||||||
|
make -j $(nproc)
|
||||||
|
make check
|
||||||
|
( echo '#include <sodium.h>' ; echo 'int main(void) { return sodium_init(); }' ) > /tmp/main.c && gcc -DDEV_MODE=1 -Isrc/libsodium/include -Isrc/libsodium/include/sodium $(find src -name '*.c' -o -name '*.S') /tmp/main.c
|
||||||
|
make distclean > /dev/null
|
||||||
|
|
||||||
|
check-globals:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: sudo apt-get install -y build-essential libtool autoconf automake
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Check globals
|
||||||
|
run: |
|
||||||
|
if [ -x test/rename-globals.sh ]; then test/rename-globals.sh; fi
|
||||||
|
|
||||||
|
other-comp:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: sudo apt-get install -y build-essential libtool autoconf automake clang
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Compilation with g++
|
||||||
|
run: |
|
||||||
|
env CC=g++ CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking
|
||||||
|
make -j $(nproc) check
|
||||||
|
make clean > /dev/null
|
||||||
|
|
||||||
|
- name: Compilation with clang
|
||||||
|
run: |
|
||||||
|
env CC=clang CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking
|
||||||
|
make -j $(nproc) check
|
||||||
|
make clean > /dev/null
|
||||||
|
|
||||||
|
other-arch:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: sudo apt-get install -y build-essential libtool autoconf automake gcc-powerpc-linux-gnu
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Big-Endian PowerPC compilation
|
||||||
|
run: |
|
||||||
|
env CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking --host=powerpc-linux-gnu
|
||||||
|
make -j $(nproc)
|
||||||
|
make clean > /dev/null
|
||||||
|
|
||||||
|
android:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update packages list
|
||||||
|
run: sudo apt-get update
|
||||||
|
|
||||||
|
- name: Install base dependencies
|
||||||
|
run: sudo apt-get install -y libtool autoconf automake unzip
|
||||||
|
|
||||||
|
- name: Autogen
|
||||||
|
run: ./autogen.sh -s
|
||||||
|
|
||||||
|
- name: Install Android NDK
|
||||||
|
run: |
|
||||||
|
mkdir /tmp/android && cd /tmp/android
|
||||||
|
curl -o ndk.zip -L https://dl.google.com/android/repository/android-ndk-r25c-linux.zip
|
||||||
|
unzip ndk.zip && rm -f *.zip && mv android-ndk* ndk
|
||||||
|
|
||||||
|
- name: Android compilation
|
||||||
|
run: |
|
||||||
|
env ANDROID_NDK_HOME=/tmp/android/ndk ./dist-build/android-aar.sh
|
30
deps/libsodium/.github/workflows/codeql-analysis.yml
vendored
Normal file
30
deps/libsodium/.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: "CodeQL scan"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 17 * * 2"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CodeQL-Build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- run: |
|
||||||
|
./autogen.sh -s
|
||||||
|
env CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking
|
||||||
|
make -j $(nproc) check
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
367
deps/libsodium/.github/workflows/dotnet-core.yml
vendored
Normal file
367
deps/libsodium/.github/workflows/dotnet-core.yml
vendored
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
name: .NET Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- stable
|
||||||
|
- next
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: buildbase.bat
|
||||||
|
run: buildbase.bat ..\vs2022\libsodium.sln 17
|
||||||
|
working-directory: builds/msvc/build/
|
||||||
|
shell: cmd
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-win-x64
|
||||||
|
path: bin/x64/Release/v143/dynamic/libsodium.dll
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-win-x86
|
||||||
|
path: bin/Win32/Release/v143/dynamic/libsodium.dll
|
||||||
|
|
||||||
|
build-linux-glibc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=x86_64-linux-gnu.2.17 -Dcpu=sandybridge
|
||||||
|
- name: tests
|
||||||
|
run: cd zig-out/bin && ./run.sh
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-x64
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-linux-glibc-arm:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- name: Set up emulation environment
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf libc6-armhf-cross
|
||||||
|
sudo dpkg --add-architecture armhf
|
||||||
|
sudo update-binfmts --enable qemu-arm
|
||||||
|
sudo update-binfmts --display
|
||||||
|
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=arm-linux-gnueabihf.2.23 -Dcpu=baseline
|
||||||
|
- name: tests
|
||||||
|
run: |
|
||||||
|
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib ./run.sh
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-arm
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-linux-glibc-arm64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- name: Set up emulation environment
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y qemu binfmt-support qemu-user-static qemu-system-arm gcc-aarch64-linux-gnu libc6-arm64-cross
|
||||||
|
sudo dpkg --add-architecture arm64
|
||||||
|
sudo update-binfmts --enable qemu-aarch64
|
||||||
|
sudo update-binfmts --display
|
||||||
|
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=aarch64-linux-gnu.2.23 -Dcpu=baseline
|
||||||
|
- name: tests
|
||||||
|
run: |
|
||||||
|
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib ./run.sh
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-arm64
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-linux-musl:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: alpine:3.13
|
||||||
|
steps:
|
||||||
|
- name: Set up build environment
|
||||||
|
run: |
|
||||||
|
apk update
|
||||||
|
apk add alpine-sdk ca-certificates xz
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=x86_64-linux-musl -Dcpu=sandybridge
|
||||||
|
- name: tests
|
||||||
|
run: |
|
||||||
|
cd zig-out/bin && ./run.sh
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-x64
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-linux-musl-arm:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=arm-linux-musleabihf -Dcpu=baseline
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-arm
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-linux-musl-arm64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Zig
|
||||||
|
uses: goto-bus-stop/setup-zig@d866436887ad1b24590684f9d00480376663dd36
|
||||||
|
with:
|
||||||
|
version: 0.11.0
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
zig build -Doptimize=ReleaseFast -Dtarget=aarch64-linux-musl -Dcpu=baseline
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-arm64
|
||||||
|
path: zig-out/lib/libsodium.so
|
||||||
|
|
||||||
|
build-macos-x64:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: configure
|
||||||
|
run: env CFLAGS="-Ofast -arch x86_64 -mmacosx-version-min=10.15" LDFLAGS="-arch x86_64 -mmacosx-version-min=10.15" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
|
||||||
|
- name: make
|
||||||
|
run: make
|
||||||
|
- name: make check
|
||||||
|
run: make check
|
||||||
|
- name: make install
|
||||||
|
run: make install
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-osx-x64
|
||||||
|
path: .libsodium-build/lib/libsodium.dylib
|
||||||
|
|
||||||
|
build-macos-arm64:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: configure
|
||||||
|
run: env CFLAGS="-Ofast -arch arm64 -mmacosx-version-min=10.15" LDFLAGS="-arch arm64 -mmacosx-version-min=10.15" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
|
||||||
|
- name: make
|
||||||
|
run: make
|
||||||
|
- name: make install
|
||||||
|
run: make install
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-osx-arm64
|
||||||
|
path: .libsodium-build/lib/libsodium.dylib
|
||||||
|
|
||||||
|
pack:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build-windows
|
||||||
|
- build-linux-glibc
|
||||||
|
- build-linux-glibc-arm
|
||||||
|
- build-linux-glibc-arm64
|
||||||
|
- build-linux-musl
|
||||||
|
- build-linux-musl-arm
|
||||||
|
- build-linux-musl-arm64
|
||||||
|
- build-macos-x64
|
||||||
|
- build-macos-arm64
|
||||||
|
container:
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||||
|
env:
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||||
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
|
||||||
|
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-win-x64
|
||||||
|
path: .libsodium-pack/runtimes/win-x64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-win-x86
|
||||||
|
path: .libsodium-pack/runtimes/win-x86/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-x64
|
||||||
|
path: .libsodium-pack/runtimes/linux-x64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-arm64
|
||||||
|
path: .libsodium-pack/runtimes/linux-arm64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-arm
|
||||||
|
path: .libsodium-pack/runtimes/linux-arm/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-x64
|
||||||
|
path: .libsodium-pack/runtimes/linux-musl-x64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-arm
|
||||||
|
path: .libsodium-pack/runtimes/linux-musl-arm/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-linux-musl-arm64
|
||||||
|
path: .libsodium-pack/runtimes/linux-musl-arm64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-osx-x64
|
||||||
|
path: .libsodium-pack/runtimes/osx-x64/native/
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: build-osx-arm64
|
||||||
|
path: .libsodium-pack/runtimes/osx-arm64/native/
|
||||||
|
- name: Copy files
|
||||||
|
run: cp AUTHORS ChangeLog LICENSE packaging/dotnet-core/libsodium.pkgproj .libsodium-pack/
|
||||||
|
- name: Create NuGet package
|
||||||
|
run: dotnet pack -c Release .libsodium-pack/libsodium.pkgproj
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: nuget-package
|
||||||
|
path: .libsodium-pack/bin/Release/*.nupkg
|
||||||
|
|
||||||
|
build-test-binaries:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- pack
|
||||||
|
container:
|
||||||
|
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||||
|
env:
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||||
|
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
|
||||||
|
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: nuget-package
|
||||||
|
path: .libsodium-pack/
|
||||||
|
- name: dotnet new
|
||||||
|
run: dotnet new console -n Tests -o .libsodium-test/
|
||||||
|
- name: dotnet add package libsodium
|
||||||
|
run: dotnet add .libsodium-test/Tests.csproj package libsodium -s $PWD/.libsodium-pack
|
||||||
|
- name: Copy files
|
||||||
|
run: cp -f packaging/dotnet-core/test.cs .libsodium-test/Program.cs
|
||||||
|
- name: dotnet publish linux-x64
|
||||||
|
run: dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=true
|
||||||
|
working-directory: .libsodium-test/
|
||||||
|
- name: dotnet publish linux-arm
|
||||||
|
run: dotnet publish -c Release -r linux-arm --self-contained true -p:PublishTrimmed=true
|
||||||
|
working-directory: .libsodium-test/
|
||||||
|
- name: dotnet publish linux-arm64
|
||||||
|
run: dotnet publish -c Release -r linux-arm64 --self-contained true -p:PublishTrimmed=true
|
||||||
|
working-directory: .libsodium-test/
|
||||||
|
- name: Move Build Output
|
||||||
|
run: |
|
||||||
|
mkdir .libsodium-builds
|
||||||
|
mv .libsodium-test/bin/Release/net6.0/linux-arm/publish .libsodium-builds/linux-arm
|
||||||
|
mv .libsodium-test/bin/Release/net6.0/linux-arm64/publish .libsodium-builds/linux-arm64
|
||||||
|
mv .libsodium-test/bin/Release/net6.0/linux-x64/publish .libsodium-builds/linux-x64
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: test-builds
|
||||||
|
path: .libsodium-builds/*
|
||||||
|
|
||||||
|
run-test-binaries-os-versions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- build-test-binaries
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# CentOS 7 and Debian 10 use an older GCC version; make sure we can run on those platforms.
|
||||||
|
arch: [ 'centos:7', 'debian:10' ]
|
||||||
|
container:
|
||||||
|
image: ${{ matrix.arch }}
|
||||||
|
env:
|
||||||
|
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: test-builds
|
||||||
|
path: .libsodium-builds/
|
||||||
|
- name: Run x64 tests
|
||||||
|
run: |
|
||||||
|
chmod +x .libsodium-builds/linux-x64/Tests
|
||||||
|
.libsodium-builds/linux-x64/Tests
|
||||||
|
|
||||||
|
run-test-binaries-cross-plat:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
needs:
|
||||||
|
- build-test-binaries
|
||||||
|
env:
|
||||||
|
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch: x64
|
||||||
|
libs: /usr/lib
|
||||||
|
- arch: arm
|
||||||
|
libs: /usr/arm-linux-gnueabihf/lib
|
||||||
|
- arch: arm64
|
||||||
|
libs: /usr/aarch64-linux-gnu/lib
|
||||||
|
arch: [x64, arm, arm64]
|
||||||
|
steps:
|
||||||
|
- name: Set up build environment
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# On virtualization systems such as the one used by WSL2, the ARM crypto extensions
|
||||||
|
# don't work as expected. As a result, installing on Ubuntu fails during integrity
|
||||||
|
# checks. As a workaround, the following command disables hardware acceleration for
|
||||||
|
# gcrypt, which the apt-get command relies on.
|
||||||
|
sudo mkdir -p /etc/gcrypt && echo all | sudo tee /etc/gcrypt/hwf.deny
|
||||||
|
|
||||||
|
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libc6-armhf-cross libc6-arm64-cross
|
||||||
|
sudo dpkg --add-architecture armhf
|
||||||
|
sudo dpkg --add-architecture arm64
|
||||||
|
sudo update-binfmts --enable qemu-aarch64
|
||||||
|
sudo update-binfmts --enable qemu-arm
|
||||||
|
sudo update-binfmts --display
|
||||||
|
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
|
||||||
|
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: test-builds
|
||||||
|
path: .libsodium-builds/
|
||||||
|
|
||||||
|
- name: Run ${{ matrix.arch }}
|
||||||
|
run: |
|
||||||
|
chmod +x .libsodium-builds/linux-${{ matrix.arch }}/Tests
|
||||||
|
env LD_LIBRARY_PATH=${{ matrix.libs }} .libsodium-builds/linux-${{ matrix.arch }}/Tests
|
167
deps/libsodium/.gitignore
vendored
Normal file
167
deps/libsodium/.gitignore
vendored
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
*.bc
|
||||||
|
*.dSYM
|
||||||
|
*.done
|
||||||
|
*.final
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
|
*.i
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
*.log
|
||||||
|
*.mem
|
||||||
|
*.nexe
|
||||||
|
*.o
|
||||||
|
*.plist
|
||||||
|
*.scan
|
||||||
|
*.sdf
|
||||||
|
*.status
|
||||||
|
*.tar.*
|
||||||
|
*.wasm
|
||||||
|
*.wast
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
.deps
|
||||||
|
.dirstamp
|
||||||
|
.done
|
||||||
|
.libs
|
||||||
|
/bin/
|
||||||
|
/obj/
|
||||||
|
Build
|
||||||
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
Vagrantfile
|
||||||
|
aclocal.m4
|
||||||
|
android-toolchain
|
||||||
|
android-toolchain-*
|
||||||
|
autom4te.cache
|
||||||
|
build
|
||||||
|
compile
|
||||||
|
confdefs.h
|
||||||
|
config.*
|
||||||
|
configure
|
||||||
|
configure.lineno
|
||||||
|
coverage.info
|
||||||
|
depcomp
|
||||||
|
install-sh
|
||||||
|
libsodium-*.tar.bz2
|
||||||
|
libsodium-*.tar.gz
|
||||||
|
libsodium-*.vcproj
|
||||||
|
libsodium-*.vcproj.filters
|
||||||
|
libsodium-*.vcxproj
|
||||||
|
libsodium-*.vcxproj.filters
|
||||||
|
libsodium-android-*
|
||||||
|
libsodium-ios
|
||||||
|
libsodium-js
|
||||||
|
libsodium-js-*
|
||||||
|
libsodium-nativeclient
|
||||||
|
libsodium-nativeclient-*
|
||||||
|
libsodium-osx
|
||||||
|
libsodium-uninstalled.pc
|
||||||
|
libsodium-wasm32-wasi
|
||||||
|
libsodium-win32
|
||||||
|
libsodium-win64
|
||||||
|
libsodium.pc
|
||||||
|
libtool
|
||||||
|
ltmain.sh
|
||||||
|
m4/argz.m4
|
||||||
|
m4/libtool.m4
|
||||||
|
m4/ltoptions.m4
|
||||||
|
m4/ltsugar.m4
|
||||||
|
m4/ltversion.m4
|
||||||
|
m4/lt~obsolete.m4
|
||||||
|
man/*.html
|
||||||
|
man/Makefile.in
|
||||||
|
missing
|
||||||
|
src/libsodium/*.def
|
||||||
|
src/libsodium/include/sodium/version.h
|
||||||
|
stamp-*
|
||||||
|
test-driver
|
||||||
|
test/default/*.asm.js
|
||||||
|
test/default/*.res
|
||||||
|
test/default/*.trs
|
||||||
|
test/default/aead_aegis128l
|
||||||
|
test/default/aead_aegis256
|
||||||
|
test/default/aead_aes256gcm
|
||||||
|
test/default/aead_aes256gcm2
|
||||||
|
test/default/aead_chacha20poly1305
|
||||||
|
test/default/aead_chacha20poly13052
|
||||||
|
test/default/aead_xchacha20poly1305
|
||||||
|
test/default/auth
|
||||||
|
test/default/auth2
|
||||||
|
test/default/auth3
|
||||||
|
test/default/auth5
|
||||||
|
test/default/auth6
|
||||||
|
test/default/auth7
|
||||||
|
test/default/box
|
||||||
|
test/default/box2
|
||||||
|
test/default/box7
|
||||||
|
test/default/box8
|
||||||
|
test/default/box_easy
|
||||||
|
test/default/box_easy2
|
||||||
|
test/default/box_seal
|
||||||
|
test/default/box_seed
|
||||||
|
test/default/browser
|
||||||
|
test/default/chacha20
|
||||||
|
test/default/codecs
|
||||||
|
test/default/core1
|
||||||
|
test/default/core2
|
||||||
|
test/default/core3
|
||||||
|
test/default/core4
|
||||||
|
test/default/core5
|
||||||
|
test/default/core6
|
||||||
|
test/default/core_ed25519
|
||||||
|
test/default/core_ristretto255
|
||||||
|
test/default/ed25519_convert
|
||||||
|
test/default/generichash
|
||||||
|
test/default/generichash2
|
||||||
|
test/default/generichash3
|
||||||
|
test/default/hash
|
||||||
|
test/default/hash3
|
||||||
|
test/default/kdf
|
||||||
|
test/default/kdf_hkdf
|
||||||
|
test/default/keygen
|
||||||
|
test/default/kx
|
||||||
|
test/default/metamorphic
|
||||||
|
test/default/misuse
|
||||||
|
test/default/onetimeauth
|
||||||
|
test/default/onetimeauth2
|
||||||
|
test/default/onetimeauth7
|
||||||
|
test/default/pwhash_argon2i
|
||||||
|
test/default/pwhash_argon2id
|
||||||
|
test/default/pwhash_scrypt
|
||||||
|
test/default/pwhash_scrypt_ll
|
||||||
|
test/default/randombytes
|
||||||
|
test/default/scalarmult
|
||||||
|
test/default/scalarmult2
|
||||||
|
test/default/scalarmult5
|
||||||
|
test/default/scalarmult6
|
||||||
|
test/default/scalarmult7
|
||||||
|
test/default/scalarmult8
|
||||||
|
test/default/scalarmult_ed25519
|
||||||
|
test/default/scalarmult_ristretto255
|
||||||
|
test/default/secretbox
|
||||||
|
test/default/secretbox2
|
||||||
|
test/default/secretbox7
|
||||||
|
test/default/secretbox8
|
||||||
|
test/default/secretbox_easy
|
||||||
|
test/default/secretbox_easy2
|
||||||
|
test/default/secretstream_xchacha20poly1305
|
||||||
|
test/default/shorthash
|
||||||
|
test/default/sign
|
||||||
|
test/default/siphashx24
|
||||||
|
test/default/sodium_core
|
||||||
|
test/default/sodium_utils
|
||||||
|
test/default/sodium_utils2
|
||||||
|
test/default/sodium_utils3
|
||||||
|
test/default/sodium_version
|
||||||
|
test/default/stream
|
||||||
|
test/default/stream2
|
||||||
|
test/default/stream3
|
||||||
|
test/default/stream4
|
||||||
|
test/default/verify1
|
||||||
|
test/default/xchacha20
|
||||||
|
test/js.done
|
||||||
|
testing
|
||||||
|
zig-cache
|
||||||
|
zig-out
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user