mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
Compare commits
120
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606cad63e0 | ||
|
|
da00f4efc2 | ||
|
|
32521d32d0 | ||
|
|
1df7c9c31d | ||
|
|
f241006773 | ||
|
|
43afd0bf1c | ||
|
|
74435f8eb3 | ||
|
|
6b73bc0356 | ||
|
|
7cf9efac69 | ||
|
|
970d5bae18 | ||
|
|
1e6d5626c8 | ||
|
|
bcce53dd34 | ||
|
|
a26e715d37 | ||
|
|
4fcbd8c517 | ||
|
|
882db38555 | ||
|
|
9d9668a3f2 | ||
|
|
8d8602badd | ||
|
|
1def6ae0d1 | ||
|
|
896ecc9a30 | ||
|
|
52d36a71f1 | ||
|
|
58a89d2d23 | ||
|
|
dbab9c6029 | ||
|
|
c99fcd78ed | ||
|
|
1e8b639eba | ||
|
|
8510587725 | ||
|
|
7d08752b0e | ||
|
|
18731eb4b9 | ||
|
|
1279beffe8 | ||
|
|
32e9c3c95d | ||
|
|
0925ddc26f | ||
|
|
bb581dec3c | ||
|
|
915446aa4a | ||
|
|
9c65783076 | ||
|
|
49c68b4b0d | ||
|
|
a0bccd8472 | ||
|
|
e6d6e4a290 | ||
|
|
814e9babff | ||
|
|
42884803ec | ||
|
|
d4f3f321a2 | ||
|
|
9b754369c0 | ||
|
|
ed2ab96198 | ||
|
|
49e842606b | ||
|
|
ee1754104e | ||
|
|
9d15ac2014 | ||
|
|
c867c8b833 | ||
|
|
4287d70395 | ||
|
|
1259db48a3 | ||
|
|
26687284d9 | ||
|
|
3dcc89db84 | ||
|
|
94a5228bc6 | ||
|
|
831b94a0a8 | ||
|
|
94aabdf0f0 | ||
|
|
5df5dfdee1 | ||
|
|
1122e55277 | ||
|
|
a303f06e5b | ||
|
|
104628a2ae | ||
|
|
9e2f957e5a | ||
|
|
b9214dfb5f | ||
|
|
958d51720e | ||
|
|
3fb61e5330 | ||
|
|
ef218d763b | ||
|
|
f586cc6b49 | ||
|
|
706d15887a | ||
|
|
4f97efb6bf | ||
|
|
48a5b0fd6f | ||
|
|
181e50d2d2 | ||
|
|
a0e41bfba0 | ||
|
|
5ee43a7150 | ||
|
|
527d1e545b | ||
|
|
d3272a1036 | ||
|
|
db0a3b0996 | ||
|
|
b8fd368d37 | ||
|
|
4ffec030cc | ||
|
|
b6b197f3ec | ||
|
|
94bc73d703 | ||
|
|
8b16a3e13f | ||
|
|
0530043136 | ||
|
|
23f4913235 | ||
|
|
1972241807 | ||
|
|
77897c7469 | ||
|
|
1c9e602cfc | ||
|
|
db7425715e | ||
|
|
c5da444134 | ||
|
|
bc3f1177e9 | ||
|
|
ccb3cc5657 | ||
|
|
5ce1ad7a0c | ||
|
|
cea81f798b | ||
|
|
e386cb2e50 | ||
|
|
0c4ed717bc | ||
|
|
42a7770592 | ||
|
|
b7c917e9fa | ||
|
|
806fe6d23c | ||
|
|
fc9e8f4340 | ||
|
|
7fde5307de | ||
|
|
87e637e2df | ||
|
|
43b09ad426 | ||
|
|
0bc95402c8 | ||
|
|
212d3e48d9 | ||
|
|
99b47403d8 | ||
|
|
2a92ef7ded | ||
|
|
4a08d5ba45 | ||
|
|
e8e9a92bbd | ||
|
|
775326df3d | ||
|
|
d6ff0fd311 | ||
|
|
ad65ee2a34 | ||
|
|
d155565e32 | ||
|
|
4804a5ef45 | ||
|
|
9851eed6f3 | ||
|
|
eeaeb5b79a | ||
|
|
c52ce4bcc2 | ||
|
|
151e79b844 | ||
|
|
21eca5f815 | ||
|
|
5205c1aaa2 | ||
|
|
1ed30f6426 | ||
|
|
0a379c9386 | ||
|
|
5ebecde547 | ||
|
|
e4de098331 | ||
|
|
423c6ff15d | ||
|
|
26859bad80 | ||
|
|
b7a5a03069 |
No files matched your search
+1
-1
@@ -514,7 +514,7 @@ update:
|
||||
@echo "--------------------------------------------------------------"
|
||||
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
|
||||
@echo "--------------------------------------------------------------"
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4 -P -d
|
||||
cd ${.CURDIR}; cvs -q update -rRELENG_4_6 -P -d
|
||||
.endif
|
||||
|
||||
#
|
||||
|
||||
@@ -8,10 +8,76 @@ A reverse chronology since 4.0 was released is included, followed by
|
||||
the common items quick how-tos, followed by entries for versions of
|
||||
-current prior to 4.0 Release.
|
||||
|
||||
20020703:
|
||||
The install(1) utility no longer allows the -d and -C options
|
||||
to be specified together. "INSTALL=install -C" in make.conf
|
||||
should be replaced with "COPY=-C".
|
||||
This is for the 4.6 release branch. All entries since 4.6 are an
|
||||
itemized list of commits to this branch, numbered from the beginning.
|
||||
|
||||
The security advisories related to various patches contain information
|
||||
on how to build/install a minimal set of binaries and start/stop a
|
||||
minimal number of processes, if possible, for that patch. For those
|
||||
updates that don't have an advisory, or to be safe, you can do a full
|
||||
build and install as described in the COMMON ITEMS section.
|
||||
|
||||
20020813: p11
|
||||
Bounds checking errors in accept(), getsockname(),
|
||||
getpeername(), and a VESA ioctl() command were corrected.
|
||||
|
||||
20020805: p10 FreeBSD-SA-02:33.openssl
|
||||
Correct a bug in the ASN.1 decoder which was introduced with
|
||||
the recent OpenSSL update.
|
||||
|
||||
20020805: p9 FreeBSD-SA-02:37.kqueue
|
||||
Registering an EVFILT_WRITE event on a pipe whose far end had
|
||||
already been closed would cause a kernel panic.
|
||||
|
||||
20020804: p8
|
||||
Bugfix for READ_BIG errors with ATAPI devices.
|
||||
|
||||
20020801: p7 FreeBSD-SA-02:36.nfs
|
||||
RPCs with zero-length payload would cause an infinite loop.
|
||||
|
||||
20020801: p6 FreeBSD-SA-02:34.rpc
|
||||
The original fix applied to the XDR decoder was in error.
|
||||
|
||||
20020731: p5 FreeBSD-SA-02:35.ffs
|
||||
A bounds checking error in FFS filesize limits was corrected.
|
||||
|
||||
20020731: p4 FreeBSD-SA-02:34.rpc
|
||||
A bounds checking error in the XDR decoder was corrected.
|
||||
|
||||
20020730: p3 FreeBSD-SA-02:33.openssl
|
||||
Upgrade to OpenSSL 0.9.6e.
|
||||
|
||||
20020730: p2 FreeBSD-SA-02:32.pppd
|
||||
A race condition in pppd(8) was corrected.
|
||||
|
||||
20020730: p1 FreeBSD-SA-02:23.stdio.v1.2
|
||||
A bug in the previous patch for the vulnerability described
|
||||
in FreeBSD-SA-02:23.stdio was found and corrected.
|
||||
|
||||
20020718:
|
||||
"Hang in atprq" bugfix for ATAPI CDROMs.
|
||||
|
||||
20020716:
|
||||
OpenSSH 3.4p1 update.
|
||||
|
||||
20020715: p3
|
||||
Upgrade to BIND 8.3.3.
|
||||
|
||||
20020714:
|
||||
pcic power bugfix.
|
||||
sendmail DNS map bugfix.
|
||||
|
||||
20020712: p2 FreeBSD-SA-02:29.tcpdump
|
||||
A buffer overflow in tcpdump has been corrected.
|
||||
|
||||
20020711: FreeBSD-SA-02:30.ktrace
|
||||
Prevent users from tracing previously privileged processes.
|
||||
|
||||
20020708:
|
||||
A tags bug in the ata(4) subsystem has been corrected.
|
||||
|
||||
20020626: p1 FreeBSD-SA-02:28.resolv
|
||||
A fix for a buffer overflow in libc has been corrected.
|
||||
|
||||
20020615:
|
||||
FreeBSD 4.6-RELEASE.
|
||||
|
||||
+5
-15
@@ -135,14 +135,13 @@ scanfiles(argv, cooked)
|
||||
{
|
||||
int i = 0;
|
||||
char *path;
|
||||
FILE *fp;
|
||||
|
||||
while ((path = argv[i]) != NULL || i == 0) {
|
||||
int fd;
|
||||
|
||||
if (path == NULL || strcmp(path, "-") == 0) {
|
||||
filename = "stdin";
|
||||
fd = STDIN_FILENO;
|
||||
fd = 0;
|
||||
} else {
|
||||
filename = path;
|
||||
fd = open(path, O_RDONLY);
|
||||
@@ -155,17 +154,12 @@ scanfiles(argv, cooked)
|
||||
warn("%s", path);
|
||||
rval = 1;
|
||||
} else if (cooked) {
|
||||
if (fd == STDIN_FILENO)
|
||||
cook_cat(stdin);
|
||||
else {
|
||||
fp = fdopen(fd, "r");
|
||||
cook_cat(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
FILE *fp = fdopen(fd, "r");
|
||||
cook_cat(fp);
|
||||
fclose(fp);
|
||||
} else {
|
||||
raw_cat(fd);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
close(fd);
|
||||
}
|
||||
if (path == NULL)
|
||||
break;
|
||||
@@ -179,10 +173,6 @@ cook_cat(fp)
|
||||
{
|
||||
register int ch, gobble, line, prev;
|
||||
|
||||
/* Reset EOF condition on stdin. */
|
||||
if (fp == stdin && feof(stdin))
|
||||
clearerr(stdin);
|
||||
|
||||
line = gobble = 0;
|
||||
for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
|
||||
if (prev == '\n') {
|
||||
|
||||
+5
-3
@@ -209,9 +209,11 @@ main(int argc, char *argv[])
|
||||
rv = 0;
|
||||
if (!*argv) {
|
||||
mntsize = regetmntinfo(&mntbuf, mntsize, vfslist);
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
for (i = 0; i < mntsize; i++)
|
||||
update_maxwidths(&maxwidths, &mntbuf[i]);
|
||||
if (vfslist != NULL) {
|
||||
bzero(&maxwidths, sizeof(maxwidths));
|
||||
for (i = 0; i < mntsize; i++)
|
||||
update_maxwidths(&maxwidths, &mntbuf[i]);
|
||||
}
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
if (aflag || (mntbuf[i].f_flags & MNT_IGNORE) == 0)
|
||||
prtstat(&mntbuf[i], &maxwidths);
|
||||
|
||||
+7
-24
@@ -12,36 +12,19 @@
|
||||
.Op Fl sx
|
||||
.Op Fl p Ar string
|
||||
.Op Ar file
|
||||
.LP
|
||||
.Nm red
|
||||
.Op Fl
|
||||
.Op Fl sx
|
||||
.Op Fl p Ar string
|
||||
.Op Ar file
|
||||
.\" .LP
|
||||
.\" red [-] [-sx] [-p \fIstring\fR] [\fIfile\fR]
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility is a line-oriented text editor.
|
||||
It is used to create, display, modify and otherwise manipulate text
|
||||
files.
|
||||
When invoked as
|
||||
.Nm red ,
|
||||
the editor runs in
|
||||
.Qq restricted
|
||||
mode, in which the only difference is that the editor restricts the
|
||||
use of filenames which start with
|
||||
.Ql \&!
|
||||
(interpreted as shell commands by
|
||||
.Nm ed )
|
||||
or contain a
|
||||
.Ql \&/ .
|
||||
Note that editing outside of the current directory is only prohibited
|
||||
if the user does not have write access to the current directory.
|
||||
If a user has write access to the current directory, then symbolic
|
||||
links can be created in the current directory, in which case
|
||||
.Nm red
|
||||
will not stop the user from editing the file that the symbolic link
|
||||
points to.
|
||||
.\" .B red
|
||||
.\" is a restricted
|
||||
.\" .BR ed :
|
||||
.\" it can only edit files in the current
|
||||
.\" directory and cannot execute shell commands.
|
||||
.Pp
|
||||
If invoked with a
|
||||
.Ar file
|
||||
|
||||
+2
-2
@@ -331,7 +331,7 @@ copy(from, to)
|
||||
int pid, status;
|
||||
|
||||
if ((pid = fork()) == 0) {
|
||||
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", "--", from, to,
|
||||
execl(_PATH_CP, "mv", vflg ? "-PRpv" : "-PRp", from, to,
|
||||
(char *)NULL);
|
||||
warn("%s", _PATH_CP);
|
||||
_exit(1);
|
||||
@@ -350,7 +350,7 @@ copy(from, to)
|
||||
return (1);
|
||||
}
|
||||
if (!(pid = vfork())) {
|
||||
execl(_PATH_RM, "mv", "-rf", "--", from, (char *)NULL);
|
||||
execl(_PATH_RM, "mv", "-rf", from, (char *)NULL);
|
||||
warn("%s", _PATH_RM);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
+20
-22
@@ -179,9 +179,8 @@
|
||||
.Op Ar
|
||||
.Ar directory
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility will read, write, and list the members of an archive file,
|
||||
.Nm Pax
|
||||
will read, write, and list the members of an archive file,
|
||||
and will copy directory hierarchies.
|
||||
.Nm Pax
|
||||
operation is independent of the specific archive format,
|
||||
@@ -203,7 +202,8 @@ and
|
||||
.Bl -tag -width 6n
|
||||
.It <none>
|
||||
.Em List .
|
||||
Write to
|
||||
.Nm Pax
|
||||
will write to
|
||||
.Dv standard output
|
||||
a table of contents of the members of the archive file read from
|
||||
.Dv standard input ,
|
||||
@@ -213,7 +213,8 @@ The table of contents contains one filename per line
|
||||
and is written using single line buffering.
|
||||
.It Fl r
|
||||
.Em Read .
|
||||
Extract the members of the archive file read from the
|
||||
.Nm Pax
|
||||
extracts the members of the archive file read from the
|
||||
.Dv standard input ,
|
||||
with pathnames matching the specified
|
||||
.Ar patterns .
|
||||
@@ -227,7 +228,8 @@ the extracted files are discussed in more detail under the
|
||||
option.
|
||||
.It Fl w
|
||||
.Em Write .
|
||||
Write an archive containing the
|
||||
.Nm Pax
|
||||
writes an archive containing the
|
||||
.Ar file
|
||||
operands to
|
||||
.Dv standard output
|
||||
@@ -242,7 +244,8 @@ operand is also a directory, the entire file hierarchy rooted
|
||||
at that directory will be included.
|
||||
.It Fl r Fl w
|
||||
.Em Copy .
|
||||
Copy the
|
||||
.Nm Pax
|
||||
copies the
|
||||
.Ar file
|
||||
operands to the destination
|
||||
.Ar directory .
|
||||
@@ -462,17 +465,15 @@ operand,
|
||||
will prompt to
|
||||
.Pa /dev/tty
|
||||
giving the name of the file, its file mode and its modification time.
|
||||
The
|
||||
.Nm
|
||||
utility will then read a line from
|
||||
.Nm Pax
|
||||
will then read a line from
|
||||
.Pa /dev/tty .
|
||||
If this line is blank, the file or archive member is skipped.
|
||||
If this line consists of a single period, the
|
||||
file or archive member is processed with no modification to its name.
|
||||
Otherwise, its name is replaced with the contents of the line.
|
||||
The
|
||||
.Nm
|
||||
utility will immediately exit with a non-zero exit status if
|
||||
.Nm Pax
|
||||
will immediately exit with a non-zero exit status if
|
||||
.Dv <EOF>
|
||||
is encountered when reading a response or if
|
||||
.Pa /dev/tty
|
||||
@@ -690,9 +691,8 @@ is not buffered, and is written only after the file has been read or written.
|
||||
.It Fl x Ar format
|
||||
Specify the output archive format, with the default format being
|
||||
.Ar ustar .
|
||||
The
|
||||
.Nm
|
||||
utility currently supports the following formats:
|
||||
.Nm Pax
|
||||
currently supports the following formats:
|
||||
.Bl -tag -width "sv4cpio"
|
||||
.It Ar cpio
|
||||
The extended cpio interchange format specified in the
|
||||
@@ -753,9 +753,8 @@ The default blocksize for this format is 10240 bytes.
|
||||
Pathnames stored by this format must be 250 characters or less in length.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
utility will detect and report any file that it is unable to store or extract
|
||||
.Nm Pax
|
||||
will detect and report any file that it is unable to store or extract
|
||||
as the result of any specific archive format restrictions.
|
||||
The individual archive formats may impose additional restrictions on use.
|
||||
Typical archive format restrictions include (but are not limited to):
|
||||
@@ -1146,9 +1145,8 @@ utility appeared in
|
||||
.An Keith Muller
|
||||
at the University of California, San Diego
|
||||
.Sh DIAGNOSTICS
|
||||
The
|
||||
.Nm
|
||||
utility will exit with one of the following values:
|
||||
.Nm Pax
|
||||
will exit with one of the following values:
|
||||
.Bl -tag -width 2n
|
||||
.It 0
|
||||
All files were processed successfully.
|
||||
|
||||
+2
-6
@@ -51,9 +51,7 @@
|
||||
.Nm
|
||||
.Op Fl L
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
.Nm Ps
|
||||
displays a header line followed by lines containing information about your
|
||||
processes that have controlling terminals.
|
||||
This information is sorted by controlling terminal, then by process
|
||||
@@ -327,9 +325,7 @@ When printing using the command keyword, a process that has exited and
|
||||
has a parent that has not yet waited for the process (in other words, a zombie)
|
||||
is listed as ``<defunct>'', and a process which is blocked while trying
|
||||
to exit is listed as ``<exiting>''.
|
||||
The
|
||||
.Nm
|
||||
utility
|
||||
.Nm Ps
|
||||
makes an educated guess as to the file name and arguments given when the
|
||||
process was created by examining memory or the swap area.
|
||||
The method is inherently somewhat unreliable and in any event a process
|
||||
|
||||
+9
-32
@@ -35,7 +35,7 @@
|
||||
.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd February 4, 2002
|
||||
.Dd April 28, 1995
|
||||
.Dt PWD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -43,11 +43,9 @@
|
||||
.Nd return working directory name
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl LP
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility writes the absolute pathname of the current working directory to
|
||||
.Nm Pwd
|
||||
writes the absolute pathname of the current working directory to
|
||||
the standard output.
|
||||
.Pp
|
||||
Some shells may provide a builtin
|
||||
@@ -56,32 +54,17 @@ command which is similar or identical to this utility.
|
||||
Consult the
|
||||
.Xr builtin 1
|
||||
manual page.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width indent
|
||||
.It Fl L
|
||||
Display the logical current working directory.
|
||||
.It Fl P
|
||||
Display the physical current working directory (all symbolic links resolved).
|
||||
.El
|
||||
.Pp
|
||||
If no options are specified, the
|
||||
.Fl P
|
||||
option is assumed.
|
||||
.Sh ENVIRONMENT
|
||||
Environment variables used by
|
||||
.Nm :
|
||||
.Bl -tag -width ".Ev PWD"
|
||||
.It Ev PWD
|
||||
Logical current working directory.
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
.Ex -std
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.1-2001 .
|
||||
utility is expected to be
|
||||
.St -p1003.2
|
||||
compatible.
|
||||
The
|
||||
.Fl L
|
||||
flag is not supported.
|
||||
.Sh SEE ALSO
|
||||
.Xr builtin 1 ,
|
||||
.Xr cd 1 ,
|
||||
@@ -97,9 +80,3 @@ is always faster because it is built into that shell.
|
||||
However, it can give a different answer in the rare case
|
||||
that the current directory or a containing directory was moved after
|
||||
the shell descended into it.
|
||||
.Pp
|
||||
The
|
||||
.Fl L
|
||||
option does not work unless the
|
||||
.Ev PWD
|
||||
environment variable is exported by the shell.
|
||||
+27
-61
@@ -45,45 +45,34 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
static char *getcwd_logical(void);
|
||||
void usage(void);
|
||||
int main __P((int, char *[]));
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int physical;
|
||||
int ch;
|
||||
char *p;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
if (strcmp(getprogname(), "realpath") == 0) {
|
||||
if (argc != 2)
|
||||
usage();
|
||||
if ((p = realpath(argv[1], buf)) == NULL)
|
||||
err(1, "%s", argv[1]);
|
||||
(void)printf("%s\n", p);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
physical = 1;
|
||||
while ((ch = getopt(argc, argv, "LP")) != -1)
|
||||
/*
|
||||
* Flags for pwd are a bit strange. The POSIX 1003.2B/D9 document
|
||||
* has an optional -P flag for physical, which is what this program
|
||||
* will produce by default. The logical flag, -L, should fail, as
|
||||
* there's no way to display a logical path after forking.
|
||||
*/
|
||||
while ((ch = getopt(argc, argv, "P")) != -1)
|
||||
switch (ch) {
|
||||
case 'L':
|
||||
physical = 0;
|
||||
break;
|
||||
case 'P':
|
||||
physical = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@@ -92,50 +81,27 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 0)
|
||||
if (argc == 1) {
|
||||
p = realpath(argv[0], buf);
|
||||
if (p == NULL)
|
||||
err(1, "%s", argv[0]);
|
||||
(void)printf("%s\n", p);
|
||||
} else if (argc == 0) {
|
||||
p = getcwd(NULL, (size_t)0);
|
||||
if (p == NULL)
|
||||
err(1, ".");
|
||||
(void)printf("%s\n", p);
|
||||
} else {
|
||||
usage();
|
||||
|
||||
/*
|
||||
* If we're trying to find the logical current directory and that
|
||||
* fails, behave as if -P was specified.
|
||||
*/
|
||||
if ((!physical && (p = getcwd_logical()) != NULL) ||
|
||||
(p = getcwd(NULL, 0)) != NULL)
|
||||
printf("%s\n", p);
|
||||
else
|
||||
err(1, ".");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
usage()
|
||||
{
|
||||
|
||||
if (strcmp(getprogname(), "realpath") == 0)
|
||||
(void)fprintf(stderr, "usage: realpath [path]\n");
|
||||
else
|
||||
(void)fprintf(stderr, "usage: pwd [-LP]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static char *
|
||||
getcwd_logical(void)
|
||||
{
|
||||
struct stat log, phy;
|
||||
char *pwd;
|
||||
|
||||
/*
|
||||
* Check that $PWD is an absolute logical pathname referring to
|
||||
* the current working directory.
|
||||
*/
|
||||
if ((pwd = getenv("PWD")) != NULL && *pwd == '/') {
|
||||
if (stat(pwd, &log) == -1 || stat(".", &phy) == -1)
|
||||
return (NULL);
|
||||
if (log.st_dev == phy.st_dev && log.st_ino == phy.st_ino)
|
||||
return (pwd);
|
||||
}
|
||||
|
||||
errno = ENOENT;
|
||||
return (NULL);
|
||||
(void)fprintf(stderr, "usage: pwd\n");
|
||||
exit(1);
|
||||
}
|
||||
+1
-1
@@ -367,7 +367,7 @@ ulimitcmd(argc, argv)
|
||||
struct rlimit limit;
|
||||
|
||||
what = 'f';
|
||||
while ((optc = nextopt("HSatfdsmcnuvlb")) != '\0')
|
||||
while ((optc = nextopt("HSatfdsmcnulb")) != '\0')
|
||||
switch (optc) {
|
||||
case 'H':
|
||||
how = HARD;
|
||||
|
||||
+6
-10
@@ -1331,19 +1331,17 @@ environment variable if no
|
||||
is specified.
|
||||
If
|
||||
.Ar directory
|
||||
does not begin with
|
||||
.Pa / ,
|
||||
.Pa \&. ,
|
||||
is not found as a subdirectory of the current directory
|
||||
(and does not begin with
|
||||
.Dq Li / ,
|
||||
.Dq Li ./ ,
|
||||
or
|
||||
.Pa .. ,
|
||||
.Dq Li ../ ) ,
|
||||
then the directories listed in the
|
||||
.Ev CDPATH
|
||||
variable will be
|
||||
searched for the specified
|
||||
.Ar directory .
|
||||
If
|
||||
.Ev CDPATH
|
||||
is unset, the current directory is searched.
|
||||
The format of
|
||||
.Ar CDPATH
|
||||
is the same as that of
|
||||
@@ -1817,7 +1815,7 @@ for commands and tracked aliases
|
||||
the complete pathname of the command is printed.
|
||||
.It Xo
|
||||
.Ic ulimit
|
||||
.Op Fl HSabcdflmnstuv
|
||||
.Op Fl HSabcdflmnust
|
||||
.Op Ar limit
|
||||
.Xc
|
||||
Set or display resource limits (see
|
||||
@@ -1878,8 +1876,6 @@ The maximal size of the stack segment, in kilobytes.
|
||||
The maximal amount of CPU time to be used by each process, in seconds.
|
||||
.It Fl u Ar userproc
|
||||
The maximal number of simultaneous processes for this user ID.
|
||||
.It Fl v Ar virtualmem
|
||||
The maximal virtual size of a process, in kilobytes.
|
||||
.El
|
||||
.It Ic umask Op Ar mask
|
||||
Set the file creation mask (see
|
||||
|
||||
@@ -1,4 +1,116 @@
|
||||
|
||||
--- 8.3.3-REL released --- (Wed Jun 26 21:15:43 PDT 2002)
|
||||
|
||||
1301. [func] log attempts to exploit #1300.
|
||||
|
||||
1300. [bug] Remote buffer overrun.
|
||||
|
||||
1299. [func] Log to xfer-in when a named-xfer fails and one of
|
||||
the masters returned REFUSED.
|
||||
|
||||
1298. [bug] named could leak a OPT record when returning a
|
||||
negative response.
|
||||
|
||||
1297. [func] 'ndc restart' will now attempt to preserve the
|
||||
arguments named was started with.
|
||||
Use 'ndc restart --' to clear the arguements.
|
||||
Use 'ndc restart <new arguements>' to restart named
|
||||
with a alternate set of arguements.
|
||||
|
||||
1296. [bug] delay setting need_restart until the response to
|
||||
ndc exec has been sent.
|
||||
|
||||
1295. [func] new ndc command 'args'. returns the arguements that
|
||||
named was started with %xx escaped.
|
||||
|
||||
1294. [bug] #1272 broke linkage for those OS's using -lfl (flex).
|
||||
Move -ll/-lfl to LIBL for all platforms.
|
||||
|
||||
--- 8.3.2-REL released --- (Mon Jun 17 20:24:32 PDT 2002)
|
||||
|
||||
1293. [doc] update man pages for 'dig', 'dnsquery' and 'host'
|
||||
to reflect IPv6 capabilities (nslookup and nsupdate
|
||||
were already IPv4/IPv6 agnostic).
|
||||
|
||||
1292. [func] host: the default lookups now also include AAAA
|
||||
records.
|
||||
|
||||
1291. [func] 'dig -x <ip6>' now works.
|
||||
|
||||
1290. [bug] 'dig @server' fail to report the IPv6 address of the
|
||||
server in error messages.
|
||||
|
||||
1289. [contrib] normalize_zone now handles $TTL.
|
||||
|
||||
1288. [bug] named: -t and -w could not be used together.
|
||||
|
||||
1287. [func] report serial(s) in out going transfer operation.
|
||||
|
||||
--- 8.3.2-RC1 released --- (Thu May 30 23:06:11 PDT 2002)
|
||||
|
||||
1286. [func] libbind: no longer attempts bit string labels for
|
||||
IPv6 reverse resolution. Try IP6.ARPA then IP6.INT
|
||||
for nibble style resolution.
|
||||
|
||||
1285. [port] linux: ss_family vs __ss_family in sockaddr_storage.
|
||||
|
||||
1284. [port] freebsd: 5.0 uses gid_t rather that int for
|
||||
GETGROUPLIST_ARGS
|
||||
|
||||
1283. [port] bsdi: 4.2 also has struct sockaddr_storage.
|
||||
|
||||
1282. [bug] nslookup was using inet_ntoa() to print out a IPv6
|
||||
address.
|
||||
|
||||
1281. [bug] escape '(' and ')' when coverting to presentation
|
||||
form.
|
||||
|
||||
1280. [func] server { edns yes_or_no; } is now supported.
|
||||
|
||||
1279. [bug] nslookup: partial coversion to similar style outputs
|
||||
for both -type=aaaa and -type=a.
|
||||
|
||||
1278. [bug] free() of non-malloced memory in nslookup.
|
||||
|
||||
1277. [port] cast all instances of yytext in commands.l to (char*)
|
||||
to silence compilers on OS's where lex declares it
|
||||
as (unsigned char *).
|
||||
|
||||
1276. [port] hpux 11.22: ansify GetAnswer in getinfo.c to
|
||||
silence compiler.
|
||||
|
||||
1275. [bug] bad declaration of si in tsig_key_from_addr().
|
||||
|
||||
1274. [port] hpux 11.22: ansify hexstring() and display() in
|
||||
addr.c to silence compiler.
|
||||
|
||||
1273. [bug] const pointer conficts in res_debug.c.
|
||||
|
||||
1272. [port] hpux 11.22: don't link against -ll unless required.
|
||||
|
||||
1272. [bug] main_need_num was not last entry in enum.
|
||||
main_need_tick nolonger required.
|
||||
|
||||
1271. [port] hpux: treat all hpux systems as BIG_ENDIAN, don't
|
||||
include <sys/mbuf.h>.
|
||||
|
||||
1270. [port] hpux 11.22 namespace clash DATASIZE -> BIND_DATASIZE.
|
||||
|
||||
1269. [port] hpux 11.11 interface scaning.
|
||||
|
||||
1268. [port] solaris: 64 bit binary compatability.
|
||||
|
||||
1267. [bug] aix4: missing IN6_IS_ADDR_V4COMPAT macro.
|
||||
|
||||
1266. [bug] If you are using TSIG #1261 introduced the potential
|
||||
of a infinite loop.
|
||||
|
||||
1265. [bug] nslookup failed on platforms that don't have BSD 43
|
||||
style sockets.
|
||||
|
||||
1264. [bug] LINK_INIT and UNLINK were not compatible with
|
||||
C++, use LINK_INIT_TYPE and UNLINK_TYPE instead.
|
||||
|
||||
--- 8.3.2-T1B released --- (Tue May 7 18:49:58 PDT 2002)
|
||||
|
||||
1263. [bug] gethostans() could get out of sync parsing the
|
||||
|
||||
@@ -10,6 +10,11 @@ artifacts including BIND, INN, and DHCP.
|
||||
Note that BIND 8 is in "end-of-life", having been replaced by BIND 9. See
|
||||
http://www.isc.org/ for more details.
|
||||
|
||||
BIND 8.3.3 Highlights
|
||||
Security Fix libbind. All applications linked against libbind
|
||||
need to relinked.
|
||||
'rndc restart' now preserves named's arguements
|
||||
|
||||
BIND 8.3.2 Highlights
|
||||
dig, nslookup, host and nsupdate have improved IPv6 support.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.3.2-T1B
|
||||
8.3.3-REL
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: addr.c,v 8.8 1999/10/13 16:38:55 vixie Exp $";
|
||||
static const char rcsid[] = "$Id: addr.c,v 8.9 2002/05/21 02:26:21 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -47,11 +47,7 @@ usage() {
|
||||
|
||||
/* Warning: this scribbles on `dst' even if it's going to return `0'. */
|
||||
static int
|
||||
hexstring(src, dst, len)
|
||||
const char *src;
|
||||
u_char *dst;
|
||||
int len;
|
||||
{
|
||||
hexstring(const char *src, u_char *dst, int len) {
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
u_char *ptr = dst, *end = dst + len;
|
||||
u_int val;
|
||||
@@ -100,12 +96,7 @@ hexstring(src, dst, len)
|
||||
}
|
||||
|
||||
static void
|
||||
display(input, af, addr, len)
|
||||
const char *input;
|
||||
int af;
|
||||
const u_char *addr;
|
||||
int len;
|
||||
{
|
||||
display(const char *input, int af, const u_char *addr, int len) {
|
||||
static int before = 0;
|
||||
char p[sizeof "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255"];
|
||||
int i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: dig.c,v 8.54 2002/04/24 00:38:08 marka Exp $";
|
||||
static const char rcsid[] = "$Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp $";
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -245,6 +245,7 @@ static int print_axfr(FILE *output, const u_char *msg,
|
||||
static struct timeval difftv(struct timeval, struct timeval);
|
||||
static void prnttime(struct timeval);
|
||||
static void stackarg(char *, char **);
|
||||
static void reverse6(char *, struct in6_addr *);
|
||||
|
||||
/* Public. */
|
||||
|
||||
@@ -289,6 +290,8 @@ main(int argc, char **argv) {
|
||||
int wait=0, delay;
|
||||
int envset=0, envsave=0;
|
||||
struct __res_state res_x, res_t;
|
||||
int r;
|
||||
struct in6_addr in6;
|
||||
|
||||
ns_tsig_key key;
|
||||
char *keyfile = NULL, *keyname = NULL;
|
||||
@@ -494,6 +497,11 @@ main(int argc, char **argv) {
|
||||
printf("; no arg for -x?\n");
|
||||
break;
|
||||
}
|
||||
r = inet_pton(AF_INET6, addrc, &in6);
|
||||
if (r > 0) {
|
||||
reverse6(domain, &in6);
|
||||
break;
|
||||
}
|
||||
addrend = addrc + strlen(addrc);
|
||||
if (*addrend == '.')
|
||||
*addrend = '\0';
|
||||
@@ -813,7 +821,7 @@ main(int argc, char **argv) {
|
||||
buf, sizeof(buf));
|
||||
break;
|
||||
case AF_INET6:
|
||||
inet_ntop(AF_INET,
|
||||
inet_ntop(AF_INET6,
|
||||
&u[0].sin6.sin6_addr,
|
||||
buf, sizeof(buf));
|
||||
break;
|
||||
@@ -1030,7 +1038,7 @@ where: server,\n\
|
||||
fputs("\
|
||||
notes: defname and search don't work; use fully-qualified names.\n\
|
||||
this is DiG version " VSTRING "\n\
|
||||
$Id: dig.c,v 8.54 2002/04/24 00:38:08 marka Exp $\n\
|
||||
$Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp $\n\
|
||||
", stderr);
|
||||
}
|
||||
|
||||
@@ -1775,3 +1783,24 @@ stackarg(char *l, char **y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
reverse6(char *domain, struct in6_addr *in6) {
|
||||
sprintf(domain, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa",
|
||||
in6->s6_addr[15] & 0x0f, (in6->s6_addr[15] >> 4) & 0x0f,
|
||||
in6->s6_addr[14] & 0x0f, (in6->s6_addr[14] >> 4) & 0x0f,
|
||||
in6->s6_addr[13] & 0x0f, (in6->s6_addr[13] >> 4) & 0x0f,
|
||||
in6->s6_addr[12] & 0x0f, (in6->s6_addr[12] >> 4) & 0x0f,
|
||||
in6->s6_addr[11] & 0x0f, (in6->s6_addr[11] >> 4) & 0x0f,
|
||||
in6->s6_addr[10] & 0x0f, (in6->s6_addr[10] >> 4) & 0x0f,
|
||||
in6->s6_addr[9] & 0x0f, (in6->s6_addr[9] >> 4) & 0x0f,
|
||||
in6->s6_addr[8] & 0x0f, (in6->s6_addr[8] >> 4) & 0x0f,
|
||||
in6->s6_addr[7] & 0x0f, (in6->s6_addr[7] >> 4) & 0x0f,
|
||||
in6->s6_addr[6] & 0x0f, (in6->s6_addr[6] >> 4) & 0x0f,
|
||||
in6->s6_addr[5] & 0x0f, (in6->s6_addr[5] >> 4) & 0x0f,
|
||||
in6->s6_addr[4] & 0x0f, (in6->s6_addr[4] >> 4) & 0x0f,
|
||||
in6->s6_addr[6] & 0x0f, (in6->s6_addr[3] >> 4) & 0x0f,
|
||||
in6->s6_addr[2] & 0x0f, (in6->s6_addr[2] >> 4) & 0x0f,
|
||||
in6->s6_addr[1] & 0x0f, (in6->s6_addr[1] >> 4) & 0x0f,
|
||||
in6->s6_addr[0] & 0x0f, (in6->s6_addr[0] >> 4) & 0x0f);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: host.c,v 8.52 2002/04/28 01:34:52 marka Exp $";
|
||||
static const char rcsid[] = "$Id: host.c,v 8.53 2002/06/18 02:34:02 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -675,7 +675,7 @@ gethostinfo(char *name) {
|
||||
|
||||
static int
|
||||
getdomaininfo(const char *name, const char *domain) {
|
||||
int val1, val2;
|
||||
int val1, val2, val3;
|
||||
|
||||
if (querytype)
|
||||
return (getinfo(name, domain, gettype=querytype));
|
||||
@@ -683,8 +683,9 @@ getdomaininfo(const char *name, const char *domain) {
|
||||
val1 = getinfo(name, domain, gettype=ns_t_a);
|
||||
if (cname || verbose)
|
||||
return (val1);
|
||||
val2 = getinfo(name, domain, gettype=ns_t_mx);
|
||||
return (val1 || val2);
|
||||
val2 = getinfo(name, domain, gettype=ns_t_aaaa);
|
||||
val3 = getinfo(name, domain, gettype=ns_t_mx);
|
||||
return (val1 || val2 || val3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1582,6 +1583,7 @@ static const char *
|
||||
pr_type(int type) {
|
||||
if (!verbose) switch (type) {
|
||||
case ns_t_a:
|
||||
case ns_t_aaaa:
|
||||
return ("has address");
|
||||
case ns_t_cname:
|
||||
return ("is a nickname for");
|
||||
|
||||
@@ -131,7 +131,7 @@ char copyright[] =
|
||||
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)named-xfer.c 4.18 (Berkeley) 3/7/91";
|
||||
static const char rcsid[] = "$Id: named-xfer.c,v 8.120 2002/01/29 06:54:52 marka Exp $";
|
||||
static const char rcsid[] = "$Id: named-xfer.c,v 8.121 2002/06/26 03:27:22 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "port_before.h"
|
||||
@@ -751,6 +751,7 @@ main(int argc, char *argv[]) {
|
||||
default:
|
||||
result = XFER_FAIL;
|
||||
/* fall through */
|
||||
case XFER_REFUSED:
|
||||
case XFER_TIMEOUT:
|
||||
case XFER_FAIL:
|
||||
(void) unlink(tmpname);
|
||||
@@ -1068,6 +1069,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
||||
u_int32_t query_serial = serial_no;
|
||||
int first_soa_printed;
|
||||
struct in_addr z_axfr_src;
|
||||
int refused = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug) {
|
||||
@@ -1631,6 +1633,7 @@ receive:
|
||||
my_addr_text,
|
||||
inet_ntoa(sin.sin_addr),
|
||||
zp->z_origin);
|
||||
refused = 1;
|
||||
} else {
|
||||
syslog(LOG_INFO,
|
||||
"[%s] record too short from [%s], zone %s\n",
|
||||
@@ -1913,6 +1916,7 @@ axfr_response:
|
||||
my_addr_text,
|
||||
inet_ntoa(sin.sin_addr),
|
||||
zp->z_origin);
|
||||
refused = 1;
|
||||
} else {
|
||||
syslog(LOG_INFO,
|
||||
"[%s] record too short from [%s], zone %s\n",
|
||||
@@ -1952,6 +1956,8 @@ axfr_response:
|
||||
}
|
||||
if (!error)
|
||||
return (XFER_TIMEOUT);
|
||||
if (refused)
|
||||
return (XFER_REFUSED);
|
||||
return (XFER_FAIL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* from db.h 4.16 (Berkeley) 6/1/90
|
||||
* $Id: db_defs.h,v 8.46 2001/11/17 15:16:46 marka Exp $
|
||||
* $Id: db_defs.h,v 8.47 2002/05/18 01:02:53 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -147,7 +147,7 @@ struct databuf {
|
||||
u_int16_t d_nstime; /* NS response time, milliseconds */
|
||||
u_char d_data[sizeof(void*)]; /* dynamic (padded) */
|
||||
};
|
||||
#define DATASIZE(n) (sizeof(struct databuf) - sizeof(void*) + n)
|
||||
#define BIND_DATASIZE(n) (sizeof(struct databuf) - sizeof(void*) + n)
|
||||
|
||||
#ifdef HITCOUNTS
|
||||
extern u_int32_t db_total_hits;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_glue.c 4.4 (Berkeley) 6/1/90";
|
||||
static const char rcsid[] = "$Id: db_glue.c,v 8.46 2001/11/25 23:52:19 marka Exp $";
|
||||
static const char rcsid[] = "$Id: db_glue.c,v 8.47 2002/05/18 01:02:54 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -441,7 +441,7 @@ nhash(const char *name) {
|
||||
|
||||
static void
|
||||
db_freedata(struct databuf *dp) {
|
||||
int bytes = DATASIZE(dp->d_size);
|
||||
int bytes = BIND_DATASIZE(dp->d_size);
|
||||
|
||||
if (dp->d_rcnt != 0)
|
||||
panic("db_freedata: d_rcnt != 0", NULL);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)db_save.c 4.16 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: db_save.c,v 8.29 2001/04/25 13:53:09 marka Exp $";
|
||||
static const char rcsid[] = "$Id: db_save.c,v 8.30 2002/05/18 01:02:56 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -137,7 +137,7 @@ savedata(class, type, ttl, data, size)
|
||||
int size;
|
||||
{
|
||||
struct databuf *dp;
|
||||
int bytes = DATASIZE(size);
|
||||
int bytes = BIND_DATASIZE(size);
|
||||
|
||||
dp = (struct databuf *)memget(bytes);
|
||||
if (dp == NULL)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: db_tsig.c,v 8.7 2001/06/18 14:42:59 marka Exp $";
|
||||
static const char rcsid[] = "$Id: db_tsig.c,v 8.8 2002/05/21 02:34:32 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -129,7 +129,7 @@ tsig_alg_value(char *name) {
|
||||
|
||||
DST_KEY *
|
||||
tsig_key_from_addr(struct in_addr addr) {
|
||||
server_info si = si = find_server(addr);
|
||||
server_info si = find_server(addr);
|
||||
if (si == NULL || si->key_list == NULL || si->key_list->first == NULL)
|
||||
return(NULL);
|
||||
return(si->key_list->first->key);
|
||||
|
||||
@@ -267,6 +267,8 @@ zone "non-default-acl.demo.zone" {
|
||||
acl key_acl { key sample_key; }; // a request signed with sample_key
|
||||
|
||||
server 1.2.3.4 {
|
||||
edns no; // if no, we won't send ends queries
|
||||
// to this server
|
||||
bogus no; // if yes, we won't query or listen
|
||||
// to this server
|
||||
transfer-format one-answer; // set transfer format for this
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_config.c,v 8.134 2002/04/25 05:27:04 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_config.c,v 8.135 2002/05/24 03:04:59 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -2549,6 +2549,7 @@ new_server(struct in_addr address) {
|
||||
si->flags |= SERVER_INFO_SUPPORT_IXFR;
|
||||
else
|
||||
si->flags &= ~SERVER_INFO_SUPPORT_IXFR;
|
||||
si->flags |= SERVER_INFO_EDNS;
|
||||
return (si);
|
||||
}
|
||||
|
||||
@@ -2649,6 +2650,7 @@ set_server_option(server_config sc, int bool_opt, int value) {
|
||||
switch (bool_opt) {
|
||||
case SERVER_INFO_BOGUS:
|
||||
case SERVER_INFO_SUPPORT_IXFR:
|
||||
case SERVER_INFO_EDNS:
|
||||
if (value)
|
||||
si->flags |= bool_opt;
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_ctl.c,v 8.46 2001/12/19 11:53:48 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_ctl.c,v 8.47 2002/06/24 07:11:07 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -112,6 +112,8 @@ static void verb_stop(struct ctl_sctx *, struct ctl_sess *,
|
||||
static void verb_exec(struct ctl_sctx *, struct ctl_sess *,
|
||||
const struct ctl_verb *,
|
||||
const char *, u_int, const void *, void *);
|
||||
static void exec_closure(struct ctl_sctx *, struct ctl_sess *,
|
||||
void *);
|
||||
static void verb_reload(struct ctl_sctx *, struct ctl_sess *,
|
||||
const struct ctl_verb *,
|
||||
const char *, u_int, const void *, void *);
|
||||
@@ -141,6 +143,9 @@ static void verb_help(struct ctl_sctx *, struct ctl_sess *,
|
||||
static void verb_quit(struct ctl_sctx *, struct ctl_sess *,
|
||||
const struct ctl_verb *,
|
||||
const char *, u_int, const void *, void *);
|
||||
static void verb_args(struct ctl_sctx *, struct ctl_sess *,
|
||||
const struct ctl_verb *,
|
||||
const char *, u_int, const void *, void *);
|
||||
|
||||
/* Private data. */
|
||||
|
||||
@@ -162,6 +167,7 @@ static struct ctl_verb verbs[] = {
|
||||
{ "qrylog", verb_querylog, "qrylog"},
|
||||
{ "help", verb_help, "help"},
|
||||
{ "quit", verb_quit, "quit"},
|
||||
{ "args", verb_args, "args"},
|
||||
{ NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -794,13 +800,25 @@ verb_exec(struct ctl_sctx *ctl, struct ctl_sess *sess,
|
||||
saved_argv[0], save);
|
||||
ctl_response(sess, 502, save, 0, NULL, NULL, NULL,
|
||||
NULL, 0);
|
||||
} else if (user_name != NULL || group_name != NULL) {
|
||||
ctl_response(sess, 502,
|
||||
"can't exec as user or group was specified",
|
||||
0, NULL, NULL, NULL, NULL, 0);
|
||||
} else {
|
||||
ns_need(main_need_restart);
|
||||
ctl_response(sess, 250, "Restart initiated.", 0, NULL,
|
||||
NULL, NULL, NULL, 0);
|
||||
exec_closure, NULL, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
exec_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
|
||||
|
||||
UNUSED(sctx);
|
||||
UNUSED(sess);
|
||||
UNUSED(uap);
|
||||
ns_need(main_need_restart);
|
||||
}
|
||||
|
||||
static void
|
||||
verb_reload(struct ctl_sctx *ctl, struct ctl_sess *sess,
|
||||
const struct ctl_verb *verb, const char *rest,
|
||||
@@ -1049,3 +1067,81 @@ verb_quit(struct ctl_sctx *ctl, struct ctl_sess *sess,
|
||||
ctl_response(sess, 221, "End of control session.", CTL_EXIT, NULL,
|
||||
NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
static char hex[] = "0123456789abcdef";
|
||||
|
||||
struct pvt_args {
|
||||
int argc;
|
||||
char text[MAX_STR_LEN];
|
||||
};
|
||||
|
||||
static void
|
||||
args_closure(struct ctl_sctx *sctx, struct ctl_sess *sess, void *uap) {
|
||||
struct pvt_args *pvt = ctl_getcsctx(sess);
|
||||
|
||||
UNUSED(sctx);
|
||||
UNUSED(uap);
|
||||
|
||||
memput(pvt, sizeof *pvt);
|
||||
ctl_setcsctx(sess, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
verb_args(struct ctl_sctx *ctl, struct ctl_sess *sess,
|
||||
const struct ctl_verb *verb, const char *rest,
|
||||
u_int respflags, const void *respctx, void *uctx)
|
||||
{
|
||||
struct pvt_args *pvt = ctl_getcsctx(sess);
|
||||
char *cp, *tp;
|
||||
|
||||
UNUSED(ctl);
|
||||
UNUSED(verb);
|
||||
UNUSED(rest);
|
||||
UNUSED(respflags);
|
||||
UNUSED(respctx);
|
||||
UNUSED(uctx);
|
||||
|
||||
if (pvt == NULL) {
|
||||
unsigned int i = 0;
|
||||
pvt = memget(sizeof *pvt);
|
||||
if (pvt == NULL) {
|
||||
ctl_response(sess, 505, "(out of memory)",
|
||||
0, NULL, NULL, NULL, NULL, 0);
|
||||
return;
|
||||
}
|
||||
pvt->argc = 0;
|
||||
ctl_setcsctx(sess, pvt);
|
||||
|
||||
/* Send the arguement count. */
|
||||
while (saved_argv[i] != NULL)
|
||||
i++;
|
||||
sprintf(pvt->text, "%u", i);
|
||||
ctl_response(sess, 250, pvt->text, CTL_MORE,
|
||||
NULL, args_closure, NULL, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Percent escape arguement.
|
||||
*/
|
||||
cp = saved_argv[pvt->argc++];
|
||||
tp = pvt->text;
|
||||
while (cp && *cp != NULL)
|
||||
if (*cp == '%' || *cp == ' ' ||
|
||||
!isprint((unsigned char)*cp)) {
|
||||
if (tp >= pvt->text + sizeof(pvt->text) - 4)
|
||||
break;
|
||||
*tp++ = '%';
|
||||
*tp++ = hex[(*cp>>4)&0xf];
|
||||
*tp++ = hex[(*cp++)&0xf];
|
||||
} else {
|
||||
if (tp >= pvt->text + sizeof(pvt->text) - 2)
|
||||
break;
|
||||
*tp++ = *cp++;
|
||||
}
|
||||
*tp = '\0';
|
||||
|
||||
ctl_response(sess, 250, pvt->text,
|
||||
saved_argv[pvt->argc] == NULL ? 0 : CTL_MORE,
|
||||
NULL, args_closure, NULL, NULL, 0);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_defs.h,v 8.118 2002/04/25 05:27:06 marka Exp $
|
||||
* $Id: ns_defs.h,v 8.121 2002/06/26 03:27:19 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -172,9 +172,8 @@ typedef enum need {
|
||||
main_need_restart, /* exec() needed. */
|
||||
main_need_reap, /* need to reap dead children. */
|
||||
main_need_noexpired, /* ns_reconfig() needed w/ noexpired set. */
|
||||
main_need_num, /* number of needs, used for array bound. */
|
||||
main_need_tick, /* tick every second to poll for cleanup (NT) */
|
||||
main_need_tryxfer /* attemt to start a zone transfer. */
|
||||
main_need_tryxfer, /* attemt to start a zone transfer. */
|
||||
main_need_num /* MUST BE LAST. */
|
||||
} main_need;
|
||||
|
||||
/* What global options are set? */
|
||||
@@ -438,6 +437,7 @@ enum zonetype { z_nil, z_master, z_slave, z_hint, z_stub, z_forward,
|
||||
#define XFER_SUCCESSAXFR 4 /* named-xfr recived a xfr */
|
||||
#define XFER_SUCCESSIXFR 5 /* named-xfr recived a ixfr */
|
||||
#define XFER_SUCCESSAXFRIXFRFILE 6 /* named-xfr received AXFR for IXFR */
|
||||
#define XFER_REFUSED 7 /* one master returned REFUSED */
|
||||
#define XFER_ISAXFR -1 /* the last XFR is AXFR */
|
||||
#define XFER_ISIXFR -2 /* the last XFR is IXFR */
|
||||
#define XFER_ISAXFRIXFR -3 /* the last XFR is AXFR but we must create IXFR base */
|
||||
@@ -835,6 +835,7 @@ typedef struct server_config {
|
||||
|
||||
#define SERVER_INFO_BOGUS 0x01
|
||||
#define SERVER_INFO_SUPPORT_IXFR 0x02
|
||||
#define SERVER_INFO_EDNS 0x04
|
||||
|
||||
typedef struct server_info {
|
||||
struct in_addr address;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_forw.c 4.32 (Berkeley) 3/3/91";
|
||||
static const char rcsid[] = "$Id: ns_forw.c,v 8.90 2002/02/22 05:12:35 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_forw.c,v 8.91 2002/05/24 03:04:57 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -612,6 +612,11 @@ nslookup(struct databuf *nsp[], struct qinfo *qp,
|
||||
qs->nsdata = dp;
|
||||
qs->forwarder = 0;
|
||||
qs->noedns = dp->d_noedns;
|
||||
if (!qs->noedns) {
|
||||
server_info si = find_server(nsa);
|
||||
if (si && (si->flags & SERVER_INFO_EDNS) == 0)
|
||||
qs->noedns = 1;
|
||||
}
|
||||
qs->nretry = 0;
|
||||
/*
|
||||
* If this A RR has no RTT, initialize its RTT to a
|
||||
@@ -1285,6 +1290,11 @@ nsfwdadd(struct qinfo *qp, struct fwdinfo *fwd) {
|
||||
qs->nsdata = fwd->fwddata->nsdata;
|
||||
qs->forwarder = 1;
|
||||
qs->noedns = fwd->fwddata->nsdata->d_noedns;
|
||||
if (!qs->noedns) {
|
||||
server_info si = find_server(qs->ns_addr.sin_addr);
|
||||
if (si && (si->flags & SERVER_INFO_EDNS) == 0)
|
||||
qs->noedns = 1;
|
||||
}
|
||||
qs->nretry = 0;
|
||||
n++;
|
||||
nextfwd:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_glob.h,v 8.57 2001/11/12 21:22:26 marka Exp $
|
||||
* $Id: ns_glob.h,v 8.58 2002/06/05 04:53:50 marka Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -336,6 +336,7 @@ DECL char * user_name INIT(NULL);
|
||||
DECL gid_t group_id;
|
||||
DECL char * group_name INIT(NULL);
|
||||
DECL char * chroot_dir INIT(NULL);
|
||||
DECL char * working_dir INIT(NULL);
|
||||
|
||||
DECL int loading INIT(0);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_ixfr.c,v 8.31 2002/01/02 05:15:20 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_ixfr.c,v 8.32 2002/05/18 01:02:57 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -201,10 +201,10 @@ sx_send_ixfr(struct qstream *qsp) {
|
||||
ns_panic(ns_log_update, 1,
|
||||
"sx_send_ixfr: unable to locate soa");
|
||||
}
|
||||
old_soadp = memget(DATASIZE(soa_dp->d_size));
|
||||
old_soadp = memget(BIND_DATASIZE(soa_dp->d_size));
|
||||
if (old_soadp == NULL)
|
||||
ns_panic(ns_log_update, 1, "sx_send_ixfr: out of memory");
|
||||
memcpy(old_soadp, soa_dp, DATASIZE(soa_dp->d_size));
|
||||
memcpy(old_soadp, soa_dp, BIND_DATASIZE(soa_dp->d_size));
|
||||
|
||||
again:
|
||||
switch (qsp->xfr.state) {
|
||||
@@ -383,7 +383,7 @@ sx_send_ixfr(struct qstream *qsp) {
|
||||
qsp->xfr.top.ixfr = NULL;
|
||||
}
|
||||
cleanup:
|
||||
memput(old_soadp, DATASIZE(old_soadp->d_size));
|
||||
memput(old_soadp, BIND_DATASIZE(old_soadp->d_size));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_lexer.c,v 8.30 2002/04/25 05:27:08 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_lexer.c,v 8.31 2002/05/24 03:05:03 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -251,6 +251,7 @@ static struct keyword keywords[] = {
|
||||
{"directory", T_DIRECTORY},
|
||||
{"dump-file", T_DUMP_FILE},
|
||||
{"dynamic", T_DYNAMIC},
|
||||
{"edns", T_EDNS},
|
||||
{"explicit", T_EXPLICIT},
|
||||
{"fail", T_FAIL},
|
||||
{"fake-iquery", T_FAKE_IQUERY},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91";
|
||||
static const char rcsid[] = "$Id: ns_main.c,v 8.157 2002/04/13 23:26:16 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_main.c,v 8.160 2002/06/24 07:06:55 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -99,8 +99,10 @@ char copyright[] =
|
||||
#ifdef SVR4 /* XXX */
|
||||
# include <sys/sockio.h>
|
||||
#else
|
||||
#ifndef __hpux
|
||||
# include <sys/mbuf.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <net/route.h>
|
||||
@@ -174,7 +176,7 @@ static u_int16_t nsid_c1, nsid_c2, nsid_c3;
|
||||
static u_int16_t nsid_state2;
|
||||
static int nsid_algorithm;
|
||||
|
||||
static int needs = 0, needs_exit = 0;
|
||||
static int needs = 0, needs_exit = 0, needs_restart = 0;
|
||||
static handler handlers[main_need_num];
|
||||
static void savedg_waitfunc(evContext, void*, const void*);
|
||||
static void need_waitfunc(evContext, void *, const void *);
|
||||
@@ -309,14 +311,7 @@ main(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (chdir(optarg) < 0) {
|
||||
syslog(LOG_CRIT, bad_directory, optarg,
|
||||
strerror(errno));
|
||||
fprintf(stderr, bad_directory, optarg,
|
||||
strerror(errno));
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
working_dir = savestr(optarg, 1);
|
||||
break;
|
||||
#ifdef QRYLOG
|
||||
case 'q':
|
||||
@@ -434,6 +429,19 @@ main(int argc, char *argv[]) {
|
||||
chroot_dir = freestr(chroot_dir);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Set working directory.
|
||||
*/
|
||||
if (working_dir != NULL) {
|
||||
if (chdir(working_dir) < 0) {
|
||||
syslog(LOG_CRIT, bad_directory, working_dir,
|
||||
strerror(errno));
|
||||
fprintf(stderr, bad_directory, working_dir,
|
||||
strerror(errno));
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Establish global event context. */
|
||||
evCreate(&ev);
|
||||
@@ -550,7 +558,10 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
INSIST_ERR(errno == EINTR);
|
||||
}
|
||||
ns_info(ns_log_default, "named shutting down");
|
||||
if (needs_restart)
|
||||
ns_info(ns_log_default, "named restarting");
|
||||
else
|
||||
ns_info(ns_log_default, "named shutting down");
|
||||
#ifdef BIND_UPDATE
|
||||
dynamic_about_to_exit();
|
||||
#endif
|
||||
@@ -563,8 +574,11 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
shutdown_configuration();
|
||||
|
||||
/* Cleanup for system-dependent stuff */
|
||||
custom_shutdown();
|
||||
if (needs_restart)
|
||||
execvp(saved_argv[0], saved_argv);
|
||||
else
|
||||
/* Cleanup for system-dependent stuff */
|
||||
custom_shutdown();
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -2746,6 +2760,9 @@ deallocate_everything(void) {
|
||||
if (chroot_dir != NULL)
|
||||
freestr(chroot_dir);
|
||||
chroot_dir = NULL;
|
||||
if (working_dir != NULL)
|
||||
freestr(working_dir);
|
||||
working_dir = NULL;
|
||||
if (nsid_pool != NULL)
|
||||
memput(nsid_pool, 0x10000 * (sizeof(u_int16_t)));
|
||||
nsid_pool = NULL;
|
||||
@@ -2764,19 +2781,8 @@ deallocate_everything(void) {
|
||||
|
||||
static void
|
||||
ns_restart(void) {
|
||||
ns_info(ns_log_default, "named restarting");
|
||||
#ifdef BIND_UPDATE
|
||||
dynamic_about_to_exit();
|
||||
#endif
|
||||
if (server_options && server_options->pid_filename)
|
||||
(void)unlink(server_options->pid_filename);
|
||||
ns_logstats(ev, NULL, evNowTime(), evConsTime(0, 0));
|
||||
if (NS_OPTION_P(OPTION_DEALLOC_ON_EXIT))
|
||||
deallocate_everything();
|
||||
else
|
||||
shutdown_configuration();
|
||||
execvp(saved_argv[0], saved_argv);
|
||||
abort();
|
||||
needs_restart = 1;
|
||||
needs_exit = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_maint.c 4.39 (Berkeley) 3/2/91";
|
||||
static const char rcsid[] = "$Id: ns_maint.c,v 8.135 2002/04/25 05:27:10 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_maint.c,v 8.136 2002/06/26 03:27:20 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -1681,6 +1681,17 @@ endxfer() {
|
||||
sched_zone_maint(zp);
|
||||
break;
|
||||
|
||||
case XFER_REFUSED:
|
||||
if (!(zp->z_flags & Z_SYSLOGGED)) {
|
||||
zp->z_flags |= Z_SYSLOGGED;
|
||||
ns_error(ns_log_xfer_in,
|
||||
"zoneref: Masters for slave zone \"%s\" REFUSED transfer",
|
||||
zp->z_origin);
|
||||
}
|
||||
ns_retrytime(zp, tt.tv_sec);
|
||||
sched_zone_maint(zp);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!(zp->z_flags & Z_SYSLOGGED)) {
|
||||
zp->z_flags |= Z_SYSLOGGED;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
%{
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_parser.y,v 8.79 2002/04/25 05:27:13 marka Exp $";
|
||||
static char rcsid[] = "$Id: ns_parser.y,v 8.80 2002/05/24 03:05:01 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -191,6 +191,7 @@ int yyparse();
|
||||
%token T_TRANSFERS
|
||||
%token T_KEYS
|
||||
%token T_SUPPORT_IXFR
|
||||
%token T_EDNS
|
||||
|
||||
/* Items used for "zone" statements: */
|
||||
%token T_ZONE
|
||||
@@ -1268,6 +1269,10 @@ server_info: T_BOGUS yea_or_nay
|
||||
set_server_transfer_format(current_server, $2);
|
||||
}
|
||||
| T_KEYS '{' key_list '}'
|
||||
| T_EDNS yea_or_nay
|
||||
{
|
||||
set_server_option(current_server, SERVER_INFO_EDNS, $2);
|
||||
}
|
||||
| error
|
||||
;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_req.c 4.47 (Berkeley) 7/1/91";
|
||||
static const char rcsid[] = "$Id: ns_req.c,v 8.168 2002/04/30 03:43:52 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_req.c,v 8.169 2002/05/12 23:41:52 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -560,6 +560,8 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp,
|
||||
hp->arcount = htons(0);
|
||||
cp = msg + HFIXEDSZ;
|
||||
cp += ns_skiprr(cp, msg + msglen, ns_s_qd, ntohs(hp->qdcount));
|
||||
ns_name_rollback(cp, (const u_char **)dnptrs,
|
||||
(const u_char **)dnptrs_end);
|
||||
if (opt > 0) {
|
||||
n = ns_add_opt(msg, cp, buflen_orig, 0,
|
||||
rcode, EDNS_MESSAGE_SZ, 0, NULL, 0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_resp.c 4.65 (Berkeley) 3/3/91";
|
||||
static const char rcsid[] = "$Id: ns_resp.c,v 8.176 2002/04/17 07:10:10 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_resp.c,v 8.178 2002/06/27 03:09:19 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -288,7 +288,6 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp)
|
||||
struct namebuf *np;
|
||||
struct fwdinfo *fwd;
|
||||
struct databuf *dp;
|
||||
int forcecmsg = 0;
|
||||
char *tname = NULL;
|
||||
int sendto_errno = 0;
|
||||
int has_tsig, oldqlen = 0;
|
||||
@@ -298,6 +297,7 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp)
|
||||
u_char sig[TSIG_SIG_SIZE];
|
||||
time_t tsig_time;
|
||||
DST_KEY *key;
|
||||
int expect_cname;
|
||||
|
||||
nameserIncr(from.sin_addr, nssRcvdR);
|
||||
nsp[0] = NULL;
|
||||
@@ -924,6 +924,7 @@ tcp_retry:
|
||||
} else
|
||||
flushset = NULL;
|
||||
|
||||
expect_cname = 1;
|
||||
for (i = 0; i < count; i++) {
|
||||
struct databuf *dp;
|
||||
int type;
|
||||
@@ -955,6 +956,19 @@ tcp_retry:
|
||||
type = dp->d_type;
|
||||
if (i < ancount) {
|
||||
/* Answer section. */
|
||||
/*
|
||||
* Check for attempts to overflow the buffer in
|
||||
* getnameanswer.
|
||||
*/
|
||||
if (type == ns_t_cname && !expect_cname) {
|
||||
ns_warning(ns_log_security,
|
||||
"late CNAME in answer section for %s %s from %s",
|
||||
*qname ? qname : ".", p_type(qtype),
|
||||
sin_ntoa(from));
|
||||
|
||||
} else if (type != ns_t_cname && type != ns_t_dname &&
|
||||
type != ns_t_sig)
|
||||
expect_cname = 0;
|
||||
if (externalcname || ns_samename(name, aname) != 1) {
|
||||
if (!externalcname)
|
||||
ns_info(ns_log_resp_checks,
|
||||
@@ -1220,12 +1234,11 @@ tcp_retry:
|
||||
cache_n_resp(msg, msglen, from, qp->q_name,
|
||||
qp->q_class, qp->q_type);
|
||||
|
||||
if (!qp->q_cmsglen) {
|
||||
if (!qp->q_cmsglen && validanswer) {
|
||||
ns_debug(ns_log_default, 3,
|
||||
"resp: leaving NO: auth = %d", hp->aa);
|
||||
goto return_msg;
|
||||
}
|
||||
forcecmsg = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91";
|
||||
static const char rcsid[] = "$Id: ns_signal.c,v 8.14 2001/06/18 14:43:25 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_signal.c,v 8.15 2002/05/18 01:39:15 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -87,8 +87,10 @@ static const char rcsid[] = "$Id: ns_signal.c,v 8.14 2001/06/18 14:43:25 marka E
|
||||
#ifdef SVR4 /* XXX */
|
||||
# include <sys/sockio.h>
|
||||
#else
|
||||
#ifndef __hpux
|
||||
# include <sys/mbuf.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <net/route.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_update.c,v 8.103 2002/01/03 00:25:02 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_update.c,v 8.104 2002/05/18 01:02:59 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -3010,9 +3010,9 @@ incr_serial(struct zoneinfo *zp) {
|
||||
return (-1);
|
||||
dp = findzonesoa(zp);
|
||||
if (dp) {
|
||||
olddp = memget(DATASIZE(dp->d_size));
|
||||
olddp = memget(BIND_DATASIZE(dp->d_size));
|
||||
if (olddp != NULL) {
|
||||
memcpy(olddp, dp, DATASIZE(dp->d_size));
|
||||
memcpy(olddp, dp, BIND_DATASIZE(dp->d_size));
|
||||
cp = findsoaserial(olddp->d_data);
|
||||
PUTLONG(old_serial, cp);
|
||||
fprintf(ifp, "update: {delete} %s. %u %s %s ",
|
||||
@@ -3021,7 +3021,7 @@ incr_serial(struct zoneinfo *zp) {
|
||||
p_type(dp->d_type));
|
||||
(void) rdata_dump(olddp, ifp);
|
||||
fprintf(ifp, "\n");
|
||||
memput(olddp, DATASIZE(dp->d_size));
|
||||
memput(olddp, BIND_DATASIZE(dp->d_size));
|
||||
}
|
||||
fprintf(ifp, "update: {add} %s. %u %s %s ",
|
||||
zp->z_origin, dp->d_ttl,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ns_xfr.c,v 8.68 2002/04/11 05:19:06 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_xfr.c,v 8.69 2002/06/05 03:53:49 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -82,15 +82,21 @@ ns_xfr(struct qstream *qsp, struct namebuf *znp,
|
||||
ns_deltalist *changes;
|
||||
|
||||
switch (type) {
|
||||
case ns_t_axfr: /*FALLTHROUGH*/
|
||||
case ns_t_ixfr:
|
||||
ns_info(ns_log_xfer_out,
|
||||
"zone transfer (%s) of \"%s\" (%s) to %s serial %u -> %u",
|
||||
p_type(type), zones[zone].z_origin, p_class(class),
|
||||
sin_ntoa(qsp->s_from), serial_ixfr,
|
||||
zones[zone].z_serial);
|
||||
break;
|
||||
case ns_t_axfr: /*FALLTHROUGH*/
|
||||
#ifdef BIND_ZXFR
|
||||
case ns_t_zxfr:
|
||||
#endif
|
||||
ns_info(ns_log_xfer_out,
|
||||
"zone transfer (%s) of \"%s\" (%s) to %s",
|
||||
"zone transfer (%s) of \"%s\" (%s) to %s serial %u",
|
||||
p_type(type), zones[zone].z_origin, p_class(class),
|
||||
sin_ntoa(qsp->s_from));
|
||||
sin_ntoa(qsp->s_from), zones[zone].z_serial);
|
||||
break;
|
||||
default:
|
||||
ns_warning(ns_log_xfer_out,
|
||||
|
||||
+183
-3
@@ -1,5 +1,5 @@
|
||||
#if !defined(lint) && !defined(SABER)
|
||||
static const char rcsid[] = "$Id: ndc.c,v 1.21 2001/12/19 23:16:23 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ndc.c,v 1.22 2002/06/24 07:28:55 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -250,6 +250,179 @@ slashhelp(void) {
|
||||
"toggle silence (suppresses nonfatal errors)");
|
||||
}
|
||||
|
||||
struct argv {
|
||||
int argc;
|
||||
char **argv;
|
||||
int error;
|
||||
};
|
||||
|
||||
static char hexdigits[] = "0123456789abcdef";
|
||||
|
||||
static void
|
||||
getargs_closure(void *arg, const char *msg, int flags) {
|
||||
struct argv *argv = arg;
|
||||
int len;
|
||||
int i;
|
||||
const char *cp, *cp2;
|
||||
char *tp, c;
|
||||
|
||||
UNUSED(flags);
|
||||
|
||||
if (argv->error)
|
||||
return;
|
||||
|
||||
if (argv->argc == -1) {
|
||||
i = atoi(msg + 4);
|
||||
if (i < 1) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
argv->argc = i;
|
||||
argv->argv = calloc((i+1), sizeof(char*));
|
||||
return;
|
||||
}
|
||||
len = 0;
|
||||
cp = msg + 4;
|
||||
while (*cp != NULL) {
|
||||
c = *cp;
|
||||
if (c == '%') {
|
||||
cp2 = strchr(hexdigits, cp[1]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c = (cp2-hexdigits) << 4;
|
||||
cp2 = strchr(hexdigits, cp[2]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c += (cp2-hexdigits);
|
||||
cp += 2;
|
||||
}
|
||||
if (!isalnum((unsigned)c)) {
|
||||
switch (c) {
|
||||
case '+': case '-': case '=': case '/': case '.':
|
||||
break;
|
||||
default:
|
||||
len++;
|
||||
}
|
||||
}
|
||||
len++;
|
||||
cp++;
|
||||
}
|
||||
i = 0;
|
||||
while (argv->argv[i] != NULL)
|
||||
i++;
|
||||
if (i >= argv->argc) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
argv->argv[i] = malloc(len + 1);
|
||||
if (argv->argv[i] == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
cp = msg + 4;
|
||||
tp = argv->argv[i];
|
||||
while (*cp != NULL) {
|
||||
c = *cp;
|
||||
if (c == '%') {
|
||||
cp2 = strchr(hexdigits, cp[1]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c = (cp2-hexdigits) << 4;
|
||||
cp2 = strchr(hexdigits, cp[2]);
|
||||
if (cp2 == NULL) {
|
||||
argv->error = 1;
|
||||
return;
|
||||
}
|
||||
c += (cp2-hexdigits);
|
||||
cp += 2;
|
||||
}
|
||||
if (!isalnum((unsigned)c)) {
|
||||
switch (c) {
|
||||
case '+': case '-': case '=': case '/': case '.':
|
||||
break;
|
||||
default:
|
||||
*tp = '\\';
|
||||
}
|
||||
}
|
||||
*tp++ = c;
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
get_args(char **restp) {
|
||||
struct argv argv;
|
||||
int len, i;
|
||||
char *rest, *p;
|
||||
int result = 1;
|
||||
|
||||
argv.argc = -1;
|
||||
argv.argv = NULL;
|
||||
argv.error = 0;
|
||||
|
||||
channel_loop("args", 1, getargs_closure, &argv);
|
||||
if (argv.error) {
|
||||
result = 0;
|
||||
goto err;
|
||||
}
|
||||
len = 0;
|
||||
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++)
|
||||
len += strlen(argv.argv[i]) + 1;
|
||||
rest = malloc(len);
|
||||
if (rest == NULL) {
|
||||
result = 0;
|
||||
goto err;
|
||||
}
|
||||
p = rest;
|
||||
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++) {
|
||||
strcpy(p, argv.argv[i]);
|
||||
p += strlen(argv.argv[i]);
|
||||
*p++ = ' ';
|
||||
}
|
||||
if (p != rest)
|
||||
p[-1] = '\0';
|
||||
*restp = rest;
|
||||
|
||||
err:
|
||||
if (argv.argv) {
|
||||
for (i = 0 ; i < argv.argc && argv.argv[i] != NULL; i++)
|
||||
free(argv.argv[i]);
|
||||
free(argv.argv);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
exec_closure(void *arg, const char *msg, int flags) {
|
||||
int *result = arg;
|
||||
UNUSED(flags);
|
||||
if (atoi(msg) == 250)
|
||||
*result = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
try_exec(int local_quiet) {
|
||||
int good = 0;
|
||||
pid_t pid;
|
||||
|
||||
channel_loop("exec", 1, exec_closure, &good);
|
||||
|
||||
if (good) {
|
||||
sleep(3);
|
||||
if (!running(0, &pid))
|
||||
error("name server has not restarted (yet?)");
|
||||
else if (!local_quiet)
|
||||
result("new pid is %ld", (long)pid);
|
||||
}
|
||||
return (good);
|
||||
}
|
||||
|
||||
static int
|
||||
builtincmd(void) {
|
||||
static const char spaces[] = " \t";
|
||||
@@ -257,14 +430,18 @@ builtincmd(void) {
|
||||
pid_t pid;
|
||||
int save_quiet = quiet;
|
||||
int len;
|
||||
int freerest = 0;
|
||||
|
||||
quiet = 1;
|
||||
|
||||
len = strcspn(cmd, spaces);
|
||||
rest = cmd + len;
|
||||
if (*rest != '\0') {
|
||||
rest++;
|
||||
if (*rest != '\0')
|
||||
rest += strspn(rest, spaces);
|
||||
if (*rest == '\0' && !strncasecmp(cmd, "restart", len)) {
|
||||
if (try_exec(save_quiet))
|
||||
return (1);
|
||||
freerest = get_args(&rest);
|
||||
}
|
||||
syscmd = malloc(strlen(named_path) + sizeof " " + strlen(rest));
|
||||
if (syscmd == NULL)
|
||||
@@ -274,6 +451,8 @@ builtincmd(void) {
|
||||
strcat(syscmd, " ");
|
||||
strcat(syscmd, rest);
|
||||
}
|
||||
if (freerest)
|
||||
free(rest);
|
||||
if (strncasecmp(cmd, "start", len) == 0) {
|
||||
if (running(debug, &pid))
|
||||
error("name server already running? (pid %ld)",
|
||||
@@ -417,6 +596,7 @@ channel_loop(const char *cmdtext, int show, closure cl, void *ua) {
|
||||
a.cl = cl;
|
||||
a.ua = ua;
|
||||
logger_show = show;
|
||||
trace("command '%s'", cmdtext);
|
||||
ctl = ctl_client(ev, client_addr, impute_addrlen(client_addr),
|
||||
(struct sockaddr *)&server,
|
||||
impute_addrlen((struct sockaddr *)&server),
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.27 2001/01/31 08:44:43 marka Exp $
|
||||
# $Id: Makefile,v 8.28 2002/05/21 00:44:59 marka Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
@@ -31,7 +31,8 @@ A=a
|
||||
O=o
|
||||
EXE=
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
SYSLIBS =-lutil
|
||||
LIBL=-ll
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
@@ -56,7 +57,7 @@ all: ${PROG}${EXE}
|
||||
|
||||
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
${LIBBIND} ${LIBL} ${SYSLIBS}
|
||||
|
||||
.c.${O}:
|
||||
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
|
||||
|
||||
@@ -171,11 +171,11 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 1 == use original server to find
|
||||
* the new one.
|
||||
*/
|
||||
SetDefaultServer(yytext, 0);
|
||||
SetDefaultServer((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ {
|
||||
SetDefaultServer(yytext, 1);
|
||||
SetDefaultServer((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*exit{WS}*$ {
|
||||
@@ -191,11 +191,11 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
Finger(yytext, 1);
|
||||
Finger((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ {
|
||||
Finger(yytext, 0);
|
||||
Finger((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
@@ -204,11 +204,11 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHosts(yytext, 1);
|
||||
ListHosts((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHosts(yytext, 0);
|
||||
ListHosts((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
@@ -217,15 +217,15 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHostsByType(yytext, 1);
|
||||
ListHostsByType((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHostsByType(yytext, 0);
|
||||
ListHostsByType((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*set{WS}+{NAME}+{WS}*$ {
|
||||
SetOption(yytext);
|
||||
SetOption((char*)yytext);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*help{WS}*$ {
|
||||
@@ -243,11 +243,11 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHost(yytext, 1);
|
||||
LookupHost((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}*$ {
|
||||
LookupHost(yytext, 0);
|
||||
LookupHost((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
@@ -255,11 +255,11 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHostWithServer(yytext, 1);
|
||||
LookupHostWithServer((char*)yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ {
|
||||
LookupHostWithServer(yytext, 0);
|
||||
LookupHostWithServer((char*)yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*\n {
|
||||
@@ -267,7 +267,7 @@ NAME [:A-Za-z0-9.*=_/-]
|
||||
}
|
||||
^.*\n {
|
||||
printf("Unrecognized command: %s",
|
||||
yytext);
|
||||
(char*)yytext);
|
||||
return(1);
|
||||
}
|
||||
\n { ; }
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)getinfo.c 5.26 (Berkeley) 3/21/91";
|
||||
static const char rcsid[] = "$Id: getinfo.c,v 8.23 2002/04/29 01:11:52 marka Exp $";
|
||||
static const char rcsid[] = "$Id: getinfo.c,v 8.27 2002/05/22 04:06:57 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -142,16 +142,9 @@ typedef union {
|
||||
*/
|
||||
|
||||
static int
|
||||
GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer,
|
||||
merge)
|
||||
union res_sockaddr_union *nsAddrPtr;
|
||||
char *msg;
|
||||
int queryType;
|
||||
int msglen;
|
||||
Boolean iquery;
|
||||
register HostInfo *hostPtr;
|
||||
Boolean isServer;
|
||||
Boolean merge;
|
||||
GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
|
||||
char *msg, int msglen, Boolean iquery, HostInfo *hostPtr,
|
||||
Boolean isServer, Boolean merge)
|
||||
{
|
||||
register HEADER *headerPtr;
|
||||
register const u_char *cp;
|
||||
@@ -253,7 +246,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer,
|
||||
printf("Non-authoritative answer:\n");
|
||||
}
|
||||
|
||||
if (queryType != T_A && !(iquery && queryType == T_PTR)) {
|
||||
if (queryType != T_A && queryType != T_AAAA && /* A6? */
|
||||
!(iquery && queryType == T_PTR)) {
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
if ((cp = Print_rr(cp, (u_char *)&answer,
|
||||
eom, stdout)) == NULL) {
|
||||
@@ -334,7 +328,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer,
|
||||
memcpy(hostPtr->name, bp, s);
|
||||
}
|
||||
}
|
||||
bp += (((u_int32_t)bp) % sizeof(align));
|
||||
bp += (((u_long)bp) % sizeof(align));
|
||||
|
||||
if (bp + dlen >= &hostbuf[sizeof(hostbuf)]) {
|
||||
if (res.options & RES_DEBUG) {
|
||||
@@ -360,7 +354,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer,
|
||||
}
|
||||
}
|
||||
|
||||
if ((queryType == T_A || queryType == T_PTR) && haveAnswer) {
|
||||
if ((queryType == T_A || queryType == T_AAAA || queryType == T_PTR) &&
|
||||
haveAnswer) {
|
||||
|
||||
/*
|
||||
* Go through the alias and address lists and return them
|
||||
@@ -540,7 +535,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer,
|
||||
*/
|
||||
cp = res_skip((u_char*)&answer, 3, eom);
|
||||
|
||||
if (queryType != T_A) {
|
||||
if (queryType != T_A && queryType != T_AAAA) {
|
||||
/*
|
||||
* If we don't need to save the record, just print it.
|
||||
*/
|
||||
|
||||
@@ -78,7 +78,7 @@ char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
|
||||
static const char rcsid[] = "$Id: main.c,v 8.22 2002/04/12 03:03:49 marka Exp $";
|
||||
static const char rcsid[] = "$Id: main.c,v 8.24 2002/05/26 03:12:20 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -341,10 +341,21 @@ main(int argc, char **argv) {
|
||||
} else {
|
||||
result = GetHostInfoByAddr(&u[i], &u[i], defaultPtr);
|
||||
if (result != SUCCESS) {
|
||||
char t[80];
|
||||
switch (u[i].sin.sin_family) {
|
||||
case AF_INET:
|
||||
inet_ntop(AF_INET, &u[i].sin.sin_addr, t, sizeof(t));
|
||||
break;
|
||||
case AF_INET6:
|
||||
inet_ntop(AF_INET6, &u[i].sin6.sin6_addr, t, sizeof(t));
|
||||
break;
|
||||
default:
|
||||
strcpy(t, "<UNKNOWN>");
|
||||
break;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"*** Can't find server name for address %s: %s\n",
|
||||
inet_ntoa(res.nsaddr_list[i].sin_addr),
|
||||
DecodeError(result));
|
||||
"*** Can't find server name for address %s: %s\n",
|
||||
t, DecodeError(result));
|
||||
} else {
|
||||
defaultAddr = u[i];
|
||||
break;
|
||||
@@ -693,7 +704,7 @@ DoLookup(host, servPtr, serverName)
|
||||
* RFC1123 says we "SHOULD check the string syntactically for a
|
||||
* dotted-decimal number before looking it up [...]" (p. 13).
|
||||
*/
|
||||
if (queryType == T_A && IsAddr(host, &addr)) {
|
||||
if ((queryType == T_A || queryType == T_AAAA) && IsAddr(host, &addr)) {
|
||||
result = GetHostInfoByAddr(&servAddr, &addr, &curHostInfo);
|
||||
} else {
|
||||
if (queryType == T_PTR) {
|
||||
@@ -711,7 +722,7 @@ DoLookup(host, servPtr, serverName)
|
||||
* There's no need to print anything for other query types
|
||||
* because the info has already been printed.
|
||||
*/
|
||||
if (queryType == T_A) {
|
||||
if (queryType == T_A || queryType == T_AAAA) {
|
||||
curHostValid = TRUE;
|
||||
PrintHostInfo(filePtr, "Name:", &curHostInfo);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char sccsid[] = "@(#)send.c 5.18 (Berkeley) 3/2/91";
|
||||
static const char rcsid[] = "$Id: send.c,v 8.13 2002/04/09 05:55:23 marka Exp $";
|
||||
static const char rcsid[] = "$Id: send.c,v 8.14 2002/05/10 04:35:09 marka Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@@ -291,7 +291,7 @@ SendRequest(union res_sockaddr_union *nsAddrPtr, const u_char *buf,
|
||||
}
|
||||
#else /* BSD */
|
||||
if (sendto(s, (const char *)buf, buflen, 0,
|
||||
(struct sockaddr *) &nsAddrPtr,
|
||||
(struct sockaddr *) nsAddrPtr,
|
||||
clen) != buflen) {
|
||||
if (res.options & RES_DEBUG)
|
||||
perror("sendto");
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<PRE>
|
||||
server <VAR><A HREF="docdef.html">ip_addr</A></VAR> {
|
||||
[ edns <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ bogus <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ support-ixfr <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ transfers <VAR><A HREF="docdef.html">number</A></VAR>; ]
|
||||
@@ -28,6 +29,10 @@ server <VAR><A HREF="docdef.html">ip_addr</A></VAR> {
|
||||
<P>The server statement defines the characteristics to be
|
||||
associated with a remote name server.</P>
|
||||
|
||||
<P>If you discover that a server does not support EDNS you can prevent
|
||||
named making EDNS queries to it by specifying <CODE>edns no;</CODE>.
|
||||
The default value of <CODE>edns</CODE> is <CODE>yes</CODE>.
|
||||
|
||||
<P>If you discover that a server is giving out bad data, marking it as
|
||||
<CODE>bogus</CODE> will prevent further queries to it. The default value of
|
||||
<CODE>bogus</CODE> is <CODE>no</CODE>. Marking a server as <CODE>bogus</CODE>
|
||||
@@ -69,7 +74,7 @@ required to be signed by this key.
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: server.html,v 1.12 2001/08/10 05:12:29 marka Exp $
|
||||
Last Updated: $Id: server.html,v 1.13 2002/05/24 03:04:51 marka Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,5 +1,5 @@
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: dig.1,v 8.8 2001/09/24 15:21:29 marka Exp $
|
||||
.\" $Id: dig.1,v 8.9 2002/06/18 01:53:43 marka Exp $
|
||||
.\"
|
||||
.\" ++Copyright++ 1993
|
||||
.\" -
|
||||
@@ -96,7 +96,7 @@ will take the form:
|
||||
where:
|
||||
.Bl -tag -width Fl
|
||||
.It Ar server
|
||||
may be either a domain name or a dot-notation
|
||||
may be either a domain name or a raw (IPv4 / IPv6)
|
||||
Internet address. If this optional field is omitted,
|
||||
.Ic dig
|
||||
will attempt to use the default name server for your machine.
|
||||
@@ -145,7 +145,7 @@ See the
|
||||
.Fl x
|
||||
option (documented in the
|
||||
.Sx OTHER OPTIONS
|
||||
subsection of this section) for convenient way to specify inverse address
|
||||
subsection of this section) for convenient way to specify reverse address
|
||||
query.
|
||||
.It Ar query-type
|
||||
is the type of information (DNS query type) that
|
||||
@@ -240,9 +240,15 @@ available (although not guaranteed to be useful):
|
||||
.It Fl x Ar dot-notation-address
|
||||
Convenient form to specify inverse address mapping.
|
||||
Instead of
|
||||
.Dq Ic dig 32.0.9.128.in-addr.arpa ,
|
||||
.Dq Ic dig 32.0.9.28.in-addr.arpa ,
|
||||
one can simply
|
||||
.Dq Ic dig -x 128.9.0.32 .
|
||||
.Dq Ic dig -x 28.9.0.32 .
|
||||
.It Fl x Ar IPv6-address
|
||||
Convenient form to specify inverse address mapping.
|
||||
Instead of
|
||||
.Dq Ic dig 1.0.0.0.0.0.0.0.0.0.0.0. 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa ,
|
||||
one can simply
|
||||
.Dq Ic dig -x ::1 .
|
||||
.It Fl f Ar file
|
||||
File for
|
||||
.Ic dig
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $Id: dnsquery.1,v 8.4 2001/08/08 07:49:58 marka Exp $
|
||||
.\" $Id: dnsquery.1,v 8.5 2002/06/18 02:04:54 marka Exp $
|
||||
.\"
|
||||
.\"Copyright (c) 1995,1996,1999 by Internet Software Consortium
|
||||
.\"
|
||||
@@ -49,8 +49,10 @@ are treated without case-sensitivity.
|
||||
.Bl -tag -width Fl
|
||||
.It Fl n Ar nameserver
|
||||
The nameserver to be used in the query. Nameservers can appear as either
|
||||
Internet addresses of the form
|
||||
.Ar w.x.y.z
|
||||
Internet addresses of the form
|
||||
.Ar ( w.x.y.z
|
||||
or
|
||||
.Ar xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx )
|
||||
or can appear as domain names.
|
||||
(Default: as specified in
|
||||
.Pa /etc/resolv.conf . )
|
||||
|
||||
+27
-39
@@ -1,3 +1,4 @@
|
||||
.\" $FreeBSD$
|
||||
.\" ++Copyright++ 1993
|
||||
.\" -
|
||||
.\" Copyright (c) 1993
|
||||
@@ -50,9 +51,7 @@
|
||||
.\" SOFTWARE.
|
||||
.\" -
|
||||
.\" --Copyright--
|
||||
.\" $Id: host.1,v 8.6 2001/08/10 00:14:47 cyarnell Exp $
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.\" $Id: host.1,v 8.7 2002/06/18 02:39:26 marka Exp $
|
||||
.Dd December 15, 1994
|
||||
.Dt HOST @CMD_EXT_U@
|
||||
.Os BSD 4
|
||||
@@ -61,9 +60,13 @@
|
||||
.Nd look up host names using domain server
|
||||
.Sh SYNOPSIS
|
||||
.Nm host
|
||||
.Op Fl adlrwv
|
||||
.Op Fl c Ar class
|
||||
.Op Fl l
|
||||
.Op Fl v
|
||||
.Op Fl w
|
||||
.Op Fl r
|
||||
.Op Fl d
|
||||
.Op Fl t Ar querytype
|
||||
.Op Fl a
|
||||
.Ar host
|
||||
.Op Ar server
|
||||
.Sh DESCRIPTION
|
||||
@@ -82,7 +85,7 @@ by the domain server.
|
||||
The arguments can be either host names or host numbers. The program
|
||||
first attempts to interpret them as host numbers. If this fails,
|
||||
it will treat them as host names. A host number consists of
|
||||
four decimal numbers separated by dots, e.g. 128.6.4.194
|
||||
IPv4 dotted decimal quad (127.0.0.1) or IPv6 raw address (::1).
|
||||
A host name consists of names separated by dots, e.g. topaz.rutgers.edu.
|
||||
Unless the name ends in a dot, the local domain
|
||||
is automatically tacked on the end. Thus, a Rutgers user can say
|
||||
@@ -156,39 +159,23 @@ There are a number of options that can be used before the
|
||||
host name. Most of these options are meaningful only to the
|
||||
staff who have to maintain the domain database.
|
||||
.Bl -tag -width Fl
|
||||
.It Fl a
|
||||
.Dq all ;
|
||||
this is equivalent to
|
||||
.Dq Fl v Fl t Cm any .
|
||||
.It Fl c Ar class
|
||||
The
|
||||
.Ar class
|
||||
to look for non-Internet data.
|
||||
.It Fl d
|
||||
Turn on debugging. Network transactions are shown in detail.
|
||||
.It Fl l
|
||||
List a complete domain; e.g.:
|
||||
.Pp
|
||||
.D1 Ic host -l rutgers.edu
|
||||
.Pp
|
||||
will give a listing of all hosts in the rutgers.edu domain. The
|
||||
.Dq Fl t
|
||||
option is used to filter what information is presented, as you
|
||||
would expect. The default is address information, which also
|
||||
include PTR and NS records. The command
|
||||
.Pp
|
||||
.D1 Ic host -l -v -t any rutgers.edu
|
||||
.Pp
|
||||
will give a complete download of the zone data for rutgers.edu,
|
||||
in the official master file format. (However the SOA record is
|
||||
listed twice, for arcane reasons.)
|
||||
.Pp
|
||||
.Sy NOTE:
|
||||
.Dq Fl l
|
||||
is implemented by
|
||||
doing a complete zone transfer and then filtering out the information
|
||||
that you have asked for. This command should be used only if it
|
||||
is absolutely necessary.
|
||||
.It Fl w
|
||||
This causes
|
||||
.Ic host
|
||||
to wait forever for a response. Normally
|
||||
it will time out after approximate one minute.
|
||||
.It Fl v
|
||||
Use "verbose" format for printout. This
|
||||
is the official domain master file format, which is documented
|
||||
in the man page for
|
||||
.Xr @INDOT@named @SYS_OPS_EXT@ .
|
||||
Without this option, output still follows
|
||||
this format in general terms, but some attempt is made to make it
|
||||
more intelligible to normal users. Without
|
||||
.Dq Fl v ,
|
||||
any "a", "mx", and "cname" records
|
||||
are written out as "has address", "mail is handled by", and
|
||||
"is a nickname for" (respectively), and TTL and class fields are not shown.
|
||||
.It Fl r
|
||||
Turn off recursion in the request.
|
||||
This means that the name server will return only data it has in
|
||||
@@ -206,6 +193,7 @@ to be looked up. The arguments are defined in the man page for
|
||||
.Xr @INDOT@named @SYS_OPS_EXT@ .
|
||||
Currently-supported types include:
|
||||
.Dq Cm a ,
|
||||
.Dq Cm aaaa ,
|
||||
.Dq Cm ns ,
|
||||
.Dq Cm md ,
|
||||
.Dq Cm mf ,
|
||||
|
||||
@@ -1895,6 +1895,7 @@ Any number of trusted keys can be specified.
|
||||
.Ss Syntax
|
||||
.Bd -literal
|
||||
server \fIip_addr\fR {
|
||||
[ edns \fIyes_or_no\fR; ]
|
||||
[ bogus \fIyes_or_no\fR; ]
|
||||
[ support-ixfr \fIyes_or_no\fR; ]
|
||||
[ transfers \fInumber\fR; ]
|
||||
@@ -1906,6 +1907,15 @@ server \fIip_addr\fR {
|
||||
The server statement defines the characteristics to be
|
||||
associated with a remote name server.
|
||||
.Pp
|
||||
If you discover that a server does not support EDNS you can prevent
|
||||
named making EDNS queries to it by specifying
|
||||
.Ic edns
|
||||
.Ic no; .
|
||||
The default value of
|
||||
.Ic edns
|
||||
is
|
||||
.Ic yes .
|
||||
.Pp
|
||||
If you discover that a server is giving out bad data, marking it as
|
||||
.Ic bogus
|
||||
will prevent further queries to it. The default value of
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
.\" $FreeBSD$
|
||||
.\" $Id: nsupdate.8,v 8.8 2002/04/22 04:38:04 marka Exp $
|
||||
.\"
|
||||
.\"Copyright (c) 1999 by Internet Software Consortium
|
||||
@@ -188,7 +187,6 @@ and examine the status field in the nameserver's reply.
|
||||
.Sh FILES
|
||||
.Bl -hang
|
||||
.It Pa /etc/resolv.conf
|
||||
.El
|
||||
initial domain name and name server addresses
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
.\"
|
||||
.\" @(#)resolver.3 6.5 (Berkeley) 6/23/90
|
||||
.\" $Id: resolver.3,v 8.16 2001/12/28 04:24:20 marka Exp $
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 4, 2000
|
||||
.Dt RESOLVER @LIB_NETWORK_EXT_U@
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
/*
|
||||
* from nameser.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: nameser_compat.h,v 8.13 2001/09/24 02:20:25 marka Exp $
|
||||
* $Id: nameser_compat.h,v 8.14 2002/05/18 01:39:11 marka Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ARPA_NAMESER_COMPAT_
|
||||
@@ -64,7 +64,7 @@
|
||||
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
|
||||
defined(__hppa) || defined(__hp9000) || \
|
||||
defined(__hp9000s300) || defined(__hp9000s700) || \
|
||||
defined(__hp3000s900) || defined(MPE) || \
|
||||
defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
|
||||
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || \
|
||||
(defined(__Lynx__) && \
|
||||
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
|
||||
|
||||
@@ -24,11 +24,13 @@
|
||||
do { (list).head = NULL; (list).tail = NULL; } while (0)
|
||||
|
||||
#define LINK(type) struct { type *prev, *next; }
|
||||
#define INIT_LINK(elt, link) \
|
||||
#define INIT_LINK_TYPE(elt, link, type) \
|
||||
do { \
|
||||
(elt)->link.prev = (void *)(-1); \
|
||||
(elt)->link.next = (void *)(-1); \
|
||||
(elt)->link.prev = (type *)(-1); \
|
||||
(elt)->link.next = (type *)(-1); \
|
||||
} while (0)
|
||||
#define INIT_LINK(elt, link) \
|
||||
INIT_LINK_TYPE(elt, link, void)
|
||||
#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
|
||||
|
||||
#define HEAD(list) ((list).head)
|
||||
@@ -59,7 +61,7 @@
|
||||
(list).tail = (elt); \
|
||||
} while (0)
|
||||
|
||||
#define UNLINK(list, elt, link) \
|
||||
#define UNLINK_TYPE(list, elt, link, type) \
|
||||
do { \
|
||||
INSIST(LINKED(elt, link));\
|
||||
if ((elt)->link.next != NULL) \
|
||||
@@ -70,8 +72,10 @@
|
||||
(elt)->link.prev->link.next = (elt)->link.next; \
|
||||
else \
|
||||
(list).head = (elt)->link.next; \
|
||||
INIT_LINK(elt, link); \
|
||||
INIT_LINK_TYPE(elt, link, type); \
|
||||
} while (0)
|
||||
#define UNLINK(list, elt, link) \
|
||||
UNLINK_TYPE(list, elt, link, void)
|
||||
|
||||
#define PREV(elt, link) ((elt)->link.prev)
|
||||
#define NEXT(elt, link) ((elt)->link.next)
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
/*
|
||||
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: resolv.h,v 8.45 2002/04/12 06:27:48 marka Exp $
|
||||
* $Id: resolv.h,v 8.48 2002/05/31 06:05:29 marka Exp $
|
||||
*/
|
||||
|
||||
#ifndef _RESOLV_H_
|
||||
@@ -156,7 +156,11 @@ struct __res_state_ext;
|
||||
struct __res_state {
|
||||
int retrans; /* retransmition time interval */
|
||||
int retry; /* number of times to retransmit */
|
||||
#ifdef sun
|
||||
u_int options; /* option flags - see below. */
|
||||
#else
|
||||
u_long options; /* option flags - see below. */
|
||||
#endif
|
||||
int nscount; /* number of name servers */
|
||||
struct sockaddr_in
|
||||
nsaddr_list[MAXNS]; /* address of name server */
|
||||
@@ -164,7 +168,11 @@ struct __res_state {
|
||||
u_short id; /* current message id */
|
||||
char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
|
||||
char defdname[256]; /* default domain (deprecated) */
|
||||
#ifdef sun
|
||||
u_int pfcode; /* RES_PRF_ flags - see below. */
|
||||
#else
|
||||
u_long pfcode; /* RES_PRF_ flags - see below. */
|
||||
#endif
|
||||
unsigned ndots:4; /* threshold for initial abs. query */
|
||||
unsigned nsort:4; /* number of elements in sort_list[] */
|
||||
char unused[3];
|
||||
@@ -177,9 +185,10 @@ struct __res_state {
|
||||
int res_h_errno; /* last one set for this context */
|
||||
int _vcsock; /* PRIVATE: for res_send VC i/o */
|
||||
u_int _flags; /* PRIVATE: see below */
|
||||
u_int _pad; /* make _u 64 bit aligned */
|
||||
union {
|
||||
/* On an 32-bit arch this means 512b total. */
|
||||
char pad[72 - 3*sizeof (int) - 2*sizeof (void *)];
|
||||
char pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
|
||||
struct {
|
||||
u_int16_t nscount;
|
||||
u_int16_t nstimes[MAXNS]; /* ms. */
|
||||
@@ -245,6 +254,7 @@ union res_sockaddr_union {
|
||||
#define RES_USE_DNAME 0x10000000 /* use DNAME */
|
||||
#define RES_USE_A6 0x20000000 /* use A6 */
|
||||
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
|
||||
#define RES_NO_NIBBLE2 0x80000000 /* disable alternate nibble lookup */
|
||||
|
||||
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
|
||||
|
||||
@@ -460,6 +470,7 @@ const char * res_protocolname __P((int num));
|
||||
void res_destroyprotolist __P((void));
|
||||
void res_buildprotolist __P((void));
|
||||
const char * res_get_nibblesuffix __P((res_state));
|
||||
const char * res_get_nibblesuffix2 __P((res_state));
|
||||
const char * res_get_bitstringsuffix __P((res_state));
|
||||
void res_ndestroy __P((res_state));
|
||||
u_int16_t res_nametoclass __P((const char *buf, int *success));
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char rcsid[] = "$Id: dns_ho.c,v 1.35 2002/05/08 01:49:27 marka Exp $";
|
||||
static const char rcsid[] = "$Id: dns_ho.c,v 1.39 2002/06/27 03:56:32 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* Imports. */
|
||||
@@ -74,6 +74,7 @@ static const char rcsid[] = "$Id: dns_ho.c,v 1.35 2002/05/08 01:49:27 marka Exp
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <isc/memcluster.h>
|
||||
#include <irs.h>
|
||||
@@ -161,7 +162,7 @@ static struct addrinfo * ho_addrinfo(struct irs_ho *this, const char *name,
|
||||
const struct addrinfo *pai);
|
||||
|
||||
static void map_v4v6_hostent(struct hostent *hp, char **bp,
|
||||
int *len);
|
||||
char *ep);
|
||||
static void addrsort(res_state, char **, int);
|
||||
static struct hostent * gethostans(struct irs_ho *this,
|
||||
const u_char *ansbuf, int anslen,
|
||||
@@ -404,15 +405,12 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
|
||||
q->answer = q->qbuf.buf;
|
||||
q->anslen = sizeof(q->qbuf);
|
||||
q->next = q2;
|
||||
if ((pvt->res->options & RES_NO_BITSTRING) != 0)
|
||||
q->action = RESTGT_IGNORE;
|
||||
else
|
||||
q->action = RESTGT_DOALWAYS;
|
||||
q->action = RESTGT_DOALWAYS;
|
||||
q2->qclass = C_IN;
|
||||
q2->qtype = T_PTR;
|
||||
q2->answer = q2->qbuf.buf;
|
||||
q2->anslen = sizeof(q2->qbuf);
|
||||
if ((pvt->res->options & RES_NO_NIBBLE) != 0)
|
||||
if ((pvt->res->options & RES_NO_NIBBLE2) != 0)
|
||||
q2->action = RESTGT_IGNORE;
|
||||
else
|
||||
q2->action = RESTGT_AFTERFAILURE;
|
||||
@@ -441,11 +439,12 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
|
||||
case AF_INET6:
|
||||
if (q->action != RESTGT_IGNORE) {
|
||||
qp = q->qname;
|
||||
qp += SPRINTF((qp, "\\[x"));
|
||||
for (n = 0; n < IN6ADDRSZ; n++)
|
||||
qp += SPRINTF((qp, "%02x", uaddr[n]));
|
||||
SPRINTF((qp, "/128].%s",
|
||||
res_get_bitstringsuffix(pvt->res)));
|
||||
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
|
||||
qp += SPRINTF((qp, "%x.%x.",
|
||||
uaddr[n] & 0xf,
|
||||
(uaddr[n] >> 4) & 0xf));
|
||||
}
|
||||
strcpy(qp, res_get_nibblesuffix(pvt->res));
|
||||
}
|
||||
if (q2->action != RESTGT_IGNORE) {
|
||||
qp = q2->qname;
|
||||
@@ -454,7 +453,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
|
||||
uaddr[n] & 0xf,
|
||||
(uaddr[n] >> 4) & 0xf));
|
||||
}
|
||||
strcpy(qp, res_get_nibblesuffix(pvt->res));
|
||||
strcpy(qp, res_get_nibblesuffix2(pvt->res));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1081,7 +1080,7 @@ gethostans(struct irs_ho *this,
|
||||
struct addrinfo **ret_aip, const struct addrinfo *pai)
|
||||
{
|
||||
struct pvt *pvt = (struct pvt *)this->private;
|
||||
int type, class, buflen, ancount, qdcount, n, haveanswer, had_error;
|
||||
int type, class, ancount, qdcount, n, haveanswer, had_error;
|
||||
int error = NETDB_SUCCESS, arcount;
|
||||
int (*name_ok)(const char *);
|
||||
const HEADER *hp;
|
||||
@@ -1090,7 +1089,7 @@ gethostans(struct irs_ho *this,
|
||||
const u_char *cp;
|
||||
const char *tname;
|
||||
const char *hname;
|
||||
char *bp, **ap, **hap;
|
||||
char *bp, *ep, **ap, **hap;
|
||||
char tbuf[MAXDNAME+1];
|
||||
struct addrinfo sentinel, *cur, ai;
|
||||
const u_char *arp = NULL;
|
||||
@@ -1133,13 +1132,13 @@ gethostans(struct irs_ho *this,
|
||||
qdcount = ntohs(hp->qdcount);
|
||||
arcount = ntohs(hp->arcount);
|
||||
bp = pvt->hostbuf;
|
||||
buflen = sizeof pvt->hostbuf;
|
||||
ep = pvt->hostbuf + sizeof(pvt->hostbuf);
|
||||
cp = ansbuf + HFIXEDSZ;
|
||||
if (qdcount != 1) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
}
|
||||
n = dn_expand(ansbuf, eom, cp, bp, buflen);
|
||||
n = dn_expand(ansbuf, eom, cp, bp, ep - bp);
|
||||
if (n < 0 || !maybe_ok(pvt->res, bp, name_ok)) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
@@ -1163,7 +1162,6 @@ gethostans(struct irs_ho *this,
|
||||
pvt->host.h_name = bp;
|
||||
hname = bp;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
/* The qname can be abbreviated, but hname is now absolute. */
|
||||
qname = pvt->host.h_name;
|
||||
}
|
||||
@@ -1176,7 +1174,7 @@ gethostans(struct irs_ho *this,
|
||||
haveanswer = 0;
|
||||
had_error = 0;
|
||||
while (ancount-- > 0 && cp < eom && !had_error) {
|
||||
n = dn_expand(ansbuf, eom, cp, bp, buflen);
|
||||
n = dn_expand(ansbuf, eom, cp, bp, ep - bp);
|
||||
if (n < 0 || !maybe_ok(pvt->res, bp, name_ok)) {
|
||||
had_error++;
|
||||
continue;
|
||||
@@ -1197,6 +1195,15 @@ gethostans(struct irs_ho *this,
|
||||
eor = cp + n;
|
||||
if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 ||
|
||||
qtype == T_ANY) && type == T_CNAME) {
|
||||
if (haveanswer) {
|
||||
int level = LOG_CRIT;
|
||||
#ifdef LOG_SECURITY
|
||||
level |= LOG_SECURITY;
|
||||
#endif
|
||||
syslog(level,
|
||||
"gethostans: possible attempt to exploit buffer overflow while looking up %s",
|
||||
*qname ? qname : ".");
|
||||
}
|
||||
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
|
||||
if (n < 0 || !maybe_ok(pvt->res, tbuf, name_ok)) {
|
||||
had_error++;
|
||||
@@ -1209,10 +1216,9 @@ gethostans(struct irs_ho *this,
|
||||
*ap++ = bp;
|
||||
n = strlen(bp) + 1; /* for the \0 */
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
/* Get canonical name. */
|
||||
n = strlen(tbuf) + 1; /* for the \0 */
|
||||
if (n > buflen || n > MAXHOSTNAMELEN) {
|
||||
if (n > (ep - bp) || n > MAXHOSTNAMELEN) {
|
||||
had_error++;
|
||||
continue;
|
||||
}
|
||||
@@ -1220,7 +1226,6 @@ gethostans(struct irs_ho *this,
|
||||
pvt->host.h_name = bp;
|
||||
hname = bp;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
continue;
|
||||
}
|
||||
if (type == ns_t_dname) {
|
||||
@@ -1256,7 +1261,7 @@ gethostans(struct irs_ho *this,
|
||||
cp += n;
|
||||
|
||||
n = strlen(t) + 1; /* for the \0 */
|
||||
if (n > buflen) {
|
||||
if (n > (ep - bp)) {
|
||||
had_error++;
|
||||
continue;
|
||||
}
|
||||
@@ -1266,7 +1271,6 @@ gethostans(struct irs_ho *this,
|
||||
else
|
||||
hname = bp;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -1292,14 +1296,13 @@ gethostans(struct irs_ho *this,
|
||||
}
|
||||
/* Get canonical name. */
|
||||
n = strlen(tbuf) + 1; /* for the \0 */
|
||||
if (n > buflen) {
|
||||
if (n > (ep - bp)) {
|
||||
had_error++;
|
||||
continue;
|
||||
}
|
||||
strcpy(bp, tbuf);
|
||||
tname = bp;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
continue;
|
||||
}
|
||||
if (qtype == T_ANY) {
|
||||
@@ -1323,7 +1326,7 @@ gethostans(struct irs_ho *this,
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
n = dn_expand(ansbuf, eor, cp, bp, buflen);
|
||||
n = dn_expand(ansbuf, eor, cp, bp, ep - bp);
|
||||
if (n < 0 || !maybe_hnok(pvt->res, bp) ||
|
||||
n >= MAXHOSTNAMELEN) {
|
||||
had_error++;
|
||||
@@ -1341,7 +1344,6 @@ gethostans(struct irs_ho *this,
|
||||
if (n != -1) {
|
||||
n = strlen(bp) + 1; /* for the \0 */
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
}
|
||||
break;
|
||||
case ns_t_a6: {
|
||||
@@ -1441,7 +1443,6 @@ gethostans(struct irs_ho *this,
|
||||
pvt->host.h_name = bp;
|
||||
hname = bp;
|
||||
bp += nn;
|
||||
buflen -= nn;
|
||||
}
|
||||
/* Ensure alignment. */
|
||||
bp = (char *)(((u_long)bp + (sizeof(align) - 1)) &
|
||||
@@ -1495,15 +1496,14 @@ gethostans(struct irs_ho *this,
|
||||
haveanswer);
|
||||
if (pvt->host.h_name == NULL) {
|
||||
n = strlen(qname) + 1; /* for the \0 */
|
||||
if (n > buflen || n >= MAXHOSTNAMELEN)
|
||||
if (n > (ep - bp) || n >= MAXHOSTNAMELEN)
|
||||
goto no_recovery;
|
||||
strcpy(bp, qname);
|
||||
pvt->host.h_name = bp;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
}
|
||||
if (pvt->res->options & RES_USE_INET6)
|
||||
map_v4v6_hostent(&pvt->host, &bp, &buflen);
|
||||
map_v4v6_hostent(&pvt->host, &bp, ep);
|
||||
RES_SET_H_ERRNO(pvt->res, NETDB_SUCCESS);
|
||||
return (&pvt->host);
|
||||
} else {
|
||||
@@ -1577,7 +1577,7 @@ add_hostent(struct pvt *pvt, char *bp, char **hap, struct addrinfo *ai)
|
||||
}
|
||||
|
||||
static void
|
||||
map_v4v6_hostent(struct hostent *hp, char **bpp, int *lenp) {
|
||||
map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep) {
|
||||
char **ap;
|
||||
|
||||
if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ)
|
||||
@@ -1590,17 +1590,15 @@ map_v4v6_hostent(struct hostent *hp, char **bpp, int *lenp) {
|
||||
if (i != 0)
|
||||
i = sizeof(align) - i;
|
||||
|
||||
if (*lenp < (i + IN6ADDRSZ)) {
|
||||
if ((ep - *bpp) < (i + IN6ADDRSZ)) {
|
||||
/* Out of memory. Truncate address list here. */
|
||||
*ap = NULL;
|
||||
return;
|
||||
}
|
||||
*bpp += i;
|
||||
*lenp -= i;
|
||||
map_v4v6_address(*ap, *bpp);
|
||||
*ap = *bpp;
|
||||
*bpp += IN6ADDRSZ;
|
||||
*lenp -= IN6ADDRSZ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char rcsid[] = "$Id: dns_nw.c,v 1.22 2002/02/27 03:50:10 marka Exp $";
|
||||
static const char rcsid[] = "$Id: dns_nw.c,v 1.23 2002/06/26 07:42:06 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* Imports. */
|
||||
@@ -299,8 +299,8 @@ get1101answer(struct irs_nw *this,
|
||||
int af, const char *name, const u_char *addr, int addrlen)
|
||||
{
|
||||
struct pvt *pvt = (struct pvt *)this->private;
|
||||
int type, class, buflen, ancount, qdcount, haveanswer;
|
||||
char *bp, **ap;
|
||||
int type, class, ancount, qdcount, haveanswer;
|
||||
char *bp, *ep, **ap;
|
||||
u_char *cp, *eom;
|
||||
HEADER *hp;
|
||||
|
||||
@@ -332,7 +332,7 @@ get1101answer(struct irs_nw *this,
|
||||
|
||||
/* Prepare a return structure. */
|
||||
bp = pvt->buf;
|
||||
buflen = sizeof pvt->buf;
|
||||
ep = pvt->buf + sizeof(pvt->buf);
|
||||
pvt->net.n_name = NULL;
|
||||
pvt->net.n_aliases = pvt->ali;
|
||||
pvt->net.n_addrtype = af;
|
||||
@@ -345,20 +345,19 @@ get1101answer(struct irs_nw *this,
|
||||
if (name != NULL) {
|
||||
int n = strlen(name) + 1;
|
||||
|
||||
if (n > buflen) {
|
||||
if (n > (ep - bp)) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
}
|
||||
pvt->net.n_name = strcpy(bp, name);
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
}
|
||||
break;
|
||||
case by_addr:
|
||||
if (addr != NULL && addrlen != 0) {
|
||||
int n = addrlen / 8 + ((addrlen % 8) != 0);
|
||||
|
||||
if (INADDRSZ > buflen) {
|
||||
if (INADDRSZ > (ep - bp)) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
}
|
||||
@@ -366,7 +365,6 @@ get1101answer(struct irs_nw *this,
|
||||
memcpy(bp, addr, n);
|
||||
pvt->net.n_addr = bp;
|
||||
bp += INADDRSZ;
|
||||
buflen -= INADDRSZ;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -377,7 +375,7 @@ get1101answer(struct irs_nw *this,
|
||||
ap = pvt->ali;
|
||||
haveanswer = 0;
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
int n = dn_expand(ansbuf, eom, cp, bp, buflen);
|
||||
int n = dn_expand(ansbuf, eom, cp, bp, ep - bp);
|
||||
|
||||
cp += n; /* Owner */
|
||||
if (n < 0 || !maybe_dnok(pvt->res, bp) ||
|
||||
@@ -392,7 +390,7 @@ get1101answer(struct irs_nw *this,
|
||||
if (class == C_IN && type == T_PTR) {
|
||||
int nn;
|
||||
|
||||
nn = dn_expand(ansbuf, eom, cp, bp, buflen);
|
||||
nn = dn_expand(ansbuf, eom, cp, bp, ep - bp);
|
||||
if (nn < 0 || !maybe_hnok(pvt->res, bp) || nn != n) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
@@ -408,7 +406,6 @@ get1101answer(struct irs_nw *this,
|
||||
*ap++ = bp;
|
||||
nn = strlen(bp) + 1;
|
||||
bp += nn;
|
||||
buflen -= nn;
|
||||
haveanswer++;
|
||||
break;
|
||||
}
|
||||
@@ -419,7 +416,7 @@ get1101answer(struct irs_nw *this,
|
||||
sscanf(bp, "%u.%u.%u.%u.in-addr.arpa",
|
||||
&b1, &b2, &b3, &b4) != 4)
|
||||
break;
|
||||
if (buflen < INADDRSZ) {
|
||||
if ((ep - bp) < INADDRSZ) {
|
||||
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
|
||||
return (NULL);
|
||||
}
|
||||
@@ -428,7 +425,6 @@ get1101answer(struct irs_nw *this,
|
||||
*bp++ = b3;
|
||||
*bp++ = b2;
|
||||
*bp++ = b1;
|
||||
buflen -= INADDRSZ;
|
||||
pvt->net.n_length = INADDRSZ * 8;
|
||||
haveanswer++;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#if !defined(LINT) && !defined(CODECENTER)
|
||||
static const char rcsid[] = "$Id: gethostent.c,v 1.29 2001/05/29 05:48:44 marka Exp $";
|
||||
static const char rcsid[] = "$Id: gethostent.c,v 1.32 2002/05/27 06:50:55 marka Exp $";
|
||||
#endif
|
||||
|
||||
/* Imports */
|
||||
@@ -458,34 +458,34 @@ freehostent(struct hostent *he) {
|
||||
* -1 on failure.
|
||||
*/
|
||||
|
||||
static int
|
||||
scan_interfaces(int *have_v4, int *have_v6) {
|
||||
#ifndef SIOCGLIFCONF
|
||||
/* map new to old */
|
||||
#define SIOCGLIFCONF SIOCGIFCONF
|
||||
#define lifc_len ifc_len
|
||||
#define lifc_buf ifc_buf
|
||||
struct ifconf lifc;
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \
|
||||
!defined(IRIX_EMUL_IOCTL_SIOCGIFCONF)
|
||||
|
||||
#ifdef __hpux
|
||||
#define lifc_len iflc_len
|
||||
#define lifc_buf iflc_buf
|
||||
#define lifc_req iflc_req
|
||||
#define LIFCONF if_laddrconf
|
||||
#else
|
||||
#define SETFAMILYFLAGS
|
||||
struct lifconf lifc;
|
||||
#define LIFCONF lifconf
|
||||
#endif
|
||||
|
||||
#ifndef SIOCGLIFADDR
|
||||
/* map new to old */
|
||||
#define SIOCGLIFADDR SIOCGIFADDR
|
||||
#endif
|
||||
|
||||
#ifndef SIOCGLIFFLAGS
|
||||
#define SIOCGLIFFLAGS SIOCGIFFLAGS
|
||||
#define lifr_addr ifr_addr
|
||||
#define lifr_name ifr_name
|
||||
#define lifr_flags ifr_flags
|
||||
|
||||
#ifdef __hpux
|
||||
#define lifr_addr iflr_addr
|
||||
#define lifr_name iflr_name
|
||||
#define lifr_dstaddr iflr_dstaddr
|
||||
#define lifr_flags iflr_flags
|
||||
#define ss_family sa_family
|
||||
struct ifreq lifreq;
|
||||
#define LIFREQ if_laddrreq
|
||||
#else
|
||||
struct lifreq lifreq;
|
||||
#define LIFREQ lifreq
|
||||
#endif
|
||||
|
||||
static int
|
||||
scan_interfaces6(int *have_v4, int *have_v6) {
|
||||
struct LIFCONF lifc;
|
||||
struct LIFREQ lifreq;
|
||||
struct in_addr in4;
|
||||
struct in6_addr in6;
|
||||
char *buf = NULL, *cp, *cplim;
|
||||
@@ -496,7 +496,7 @@ scan_interfaces(int *have_v4, int *have_v6) {
|
||||
*have_v4 = *have_v6 = 0;
|
||||
|
||||
/* Get interface list from system. */
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
|
||||
goto err_ret;
|
||||
|
||||
/*
|
||||
@@ -508,20 +508,11 @@ scan_interfaces(int *have_v4, int *have_v6) {
|
||||
if (buf == NULL)
|
||||
goto err_ret;
|
||||
#ifdef SETFAMILYFLAGS
|
||||
lifc.lifc_family = AF_UNSPEC;
|
||||
lifc.lifc_family = AF_UNSPEC; /* request all families */
|
||||
lifc.lifc_flags = 0;
|
||||
#endif
|
||||
lifc.lifc_len = bufsiz;
|
||||
lifc.lifc_buf = buf;
|
||||
#ifdef IRIX_EMUL_IOCTL_SIOCGIFCONF
|
||||
/*
|
||||
* This is a fix for IRIX OS in which the call to ioctl with
|
||||
* the flag SIOCGIFCONF may not return an entry for all the
|
||||
* interfaces like most flavors of Unix.
|
||||
*/
|
||||
if (emul_ioctl(&lifc) >= 0)
|
||||
break;
|
||||
#else
|
||||
if ((n = ioctl(s, SIOCGLIFCONF, (char *)&lifc)) != -1) {
|
||||
/*
|
||||
* Some OS's just return what will fit rather
|
||||
@@ -534,7 +525,6 @@ scan_interfaces(int *have_v4, int *have_v6) {
|
||||
if (lifc.lifc_len + 2 * sizeof(lifreq) < bufsiz)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if ((n == -1) && errno != EINVAL)
|
||||
goto err_ret;
|
||||
|
||||
@@ -620,6 +610,158 @@ scan_interfaces(int *have_v4, int *have_v6) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int
|
||||
scan_interfaces(int *have_v4, int *have_v6) {
|
||||
struct ifconf ifc;
|
||||
union {
|
||||
char _pad[256]; /* leave space for IPv6 addresses */
|
||||
struct ifreq ifreq;
|
||||
} u;
|
||||
struct in_addr in4;
|
||||
struct in6_addr in6;
|
||||
char *buf = NULL, *cp, *cplim;
|
||||
static unsigned int bufsiz = 4095;
|
||||
int s, n;
|
||||
size_t cpsize;
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \
|
||||
!defined(IRIX_EMUL_IOCTL_SIOCGIFCONF)
|
||||
/*
|
||||
* Try to scan the interfaces using IPv6 ioctls().
|
||||
*/
|
||||
if (!scan_interfaces6(have_v4, have_v6))
|
||||
return (0);
|
||||
#endif
|
||||
|
||||
/* Set to zero. Used as loop terminators below. */
|
||||
*have_v4 = *have_v6 = 0;
|
||||
|
||||
/* Get interface list from system. */
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||
goto err_ret;
|
||||
|
||||
/*
|
||||
* Grow buffer until large enough to contain all interface
|
||||
* descriptions.
|
||||
*/
|
||||
for (;;) {
|
||||
buf = memget(bufsiz);
|
||||
if (buf == NULL)
|
||||
goto err_ret;
|
||||
ifc.ifc_len = bufsiz;
|
||||
ifc.ifc_buf = buf;
|
||||
#ifdef IRIX_EMUL_IOCTL_SIOCGIFCONF
|
||||
/*
|
||||
* This is a fix for IRIX OS in which the call to ioctl with
|
||||
* the flag SIOCGIFCONF may not return an entry for all the
|
||||
* interfaces like most flavors of Unix.
|
||||
*/
|
||||
if (emul_ioctl(&ifc) >= 0)
|
||||
break;
|
||||
#else
|
||||
if ((n = ioctl(s, SIOCGIFCONF, (char *)&ifc)) != -1) {
|
||||
/*
|
||||
* Some OS's just return what will fit rather
|
||||
* than set EINVAL if the buffer is too small
|
||||
* to fit all the interfaces in. If
|
||||
* ifc.ifc_len is too near to the end of the
|
||||
* buffer we will grow it just in case and
|
||||
* retry.
|
||||
*/
|
||||
if (ifc.ifc_len + 2 * sizeof(u.ifreq) < bufsiz)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if ((n == -1) && errno != EINVAL)
|
||||
goto err_ret;
|
||||
|
||||
if (bufsiz > 1000000)
|
||||
goto err_ret;
|
||||
|
||||
memput(buf, bufsiz);
|
||||
bufsiz += 4096;
|
||||
}
|
||||
|
||||
/* Parse system's interface list. */
|
||||
cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */
|
||||
for (cp = buf;
|
||||
(*have_v4 == 0 || *have_v6 == 0) && cp < cplim;
|
||||
cp += cpsize) {
|
||||
memcpy(&u.ifreq, cp, sizeof u.ifreq);
|
||||
#ifdef HAVE_SA_LEN
|
||||
#ifdef FIX_ZERO_SA_LEN
|
||||
if (u.ifreq.ifr_addr.sa_len == 0)
|
||||
u.ifreq.ifr_addr.sa_len = 16;
|
||||
#endif
|
||||
#ifdef HAVE_MINIMUM_IFREQ
|
||||
cpsize = sizeof u.ifreq;
|
||||
if (u.ifreq.ifr_addr.sa_len > sizeof (struct sockaddr))
|
||||
cpsize += (int)u.ifreq.ifr_addr.sa_len -
|
||||
(int)(sizeof (struct sockaddr));
|
||||
#else
|
||||
cpsize = sizeof u.ifreq.ifr_name + u.ifreq.ifr_addr.sa_len;
|
||||
#endif /* HAVE_MINIMUM_IFREQ */
|
||||
if (cpsize > sizeof u.ifreq && cpsize <= sizeof u)
|
||||
memcpy(&u.ifreq, cp, cpsize);
|
||||
#elif defined SIOCGIFCONF_ADDR
|
||||
cpsize = sizeof u.ifreq;
|
||||
#else
|
||||
cpsize = sizeof u.ifreq.ifr_name;
|
||||
/* XXX maybe this should be a hard error? */
|
||||
if (ioctl(s, SIOCGIFADDR, (char *)&u.ifreq) < 0)
|
||||
continue;
|
||||
#endif
|
||||
switch (u.ifreq.ifr_addr.sa_family) {
|
||||
case AF_INET:
|
||||
if (*have_v4 == 0) {
|
||||
memcpy(&in4,
|
||||
&((struct sockaddr_in *)
|
||||
&u.ifreq.ifr_addr)->sin_addr,
|
||||
sizeof in4);
|
||||
if (in4.s_addr == INADDR_ANY)
|
||||
break;
|
||||
n = ioctl(s, SIOCGIFFLAGS, (char *)&u.ifreq);
|
||||
if (n < 0)
|
||||
break;
|
||||
if ((u.ifreq.ifr_flags & IFF_UP) == 0)
|
||||
break;
|
||||
*have_v4 = 1;
|
||||
}
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (*have_v6 == 0) {
|
||||
memcpy(&in6,
|
||||
&((struct sockaddr_in6 *)
|
||||
&u.ifreq.ifr_addr)->sin6_addr,
|
||||
sizeof in6);
|
||||
if (memcmp(&in6, &in6addr_any, sizeof in6) == 0)
|
||||
break;
|
||||
n = ioctl(s, SIOCGIFFLAGS, (char *)&u.ifreq);
|
||||
if (n < 0)
|
||||
break;
|
||||
if ((u.ifreq.ifr_flags & IFF_UP) == 0)
|
||||
break;
|
||||
*have_v6 = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (buf != NULL)
|
||||
memput(buf, bufsiz);
|
||||
close(s);
|
||||
/* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
|
||||
return (0);
|
||||
err_ret:
|
||||
if (buf != NULL)
|
||||
memput(buf, bufsiz);
|
||||
if (s != -1)
|
||||
close(s);
|
||||
/* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static struct hostent *
|
||||
copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) {
|
||||
struct hostent *he = NULL;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] = "$Id: ns_name.c,v 8.17 2001/10/03 14:34:32 marka Exp $";
|
||||
static const char rcsid[] = "$Id: ns_name.c,v 8.18 2002/05/24 05:10:40 marka Exp $";
|
||||
#endif
|
||||
|
||||
#include "port_before.h"
|
||||
@@ -681,6 +681,8 @@ special(int ch) {
|
||||
case 0x2E: /* '.' */
|
||||
case 0x3B: /* ';' */
|
||||
case 0x5C: /* '\\' */
|
||||
case 0x28: /* '(' */
|
||||
case 0x29: /* ')' */
|
||||
/* Special modifiers in zone files. */
|
||||
case 0x40: /* '@' */
|
||||
case 0x24: /* '$' */
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
|
||||
static const char rcsid[] = "$Id: res_debug.c,v 8.45 2001/12/19 12:05:56 marka Exp $";
|
||||
static const char rcsid[] = "$Id: res_debug.c,v 8.46 2002/05/21 01:57:45 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "port_before.h"
|
||||
@@ -683,12 +683,10 @@ precsize_ntoa(prec)
|
||||
|
||||
/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */
|
||||
static u_int8_t
|
||||
precsize_aton(strptr)
|
||||
char **strptr;
|
||||
{
|
||||
precsize_aton(const char **strptr) {
|
||||
unsigned int mval = 0, cmval = 0;
|
||||
u_int8_t retval = 0;
|
||||
char *cp;
|
||||
const char *cp;
|
||||
int exponent;
|
||||
int mantissa;
|
||||
|
||||
@@ -725,11 +723,8 @@ precsize_aton(strptr)
|
||||
|
||||
/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */
|
||||
static u_int32_t
|
||||
latlon2ul(latlonstrptr,which)
|
||||
char **latlonstrptr;
|
||||
int *which;
|
||||
{
|
||||
char *cp;
|
||||
latlon2ul(const char **latlonstrptr, int *which) {
|
||||
const char *cp;
|
||||
u_int32_t retval;
|
||||
int deg = 0, min = 0, secs = 0, secsfrac = 0;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
|
||||
static const char rcsid[] = "$Id: res_init.c,v 8.28 2002/01/30 01:07:35 marka Exp $";
|
||||
static const char rcsid[] = "$Id: res_init.c,v 8.29 2002/05/31 06:05:31 marka Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "port_before.h"
|
||||
@@ -194,7 +194,8 @@ __res_vinit(res_state statp, int preinit) {
|
||||
if (statp->_u._ext.ext != NULL) {
|
||||
memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext));
|
||||
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
|
||||
strcpy(statp->_u._ext.ext->nsuffix, "ip6.int");
|
||||
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
|
||||
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
|
||||
strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa");
|
||||
}
|
||||
#ifdef RESOLVSORT
|
||||
@@ -520,6 +521,14 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
strncpy(ext->nsuffix, cp, i);
|
||||
ext->nsuffix[i] = '\0';
|
||||
}
|
||||
else if (!strncmp(cp, "nibble2:", sizeof("nibble2:") - 1)) {
|
||||
if (ext == NULL)
|
||||
goto skip;
|
||||
cp += sizeof("nibble2:") - 1;
|
||||
i = MIN(strcspn(cp, " \t"), sizeof(ext->nsuffix2) - 1);
|
||||
strncpy(ext->nsuffix2, cp, i);
|
||||
ext->nsuffix2[i] = '\0';
|
||||
}
|
||||
else if (!strncmp(cp, "bitstring:", sizeof("bitstring:") - 1)) {
|
||||
if (ext == NULL)
|
||||
goto skip;
|
||||
@@ -530,16 +539,12 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
}
|
||||
else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
|
||||
cp += sizeof("v6revmode:") - 1;
|
||||
if (!strncmp(cp, "nibble", sizeof("nibble") - 1)) {
|
||||
statp->options &= ~RES_NO_NIBBLE;
|
||||
statp->options |= RES_NO_BITSTRING;
|
||||
} else if (!strncmp(cp, "bitstring",
|
||||
sizeof("bitstring") - 1)) {
|
||||
statp->options |= RES_NO_NIBBLE;
|
||||
statp->options &= ~RES_NO_BITSTRING;
|
||||
/* "nibble" and "bitstring" used to be valid */
|
||||
if (!strncmp(cp, "single", sizeof("single") - 1)) {
|
||||
statp->options |= RES_NO_NIBBLE2;
|
||||
} else if (!strncmp(cp, "both", sizeof("both") - 1)) {
|
||||
statp->options &=
|
||||
~(RES_NO_NIBBLE|RES_NO_BITSTRING);
|
||||
~RES_NO_NIBBLE2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -613,6 +618,13 @@ const char *
|
||||
res_get_nibblesuffix(res_state statp) {
|
||||
if (statp->_u._ext.ext)
|
||||
return (statp->_u._ext.ext->nsuffix);
|
||||
return ("ip6.arpa");
|
||||
}
|
||||
|
||||
const char *
|
||||
res_get_nibblesuffix2(res_state statp) {
|
||||
if (statp->_u._ext.ext)
|
||||
return (statp->_u._ext.ext->nsuffix2);
|
||||
return ("ip6.int");
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ struct __res_state_ext {
|
||||
} sort_list[MAXRESOLVSORT];
|
||||
char nsuffix[64];
|
||||
char bsuffix[64];
|
||||
char nsuffix2[64];
|
||||
};
|
||||
|
||||
extern int
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'CC=cc'
|
||||
'CDEBUG=-O2 -g -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -DMEMCLUSTER_RECORD=1'
|
||||
'CDEBUG=-O2 -g -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat'
|
||||
'DESTBIN=/usr/bin'
|
||||
'DESTSBIN=/usr/sbin'
|
||||
'DESTEXEC=/usr/libexec'
|
||||
@@ -9,7 +9,8 @@
|
||||
'DESTRUN=/var/run'
|
||||
'LEX=lex -I'
|
||||
'YACC=yacc -d'
|
||||
'SYSLIBS=-ll -lutil'
|
||||
'SYSLIBS=-lutil'
|
||||
'LIBL=-ll'
|
||||
'INSTALL=install'
|
||||
'MANDIR=cat'
|
||||
'MANROFF=(tbl|nroff -man)'
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define SETPWENT_VOID
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define GROUP_R_RETURN struct group *
|
||||
@@ -27,8 +28,13 @@
|
||||
#define GROUP_R_ENT_ARGS void
|
||||
#define GROUP_R_OK gptr
|
||||
#define GROUP_R_BAD NULL
|
||||
#if defined(__FreeBSD_version) && __FreeBSD_version >= 500030
|
||||
#define GETGROUPLIST_ARGS const char *name, gid_t basegid, gid_t *groups, \
|
||||
int *ngroups
|
||||
#else
|
||||
#define GETGROUPLIST_ARGS const char *name, int basegid, int *groups, \
|
||||
int *ngroups
|
||||
#endif
|
||||
|
||||
#define HOST_R_RETURN struct hostent *
|
||||
#define HOST_R_SET_RETURN void
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,245 +0,0 @@
|
||||
/* MIPS-specific support for 64-bit ELF
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001
|
||||
Free Software Foundation, Inc.
|
||||
Ian Lance Taylor, Cygnus Support
|
||||
Linker support added by Mark Mitchell, CodeSourcery, LLC.
|
||||
<mark@codesourcery.com>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file supports the 64-bit (MIPS) ELF archives. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "aout/ar.h"
|
||||
|
||||
/* Irix 6 defines a 64bit archive map format, so that they can
|
||||
have archives more than 4 GB in size. */
|
||||
|
||||
boolean bfd_elf64_archive_slurp_armap PARAMS ((bfd *));
|
||||
boolean bfd_elf64_archive_write_armap
|
||||
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
|
||||
|
||||
/* Read an Irix 6 armap. */
|
||||
|
||||
boolean
|
||||
bfd_elf64_archive_slurp_armap (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct artdata *ardata = bfd_ardata (abfd);
|
||||
char nextname[17];
|
||||
file_ptr arhdrpos;
|
||||
bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;
|
||||
struct areltdata *mapdata;
|
||||
bfd_byte int_buf[8];
|
||||
char *stringbase;
|
||||
bfd_byte *raw_armap = NULL;
|
||||
carsym *carsyms;
|
||||
bfd_size_type amt;
|
||||
|
||||
ardata->symdefs = NULL;
|
||||
|
||||
/* Get the name of the first element. */
|
||||
arhdrpos = bfd_tell (abfd);
|
||||
i = bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd);
|
||||
if (i == 0)
|
||||
return true;
|
||||
if (i != 16)
|
||||
return false;
|
||||
|
||||
if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
|
||||
return false;
|
||||
|
||||
/* Archives with traditional armaps are still permitted. */
|
||||
if (strncmp (nextname, "/ ", 16) == 0)
|
||||
return bfd_slurp_armap (abfd);
|
||||
|
||||
if (strncmp (nextname, "/SYM64/ ", 16) != 0)
|
||||
{
|
||||
bfd_has_map (abfd) = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
|
||||
if (mapdata == NULL)
|
||||
return false;
|
||||
parsed_size = mapdata->parsed_size;
|
||||
bfd_release (abfd, (PTR) mapdata);
|
||||
|
||||
if (bfd_bread (int_buf, (bfd_size_type) 8, abfd) != 8)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
return false;
|
||||
}
|
||||
|
||||
nsymz = bfd_getb64 (int_buf);
|
||||
stringsize = parsed_size - 8 * nsymz - 8;
|
||||
|
||||
carsym_size = nsymz * sizeof (carsym);
|
||||
ptrsize = 8 * nsymz;
|
||||
|
||||
amt = carsym_size + stringsize + 1;
|
||||
ardata->symdefs = (carsym *) bfd_zalloc (abfd, amt);
|
||||
if (ardata->symdefs == NULL)
|
||||
return false;
|
||||
carsyms = ardata->symdefs;
|
||||
stringbase = ((char *) ardata->symdefs) + carsym_size;
|
||||
|
||||
raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize);
|
||||
if (raw_armap == NULL)
|
||||
goto release_symdefs;
|
||||
|
||||
if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize
|
||||
|| bfd_bread (stringbase, stringsize, abfd) != stringsize)
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
goto release_raw_armap;
|
||||
}
|
||||
|
||||
for (i = 0; i < nsymz; i++)
|
||||
{
|
||||
carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);
|
||||
carsyms->name = stringbase;
|
||||
stringbase += strlen (stringbase) + 1;
|
||||
++carsyms;
|
||||
}
|
||||
*stringbase = '\0';
|
||||
|
||||
ardata->symdef_count = nsymz;
|
||||
ardata->first_file_filepos = bfd_tell (abfd);
|
||||
/* Pad to an even boundary if you have to. */
|
||||
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
|
||||
|
||||
bfd_has_map (abfd) = true;
|
||||
bfd_release (abfd, raw_armap);
|
||||
|
||||
return true;
|
||||
|
||||
release_raw_armap:
|
||||
bfd_release (abfd, raw_armap);
|
||||
release_symdefs:
|
||||
bfd_release (abfd, ardata->symdefs);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Write out an Irix 6 armap. The Irix 6 tools are supposed to be
|
||||
able to handle ordinary ELF armaps, but at least on Irix 6.2 the
|
||||
linker crashes. */
|
||||
|
||||
boolean
|
||||
bfd_elf64_archive_write_armap (arch, elength, map, symbol_count, stridx)
|
||||
bfd *arch;
|
||||
unsigned int elength;
|
||||
struct orl *map;
|
||||
unsigned int symbol_count;
|
||||
int stridx;
|
||||
{
|
||||
unsigned int ranlibsize = (symbol_count * 8) + 8;
|
||||
unsigned int stringsize = stridx;
|
||||
unsigned int mapsize = stringsize + ranlibsize;
|
||||
file_ptr archive_member_file_ptr;
|
||||
bfd *current = arch->archive_head;
|
||||
unsigned int count;
|
||||
struct ar_hdr hdr;
|
||||
unsigned int i;
|
||||
int padding;
|
||||
bfd_byte buf[8];
|
||||
|
||||
padding = BFD_ALIGN (mapsize, 8) - mapsize;
|
||||
mapsize += padding;
|
||||
|
||||
/* work out where the first object file will go in the archive */
|
||||
archive_member_file_ptr = (mapsize
|
||||
+ elength
|
||||
+ sizeof (struct ar_hdr)
|
||||
+ SARMAG);
|
||||
|
||||
memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
|
||||
strcpy (hdr.ar_name, "/SYM64/");
|
||||
sprintf (hdr.ar_size, "%-10d", (int) mapsize);
|
||||
sprintf (hdr.ar_date, "%ld", (long) time (NULL));
|
||||
/* This, at least, is what Intel coff sets the values to.: */
|
||||
sprintf ((hdr.ar_uid), "%d", 0);
|
||||
sprintf ((hdr.ar_gid), "%d", 0);
|
||||
sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0);
|
||||
strncpy (hdr.ar_fmag, ARFMAG, 2);
|
||||
|
||||
for (i = 0; i < sizeof (struct ar_hdr); i++)
|
||||
if (((char *) (&hdr))[i] == '\0')
|
||||
(((char *) (&hdr))[i]) = ' ';
|
||||
|
||||
/* Write the ar header for this item and the number of symbols */
|
||||
|
||||
if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), arch)
|
||||
!= sizeof (struct ar_hdr))
|
||||
return false;
|
||||
|
||||
bfd_putb64 ((bfd_vma) symbol_count, buf);
|
||||
if (bfd_bwrite (buf, (bfd_size_type) 8, arch) != 8)
|
||||
return false;
|
||||
|
||||
/* Two passes, first write the file offsets for each symbol -
|
||||
remembering that each offset is on a two byte boundary. */
|
||||
|
||||
/* Write out the file offset for the file associated with each
|
||||
symbol, and remember to keep the offsets padded out. */
|
||||
|
||||
current = arch->archive_head;
|
||||
count = 0;
|
||||
while (current != (bfd *) NULL && count < symbol_count)
|
||||
{
|
||||
/* For each symbol which is used defined in this object, write out
|
||||
the object file's address in the archive */
|
||||
|
||||
while (map[count].u.abfd == current)
|
||||
{
|
||||
bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
|
||||
if (bfd_bwrite (buf, (bfd_size_type) 8, arch) != 8)
|
||||
return false;
|
||||
count++;
|
||||
}
|
||||
/* Add size of this archive entry */
|
||||
archive_member_file_ptr += (arelt_size (current)
|
||||
+ sizeof (struct ar_hdr));
|
||||
/* remember about the even alignment */
|
||||
archive_member_file_ptr += archive_member_file_ptr % 2;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
/* now write the strings themselves */
|
||||
for (count = 0; count < symbol_count; count++)
|
||||
{
|
||||
size_t len = strlen (*map[count].name) + 1;
|
||||
|
||||
if (bfd_bwrite (*map[count].name, (bfd_size_type) len, arch) != len)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The spec says that this should be padded to an 8 byte boundary.
|
||||
However, the Irix 6.2 tools do not appear to do this. */
|
||||
while (padding != 0)
|
||||
{
|
||||
if (bfd_bwrite ("", (bfd_size_type) 1, arch) != 1)
|
||||
return false;
|
||||
--padding;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
s|\(.*\) [^ ]*header.sed.*|\1|
|
||||
s|[^ ]*/||g
|
||||
s|^ *|"|
|
||||
s| |", "|g
|
||||
s|$|"|
|
||||
s|, \([^ ]*\)$| and \1|
|
||||
s|^|/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically generated from |
|
||||
s|\(.\{60\}[^ ]* \)|\1\
|
||||
|g
|
||||
s|$|.\
|
||||
Run "make headers" in your build bfd/ to regenerate. */\
|
||||
|
|
||||
@@ -1,449 +0,0 @@
|
||||
/* ELF strtab with GC and suffix merging support.
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
Written by Jakub Jelinek <jakub@redhat.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
#include "hashtab.h"
|
||||
|
||||
/* An entry in the strtab hash table. */
|
||||
|
||||
struct elf_strtab_hash_entry
|
||||
{
|
||||
struct bfd_hash_entry root;
|
||||
/* Length of this entry. */
|
||||
unsigned int len;
|
||||
unsigned int refcount;
|
||||
union {
|
||||
/* Index within the merged section. */
|
||||
bfd_size_type index;
|
||||
/* Entry this is a suffix of (if len is 0). */
|
||||
struct elf_strtab_hash_entry *suffix;
|
||||
struct elf_strtab_hash_entry *next;
|
||||
} u;
|
||||
};
|
||||
|
||||
/* The strtab hash table. */
|
||||
|
||||
struct elf_strtab_hash
|
||||
{
|
||||
struct bfd_hash_table table;
|
||||
/* Next available index. */
|
||||
bfd_size_type size;
|
||||
/* Number of array entries alloced. */
|
||||
bfd_size_type alloced;
|
||||
/* Final strtab size. */
|
||||
bfd_size_type sec_size;
|
||||
/* Array of pointers to strtab entries. */
|
||||
struct elf_strtab_hash_entry **array;
|
||||
};
|
||||
|
||||
static struct bfd_hash_entry *elf_strtab_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
||||
static int cmplengthentry PARAMS ((const PTR, const PTR));
|
||||
static int last4_eq PARAMS ((const PTR, const PTR));
|
||||
|
||||
/* Routine to create an entry in a section merge hashtab. */
|
||||
|
||||
static struct bfd_hash_entry *
|
||||
elf_strtab_hash_newfunc (entry, table, string)
|
||||
struct bfd_hash_entry *entry;
|
||||
struct bfd_hash_table *table;
|
||||
const char *string;
|
||||
{
|
||||
struct elf_strtab_hash_entry *ret = (struct elf_strtab_hash_entry *) entry;
|
||||
|
||||
/* Allocate the structure if it has not already been allocated by a
|
||||
subclass. */
|
||||
if (ret == (struct elf_strtab_hash_entry *) NULL)
|
||||
ret = ((struct elf_strtab_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct elf_strtab_hash_entry)));
|
||||
if (ret == (struct elf_strtab_hash_entry *) NULL)
|
||||
return NULL;
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct elf_strtab_hash_entry *)
|
||||
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
|
||||
|
||||
if (ret)
|
||||
{
|
||||
/* Initialize the local fields. */
|
||||
ret->u.index = -1;
|
||||
ret->refcount = 0;
|
||||
ret->len = 0;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *)ret;
|
||||
}
|
||||
|
||||
/* Create a new hash table. */
|
||||
|
||||
struct elf_strtab_hash *
|
||||
_bfd_elf_strtab_init ()
|
||||
{
|
||||
struct elf_strtab_hash *table;
|
||||
bfd_size_type amt = sizeof (struct elf_strtab_hash);
|
||||
|
||||
table = (struct elf_strtab_hash *) bfd_malloc (amt);
|
||||
if (table == NULL)
|
||||
return NULL;
|
||||
|
||||
if (! bfd_hash_table_init (&table->table, elf_strtab_hash_newfunc))
|
||||
{
|
||||
free (table);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table->sec_size = 0;
|
||||
table->size = 1;
|
||||
table->alloced = 64;
|
||||
amt = sizeof (struct elf_strtab_hasn_entry *);
|
||||
table->array = (struct elf_strtab_hash_entry **)
|
||||
bfd_malloc (table->alloced * amt);
|
||||
if (table->array == NULL)
|
||||
{
|
||||
free (table);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table->array[0] = NULL;
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/* Free a strtab. */
|
||||
|
||||
void
|
||||
_bfd_elf_strtab_free (tab)
|
||||
struct elf_strtab_hash *tab;
|
||||
{
|
||||
bfd_hash_table_free (&tab->table);
|
||||
free (tab->array);
|
||||
free (tab);
|
||||
}
|
||||
|
||||
/* Get the index of an entity in a hash table, adding it if it is not
|
||||
already present. */
|
||||
|
||||
bfd_size_type
|
||||
_bfd_elf_strtab_add (tab, str, copy)
|
||||
struct elf_strtab_hash *tab;
|
||||
const char *str;
|
||||
boolean copy;
|
||||
{
|
||||
register struct elf_strtab_hash_entry *entry;
|
||||
|
||||
/* We handle this specially, since we don't want to do refcounting
|
||||
on it. */
|
||||
if (*str == '\0')
|
||||
return 0;
|
||||
|
||||
BFD_ASSERT (tab->sec_size == 0);
|
||||
entry = (struct elf_strtab_hash_entry *)
|
||||
bfd_hash_lookup (&tab->table, str, true, copy);
|
||||
|
||||
if (entry == NULL)
|
||||
return (bfd_size_type) -1;
|
||||
|
||||
entry->refcount++;
|
||||
if (entry->len == 0)
|
||||
{
|
||||
entry->len = strlen (str) + 1;
|
||||
if (tab->size == tab->alloced)
|
||||
{
|
||||
bfd_size_type amt = sizeof (struct elf_strtab_hash_entry *);
|
||||
tab->alloced *= 2;
|
||||
tab->array = (struct elf_strtab_hash_entry **)
|
||||
bfd_realloc (tab->array, tab->alloced * amt);
|
||||
if (tab->array == NULL)
|
||||
return (bfd_size_type) -1;
|
||||
}
|
||||
|
||||
entry->u.index = tab->size++;
|
||||
tab->array[entry->u.index] = entry;
|
||||
}
|
||||
return entry->u.index;
|
||||
}
|
||||
|
||||
void
|
||||
_bfd_elf_strtab_addref (tab, idx)
|
||||
struct elf_strtab_hash *tab;
|
||||
bfd_size_type idx;
|
||||
{
|
||||
if (idx == 0 || idx == (bfd_size_type) -1)
|
||||
return;
|
||||
BFD_ASSERT (tab->sec_size == 0);
|
||||
BFD_ASSERT (idx < tab->size);
|
||||
++tab->array[idx]->refcount;
|
||||
}
|
||||
|
||||
void
|
||||
_bfd_elf_strtab_delref (tab, idx)
|
||||
struct elf_strtab_hash *tab;
|
||||
bfd_size_type idx;
|
||||
{
|
||||
if (idx == 0 || idx == (bfd_size_type) -1)
|
||||
return;
|
||||
BFD_ASSERT (tab->sec_size == 0);
|
||||
BFD_ASSERT (idx < tab->size);
|
||||
BFD_ASSERT (tab->array[idx]->refcount > 0);
|
||||
--tab->array[idx]->refcount;
|
||||
}
|
||||
|
||||
void
|
||||
_bfd_elf_strtab_clear_all_refs (tab)
|
||||
struct elf_strtab_hash *tab;
|
||||
{
|
||||
bfd_size_type idx;
|
||||
|
||||
for (idx = 1; idx < tab->size; ++idx)
|
||||
tab->array[idx]->refcount = 0;
|
||||
}
|
||||
|
||||
bfd_size_type
|
||||
_bfd_elf_strtab_size (tab)
|
||||
struct elf_strtab_hash *tab;
|
||||
{
|
||||
return tab->sec_size ? tab->sec_size : tab->size;
|
||||
}
|
||||
|
||||
bfd_size_type
|
||||
_bfd_elf_strtab_offset (tab, idx)
|
||||
struct elf_strtab_hash *tab;
|
||||
bfd_size_type idx;
|
||||
{
|
||||
struct elf_strtab_hash_entry *entry;
|
||||
|
||||
if (idx == 0)
|
||||
return 0;
|
||||
BFD_ASSERT (idx < tab->size);
|
||||
BFD_ASSERT (tab->sec_size);
|
||||
entry = tab->array[idx];
|
||||
BFD_ASSERT (entry->refcount > 0);
|
||||
entry->refcount--;
|
||||
return tab->array[idx]->u.index;
|
||||
}
|
||||
|
||||
boolean
|
||||
_bfd_elf_strtab_emit (abfd, tab)
|
||||
register bfd *abfd;
|
||||
struct elf_strtab_hash *tab;
|
||||
{
|
||||
bfd_size_type off = 1, i;
|
||||
|
||||
if (bfd_bwrite ("", 1, abfd) != 1)
|
||||
return false;
|
||||
|
||||
for (i = 1; i < tab->size; ++i)
|
||||
{
|
||||
register const char *str;
|
||||
register size_t len;
|
||||
|
||||
str = tab->array[i]->root.string;
|
||||
len = tab->array[i]->len;
|
||||
BFD_ASSERT (tab->array[i]->refcount == 0);
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
|
||||
return false;
|
||||
|
||||
off += len;
|
||||
}
|
||||
|
||||
BFD_ASSERT (off == tab->sec_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Compare two elf_strtab_hash_entry structures. This is called via qsort. */
|
||||
|
||||
static int
|
||||
cmplengthentry (a, b)
|
||||
const PTR a;
|
||||
const PTR b;
|
||||
{
|
||||
struct elf_strtab_hash_entry * A = *(struct elf_strtab_hash_entry **) a;
|
||||
struct elf_strtab_hash_entry * B = *(struct elf_strtab_hash_entry **) b;
|
||||
|
||||
if (A->len < B->len)
|
||||
return 1;
|
||||
else if (A->len > B->len)
|
||||
return -1;
|
||||
|
||||
return memcmp (A->root.string, B->root.string, A->len);
|
||||
}
|
||||
|
||||
static int
|
||||
last4_eq (a, b)
|
||||
const PTR a;
|
||||
const PTR b;
|
||||
{
|
||||
struct elf_strtab_hash_entry * A = (struct elf_strtab_hash_entry *) a;
|
||||
struct elf_strtab_hash_entry * B = (struct elf_strtab_hash_entry *) b;
|
||||
|
||||
if (memcmp (A->root.string + A->len - 5, B->root.string + B->len - 5, 4)
|
||||
!= 0)
|
||||
/* This was a hashtable collision. */
|
||||
return 0;
|
||||
|
||||
if (A->len <= B->len)
|
||||
/* B cannot be a suffix of A unless A is equal to B, which is guaranteed
|
||||
not to be equal by the hash table. */
|
||||
return 0;
|
||||
|
||||
return memcmp (A->root.string + (A->len - B->len),
|
||||
B->root.string, B->len - 5) == 0;
|
||||
}
|
||||
|
||||
/* This function assigns final string table offsets for used strings,
|
||||
merging strings matching suffixes of longer strings if possible. */
|
||||
|
||||
void
|
||||
_bfd_elf_strtab_finalize (tab)
|
||||
struct elf_strtab_hash *tab;
|
||||
{
|
||||
struct elf_strtab_hash_entry **array, **a, **end, *e;
|
||||
htab_t last4tab = NULL;
|
||||
bfd_size_type size, amt;
|
||||
struct elf_strtab_hash_entry *last[256], **last_ptr[256];
|
||||
|
||||
/* GCC 2.91.66 (egcs-1.1.2) on i386 miscompiles this function when i is
|
||||
a 64-bit bfd_size_type: a 64-bit target or --enable-64-bit-bfd.
|
||||
Besides, indexing with a long long wouldn't give anything but extra
|
||||
cycles. */
|
||||
size_t i;
|
||||
|
||||
/* Now sort the strings by length, longest first. */
|
||||
array = NULL;
|
||||
amt = tab->size * sizeof (struct elf_strtab_hash_entry *);
|
||||
array = (struct elf_strtab_hash_entry **) bfd_malloc (amt);
|
||||
if (array == NULL)
|
||||
goto alloc_failure;
|
||||
|
||||
memset (last, 0, sizeof (last));
|
||||
for (i = 0; i < 256; ++i)
|
||||
last_ptr[i] = &last[i];
|
||||
for (i = 1, a = array; i < tab->size; ++i)
|
||||
if (tab->array[i]->refcount)
|
||||
*a++ = tab->array[i];
|
||||
else
|
||||
tab->array[i]->len = 0;
|
||||
|
||||
size = a - array;
|
||||
|
||||
qsort (array, size, sizeof (struct elf_strtab_hash_entry *), cmplengthentry);
|
||||
|
||||
last4tab = htab_create (size * 4, NULL, last4_eq, NULL);
|
||||
if (last4tab == NULL)
|
||||
goto alloc_failure;
|
||||
|
||||
/* Now insert the strings into hash tables (strings with last 4 characters
|
||||
and strings with last character equal), look for longer strings which
|
||||
we're suffix of. */
|
||||
for (a = array, end = array + size; a < end; a++)
|
||||
{
|
||||
register hashval_t hash;
|
||||
unsigned int c;
|
||||
unsigned int j;
|
||||
const unsigned char *s;
|
||||
PTR *p;
|
||||
|
||||
e = *a;
|
||||
if (e->len > 4)
|
||||
{
|
||||
s = e->root.string + e->len - 1;
|
||||
hash = 0;
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
c = *--s;
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
}
|
||||
p = htab_find_slot_with_hash (last4tab, e, hash, INSERT);
|
||||
if (p == NULL)
|
||||
goto alloc_failure;
|
||||
if (*p)
|
||||
{
|
||||
struct elf_strtab_hash_entry *ent;
|
||||
|
||||
ent = (struct elf_strtab_hash_entry *) *p;
|
||||
e->u.suffix = ent;
|
||||
e->len = 0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
*p = (PTR) e;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct elf_strtab_hash_entry *tem;
|
||||
|
||||
c = e->root.string[e->len - 2] & 0xff;
|
||||
|
||||
for (tem = last[c]; tem; tem = tem->u.next)
|
||||
if (tem->len > e->len
|
||||
&& memcmp (tem->root.string + (tem->len - e->len),
|
||||
e->root.string, e->len - 1) == 0)
|
||||
break;
|
||||
if (tem)
|
||||
{
|
||||
e->u.suffix = tem;
|
||||
e->len = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
c = e->root.string[e->len - 2] & 0xff;
|
||||
/* Put longest strings first. */
|
||||
*last_ptr[c] = e;
|
||||
last_ptr[c] = &e->u.next;
|
||||
e->u.next = NULL;
|
||||
}
|
||||
|
||||
alloc_failure:
|
||||
if (array)
|
||||
free (array);
|
||||
if (last4tab)
|
||||
htab_delete (last4tab);
|
||||
|
||||
/* Now assign positions to the strings we want to keep. */
|
||||
size = 1;
|
||||
for (i = 1; i < tab->size; ++i)
|
||||
{
|
||||
e = tab->array[i];
|
||||
if (e->refcount && e->len)
|
||||
{
|
||||
e->u.index = size;
|
||||
size += e->len;
|
||||
}
|
||||
}
|
||||
|
||||
tab->sec_size = size;
|
||||
|
||||
/* And now adjust the rest. */
|
||||
for (i = 1; i < tab->size; ++i)
|
||||
{
|
||||
e = tab->array[i];
|
||||
if (e->refcount && ! e->len)
|
||||
e->u.index = e->u.suffix->u.index
|
||||
+ (e->u.suffix->len - strlen (e->root.string) - 1);
|
||||
}
|
||||
}
|
||||
@@ -1,335 +0,0 @@
|
||||
/* Support for the generic parts of PE/PEI; common header information.
|
||||
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
Free Software Foundation, Inc.
|
||||
Written by Cygnus Solutions.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/*
|
||||
Most of this hacked by Steve Chamberlain,
|
||||
sac@cygnus.com
|
||||
|
||||
PE/PEI rearrangement (and code added): Donn Terry
|
||||
Softway Systems, Inc.
|
||||
*/
|
||||
|
||||
/* Hey look, some documentation [and in a place you expect to find it]!
|
||||
|
||||
The main reference for the pei format is "Microsoft Portable Executable
|
||||
and Common Object File Format Specification 4.1". Get it if you need to
|
||||
do some serious hacking on this code.
|
||||
|
||||
Another reference:
|
||||
"Peering Inside the PE: A Tour of the Win32 Portable Executable
|
||||
File Format", MSJ 1994, Volume 9.
|
||||
|
||||
The *sole* difference between the pe format and the pei format is that the
|
||||
latter has an MSDOS 2.0 .exe header on the front that prints the message
|
||||
"This app must be run under Windows." (or some such).
|
||||
(FIXME: Whether that statement is *really* true or not is unknown.
|
||||
Are there more subtle differences between pe and pei formats?
|
||||
For now assume there aren't. If you find one, then for God sakes
|
||||
document it here!)
|
||||
|
||||
The Microsoft docs use the word "image" instead of "executable" because
|
||||
the former can also refer to a DLL (shared library). Confusion can arise
|
||||
because the `i' in `pei' also refers to "image". The `pe' format can
|
||||
also create images (i.e. executables), it's just that to run on a win32
|
||||
system you need to use the pei format.
|
||||
|
||||
FIXME: Please add more docs here so the next poor fool that has to hack
|
||||
on this code has a chance of getting something accomplished without
|
||||
wasting too much time.
|
||||
*/
|
||||
|
||||
#ifndef GET_FCN_LNNOPTR
|
||||
#define GET_FCN_LNNOPTR(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
||||
#endif
|
||||
|
||||
#ifndef GET_FCN_ENDNDX
|
||||
#define GET_FCN_ENDNDX(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
||||
#endif
|
||||
|
||||
#ifndef PUT_FCN_LNNOPTR
|
||||
#define PUT_FCN_LNNOPTR(abfd, in, ext) \
|
||||
H_PUT_32(abfd, in, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
|
||||
#endif
|
||||
#ifndef PUT_FCN_ENDNDX
|
||||
#define PUT_FCN_ENDNDX(abfd, in, ext) \
|
||||
H_PUT_32(abfd, in, ext->x_sym.x_fcnary.x_fcn.x_endndx)
|
||||
#endif
|
||||
#ifndef GET_LNSZ_LNNO
|
||||
#define GET_LNSZ_LNNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno)
|
||||
#endif
|
||||
#ifndef GET_LNSZ_SIZE
|
||||
#define GET_LNSZ_SIZE(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size)
|
||||
#endif
|
||||
#ifndef PUT_LNSZ_LNNO
|
||||
#define PUT_LNSZ_LNNO(abfd, in, ext) \
|
||||
H_PUT_16(abfd, in, ext->x_sym.x_misc.x_lnsz.x_lnno)
|
||||
#endif
|
||||
#ifndef PUT_LNSZ_SIZE
|
||||
#define PUT_LNSZ_SIZE(abfd, in, ext) \
|
||||
H_PUT_16(abfd, in, ext->x_sym.x_misc.x_lnsz.x_size)
|
||||
#endif
|
||||
#ifndef GET_SCN_SCNLEN
|
||||
#define GET_SCN_SCNLEN(abfd, ext) \
|
||||
H_GET_32 (abfd, ext->x_scn.x_scnlen)
|
||||
#endif
|
||||
#ifndef GET_SCN_NRELOC
|
||||
#define GET_SCN_NRELOC(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_scn.x_nreloc)
|
||||
#endif
|
||||
#ifndef GET_SCN_NLINNO
|
||||
#define GET_SCN_NLINNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->x_scn.x_nlinno)
|
||||
#endif
|
||||
#ifndef PUT_SCN_SCNLEN
|
||||
#define PUT_SCN_SCNLEN(abfd, in, ext) \
|
||||
H_PUT_32(abfd, in, ext->x_scn.x_scnlen)
|
||||
#endif
|
||||
#ifndef PUT_SCN_NRELOC
|
||||
#define PUT_SCN_NRELOC(abfd, in, ext) \
|
||||
H_PUT_16(abfd, in, ext->x_scn.x_nreloc)
|
||||
#endif
|
||||
#ifndef PUT_SCN_NLINNO
|
||||
#define PUT_SCN_NLINNO(abfd, in, ext) \
|
||||
H_PUT_16(abfd,in, ext->x_scn.x_nlinno)
|
||||
#endif
|
||||
#ifndef GET_LINENO_LNNO
|
||||
#define GET_LINENO_LNNO(abfd, ext) \
|
||||
H_GET_16 (abfd, ext->l_lnno);
|
||||
#endif
|
||||
#ifndef PUT_LINENO_LNNO
|
||||
#define PUT_LINENO_LNNO(abfd, val, ext) \
|
||||
H_PUT_16(abfd,val, ext->l_lnno);
|
||||
#endif
|
||||
|
||||
/* The f_symptr field in the filehdr is sometimes 64 bits. */
|
||||
#ifndef GET_FILEHDR_SYMPTR
|
||||
#define GET_FILEHDR_SYMPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_FILEHDR_SYMPTR
|
||||
#define PUT_FILEHDR_SYMPTR H_PUT_32
|
||||
#endif
|
||||
|
||||
/* Some fields in the aouthdr are sometimes 64 bits. */
|
||||
#ifndef GET_AOUTHDR_TSIZE
|
||||
#define GET_AOUTHDR_TSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_TSIZE
|
||||
#define PUT_AOUTHDR_TSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_DSIZE
|
||||
#define GET_AOUTHDR_DSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_DSIZE
|
||||
#define PUT_AOUTHDR_DSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_BSIZE
|
||||
#define GET_AOUTHDR_BSIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_BSIZE
|
||||
#define PUT_AOUTHDR_BSIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_ENTRY
|
||||
#define GET_AOUTHDR_ENTRY H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_ENTRY
|
||||
#define PUT_AOUTHDR_ENTRY H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_TEXT_START
|
||||
#define GET_AOUTHDR_TEXT_START H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_TEXT_START
|
||||
#define PUT_AOUTHDR_TEXT_START H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_AOUTHDR_DATA_START
|
||||
#define GET_AOUTHDR_DATA_START H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_AOUTHDR_DATA_START
|
||||
#define PUT_AOUTHDR_DATA_START H_PUT_32
|
||||
#endif
|
||||
|
||||
/* Some fields in the scnhdr are sometimes 64 bits. */
|
||||
#ifndef GET_SCNHDR_PADDR
|
||||
#define GET_SCNHDR_PADDR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_PADDR
|
||||
#define PUT_SCNHDR_PADDR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_VADDR
|
||||
#define GET_SCNHDR_VADDR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_VADDR
|
||||
#define PUT_SCNHDR_VADDR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_SIZE
|
||||
#define GET_SCNHDR_SIZE H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_SIZE
|
||||
#define PUT_SCNHDR_SIZE H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_SCNPTR
|
||||
#define GET_SCNHDR_SCNPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_SCNPTR
|
||||
#define PUT_SCNHDR_SCNPTR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_RELPTR
|
||||
#define GET_SCNHDR_RELPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_RELPTR
|
||||
#define PUT_SCNHDR_RELPTR H_PUT_32
|
||||
#endif
|
||||
#ifndef GET_SCNHDR_LNNOPTR
|
||||
#define GET_SCNHDR_LNNOPTR H_GET_32
|
||||
#endif
|
||||
#ifndef PUT_SCNHDR_LNNOPTR
|
||||
#define PUT_SCNHDR_LNNOPTR H_PUT_32
|
||||
#endif
|
||||
|
||||
#ifdef COFF_WITH_pep
|
||||
|
||||
#define GET_OPTHDR_IMAGE_BASE H_GET_64
|
||||
#define PUT_OPTHDR_IMAGE_BASE H_PUT_64
|
||||
#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_64
|
||||
#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_64
|
||||
#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_64
|
||||
#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_64
|
||||
#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_64
|
||||
#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_64
|
||||
#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_64
|
||||
#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_64
|
||||
#define GET_PDATA_ENTRY bfd_get_64
|
||||
|
||||
#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_pep_bfd_copy_private_bfd_data_common
|
||||
#define _bfd_XX_bfd_copy_private_section_data _bfd_pep_bfd_copy_private_section_data
|
||||
#define _bfd_XX_get_symbol_info _bfd_pep_get_symbol_info
|
||||
#define _bfd_XX_only_swap_filehdr_out _bfd_pep_only_swap_filehdr_out
|
||||
#define _bfd_XX_print_private_bfd_data_common _bfd_pep_print_private_bfd_data_common
|
||||
#define _bfd_XXi_final_link_postscript _bfd_pepi_final_link_postscript
|
||||
#define _bfd_XXi_final_link_postscript _bfd_pepi_final_link_postscript
|
||||
#define _bfd_XXi_only_swap_filehdr_out _bfd_pepi_only_swap_filehdr_out
|
||||
#define _bfd_XXi_swap_aouthdr_in _bfd_pepi_swap_aouthdr_in
|
||||
#define _bfd_XXi_swap_aouthdr_out _bfd_pepi_swap_aouthdr_out
|
||||
#define _bfd_XXi_swap_aux_in _bfd_pepi_swap_aux_in
|
||||
#define _bfd_XXi_swap_aux_out _bfd_pepi_swap_aux_out
|
||||
#define _bfd_XXi_swap_lineno_in _bfd_pepi_swap_lineno_in
|
||||
#define _bfd_XXi_swap_lineno_out _bfd_pepi_swap_lineno_out
|
||||
#define _bfd_XXi_swap_scnhdr_out _bfd_pepi_swap_scnhdr_out
|
||||
#define _bfd_XXi_swap_sym_in _bfd_pepi_swap_sym_in
|
||||
#define _bfd_XXi_swap_sym_out _bfd_pepi_swap_sym_out
|
||||
|
||||
#else /* !COFF_WITH_pep */
|
||||
|
||||
#define GET_OPTHDR_IMAGE_BASE H_GET_32
|
||||
#define PUT_OPTHDR_IMAGE_BASE H_PUT_32
|
||||
#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_32
|
||||
#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_32
|
||||
#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_32
|
||||
#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_32
|
||||
#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_32
|
||||
#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_32
|
||||
#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_32
|
||||
#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_32
|
||||
#define GET_PDATA_ENTRY bfd_get_32
|
||||
|
||||
#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_pe_bfd_copy_private_bfd_data_common
|
||||
#define _bfd_XX_bfd_copy_private_section_data _bfd_pe_bfd_copy_private_section_data
|
||||
#define _bfd_XX_get_symbol_info _bfd_pe_get_symbol_info
|
||||
#define _bfd_XX_only_swap_filehdr_out _bfd_pe_only_swap_filehdr_out
|
||||
#define _bfd_XX_print_private_bfd_data_common _bfd_pe_print_private_bfd_data_common
|
||||
#define _bfd_XXi_final_link_postscript _bfd_pei_final_link_postscript
|
||||
#define _bfd_XXi_final_link_postscript _bfd_pei_final_link_postscript
|
||||
#define _bfd_XXi_only_swap_filehdr_out _bfd_pei_only_swap_filehdr_out
|
||||
#define _bfd_XXi_swap_aouthdr_in _bfd_pei_swap_aouthdr_in
|
||||
#define _bfd_XXi_swap_aouthdr_out _bfd_pei_swap_aouthdr_out
|
||||
#define _bfd_XXi_swap_aux_in _bfd_pei_swap_aux_in
|
||||
#define _bfd_XXi_swap_aux_out _bfd_pei_swap_aux_out
|
||||
#define _bfd_XXi_swap_lineno_in _bfd_pei_swap_lineno_in
|
||||
#define _bfd_XXi_swap_lineno_out _bfd_pei_swap_lineno_out
|
||||
#define _bfd_XXi_swap_scnhdr_out _bfd_pei_swap_scnhdr_out
|
||||
#define _bfd_XXi_swap_sym_in _bfd_pei_swap_sym_in
|
||||
#define _bfd_XXi_swap_sym_out _bfd_pei_swap_sym_out
|
||||
|
||||
#endif /* !COFF_WITH_pep */
|
||||
|
||||
/* These functions are architecture dependent, and are in peicode.h:
|
||||
coff_swap_reloc_in
|
||||
int coff_swap_reloc_out
|
||||
coff_swap_filehdr_in
|
||||
coff_swap_scnhdr_in
|
||||
pe_mkobject
|
||||
pe_mkobject_hook */
|
||||
|
||||
/* The functions described below are common across all PE/PEI
|
||||
implementations architecture types, and actually appear in
|
||||
peigen.c. */
|
||||
|
||||
void _bfd_XXi_swap_sym_in PARAMS ((bfd*, PTR, PTR));
|
||||
#define coff_swap_sym_in _bfd_XXi_swap_sym_in
|
||||
|
||||
unsigned int _bfd_XXi_swap_sym_out PARAMS ((bfd*, PTR, PTR));
|
||||
#define coff_swap_sym_out _bfd_XXi_swap_sym_out
|
||||
|
||||
void _bfd_XXi_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
#define coff_swap_aux_in _bfd_XXi_swap_aux_in
|
||||
|
||||
unsigned int _bfd_XXi_swap_aux_out \
|
||||
PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
#define coff_swap_aux_out _bfd_XXi_swap_aux_out
|
||||
|
||||
void _bfd_XXi_swap_lineno_in PARAMS ((bfd*, PTR, PTR));
|
||||
#define coff_swap_lineno_in _bfd_XXi_swap_lineno_in
|
||||
|
||||
unsigned int _bfd_XXi_swap_lineno_out PARAMS ((bfd*, PTR, PTR));
|
||||
#define coff_swap_lineno_out _bfd_XXi_swap_lineno_out
|
||||
|
||||
void _bfd_XXi_swap_aouthdr_in PARAMS ((bfd*, PTR, PTR));
|
||||
#define coff_swap_aouthdr_in _bfd_XXi_swap_aouthdr_in
|
||||
|
||||
unsigned int _bfd_XXi_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
|
||||
#define coff_swap_aouthdr_out _bfd_XXi_swap_aouthdr_out
|
||||
|
||||
unsigned int _bfd_XXi_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
|
||||
#define coff_swap_scnhdr_out _bfd_XXi_swap_scnhdr_out
|
||||
|
||||
boolean _bfd_XX_print_private_bfd_data_common PARAMS ((bfd *, PTR));
|
||||
|
||||
boolean _bfd_XX_bfd_copy_private_bfd_data_common PARAMS ((bfd *, bfd *));
|
||||
|
||||
void _bfd_XX_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
|
||||
|
||||
boolean _bfd_XXi_final_link_postscript
|
||||
PARAMS ((bfd *, struct coff_final_link_info *));
|
||||
|
||||
#ifndef coff_final_link_postscript
|
||||
#define coff_final_link_postscript _bfd_XXi_final_link_postscript
|
||||
#endif
|
||||
/* The following are needed only for ONE of pe or pei, but don't
|
||||
otherwise vary; peicode.h fixes up ifdefs but we provide the
|
||||
prototype. */
|
||||
|
||||
unsigned int _bfd_XX_only_swap_filehdr_out PARAMS ((bfd*, PTR, PTR));
|
||||
unsigned int _bfd_XXi_only_swap_filehdr_out PARAMS ((bfd*, PTR, PTR));
|
||||
boolean _bfd_XX_bfd_copy_private_section_data
|
||||
PARAMS ((bfd *, asection *, bfd *, asection *));
|
||||
@@ -1,958 +0,0 @@
|
||||
/* SEC_MERGE support.
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
Written by Jakub Jelinek <jakub@redhat.com>.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file contains support for merging duplicate entities within sections,
|
||||
as used in ELF SHF_MERGE. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "hashtab.h"
|
||||
|
||||
struct sec_merge_sec_info;
|
||||
|
||||
/* An entry in the section merge hash table. */
|
||||
|
||||
struct sec_merge_hash_entry
|
||||
{
|
||||
struct bfd_hash_entry root;
|
||||
/* Length of this entry. */
|
||||
unsigned int len;
|
||||
/* Start of this string needs to be aligned to
|
||||
alignment octets (not 1 << align). */
|
||||
unsigned int alignment;
|
||||
union {
|
||||
/* Index within the merged section. */
|
||||
bfd_size_type index;
|
||||
/* Entity size (if present in suffix hash tables). */
|
||||
unsigned int entsize;
|
||||
/* Entry this is a suffix of (if alignment is 0). */
|
||||
struct sec_merge_hash_entry *suffix;
|
||||
} u;
|
||||
/* Which section is it in. */
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
/* Next entity in the hash table. */
|
||||
struct sec_merge_hash_entry *next;
|
||||
};
|
||||
|
||||
/* The section merge hash table. */
|
||||
|
||||
struct sec_merge_hash
|
||||
{
|
||||
struct bfd_hash_table table;
|
||||
/* Next available index. */
|
||||
bfd_size_type size;
|
||||
/* First entity in the SEC_MERGE sections of this type. */
|
||||
struct sec_merge_hash_entry *first;
|
||||
/* Last entity in the SEC_MERGE sections of this type. */
|
||||
struct sec_merge_hash_entry *last;
|
||||
/* Entity size. */
|
||||
unsigned int entsize;
|
||||
/* Are entries fixed size or zero terminated strings? */
|
||||
boolean strings;
|
||||
};
|
||||
|
||||
struct sec_merge_info
|
||||
{
|
||||
/* Chain of sec_merge_infos. */
|
||||
struct sec_merge_info *next;
|
||||
/* Chain of sec_merge_sec_infos. */
|
||||
struct sec_merge_sec_info *chain;
|
||||
/* A hash table used to hold section content. */
|
||||
struct sec_merge_hash *htab;
|
||||
};
|
||||
|
||||
struct sec_merge_sec_info
|
||||
{
|
||||
/* Chain of sec_merge_sec_infos. */
|
||||
struct sec_merge_sec_info *next;
|
||||
/* The corresponding section. */
|
||||
asection *sec;
|
||||
/* Pointer to merge_info pointing to us. */
|
||||
PTR *psecinfo;
|
||||
/* A hash table used to hold section content. */
|
||||
struct sec_merge_hash *htab;
|
||||
/* First string in this section. */
|
||||
struct sec_merge_hash_entry *first;
|
||||
/* Original section content. */
|
||||
unsigned char contents[1];
|
||||
};
|
||||
|
||||
static struct bfd_hash_entry *sec_merge_hash_newfunc
|
||||
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
||||
static struct sec_merge_hash_entry *sec_merge_hash_lookup
|
||||
PARAMS ((struct sec_merge_hash *, const char *, unsigned int, boolean));
|
||||
static struct sec_merge_hash *sec_merge_init
|
||||
PARAMS ((unsigned int, boolean));
|
||||
static struct sec_merge_hash_entry *sec_merge_add
|
||||
PARAMS ((struct sec_merge_hash *, const char *, unsigned int,
|
||||
struct sec_merge_sec_info *));
|
||||
static boolean sec_merge_emit
|
||||
PARAMS ((bfd *, struct sec_merge_hash_entry *));
|
||||
static int cmplengthentry PARAMS ((const PTR, const PTR));
|
||||
static int last4_eq PARAMS ((const PTR, const PTR));
|
||||
static int last_eq PARAMS ((const PTR, const PTR));
|
||||
static boolean record_section
|
||||
PARAMS ((struct sec_merge_info *, struct sec_merge_sec_info *));
|
||||
static void merge_strings PARAMS ((struct sec_merge_info *));
|
||||
|
||||
/* Routine to create an entry in a section merge hashtab. */
|
||||
|
||||
static struct bfd_hash_entry *
|
||||
sec_merge_hash_newfunc (entry, table, string)
|
||||
struct bfd_hash_entry *entry;
|
||||
struct bfd_hash_table *table;
|
||||
const char *string;
|
||||
{
|
||||
struct sec_merge_hash_entry *ret = (struct sec_merge_hash_entry *) entry;
|
||||
|
||||
/* Allocate the structure if it has not already been allocated by a
|
||||
subclass. */
|
||||
if (ret == (struct sec_merge_hash_entry *) NULL)
|
||||
ret = ((struct sec_merge_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct sec_merge_hash_entry)));
|
||||
if (ret == (struct sec_merge_hash_entry *) NULL)
|
||||
return NULL;
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct sec_merge_hash_entry *)
|
||||
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
|
||||
|
||||
if (ret)
|
||||
{
|
||||
/* Initialize the local fields. */
|
||||
ret->u.suffix = NULL;
|
||||
ret->alignment = 0;
|
||||
ret->secinfo = NULL;
|
||||
ret->next = NULL;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *)ret;
|
||||
}
|
||||
|
||||
/* Look up an entry in a section merge hash table. */
|
||||
|
||||
static struct sec_merge_hash_entry *
|
||||
sec_merge_hash_lookup (table, string, alignment, create)
|
||||
struct sec_merge_hash *table;
|
||||
const char *string;
|
||||
unsigned int alignment;
|
||||
boolean create;
|
||||
{
|
||||
register const unsigned char *s;
|
||||
register unsigned long hash;
|
||||
register unsigned int c;
|
||||
struct sec_merge_hash_entry *hashp;
|
||||
unsigned int len, i;
|
||||
unsigned int index;
|
||||
|
||||
hash = 0;
|
||||
len = 0;
|
||||
s = (const unsigned char *) string;
|
||||
if (table->strings)
|
||||
{
|
||||
if (table->entsize == 1)
|
||||
{
|
||||
while ((c = *s++) != '\0')
|
||||
{
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
++len;
|
||||
}
|
||||
hash += len + (len << 17);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
for (i = 0; i < table->entsize; ++i)
|
||||
if (s[i] != '\0')
|
||||
break;
|
||||
if (i == table->entsize)
|
||||
break;
|
||||
for (i = 0; i < table->entsize; ++i)
|
||||
{
|
||||
c = *s++;
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
}
|
||||
++len;
|
||||
}
|
||||
hash += len + (len << 17);
|
||||
len *= table->entsize;
|
||||
}
|
||||
hash ^= hash >> 2;
|
||||
len += table->entsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < table->entsize; ++i)
|
||||
{
|
||||
c = *s++;
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
}
|
||||
len = table->entsize;
|
||||
}
|
||||
|
||||
index = hash % table->table.size;
|
||||
for (hashp = (struct sec_merge_hash_entry *) table->table.table[index];
|
||||
hashp != (struct sec_merge_hash_entry *) NULL;
|
||||
hashp = (struct sec_merge_hash_entry *) hashp->root.next)
|
||||
{
|
||||
if (hashp->root.hash == hash
|
||||
&& len == hashp->len
|
||||
&& memcmp (hashp->root.string, string, len) == 0)
|
||||
{
|
||||
/* If the string we found does not have at least the required
|
||||
alignment, we need to insert another copy. */
|
||||
if (hashp->alignment < alignment)
|
||||
{
|
||||
/* Mark the less aligned copy as deleted. */
|
||||
hashp->len = 0;
|
||||
hashp->alignment = 0;
|
||||
break;
|
||||
}
|
||||
return hashp;
|
||||
}
|
||||
}
|
||||
|
||||
if (! create)
|
||||
return (struct sec_merge_hash_entry *) NULL;
|
||||
|
||||
hashp = (struct sec_merge_hash_entry *)
|
||||
sec_merge_hash_newfunc ((struct bfd_hash_entry *) NULL,
|
||||
(struct bfd_hash_table *) table, string);
|
||||
if (hashp == (struct sec_merge_hash_entry *) NULL)
|
||||
return (struct sec_merge_hash_entry *) NULL;
|
||||
hashp->root.string = string;
|
||||
hashp->root.hash = hash;
|
||||
hashp->len = len;
|
||||
hashp->alignment = alignment;
|
||||
hashp->root.next = table->table.table[index];
|
||||
table->table.table[index] = (struct bfd_hash_entry *) hashp;
|
||||
|
||||
return hashp;
|
||||
}
|
||||
|
||||
/* Create a new hash table. */
|
||||
|
||||
static struct sec_merge_hash *
|
||||
sec_merge_init (entsize, strings)
|
||||
unsigned int entsize;
|
||||
boolean strings;
|
||||
{
|
||||
struct sec_merge_hash *table;
|
||||
bfd_size_type amt = sizeof (struct sec_merge_hash);
|
||||
|
||||
table = (struct sec_merge_hash *) bfd_malloc (amt);
|
||||
if (table == NULL)
|
||||
return NULL;
|
||||
|
||||
if (! bfd_hash_table_init (&table->table, sec_merge_hash_newfunc))
|
||||
{
|
||||
free (table);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
table->size = 0;
|
||||
table->first = NULL;
|
||||
table->last = NULL;
|
||||
table->entsize = entsize;
|
||||
table->strings = strings;
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
/* Get the index of an entity in a hash table, adding it if it is not
|
||||
already present. */
|
||||
|
||||
static struct sec_merge_hash_entry *
|
||||
sec_merge_add (tab, str, alignment, secinfo)
|
||||
struct sec_merge_hash *tab;
|
||||
const char *str;
|
||||
unsigned int alignment;
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
{
|
||||
register struct sec_merge_hash_entry *entry;
|
||||
|
||||
entry = sec_merge_hash_lookup (tab, str, alignment, true);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
|
||||
if (entry->secinfo == NULL)
|
||||
{
|
||||
tab->size++;
|
||||
entry->secinfo = secinfo;
|
||||
if (tab->first == NULL)
|
||||
tab->first = entry;
|
||||
else
|
||||
tab->last->next = entry;
|
||||
tab->last = entry;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static boolean
|
||||
sec_merge_emit (abfd, entry)
|
||||
register bfd *abfd;
|
||||
struct sec_merge_hash_entry *entry;
|
||||
{
|
||||
struct sec_merge_sec_info *secinfo = entry->secinfo;
|
||||
asection *sec = secinfo->sec;
|
||||
char *pad = "";
|
||||
bfd_size_type off = 0;
|
||||
int alignment_power = bfd_get_section_alignment (abfd, sec->output_section);
|
||||
|
||||
if (alignment_power)
|
||||
pad = bfd_zmalloc ((bfd_size_type) 1 << alignment_power);
|
||||
|
||||
for (; entry != NULL && entry->secinfo == secinfo; entry = entry->next)
|
||||
{
|
||||
register const char *str;
|
||||
register size_t len;
|
||||
|
||||
len = off & (entry->alignment - 1);
|
||||
if (len)
|
||||
{
|
||||
len = entry->alignment - len;
|
||||
if (bfd_bwrite ((PTR) pad, (bfd_size_type) len, abfd) != len)
|
||||
break;
|
||||
off += len;
|
||||
}
|
||||
|
||||
str = entry->root.string;
|
||||
len = entry->len;
|
||||
|
||||
if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
|
||||
break;
|
||||
|
||||
off += len;
|
||||
}
|
||||
|
||||
if (alignment_power)
|
||||
free (pad);
|
||||
|
||||
return entry == NULL || entry->secinfo != secinfo;
|
||||
}
|
||||
|
||||
/* This function is called for each input file from the add_symbols
|
||||
pass of the linker. */
|
||||
|
||||
boolean
|
||||
_bfd_merge_section (abfd, psinfo, sec, psecinfo)
|
||||
bfd *abfd;
|
||||
PTR *psinfo;
|
||||
asection *sec;
|
||||
PTR *psecinfo;
|
||||
{
|
||||
struct sec_merge_info *sinfo;
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
unsigned int align;
|
||||
bfd_size_type amt;
|
||||
|
||||
if (sec->_raw_size == 0
|
||||
|| (sec->flags & SEC_EXCLUDE)
|
||||
|| (sec->flags & SEC_MERGE) == 0
|
||||
|| sec->entsize == 0)
|
||||
return true;
|
||||
|
||||
if ((sec->flags & SEC_RELOC) != 0)
|
||||
{
|
||||
/* We aren't prepared to handle relocations in merged sections. */
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sec->output_section != NULL
|
||||
&& bfd_is_abs_section (sec->output_section))
|
||||
{
|
||||
/* The section is being discarded from the link, so we should
|
||||
just ignore it. */
|
||||
return true;
|
||||
}
|
||||
|
||||
align = bfd_get_section_alignment (sec->owner, sec);
|
||||
if ((sec->entsize < (unsigned int)(1 << align)
|
||||
&& ((sec->entsize & (sec->entsize - 1))
|
||||
|| !(sec->flags & SEC_STRINGS)))
|
||||
|| (sec->entsize > (unsigned int)(1 << align)
|
||||
&& (sec->entsize & ((1 << align) - 1))))
|
||||
{
|
||||
/* Sanity check. If string character size is smaller than
|
||||
alignment, then we require character size to be a power
|
||||
of 2, otherwise character size must be integer multiple
|
||||
of alignment. For non-string constants, alignment must
|
||||
be smaller than or equal to entity size and entity size
|
||||
must be integer multiple of alignment. */
|
||||
return true;
|
||||
}
|
||||
|
||||
for (sinfo = (struct sec_merge_info *) *psinfo; sinfo; sinfo = sinfo->next)
|
||||
if ((secinfo = sinfo->chain)
|
||||
&& ! ((secinfo->sec->flags ^ sec->flags) & (SEC_MERGE | SEC_STRINGS))
|
||||
&& secinfo->sec->entsize == sec->entsize
|
||||
&& ! strcmp (secinfo->sec->name, sec->name))
|
||||
break;
|
||||
|
||||
if (sinfo == NULL)
|
||||
{
|
||||
/* Initialize the information we need to keep track of. */
|
||||
sinfo = (struct sec_merge_info *)
|
||||
bfd_alloc (abfd, (bfd_size_type) sizeof (struct sec_merge_info));
|
||||
if (sinfo == NULL)
|
||||
goto error_return;
|
||||
sinfo->next = (struct sec_merge_info *) *psinfo;
|
||||
sinfo->chain = NULL;
|
||||
*psinfo = (PTR) sinfo;
|
||||
sinfo->htab =
|
||||
sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS));
|
||||
if (sinfo->htab == NULL)
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
/* Read the section from abfd. */
|
||||
|
||||
amt = sizeof (struct sec_merge_sec_info) + sec->_raw_size - 1;
|
||||
*psecinfo = bfd_alloc (abfd, amt);
|
||||
if (*psecinfo == NULL)
|
||||
goto error_return;
|
||||
|
||||
secinfo = (struct sec_merge_sec_info *)*psecinfo;
|
||||
if (sinfo->chain)
|
||||
{
|
||||
secinfo->next = sinfo->chain->next;
|
||||
sinfo->chain->next = secinfo;
|
||||
}
|
||||
else
|
||||
secinfo->next = secinfo;
|
||||
sinfo->chain = secinfo;
|
||||
secinfo->sec = sec;
|
||||
secinfo->psecinfo = psecinfo;
|
||||
secinfo->htab = sinfo->htab;
|
||||
secinfo->first = NULL;
|
||||
|
||||
if (! bfd_get_section_contents (sec->owner, sec, secinfo->contents,
|
||||
(bfd_vma) 0, sec->_raw_size))
|
||||
goto error_return;
|
||||
|
||||
return true;
|
||||
|
||||
error_return:
|
||||
*psecinfo = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Compare two sec_merge_hash_entry structures. This is called via qsort. */
|
||||
|
||||
static int
|
||||
cmplengthentry (a, b)
|
||||
const PTR a;
|
||||
const PTR b;
|
||||
{
|
||||
struct sec_merge_hash_entry * A = *(struct sec_merge_hash_entry **) a;
|
||||
struct sec_merge_hash_entry * B = *(struct sec_merge_hash_entry **) b;
|
||||
|
||||
if (A->len < B->len)
|
||||
return 1;
|
||||
else if (A->len > B->len)
|
||||
return -1;
|
||||
|
||||
return memcmp (A->root.string, B->root.string, A->len);
|
||||
}
|
||||
|
||||
static int
|
||||
last4_eq (a, b)
|
||||
const PTR a;
|
||||
const PTR b;
|
||||
{
|
||||
struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
|
||||
struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
|
||||
|
||||
if (memcmp (A->root.string + A->len - 5 * A->u.entsize,
|
||||
B->root.string + B->len - 5 * A->u.entsize,
|
||||
4 * A->u.entsize) != 0)
|
||||
/* This was a hashtable collision. */
|
||||
return 0;
|
||||
|
||||
if (A->len <= B->len)
|
||||
/* B cannot be a suffix of A unless A is equal to B, which is guaranteed
|
||||
not to be equal by the hash table. */
|
||||
return 0;
|
||||
|
||||
if (A->alignment < B->alignment
|
||||
|| ((A->len - B->len) & (B->alignment - 1)))
|
||||
/* The suffix is not sufficiently aligned. */
|
||||
return 0;
|
||||
|
||||
return memcmp (A->root.string + (A->len - B->len),
|
||||
B->root.string, B->len - 5 * A->u.entsize) == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
last_eq (a, b)
|
||||
const PTR a;
|
||||
const PTR b;
|
||||
{
|
||||
struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
|
||||
struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
|
||||
|
||||
if (B->len >= 5 * A->u.entsize)
|
||||
/* Longer strings are just pushed into the hash table,
|
||||
they'll be used when looking up for very short strings. */
|
||||
return 0;
|
||||
|
||||
if (memcmp (A->root.string + A->len - 2 * A->u.entsize,
|
||||
B->root.string + B->len - 2 * A->u.entsize,
|
||||
A->u.entsize) != 0)
|
||||
/* This was a hashtable collision. */
|
||||
return 0;
|
||||
|
||||
if (A->len <= B->len)
|
||||
/* B cannot be a suffix of A unless A is equal to B, which is guaranteed
|
||||
not to be equal by the hash table. */
|
||||
return 0;
|
||||
|
||||
if (A->alignment < B->alignment
|
||||
|| ((A->len - B->len) & (B->alignment - 1)))
|
||||
/* The suffix is not sufficiently aligned. */
|
||||
return 0;
|
||||
|
||||
return memcmp (A->root.string + (A->len - B->len),
|
||||
B->root.string, B->len - 2 * A->u.entsize) == 0;
|
||||
}
|
||||
|
||||
/* Record one section into the hash table. */
|
||||
static boolean
|
||||
record_section (sinfo, secinfo)
|
||||
struct sec_merge_info *sinfo;
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
{
|
||||
asection *sec = secinfo->sec;
|
||||
struct sec_merge_hash_entry *entry;
|
||||
boolean nul;
|
||||
unsigned char *p, *end;
|
||||
bfd_vma mask, eltalign;
|
||||
unsigned int align, i;
|
||||
|
||||
align = bfd_get_section_alignment (sec->owner, sec);
|
||||
end = secinfo->contents + sec->_raw_size;
|
||||
nul = false;
|
||||
mask = ((bfd_vma) 1 << align) - 1;
|
||||
if (sec->flags & SEC_STRINGS)
|
||||
{
|
||||
for (p = secinfo->contents; p < end; )
|
||||
{
|
||||
eltalign = p - secinfo->contents;
|
||||
eltalign = ((eltalign ^ (eltalign - 1)) + 1) >> 1;
|
||||
if (!eltalign || eltalign > mask)
|
||||
eltalign = mask + 1;
|
||||
entry = sec_merge_add (sinfo->htab, p, (unsigned) eltalign, secinfo);
|
||||
if (! entry)
|
||||
goto error_return;
|
||||
p += entry->len;
|
||||
if (sec->entsize == 1)
|
||||
{
|
||||
while (p < end && *p == 0)
|
||||
{
|
||||
if (!nul && !((p - secinfo->contents) & mask))
|
||||
{
|
||||
nul = true;
|
||||
entry = sec_merge_add (sinfo->htab, "",
|
||||
(unsigned) mask + 1, secinfo);
|
||||
if (! entry)
|
||||
goto error_return;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (p < end)
|
||||
{
|
||||
for (i = 0; i < sec->entsize; i++)
|
||||
if (p[i] != '\0')
|
||||
break;
|
||||
if (i != sec->entsize)
|
||||
break;
|
||||
if (!nul && !((p - secinfo->contents) & mask))
|
||||
{
|
||||
nul = true;
|
||||
entry = sec_merge_add (sinfo->htab, p,
|
||||
(unsigned) mask + 1, secinfo);
|
||||
if (! entry)
|
||||
goto error_return;
|
||||
}
|
||||
p += sec->entsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (p = secinfo->contents; p < end; p += sec->entsize)
|
||||
{
|
||||
entry = sec_merge_add (sinfo->htab, p, 1, secinfo);
|
||||
if (! entry)
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error_return:
|
||||
for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
|
||||
*secinfo->psecinfo = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This is a helper function for _bfd_merge_sections. It attempts to
|
||||
merge strings matching suffixes of longer strings. */
|
||||
static void
|
||||
merge_strings (sinfo)
|
||||
struct sec_merge_info *sinfo;
|
||||
{
|
||||
struct sec_merge_hash_entry **array, **a, **end, *e;
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
htab_t lasttab = NULL, last4tab = NULL;
|
||||
bfd_size_type size, amt;
|
||||
|
||||
/* Now sort the strings by length, longest first. */
|
||||
array = NULL;
|
||||
amt = sinfo->htab->size * sizeof (struct sec_merge_hash_entry *);
|
||||
array = (struct sec_merge_hash_entry **) bfd_malloc (amt);
|
||||
if (array == NULL)
|
||||
goto alloc_failure;
|
||||
|
||||
for (e = sinfo->htab->first, a = array; e; e = e->next)
|
||||
if (e->alignment)
|
||||
*a++ = e;
|
||||
|
||||
sinfo->htab->size = a - array;
|
||||
|
||||
qsort (array, (size_t) sinfo->htab->size,
|
||||
sizeof (struct sec_merge_hash_entry *), cmplengthentry);
|
||||
|
||||
last4tab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last4_eq, NULL);
|
||||
lasttab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last_eq, NULL);
|
||||
if (lasttab == NULL || last4tab == NULL)
|
||||
goto alloc_failure;
|
||||
|
||||
/* Now insert the strings into hash tables (strings with last 4 characters
|
||||
and strings with last character equal), look for longer strings which
|
||||
we're suffix of. */
|
||||
for (a = array, end = array + sinfo->htab->size; a < end; a++)
|
||||
{
|
||||
register hashval_t hash;
|
||||
unsigned int c;
|
||||
unsigned int i;
|
||||
const unsigned char *s;
|
||||
PTR *p;
|
||||
|
||||
e = *a;
|
||||
e->u.entsize = sinfo->htab->entsize;
|
||||
if (e->len <= e->u.entsize)
|
||||
break;
|
||||
if (e->len > 4 * e->u.entsize)
|
||||
{
|
||||
s = e->root.string + e->len - e->u.entsize;
|
||||
hash = 0;
|
||||
for (i = 0; i < 4 * e->u.entsize; i++)
|
||||
{
|
||||
c = *--s;
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
}
|
||||
p = htab_find_slot_with_hash (last4tab, e, hash, INSERT);
|
||||
if (p == NULL)
|
||||
goto alloc_failure;
|
||||
if (*p)
|
||||
{
|
||||
struct sec_merge_hash_entry *ent;
|
||||
|
||||
ent = (struct sec_merge_hash_entry *) *p;
|
||||
e->u.suffix = ent;
|
||||
e->alignment = 0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
*p = (PTR) e;
|
||||
}
|
||||
s = e->root.string + e->len - e->u.entsize;
|
||||
hash = 0;
|
||||
for (i = 0; i < e->u.entsize; i++)
|
||||
{
|
||||
c = *--s;
|
||||
hash += c + (c << 17);
|
||||
hash ^= hash >> 2;
|
||||
}
|
||||
p = htab_find_slot_with_hash (lasttab, e, hash, INSERT);
|
||||
if (p == NULL)
|
||||
goto alloc_failure;
|
||||
if (*p)
|
||||
{
|
||||
struct sec_merge_hash_entry *ent;
|
||||
|
||||
ent = (struct sec_merge_hash_entry *) *p;
|
||||
e->u.suffix = ent;
|
||||
e->alignment = 0;
|
||||
}
|
||||
else
|
||||
*p = (PTR) e;
|
||||
}
|
||||
|
||||
alloc_failure:
|
||||
if (array)
|
||||
free (array);
|
||||
if (lasttab)
|
||||
htab_delete (lasttab);
|
||||
if (last4tab)
|
||||
htab_delete (last4tab);
|
||||
|
||||
/* Now assign positions to the strings we want to keep. */
|
||||
size = 0;
|
||||
secinfo = sinfo->htab->first->secinfo;
|
||||
for (e = sinfo->htab->first; e; e = e->next)
|
||||
{
|
||||
if (e->secinfo != secinfo)
|
||||
{
|
||||
secinfo->sec->_cooked_size = size;
|
||||
secinfo = e->secinfo;
|
||||
}
|
||||
if (e->alignment)
|
||||
{
|
||||
if (e->secinfo->first == NULL)
|
||||
{
|
||||
e->secinfo->first = e;
|
||||
size = 0;
|
||||
}
|
||||
size = (size + e->alignment - 1) & ~((bfd_vma) e->alignment - 1);
|
||||
e->u.index = size;
|
||||
size += e->len;
|
||||
}
|
||||
}
|
||||
secinfo->sec->_cooked_size = size;
|
||||
|
||||
/* And now adjust the rest, removing them from the chain (but not hashtable)
|
||||
at the same time. */
|
||||
for (a = &sinfo->htab->first, e = *a; e; e = e->next)
|
||||
if (e->alignment)
|
||||
a = &e->next;
|
||||
else
|
||||
{
|
||||
*a = e->next;
|
||||
if (e->len)
|
||||
{
|
||||
e->secinfo = e->u.suffix->secinfo;
|
||||
e->alignment = e->u.suffix->alignment;
|
||||
e->u.index = e->u.suffix->u.index + (e->u.suffix->len - e->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is called once after all SEC_MERGE sections are registered
|
||||
with _bfd_merge_section. */
|
||||
|
||||
boolean
|
||||
_bfd_merge_sections (abfd, xsinfo, remove_hook)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
PTR xsinfo;
|
||||
void (*remove_hook) PARAMS((bfd *, asection *));
|
||||
{
|
||||
struct sec_merge_info *sinfo;
|
||||
|
||||
for (sinfo = (struct sec_merge_info *) xsinfo; sinfo; sinfo = sinfo->next)
|
||||
{
|
||||
struct sec_merge_sec_info * secinfo;
|
||||
|
||||
if (! sinfo->chain)
|
||||
continue;
|
||||
|
||||
/* Move sinfo->chain to head of the chain, terminate it. */
|
||||
secinfo = sinfo->chain;
|
||||
sinfo->chain = secinfo->next;
|
||||
secinfo->next = NULL;
|
||||
|
||||
/* Record the sections into the hash table. */
|
||||
for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
|
||||
if (secinfo->sec->flags & SEC_EXCLUDE)
|
||||
{
|
||||
*secinfo->psecinfo = NULL;
|
||||
if (remove_hook)
|
||||
(*remove_hook) (abfd, secinfo->sec);
|
||||
}
|
||||
else if (! record_section (sinfo, secinfo))
|
||||
break;
|
||||
|
||||
if (secinfo)
|
||||
continue;
|
||||
|
||||
if (sinfo->htab->first == NULL)
|
||||
continue;
|
||||
|
||||
if (sinfo->htab->strings)
|
||||
merge_strings (sinfo);
|
||||
else
|
||||
{
|
||||
struct sec_merge_hash_entry *e;
|
||||
bfd_size_type size = 0;
|
||||
|
||||
/* Things are much simpler for non-strings.
|
||||
Just assign them slots in the section. */
|
||||
secinfo = NULL;
|
||||
for (e = sinfo->htab->first; e; e = e->next)
|
||||
{
|
||||
if (e->secinfo->first == NULL)
|
||||
{
|
||||
if (secinfo)
|
||||
secinfo->sec->_cooked_size = size;
|
||||
e->secinfo->first = e;
|
||||
size = 0;
|
||||
}
|
||||
size = (size + e->alignment - 1)
|
||||
& ~((bfd_vma) e->alignment - 1);
|
||||
e->u.index = size;
|
||||
size += e->len;
|
||||
secinfo = e->secinfo;
|
||||
}
|
||||
secinfo->sec->_cooked_size = size;
|
||||
}
|
||||
|
||||
/* Finally shrink all input sections which have not made it into
|
||||
the hash table at all. */
|
||||
for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
|
||||
if (secinfo->first == NULL)
|
||||
{
|
||||
secinfo->sec->_cooked_size = 0;
|
||||
secinfo->sec->flags |= SEC_EXCLUDE;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write out the merged section. */
|
||||
|
||||
boolean
|
||||
_bfd_write_merged_section (output_bfd, sec, psecinfo)
|
||||
bfd *output_bfd;
|
||||
asection *sec;
|
||||
PTR psecinfo;
|
||||
{
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
file_ptr pos;
|
||||
|
||||
secinfo = (struct sec_merge_sec_info *) psecinfo;
|
||||
|
||||
if (!secinfo->first)
|
||||
return true;
|
||||
|
||||
pos = sec->output_section->filepos + sec->output_offset;
|
||||
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0)
|
||||
return false;
|
||||
|
||||
if (! sec_merge_emit (output_bfd, secinfo->first))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Adjust an address in the SEC_MERGE section. Given OFFSET within
|
||||
*PSEC, this returns the new offset in the adjusted SEC_MERGE
|
||||
section and writes the new section back into *PSEC. */
|
||||
|
||||
bfd_vma
|
||||
_bfd_merged_section_offset (output_bfd, psec, psecinfo, offset, addend)
|
||||
bfd *output_bfd ATTRIBUTE_UNUSED;
|
||||
asection **psec;
|
||||
PTR psecinfo;
|
||||
bfd_vma offset, addend;
|
||||
{
|
||||
struct sec_merge_sec_info *secinfo;
|
||||
struct sec_merge_hash_entry *entry;
|
||||
unsigned char *p;
|
||||
asection *sec = *psec;
|
||||
|
||||
secinfo = (struct sec_merge_sec_info *) psecinfo;
|
||||
|
||||
if (offset + addend >= sec->_raw_size)
|
||||
{
|
||||
if (offset + addend > sec->_raw_size)
|
||||
{
|
||||
(*_bfd_error_handler)
|
||||
(_("%s: access beyond end of merged section (%ld + %ld)"),
|
||||
bfd_get_filename (sec->owner), (long) offset, (long) addend);
|
||||
}
|
||||
return (secinfo->first ? sec->_cooked_size : 0);
|
||||
}
|
||||
|
||||
if (secinfo->htab->strings)
|
||||
{
|
||||
if (sec->entsize == 1)
|
||||
{
|
||||
p = secinfo->contents + offset + addend - 1;
|
||||
while (*p && p >= secinfo->contents)
|
||||
--p;
|
||||
++p;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = secinfo->contents
|
||||
+ ((offset + addend) / sec->entsize) * sec->entsize;
|
||||
p -= sec->entsize;
|
||||
while (p >= secinfo->contents)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < sec->entsize; ++i)
|
||||
if (p[i] != '\0')
|
||||
break;
|
||||
if (i == sec->entsize)
|
||||
break;
|
||||
p -= sec->entsize;
|
||||
}
|
||||
p += sec->entsize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = secinfo->contents
|
||||
+ ((offset + addend) / sec->entsize) * sec->entsize;
|
||||
}
|
||||
entry = sec_merge_hash_lookup (secinfo->htab, p, 0, false);
|
||||
if (!entry)
|
||||
{
|
||||
if (! secinfo->htab->strings)
|
||||
abort ();
|
||||
/* This should only happen if somebody points into the padding
|
||||
after a NUL character but before next entity. */
|
||||
if (*p)
|
||||
abort ();
|
||||
if (! secinfo->htab->first)
|
||||
abort ();
|
||||
entry = secinfo->htab->first;
|
||||
p = secinfo->contents
|
||||
+ ((offset + addend) / sec->entsize + 1) * sec->entsize
|
||||
- entry->len;
|
||||
}
|
||||
|
||||
*psec = entry->secinfo->sec;
|
||||
return entry->u.index + (secinfo->contents + offset - p);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,195 +0,0 @@
|
||||
/* Common definitions for backends based on IBM RS/6000 "XCOFF64" files.
|
||||
Copyright 2000, 2001
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Internalcoff.h and coffcode.h modify themselves based on this flag. */
|
||||
#define RS6000COFF_C 1
|
||||
|
||||
#define SELECT_RELOC(internal, howto) \
|
||||
{ \
|
||||
internal.r_type = howto->type; \
|
||||
internal.r_size = \
|
||||
((howto->complain_on_overflow == complain_overflow_signed \
|
||||
? 0x80 \
|
||||
: 0) \
|
||||
| (howto->bitsize - 1)); \
|
||||
}
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
|
||||
|
||||
#define COFF_LONG_FILENAMES
|
||||
|
||||
#define NO_COFF_SYMBOLS
|
||||
|
||||
#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
|
||||
|
||||
#define coff_mkobject _bfd_xcoff_mkobject
|
||||
#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
|
||||
#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
|
||||
#define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
|
||||
#define coff_relocate_section _bfd_ppc_xcoff_relocate_section
|
||||
|
||||
#define CORE_FILE_P _bfd_dummy_target
|
||||
|
||||
#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
|
||||
#define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
|
||||
#define coff_core_file_matches_executable_p \
|
||||
_bfd_nocore_core_file_matches_executable_p
|
||||
|
||||
#ifdef AIX_CORE
|
||||
#undef CORE_FILE_P
|
||||
#define CORE_FILE_P rs6000coff_core_p
|
||||
extern const bfd_target * rs6000coff_core_p ();
|
||||
extern boolean rs6000coff_core_file_matches_executable_p ();
|
||||
|
||||
#undef coff_core_file_matches_executable_p
|
||||
#define coff_core_file_matches_executable_p \
|
||||
rs6000coff_core_file_matches_executable_p
|
||||
|
||||
extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
|
||||
#undef coff_core_file_failing_command
|
||||
#define coff_core_file_failing_command rs6000coff_core_file_failing_command
|
||||
|
||||
extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
|
||||
#undef coff_core_file_failing_signal
|
||||
#define coff_core_file_failing_signal rs6000coff_core_file_failing_signal
|
||||
#endif /* AIX_CORE */
|
||||
|
||||
#ifdef LYNX_CORE
|
||||
|
||||
#undef CORE_FILE_P
|
||||
#define CORE_FILE_P lynx_core_file_p
|
||||
extern const bfd_target *lynx_core_file_p PARAMS ((bfd *abfd));
|
||||
|
||||
extern boolean lynx_core_file_matches_executable_p PARAMS ((bfd *core_bfd,
|
||||
bfd *exec_bfd));
|
||||
#undef coff_core_file_matches_executable_p
|
||||
#define coff_core_file_matches_executable_p lynx_core_file_matches_executable_p
|
||||
|
||||
extern char *lynx_core_file_failing_command PARAMS ((bfd *abfd));
|
||||
#undef coff_core_file_failing_command
|
||||
#define coff_core_file_failing_command lynx_core_file_failing_command
|
||||
|
||||
extern int lynx_core_file_failing_signal PARAMS ((bfd *abfd));
|
||||
#undef coff_core_file_failing_signal
|
||||
#define coff_core_file_failing_signal lynx_core_file_failing_signal
|
||||
|
||||
#endif /* LYNX_CORE */
|
||||
|
||||
#define _bfd_xcoff_bfd_get_relocated_section_contents \
|
||||
coff_bfd_get_relocated_section_contents
|
||||
#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
|
||||
#define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections
|
||||
#define _bfd_xcoff_bfd_merge_sections coff_bfd_merge_sections
|
||||
#define _bfd_xcoff_bfd_link_split_section coff_bfd_link_split_section
|
||||
|
||||
/* XCOFF archives do not have anything which corresponds to an
|
||||
extended name table. */
|
||||
|
||||
#define _bfd_xcoff_slurp_extended_name_table bfd_false
|
||||
#define _bfd_xcoff_construct_extended_name_table \
|
||||
((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
|
||||
bfd_false)
|
||||
#define _bfd_xcoff_truncate_arname bfd_dont_truncate_arname
|
||||
|
||||
/* We can use the standard get_elt_at_index routine. */
|
||||
|
||||
#define _bfd_xcoff_get_elt_at_index _bfd_generic_get_elt_at_index
|
||||
|
||||
/* XCOFF archives do not have a timestamp. */
|
||||
|
||||
#define _bfd_xcoff_update_armap_timestamp bfd_true
|
||||
|
||||
extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
|
||||
extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
|
||||
extern void _bfd_xcoff_rtype2howto
|
||||
PARAMS ((arelent *, struct internal_reloc *));
|
||||
extern reloc_howto_type *_bfd_xcoff_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
|
||||
extern const bfd_target *_bfd_xcoff_archive_p PARAMS ((bfd *));
|
||||
extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
|
||||
extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
|
||||
extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
|
||||
extern boolean _bfd_xcoff_write_armap
|
||||
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
|
||||
extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
|
||||
extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
|
||||
extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
|
||||
extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||
|
||||
#ifndef coff_SWAP_sym_in
|
||||
#define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
|
||||
#define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
|
||||
#define coff_SWAP_aux_in _bfd_xcoff_swap_aux_in
|
||||
#define coff_SWAP_aux_out _bfd_xcoff_swap_aux_out
|
||||
#endif
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
/* The transfer vector that leads the outside world to all of the above. */
|
||||
|
||||
const bfd_target TARGET_SYM =
|
||||
{
|
||||
TARGET_NAME,
|
||||
bfd_target_xcoff_flavour,
|
||||
BFD_ENDIAN_BIG, /* data byte order is big */
|
||||
BFD_ENDIAN_BIG, /* header byte order is big */
|
||||
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG | DYNAMIC |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen??? FIXMEmgo */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
|
||||
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
|
||||
_bfd_xcoff_archive_p, CORE_FILE_P},
|
||||
{bfd_false, coff_mkobject, /* bfd_set_format */
|
||||
_bfd_generic_mkarchive, bfd_false},
|
||||
{bfd_false, coff_write_object_contents, /* bfd_write_contents */
|
||||
_bfd_xcoff_write_archive_contents, bfd_false},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (coff),
|
||||
BFD_JUMP_TABLE_COPY (coff),
|
||||
BFD_JUMP_TABLE_CORE (coff),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_xcoff),
|
||||
BFD_JUMP_TABLE_SYMBOLS (coff),
|
||||
BFD_JUMP_TABLE_RELOCS (coff),
|
||||
BFD_JUMP_TABLE_WRITE (coff),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_xcoff),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_xcoff),
|
||||
|
||||
NULL,
|
||||
|
||||
COFF_SWAP_TABLE
|
||||
};
|
||||
@@ -1,165 +0,0 @@
|
||||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = cygnus
|
||||
|
||||
# What version of the manual you want; "all" includes everything
|
||||
CONFIG=all
|
||||
|
||||
# Options to extract the man page from as.texinfo
|
||||
MANCONF = -Dman
|
||||
|
||||
TEXI2POD = perl $(top_srcdir)/../etc/texi2pod.pl
|
||||
|
||||
POD2MAN = pod2man --center="GNU Development Tools" \
|
||||
--release="binutils-$(VERSION)" --section=1
|
||||
|
||||
# List of man pages generated from binutils.texi
|
||||
man_MANS = \
|
||||
addr2line.1 \
|
||||
ar.1 \
|
||||
dlltool.1 \
|
||||
nlmconv.1 \
|
||||
nm.1 \
|
||||
objcopy.1 \
|
||||
objdump.1 \
|
||||
ranlib.1 \
|
||||
readelf.1 \
|
||||
size.1 \
|
||||
strings.1 \
|
||||
strip.1 \
|
||||
windres.1 \
|
||||
$(DEMANGLER_NAME).1
|
||||
|
||||
info_TEXINFOS = binutils.texi
|
||||
|
||||
config.texi: Makefile
|
||||
rm -f config.texi
|
||||
echo '@set VERSION $(VERSION)' > config.texi
|
||||
|
||||
binutils_TEXI = $(srcdir)/binutils.texi
|
||||
|
||||
binutils.dvi: $(binutils_TEXI) config.texi
|
||||
|
||||
binutils.info: $(binutils_TEXI) config.texi
|
||||
|
||||
# Man page generation from texinfo
|
||||
addr2line.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Daddr2line < $< > addr2line.pod
|
||||
-($(POD2MAN) addr2line.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f addr2line.pod
|
||||
|
||||
ar.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dar < $< > ar.pod
|
||||
-($(POD2MAN) ar.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f ar.pod
|
||||
|
||||
dlltool.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Ddlltool < $< > dlltool.pod
|
||||
-($(POD2MAN) dlltool.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f dlltool.pod
|
||||
|
||||
nlmconv.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dnlmconv < $< > nlmconv.pod
|
||||
-($(POD2MAN) nlmconv.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f nlmconv.pod
|
||||
|
||||
nm.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dnm < $< > nm.pod
|
||||
-($(POD2MAN) nm.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f nm.pod
|
||||
|
||||
objcopy.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dobjcopy < $< > objcopy.pod
|
||||
-($(POD2MAN) objcopy.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f objcopy.pod
|
||||
|
||||
objdump.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dobjdump < $< > objdump.pod
|
||||
-($(POD2MAN) objdump.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f objdump.pod
|
||||
|
||||
ranlib.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dranlib < $< > ranlib.pod
|
||||
-($(POD2MAN) ranlib.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f ranlib.pod
|
||||
|
||||
readelf.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dreadelf < $< > readelf.pod
|
||||
-($(POD2MAN) readelf.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f readelf.pod
|
||||
|
||||
size.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dsize < $< > size.pod
|
||||
-($(POD2MAN) size.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f size.pod
|
||||
|
||||
strings.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dstrings < $< > strings.pod
|
||||
-($(POD2MAN) strings.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f strings.pod
|
||||
|
||||
strip.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dstrip < $< > strip.pod
|
||||
-($(POD2MAN) strip.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f strip.pod
|
||||
|
||||
windres.1: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dwindres < $< > windres.pod
|
||||
-($(POD2MAN) windres.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f windres.pod
|
||||
|
||||
cxxfilt.man: $(binutils_TEXI)
|
||||
touch $@
|
||||
-$(TEXI2POD) $(MANCONF) -Dcxxfilt < $< > $(DEMANGLER_NAME).pod
|
||||
-($(POD2MAN) $(DEMANGLER_NAME).pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
|
||||
mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
|
||||
rm -f $(DEMANGLER_NAME).pod
|
||||
|
||||
MAINTAINERCLEANFILES = config.texi
|
||||
DISTCLEANFILES = config.texi
|
||||
MOSTLYCLEANFILES = $(DEMANGLER_NAME).1
|
||||
|
||||
$(DEMANGLER_NAME).1: cxxfilt.man Makefile
|
||||
if test -f cxxfilt.man; then \
|
||||
man=cxxfilt.man; \
|
||||
else \
|
||||
man=$(srcdir)/cxxfilt.man; \
|
||||
fi; \
|
||||
sed -e 's/@PROGRAM@/$(DEMANGLER_NAME)/' \
|
||||
-e 's/cxxfilt/$(DEMANGLER_NAME)/' < $$man \
|
||||
> $(DEMANGLER_NAME).1
|
||||
|
||||
# We want install to imply install-info as per GNU standards, despite the
|
||||
# cygnus option.
|
||||
install: install-info
|
||||
|
||||
# Maintenance
|
||||
|
||||
# We need it for the taz target in ../../Makefile.in.
|
||||
info: $(MANS)
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,396 +0,0 @@
|
||||
@c Copyright 2002
|
||||
@c Free Software Foundation, Inc.
|
||||
@c This is part of the GAS manual.
|
||||
@c For copying conditions, see the file as.texinfo.
|
||||
|
||||
@ifset GENERIC
|
||||
@page
|
||||
@node Alpha-Dependent
|
||||
@chapter Alpha Dependent Features
|
||||
@end ifset
|
||||
|
||||
@ifclear GENERIC
|
||||
@node Machine Dependencies
|
||||
@chapter Alpha Dependent Features
|
||||
@end ifclear
|
||||
|
||||
@cindex Alpha support
|
||||
@menu
|
||||
* Alpha Notes:: Notes
|
||||
* Alpha Options:: Options
|
||||
* Alpha Syntax:: Syntax
|
||||
* Alpha Floating Point:: Floating Point
|
||||
* Alpha Directives:: Alpha Machine Directives
|
||||
* Alpha Opcodes:: Opcodes
|
||||
@end menu
|
||||
|
||||
@node Alpha Notes
|
||||
@section Notes
|
||||
@cindex Alpha notes
|
||||
@cindex notes for Alpha
|
||||
|
||||
The documentation here is primarily for the ELF object format.
|
||||
@code{@value{AS}} also supports the ECOFF and EVAX formats, but
|
||||
features specific to these formats are not yet documented.
|
||||
|
||||
@node Alpha Options
|
||||
@section Options
|
||||
@cindex Alpha options
|
||||
@cindex options for Alpha
|
||||
|
||||
@table @option
|
||||
@cindex @code{-m@var{cpu}} command line option, Alpha
|
||||
@item -m@var{cpu}
|
||||
This option specifies the target processor. If an attempt is made to
|
||||
assemble an instruction which will not execute on the target processor,
|
||||
the assembler may either expand the instruction as a macro or issue an
|
||||
error message. This option is equivalent to the @code{.arch} directive.
|
||||
|
||||
The following processor names are recognized:
|
||||
@code{21064},
|
||||
@code{21064a},
|
||||
@code{21066},
|
||||
@code{21068},
|
||||
@code{21164},
|
||||
@code{21164a},
|
||||
@code{21164pc},
|
||||
@code{21264},
|
||||
@code{ev4},
|
||||
@code{ev5},
|
||||
@code{lca45},
|
||||
@code{ev5},
|
||||
@code{ev56},
|
||||
@code{pca56},
|
||||
@code{ev6}.
|
||||
The special name @code{all} may be used to allow the assembler to accept
|
||||
instructions valid for any Alpha processor.
|
||||
|
||||
In order to support existing practice in OSF/1 with respect to @code{.arch},
|
||||
and existing practice within @command{MILO} (the Linux ARC bootloader), the
|
||||
numbered processor names (e.g.@: 21064) enable the processor-specific PALcode
|
||||
instructions, while the ``electro-vlasic'' names (e.g.@: @code{ev4}) do not.
|
||||
|
||||
@cindex @code{-mdebug} command line option, Alpha
|
||||
@cindex @code{-no-mdebug} command line option, Alpha
|
||||
@item -mdebug
|
||||
@itemx -no-mdebug
|
||||
Enables or disables the generation of @code{.mdebug} encapsulation for
|
||||
stabs directives and procedure descriptors. The default is to automatically
|
||||
enable @code{.mdebug} when the first stabs directive is seen.
|
||||
|
||||
@cindex @code{-relax} command line option, Alpha
|
||||
@item -relax
|
||||
This option forces all relocations to be put into the object file, instead
|
||||
of saving space and resolving some relocations at assembly time. Note that
|
||||
this option does not propagate all symbol arithmetic into the object file,
|
||||
because not all symbol arithmetic can be represented. However, the option
|
||||
can still be useful in specific applications.
|
||||
|
||||
@cindex @code{-g} command line option, Alpha
|
||||
@item -g
|
||||
This option is used when the compiler generates debug information. When
|
||||
@command{gcc} is using @command{mips-tfile} to generate debug
|
||||
information for ECOFF, local labels must be passed through to the object
|
||||
file. Otherwise this option has no effect.
|
||||
|
||||
@cindex @code{-G} command line option, Alpha
|
||||
@item -G@var{size}
|
||||
A local common symbol larger than @var{size} is placed in @code{.bss},
|
||||
while smaller symbols are placed in @code{.sbss}.
|
||||
|
||||
@cindex @code{-F} command line option, Alpha
|
||||
@cindex @code{-32addr} command line option, Alpha
|
||||
@item -F
|
||||
@itemx -32addr
|
||||
These options are ignored for backward compatibility.
|
||||
@end table
|
||||
|
||||
@cindex Alpha Syntax
|
||||
@node Alpha Syntax
|
||||
@section Syntax
|
||||
The assembler syntax closely follow the Alpha Reference Manual;
|
||||
assembler directives and general syntax closely follow the OSF/1 and
|
||||
OpenVMS syntax, with a few differences for ELF.
|
||||
|
||||
@menu
|
||||
* Alpha-Chars:: Special Characters
|
||||
* Alpha-Regs:: Register Names
|
||||
* Alpha-Relocs:: Relocations
|
||||
@end menu
|
||||
|
||||
@node Alpha-Chars
|
||||
@subsection Special Characters
|
||||
|
||||
@cindex line comment character, Alpha
|
||||
@cindex Alpha line comment character
|
||||
@samp{#} is the line comment character.
|
||||
|
||||
@cindex line separator, Alpha
|
||||
@cindex statement separator, Alpha
|
||||
@cindex Alpha line separator
|
||||
@samp{;} can be used instead of a newline to separate statements.
|
||||
|
||||
@node Alpha-Regs
|
||||
@subsection Register Names
|
||||
@cindex Alpha registers
|
||||
@cindex register names, Alpha
|
||||
|
||||
The 32 integer registers are refered to as @samp{$@var{n}} or
|
||||
@samp{$r@var{n}}. In addition, registers 15, 28, 29, and 30 may
|
||||
be refered to by the symbols @samp{$fp}, @samp{$at}, @samp{$gp},
|
||||
and @samp{$sp} respectively.
|
||||
|
||||
The 32 floating-point registers are refered to as @samp{$f@var{n}}.
|
||||
|
||||
@node Alpha-Relocs
|
||||
@subsection Relocations
|
||||
@cindex Alpha relocations
|
||||
@cindex relocations, Alpha
|
||||
|
||||
Some of these relocations are available for ECOFF, but mostly
|
||||
only for ELF. They are modeled after the relocation format
|
||||
introduced in Digial Unix 4.0, but there are additions.
|
||||
|
||||
The format is @samp{!@var{tag}} or @samp{!@var{tag}!@var{number}}
|
||||
where @var{tag} is the name of the relocation. In some cases
|
||||
@var{number} is used to relate specific instructions.
|
||||
|
||||
The relocation is placed at the end of the instruction like so:
|
||||
|
||||
@example
|
||||
ldah $0,a($29) !gprelhigh
|
||||
lda $0,a($0) !gprellow
|
||||
ldq $1,b($29) !literal!100
|
||||
ldl $2,0($1) !lituse_base!100
|
||||
@end example
|
||||
|
||||
@table @code
|
||||
@item !literal
|
||||
@itemx !literal!@var{N}
|
||||
Used with an @code{ldq} instruction to load the address of a symbol
|
||||
from the GOT.
|
||||
|
||||
A sequence number @var{N} is optional, and if present is used to pair
|
||||
@code{lituse} relocations with this @code{literal} relocation. The
|
||||
@code{lituse} relocations are used by the linker to optimize the code
|
||||
based on the final location of the symbol.
|
||||
|
||||
Note that these optimizations are dependent on the data flow of the
|
||||
program. Therefore, if @emph{any} @code{lituse} is paired with a
|
||||
@code{literal} relocation, then @emph{all} uses of the register set by
|
||||
the @code{literal} instruction must also be marked with @code{lituse}
|
||||
relocations. This is because the original @code{literal} instruction
|
||||
may be deleted or transformed into another instruction.
|
||||
|
||||
Also note that there may be a one-to-many relationship between
|
||||
@code{literal} and @code{lituse}, but not a many-to-one. That is, if
|
||||
there are two code paths that load up the same address and feed the
|
||||
value to a single use, then the use may not use a @code{lituse}
|
||||
relocation.
|
||||
|
||||
@item !lituse_base!@var{N}
|
||||
Used with any memory format instruction (e.g.@: @code{ldl}) to indicate
|
||||
that the literal is used for an address load. The offset field of the
|
||||
instruction must be zero. During relaxation, the code may be altered
|
||||
to use a gp-relative load.
|
||||
|
||||
@item !lituse_jsr!@var{N}
|
||||
Used with a register branch format instruction (e.g.@: @code{jsr}) to
|
||||
indicate that the literal is used for a call. During relaxation, the
|
||||
code may be altered to use a direct branch (e.g.@: @code{bsr}).
|
||||
|
||||
@item !lituse_bytoff!@var{N}
|
||||
Used with a byte mask instruction (e.g.@: @code{extbl}) to indicate
|
||||
that only the low 3 bits of the address are relevant. During relaxation,
|
||||
the code may be altered to use an immediate instead of a register shift.
|
||||
|
||||
@item !lituse_addr!@var{N}
|
||||
Used with any other instruction to indicate that the original address
|
||||
is in fact used, and the original @code{ldq} instruction may not be
|
||||
altered or deleted. This is useful in conjunction with @code{lituse_jsr}
|
||||
to test whether a weak symbol is defined.
|
||||
|
||||
@example
|
||||
ldq $27,foo($29) !literal!1
|
||||
beq $27,is_undef !lituse_addr!1
|
||||
jsr $26,($27),foo !lituse_jsr!1
|
||||
@end example
|
||||
|
||||
@item !gpdisp!@var{N}
|
||||
Used with @code{ldah} and @code{lda} to load the GP from the current
|
||||
address, a-la the @code{ldgp} macro. The source register for the
|
||||
@code{ldah} instruction must contain the address of the @code{ldah}
|
||||
instruction. There must be exactly one @code{lda} instruction paired
|
||||
with the @code{ldah} instruction, though it may appear anywhere in
|
||||
the instruction stream. The immediate operands must be zero.
|
||||
|
||||
@example
|
||||
bsr $26,foo
|
||||
ldah $29,0($26) !gpdisp!1
|
||||
lda $29,0($29) !gpdisp!1
|
||||
@end example
|
||||
|
||||
@item !gprelhigh
|
||||
Used with an @code{ldah} instruction to add the high 16 bits of a
|
||||
32-bit displacement from the GP.
|
||||
|
||||
@item !gprellow
|
||||
Used with any memory format instruction to add the low 16 bits of a
|
||||
32-bit displacement from the GP.
|
||||
|
||||
@item !gprel
|
||||
Used with any memory format instruction to add a 16-bit displacement
|
||||
from the GP.
|
||||
|
||||
@item !samegp
|
||||
Used with any branch format instruction to skip the GP load at the
|
||||
target address. The referenced symbol must have the same GP as the
|
||||
source object file, and it must be declared to either not use @code{$27}
|
||||
or perform a standard GP load in the first two instructions via the
|
||||
@code{.prologue} directive.
|
||||
@end table
|
||||
|
||||
@node Alpha Floating Point
|
||||
@section Floating Point
|
||||
@cindex floating point, Alpha (@sc{ieee})
|
||||
@cindex Alpha floating point (@sc{ieee})
|
||||
The Alpha family uses both @sc{ieee} and VAX floating-point numbers.
|
||||
|
||||
@node Alpha Directives
|
||||
@section Alpha Assembler Directives
|
||||
|
||||
@command{@value{AS}} for the Alpha supports many additional directives for
|
||||
compatibility with the native assembler. This section describes them only
|
||||
briefly.
|
||||
|
||||
@cindex Alpha-only directives
|
||||
These are the additional directives in @code{@value{AS}} for the Alpha:
|
||||
|
||||
@table @code
|
||||
@item .arch @var{cpu}
|
||||
Specifies the target processor. This is equivalent to the
|
||||
@option{-m@var{cpu}} command-line option. @xref{Alpha Options, Options},
|
||||
for a list of values for @var{cpu}.
|
||||
|
||||
@item .ent @var{function}[, @var{n}]
|
||||
Mark the beginning of @var{function}. An optional number may follow for
|
||||
compatibility with the OSF/1 assembler, but is ignored. When generating
|
||||
@code{.mdebug} information, this will create a procedure descriptor for
|
||||
the function. In ELF, it will mark the symbol as a function a-la the
|
||||
generic @code{.type} directive.
|
||||
|
||||
@item .end @var{function}
|
||||
Mark the end of @var{function}. In ELF, it will set the size of the symbol
|
||||
a-la the generic @code{.size} directive.
|
||||
|
||||
@item .mask @var{mask}, @var{offset}
|
||||
Indicate which of the integer registers are saved in the current
|
||||
function's stack frame. @var{mask} is interpreted a bit mask in which
|
||||
bit @var{n} set indicates that register @var{n} is saved. The registers
|
||||
are saved in a block located @var{offset} bytes from the @dfn{canonical
|
||||
frame address} (CFA) which is the value of the stack pointer on entry to
|
||||
the function. The registers are saved sequentially, except that the
|
||||
return address register (normally @code{$26}) is saved first.
|
||||
|
||||
This and the other directives that describe the stack frame are
|
||||
currently only used when generating @code{.mdebug} information. They
|
||||
may in the future be used to generate DWARF2 @code{.debug_frame} unwind
|
||||
information for hand written assembly.
|
||||
|
||||
@item .fmask @var{mask}, @var{offset}
|
||||
Indicate which of the floating-point registers are saved in the current
|
||||
stack frame. The @var{mask} and @var{offset} parameters are interpreted
|
||||
as with @code{.mask}.
|
||||
|
||||
@item .frame @var{framereg}, @var{frameoffset}, @var{retreg}[, @var{argoffset}]
|
||||
Describes the shape of the stack frame. The frame pointer in use is
|
||||
@var{framereg}; normally this is either @code{$fp} or @code{$sp}. The
|
||||
frame pointer is @var{frameoffset} bytes below the CFA. The return
|
||||
address is initially located in @var{retreg} until it is saved as
|
||||
indicated in @code{.mask}. For compatibility with OSF/1 an optional
|
||||
@var{argoffset} parameter is accepted and ignored. It is believed to
|
||||
indicate the offset from the CFA to the saved argument registers.
|
||||
|
||||
@item .prologue @var{n}
|
||||
Indicate that the stack frame is set up and all registers have been
|
||||
spilled. The argument @var{n} indicates whether and how the function
|
||||
uses the incoming @dfn{procedure vector} (the address of the called
|
||||
function) in @code{$27}. 0 indicates that @code{$27} is not used; 1
|
||||
indicates that the first two instructions of the function use @code{$27}
|
||||
to perform a load of the GP register; 2 indicates that @code{$27} is
|
||||
used in some non-standard way and so the linker cannot elide the load of
|
||||
the procedure vector during relaxation.
|
||||
|
||||
@item .gprel32 @var{expression}
|
||||
Computes the difference between the address in @var{expression} and the
|
||||
GP for the current object file, and stores it in 4 bytes. In addition
|
||||
to being smaller than a full 8 byte address, this also does not require
|
||||
a dynamic relocation when used in a shared library.
|
||||
|
||||
@item .t_floating @var{expression}
|
||||
Stores @var{expression} as an @sc{ieee} double precision value.
|
||||
|
||||
@item .s_floating @var{expression}
|
||||
Stores @var{expression} as an @sc{ieee} single precision value.
|
||||
|
||||
@item .f_floating @var{expression}
|
||||
Stores @var{expression} as a VAX F format value.
|
||||
|
||||
@item .g_floating @var{expression}
|
||||
Stores @var{expression} as a VAX G format value.
|
||||
|
||||
@item .d_floating @var{expression}
|
||||
Stores @var{expression} as a VAX D format value.
|
||||
|
||||
@item .set @var{feature}
|
||||
Enables or disables various assembler features. Using the positive
|
||||
name of the feature enables while using @samp{no@var{feature}} disables.
|
||||
|
||||
@table @code
|
||||
@item at
|
||||
Indicates that macro expansions may clobber the @dfn{assembler
|
||||
temporary} (@code{$at} or @code{$28}) register. Some macros may not be
|
||||
expanded without this and will generate an error message if @code{noat}
|
||||
is in effect. When @code{at} is in effect, a warning will be generated
|
||||
if @code{$at} is used by the programmer.
|
||||
|
||||
@item macro
|
||||
Enables the expasion of macro instructions. Note that variants of real
|
||||
instructions, such as @code{br label} vs @code{br $31,label} are
|
||||
considered alternate forms and not macros.
|
||||
|
||||
@item move
|
||||
@itemx reorder
|
||||
@itemx volatile
|
||||
These control whether and how the assembler may re-order instructions.
|
||||
Accepted for compatibility with the OSF/1 assembler, but @command{@value{AS}}
|
||||
does not do instruction scheduling, so these features are ignored.
|
||||
@end table
|
||||
@end table
|
||||
|
||||
The following directives are recognized for compatibility with the OSF/1
|
||||
assembler but are ignored.
|
||||
|
||||
@example
|
||||
.proc .aproc
|
||||
.reguse .livereg
|
||||
.option .aent
|
||||
.ugen .eflag
|
||||
.alias .noalias
|
||||
@end example
|
||||
|
||||
@node Alpha Opcodes
|
||||
@section Opcodes
|
||||
For detailed information on the Alpha machine instruction set, see the
|
||||
@c Attempt to work around a very overfull hbox.
|
||||
@iftex
|
||||
Alpha Architecture Handbook located at
|
||||
@smallfonts
|
||||
@example
|
||||
ftp://ftp.digital.com/pub/Digital/info/semiconductor/literature/alphaahb.pdf
|
||||
@end example
|
||||
@textfonts
|
||||
@end iftex
|
||||
@ifnottex
|
||||
@uref{ftp://ftp.digital.com/pub/Digital/info/semiconductor/literature/alphaahb.pdf,Alpha Architecture Handbook}.
|
||||
@end ifnottex
|
||||
@@ -1,207 +0,0 @@
|
||||
@c Copyright 2000, 2001 Free Software Foundation, Inc.
|
||||
@c This is part of the GAS manual.
|
||||
@c For copying conditions, see the file as.texinfo.
|
||||
|
||||
@ifset GENERIC
|
||||
@page
|
||||
@node ARC-Dependent
|
||||
@chapter ARC Dependent Features
|
||||
@end ifset
|
||||
|
||||
@ifclear GENERIC
|
||||
@node Machine Dependencies
|
||||
@chapter ARC Dependent Features
|
||||
@end ifclear
|
||||
|
||||
@set ARC_CORE_DEFAULT 6
|
||||
|
||||
@cindex ARC support
|
||||
@menu
|
||||
* ARC Options:: Options
|
||||
* ARC Syntax:: Syntax
|
||||
* ARC Floating Point:: Floating Point
|
||||
* ARC Directives:: ARC Machine Directives
|
||||
* ARC Opcodes:: Opcodes
|
||||
@end menu
|
||||
|
||||
|
||||
@node ARC Options
|
||||
@section Options
|
||||
@cindex ARC options (none)
|
||||
@cindex options for ARC (none)
|
||||
|
||||
@table @code
|
||||
|
||||
@cindex @code{-marc[5|6|7|8]} command line option, ARC
|
||||
@item -marc[5|6|7|8]
|
||||
This option selects the core processor variant. Using
|
||||
@code{-marc} is the same as @code{-marc@value{ARC_CORE_DEFAULT}}, which
|
||||
is also the default.
|
||||
|
||||
@table @code
|
||||
|
||||
@cindex @code{arc5} arc5, ARC
|
||||
@item arc5
|
||||
Base instruction set.
|
||||
|
||||
@cindex @code{arc6} arc6, ARC
|
||||
@item arc6
|
||||
Jump-and-link (jl) instruction. No requirement of an instruction between
|
||||
setting flags and conditional jump. For example:
|
||||
|
||||
@smallexample
|
||||
mov.f r0,r1
|
||||
beq foo
|
||||
@end smallexample
|
||||
|
||||
@cindex @code{arc7} arc7, ARC
|
||||
@item arc7
|
||||
Break (brk) and sleep (sleep) instructions.
|
||||
|
||||
@cindex @code{arc8} arc8, ARC
|
||||
@item arc8
|
||||
Software interrupt (swi) instruction.
|
||||
|
||||
@end table
|
||||
|
||||
Note: the @code{.option} directive can to be used to select a core
|
||||
variant from within assembly code.
|
||||
|
||||
@cindex @code{-EB} command line option, ARC
|
||||
@item -EB
|
||||
This option specifies that the output generated by the assembler should
|
||||
be marked as being encoded for a big-endian processor.
|
||||
|
||||
@cindex @code{-EL} command line option, ARC
|
||||
@item -EL
|
||||
This option specifies that the output generated by the assembler should
|
||||
be marked as being encoded for a little-endian processor - this is the
|
||||
default.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node ARC Syntax
|
||||
@section Syntax
|
||||
@menu
|
||||
* ARC-Chars:: Special Characters
|
||||
* ARC-Regs:: Register Names
|
||||
@end menu
|
||||
|
||||
@node ARC-Chars
|
||||
@subsection Special Characters
|
||||
|
||||
@cindex ARC special characters
|
||||
@cindex special characters, ARC
|
||||
*TODO*
|
||||
|
||||
@node ARC-Regs
|
||||
@subsection Register Names
|
||||
|
||||
@cindex ARC register names
|
||||
@cindex register names, ARC
|
||||
*TODO*
|
||||
|
||||
|
||||
@node ARC Floating Point
|
||||
@section Floating Point
|
||||
|
||||
@cindex floating point, ARC (@sc{ieee})
|
||||
@cindex ARC floating point (@sc{ieee})
|
||||
The ARC core does not currently have hardware floating point
|
||||
support. Software floating point support is provided by @code{GCC}
|
||||
and uses @sc{ieee} floating-point numbers.
|
||||
|
||||
|
||||
@node ARC Directives
|
||||
@section ARC Machine Directives
|
||||
|
||||
@cindex machine directives, ARC
|
||||
@cindex ARC machine directives
|
||||
The ARC version of @code{@value{AS}} supports the following additional
|
||||
machine directives:
|
||||
|
||||
@table @code
|
||||
|
||||
@cindex @code{2byte} directive, ARC
|
||||
@item .2byte @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{3byte} directive, ARC
|
||||
@item .3byte @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{4byte} directive, ARC
|
||||
@item .4byte @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{extAuxRegister} directive, ARC
|
||||
@item .extAuxRegister @var{name},@var{address},@var{mode}
|
||||
*TODO*
|
||||
|
||||
@smallexample
|
||||
.extAuxRegister mulhi,0x12,w
|
||||
@end smallexample
|
||||
|
||||
@cindex @code{extCondCode} directive, ARC
|
||||
@item .extCondCode @var{suffix},@var{value}
|
||||
*TODO*
|
||||
|
||||
@smallexample
|
||||
.extCondCode is_busy,0x14
|
||||
@end smallexample
|
||||
|
||||
@cindex @code{extCoreRegister} directive, ARC
|
||||
@item .extCoreRegister @var{name},@var{regnum},@var{mode},@var{shortcut}
|
||||
*TODO*
|
||||
|
||||
@smallexample
|
||||
.extCoreRegister mlo,57,r,can_shortcut
|
||||
@end smallexample
|
||||
|
||||
@cindex @code{extInstruction} directive, ARC
|
||||
@item .extInstruction @var{name},@var{opcode},@var{subopcode},@var{suffixclass},@var{syntaxclass}
|
||||
*TODO*
|
||||
|
||||
@smallexample
|
||||
.extInstruction mul64,0x14,0x0,SUFFIX_COND,SYNTAX_3OP|OP1_MUST_BE_IMM
|
||||
@end smallexample
|
||||
|
||||
@cindex @code{half} directive, ARC
|
||||
@item .half @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{long} directive, ARC
|
||||
@item .long @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{option} directive, ARC
|
||||
@item .option @var{arc|arc5|arc6|arc7|arc8}
|
||||
The @code{.option} directive must be followed by the desired core
|
||||
version. Again @code{arc} is an alias for
|
||||
@code{arc@value{ARC_CORE_DEFAULT}}.
|
||||
|
||||
Note: the @code{.option} directive overrides the command line option
|
||||
@code{-marc}; a warning is emitted when the version is not consistent
|
||||
between the two - even for the implicit default core version
|
||||
(arc@value{ARC_CORE_DEFAULT}).
|
||||
|
||||
@cindex @code{short} directive, ARC
|
||||
@item .short @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@cindex @code{word} directive, ARC
|
||||
@item .word @var{expressions}
|
||||
*TODO*
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node ARC Opcodes
|
||||
@section Opcodes
|
||||
|
||||
@cindex ARC opcodes
|
||||
@cindex opcodes for ARC
|
||||
|
||||
For information on the ARC instruction set, see @cite{ARC Programmers
|
||||
Reference Manual}, ARC Cores Ltd.
|
||||
@@ -1,104 +0,0 @@
|
||||
@c Copyright 2001, 2002
|
||||
@c Free Software Foundation, Inc.
|
||||
@c This is part of the GAS manual.
|
||||
@c For copying conditions, see the file as.texinfo.
|
||||
@ifset GENERIC
|
||||
@page
|
||||
@node PPC-Dependent
|
||||
@chapter PowerPC Dependent Features
|
||||
@end ifset
|
||||
@ifclear GENERIC
|
||||
@node Machine Dependencies
|
||||
@chapter PowerPC Dependent Features
|
||||
@end ifclear
|
||||
|
||||
@cindex PowerPC support
|
||||
@menu
|
||||
* PowerPC-Opts:: Options
|
||||
@end menu
|
||||
|
||||
@node PowerPC-Opts
|
||||
@section Options
|
||||
|
||||
@cindex options for PowerPC
|
||||
@cindex PowerPC options
|
||||
@cindex architectures, PowerPC
|
||||
@cindex PowerPC architectures
|
||||
The PowerPC chip family includes several successive levels, using the same
|
||||
core instruction set, but including a few additional instructions at
|
||||
each level. There are exceptions to this however. For details on what
|
||||
instructions each variant supports, please see the chip's architecture
|
||||
reference manual.
|
||||
|
||||
The following table lists all available PowerPC options.
|
||||
|
||||
@table @code
|
||||
@item -mpwrx | -mpwr2
|
||||
Generate code for POWER/2 (RIOS2).
|
||||
|
||||
@item -mpwr
|
||||
Generate code for POWER (RIOS1)
|
||||
|
||||
@item -m601
|
||||
Generate code for PowerPC 601.
|
||||
|
||||
@item -mppc, -mppc32, -m603, -m604
|
||||
Generate code for PowerPC 603/604.
|
||||
|
||||
@item -m403, -m405
|
||||
Generate code for PowerPC 403/405.
|
||||
|
||||
@item -m7400, -m7410, -m7450, -m7455
|
||||
Generate code for PowerPC 7400/7410/7450/7455.
|
||||
|
||||
@item -mppc64, -m620
|
||||
Generate code for PowerPC 620/625/630.
|
||||
|
||||
@item -mppc64bridge
|
||||
Generate code for PowerPC 64, including bridge insns.
|
||||
|
||||
@item -mbooke64
|
||||
Generate code for 64-bit BookE.
|
||||
|
||||
@item -mbooke, mbooke32
|
||||
Generate code for 32-bit BookE.
|
||||
|
||||
@item -maltivec
|
||||
Generate code for processors with AltiVec instructions.
|
||||
|
||||
@item -mpower4
|
||||
Generate code for Power4 architecture.
|
||||
|
||||
@item -mcom
|
||||
Generate code Power/PowerPC common instructions.
|
||||
|
||||
@item -many
|
||||
Generate code for any architecture (PWR/PWRX/PPC).
|
||||
|
||||
@item -mregnames
|
||||
Allow symbolic names for registers.
|
||||
|
||||
@item -mno-regnames
|
||||
Do not allow symbolic names for registers.
|
||||
|
||||
@item -mrelocatable
|
||||
Support for GCC's -mrelocatble option.
|
||||
|
||||
@item -mrelocatable-lib
|
||||
Support for GCC's -mrelocatble-lib option.
|
||||
|
||||
@item -memb
|
||||
Set PPC_EMB bit in ELF flags.
|
||||
|
||||
@item -mlittle, -mlittle-endian
|
||||
Generate code for a little endian machine.
|
||||
|
||||
@item -mbig, -mbig-endian
|
||||
Generate code for a big endian machine.
|
||||
|
||||
@item -msolaris
|
||||
Generate code for Solaris.
|
||||
|
||||
@item -mno-solaris
|
||||
Do not generate code for Solaris.
|
||||
@end table
|
||||
@@ -1,254 +0,0 @@
|
||||
/* external.h -- External COFF structures
|
||||
|
||||
Copyright 2001 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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef COFF_EXTERNAL_H
|
||||
#define COFF_EXTERNAL_H
|
||||
|
||||
#ifndef DO_NOT_DEFINE_FILHDR
|
||||
/********************** FILE HEADER **********************/
|
||||
|
||||
struct external_filehdr
|
||||
{
|
||||
char f_magic[2]; /* magic number */
|
||||
char f_nscns[2]; /* number of sections */
|
||||
char f_timdat[4]; /* time & date stamp */
|
||||
char f_symptr[4]; /* file pointer to symtab */
|
||||
char f_nsyms[4]; /* number of symtab entries */
|
||||
char f_opthdr[2]; /* sizeof(optional hdr) */
|
||||
char f_flags[2]; /* flags */
|
||||
};
|
||||
|
||||
#define FILHDR struct external_filehdr
|
||||
#define FILHSZ 20
|
||||
#endif
|
||||
|
||||
#ifndef DO_NOT_DEFINE_AOUTHDR
|
||||
/********************** AOUT "OPTIONAL HEADER" **********************/
|
||||
|
||||
typedef struct external_aouthdr
|
||||
{
|
||||
char magic[2]; /* type of file */
|
||||
char vstamp[2]; /* version stamp */
|
||||
char tsize[4]; /* text size in bytes, padded to FW bdry*/
|
||||
char dsize[4]; /* initialized data " " */
|
||||
char bsize[4]; /* uninitialized data " " */
|
||||
char entry[4]; /* entry pt. */
|
||||
char text_start[4]; /* base of text used for this file */
|
||||
char data_start[4]; /* base of data used for this file */
|
||||
}
|
||||
AOUTHDR;
|
||||
|
||||
#define AOUTHDRSZ 28
|
||||
#define AOUTSZ 28
|
||||
#endif
|
||||
|
||||
#ifndef DO_NOT_DEFINE_SCNHDR
|
||||
/********************** SECTION HEADER **********************/
|
||||
|
||||
struct external_scnhdr
|
||||
{
|
||||
char s_name[8]; /* section name */
|
||||
char s_paddr[4]; /* physical address, aliased s_nlib */
|
||||
char s_vaddr[4]; /* virtual address */
|
||||
char s_size[4]; /* section size */
|
||||
char s_scnptr[4]; /* file ptr to raw data for section */
|
||||
char s_relptr[4]; /* file ptr to relocation */
|
||||
char s_lnnoptr[4]; /* file ptr to line numbers */
|
||||
char s_nreloc[2]; /* number of relocation entries */
|
||||
char s_nlnno[2]; /* number of line number entries */
|
||||
char s_flags[4]; /* flags */
|
||||
};
|
||||
|
||||
#define SCNHDR struct external_scnhdr
|
||||
#define SCNHSZ 40
|
||||
|
||||
/* Names of "special" sections. */
|
||||
|
||||
#define _TEXT ".text"
|
||||
#define _DATA ".data"
|
||||
#define _BSS ".bss"
|
||||
#define _COMMENT ".comment"
|
||||
#define _LIB ".lib"
|
||||
#endif /* not DO_NOT_DEFINE_SCNHDR */
|
||||
|
||||
#ifndef DO_NOT_DEFINE_LINENO
|
||||
|
||||
/********************** LINE NUMBERS **********************/
|
||||
|
||||
#ifndef L_LNNO_SIZE
|
||||
#error L_LNNO_SIZE needs to be defined
|
||||
#endif
|
||||
|
||||
/* 1 line number entry for every "breakpointable" source line in a section.
|
||||
Line numbers are grouped on a per function basis; first entry in a function
|
||||
grouping will have l_lnno = 0 and in place of physical address will be the
|
||||
symbol table index of the function name. */
|
||||
struct external_lineno
|
||||
{
|
||||
union
|
||||
{
|
||||
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
||||
char l_paddr[4]; /* (physical) address of line number */
|
||||
} l_addr;
|
||||
|
||||
char l_lnno[L_LNNO_SIZE]; /* line number */
|
||||
};
|
||||
|
||||
#define LINENO struct external_lineno
|
||||
#define LINESZ (4 + L_LNNO_SIZE)
|
||||
|
||||
#if L_LNNO_SIZE == 4
|
||||
#define GET_LINENO_LNNO(abfd, ext) H_GET_32 (abfd, (ext->l_lnno))
|
||||
#define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_32 (abfd, val, (ext->l_lnno))
|
||||
#endif
|
||||
#if L_LNNO_SIZE == 2
|
||||
#define GET_LINENO_LNNO(abfd, ext) H_GET_16 (abfd, (ext->l_lnno))
|
||||
#define PUT_LINENO_LNNO(abfd, val, ext) H_PUT_16 (abfd, val, (ext->l_lnno))
|
||||
#endif
|
||||
|
||||
#endif /* not DO_NOT_DEFINE_LINENO */
|
||||
|
||||
#ifndef DO_NOT_DEFINE_SYMENT
|
||||
/********************** SYMBOLS **********************/
|
||||
|
||||
#define E_SYMNMLEN 8 /* # characters in a symbol name */
|
||||
#ifndef E_FILNMLEN
|
||||
#define E_FILNMLEN 14
|
||||
#endif
|
||||
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
|
||||
|
||||
struct external_syment
|
||||
{
|
||||
union
|
||||
{
|
||||
char e_name[E_SYMNMLEN];
|
||||
|
||||
struct
|
||||
{
|
||||
char e_zeroes[4];
|
||||
char e_offset[4];
|
||||
} e;
|
||||
} e;
|
||||
|
||||
char e_value[4];
|
||||
char e_scnum[2];
|
||||
char e_type[2];
|
||||
char e_sclass[1];
|
||||
char e_numaux[1];
|
||||
};
|
||||
|
||||
#define SYMENT struct external_syment
|
||||
#define SYMESZ 18
|
||||
|
||||
#ifndef N_BTMASK
|
||||
#define N_BTMASK 0xf
|
||||
#endif
|
||||
|
||||
#ifndef N_TMASK
|
||||
#define N_TMASK 0x30
|
||||
#endif
|
||||
|
||||
#ifndef N_BTSHFT
|
||||
#define N_BTSHFT 4
|
||||
#endif
|
||||
|
||||
#ifndef N_TSHIFT
|
||||
#define N_TSHIFT 2
|
||||
#endif
|
||||
|
||||
#endif /* not DO_NOT_DEFINE_SYMENT */
|
||||
|
||||
#ifndef DO_NOT_DEFINE_AUXENT
|
||||
|
||||
union external_auxent
|
||||
{
|
||||
struct
|
||||
{
|
||||
char x_tagndx[4]; /* str, un, or enum tag indx */
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
char x_lnno[2]; /* declaration line number */
|
||||
char x_size[2]; /* str/union/array size */
|
||||
} x_lnsz;
|
||||
|
||||
char x_fsize[4]; /* size of function */
|
||||
|
||||
} x_misc;
|
||||
|
||||
union
|
||||
{
|
||||
struct /* if ISFCN, tag, or .bb */
|
||||
{
|
||||
char x_lnnoptr[4]; /* ptr to fcn line # */
|
||||
char x_endndx[4]; /* entry ndx past block end */
|
||||
} x_fcn;
|
||||
|
||||
struct /* if ISARY, up to 4 dimen. */
|
||||
{
|
||||
char x_dimen[E_DIMNUM][2];
|
||||
} x_ary;
|
||||
|
||||
} x_fcnary;
|
||||
|
||||
char x_tvndx[2]; /* tv index */
|
||||
|
||||
} x_sym;
|
||||
|
||||
union
|
||||
{
|
||||
char x_fname[E_FILNMLEN];
|
||||
|
||||
struct
|
||||
{
|
||||
char x_zeroes[4];
|
||||
char x_offset[4];
|
||||
} x_n;
|
||||
|
||||
} x_file;
|
||||
|
||||
struct
|
||||
{
|
||||
char x_scnlen[4]; /* section length */
|
||||
char x_nreloc[2]; /* # relocation entries */
|
||||
char x_nlinno[2]; /* # line numbers */
|
||||
#ifdef INCLUDE_COMDAT_FIELDS_IN_AUXENT
|
||||
char x_checksum[4]; /* section COMDAT checksum */
|
||||
char x_associated[2]; /* COMDAT associated section index */
|
||||
char x_comdat[1]; /* COMDAT selection number */
|
||||
#endif
|
||||
} x_scn;
|
||||
|
||||
struct
|
||||
{
|
||||
char x_tvfill[4]; /* tv fill value */
|
||||
char x_tvlen[2]; /* length of .tv */
|
||||
char x_tvran[2][2]; /* tv range */
|
||||
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
||||
};
|
||||
|
||||
#define AUXENT union external_auxent
|
||||
#define AUXESZ 18
|
||||
|
||||
#define _ETEXT "etext"
|
||||
|
||||
#endif /* not DO_NOT_DEFINE_AUXENT */
|
||||
|
||||
#endif /* COFF_EXTERNAL_H */
|
||||
@@ -1,96 +0,0 @@
|
||||
/* H8300/h8500 ELF support for BFD.
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF_H8_H
|
||||
#define _ELF_H8_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocations. */
|
||||
/* Relocations 59..63 are GNU extensions. */
|
||||
START_RELOC_NUMBERS (elf_h8_reloc_type)
|
||||
RELOC_NUMBER (R_H8_NONE, 0)
|
||||
RELOC_NUMBER (R_H8_DIR32, 1)
|
||||
RELOC_NUMBER (R_H8_DIR32_28, 2)
|
||||
RELOC_NUMBER (R_H8_DIR32_24, 3)
|
||||
RELOC_NUMBER (R_H8_DIR32_16, 4)
|
||||
RELOC_NUMBER (R_H8_DIR32U, 6)
|
||||
RELOC_NUMBER (R_H8_DIR32U_28, 7)
|
||||
RELOC_NUMBER (R_H8_DIR32U_24, 8)
|
||||
RELOC_NUMBER (R_H8_DIR32U_20, 9)
|
||||
RELOC_NUMBER (R_H8_DIR32U_16, 10)
|
||||
RELOC_NUMBER (R_H8_DIR24, 11)
|
||||
RELOC_NUMBER (R_H8_DIR24_20, 12)
|
||||
RELOC_NUMBER (R_H8_DIR24_16, 13)
|
||||
RELOC_NUMBER (R_H8_DIR24U, 14)
|
||||
RELOC_NUMBER (R_H8_DIR24U_20, 15)
|
||||
RELOC_NUMBER (R_H8_DIR24U_16, 16)
|
||||
RELOC_NUMBER (R_H8_DIR16, 17)
|
||||
RELOC_NUMBER (R_H8_DIR16U, 18)
|
||||
RELOC_NUMBER (R_H8_DIR16S_32, 19)
|
||||
RELOC_NUMBER (R_H8_DIR16S_28, 20)
|
||||
RELOC_NUMBER (R_H8_DIR16S_24, 21)
|
||||
RELOC_NUMBER (R_H8_DIR16S_20, 22)
|
||||
RELOC_NUMBER (R_H8_DIR16S, 23)
|
||||
RELOC_NUMBER (R_H8_DIR8, 24)
|
||||
RELOC_NUMBER (R_H8_DIR8U, 25)
|
||||
RELOC_NUMBER (R_H8_DIR8Z_32, 26)
|
||||
RELOC_NUMBER (R_H8_DIR8Z_28, 27)
|
||||
RELOC_NUMBER (R_H8_DIR8Z_24, 28)
|
||||
RELOC_NUMBER (R_H8_DIR8Z_20, 29)
|
||||
RELOC_NUMBER (R_H8_DIR8Z_16, 30)
|
||||
RELOC_NUMBER (R_H8_PCREL16, 31)
|
||||
RELOC_NUMBER (R_H8_PCREL8, 32)
|
||||
RELOC_NUMBER (R_H8_BPOS, 33)
|
||||
FAKE_RELOC (R_H8_FIRST_INVALID_DIR_RELOC, 34)
|
||||
FAKE_RELOC (R_H8_LAST_INVALID_DIR_RELOC, 58)
|
||||
RELOC_NUMBER (R_H8_DIR16A8, 59)
|
||||
RELOC_NUMBER (R_H8_DIR16R8, 60)
|
||||
RELOC_NUMBER (R_H8_DIR24A8, 61)
|
||||
RELOC_NUMBER (R_H8_DIR24R8, 62)
|
||||
RELOC_NUMBER (R_H8_DIR32A16, 63)
|
||||
RELOC_NUMBER (R_H8_ABS32, 65)
|
||||
RELOC_NUMBER (R_H8_ABS32A16, 127)
|
||||
RELOC_NUMBER (R_H8_SYM, 128)
|
||||
RELOC_NUMBER (R_H8_OPneg, 129)
|
||||
RELOC_NUMBER (R_H8_OPadd, 130)
|
||||
RELOC_NUMBER (R_H8_OPsub, 131)
|
||||
RELOC_NUMBER (R_H8_OPmul, 132)
|
||||
RELOC_NUMBER (R_H8_OPdiv, 133)
|
||||
RELOC_NUMBER (R_H8_OPshla, 134)
|
||||
RELOC_NUMBER (R_H8_OPshra, 135)
|
||||
RELOC_NUMBER (R_H8_OPsctsize, 136)
|
||||
RELOC_NUMBER (R_H8_OPhword, 137)
|
||||
RELOC_NUMBER (R_H8_OPlword, 138)
|
||||
RELOC_NUMBER (R_H8_OPhigh, 139)
|
||||
RELOC_NUMBER (R_H8_OPlow, 140)
|
||||
RELOC_NUMBER (R_H8_OPscttop, 141)
|
||||
END_RELOC_NUMBERS (R_H8_max)
|
||||
|
||||
/* Machine variant if we know it. This field was invented at Cygnus,
|
||||
but it is hoped that other vendors will adopt it. If some standard
|
||||
is developed, this code should be changed to follow it. */
|
||||
|
||||
#define EF_H8_MACH 0x00FF0000
|
||||
|
||||
#define E_H8_MACH_H8300 0x00800000
|
||||
#define E_H8_MACH_H8300H 0x00810000
|
||||
#define E_H8_MACH_H8300S 0x00820000
|
||||
|
||||
#endif
|
||||
@@ -1,168 +0,0 @@
|
||||
/* MMIX support for BFD.
|
||||
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file holds definitions specific to the MMIX ELF ABI. */
|
||||
#ifndef ELF_MMIX_H
|
||||
#define ELF_MMIX_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocations. */
|
||||
START_RELOC_NUMBERS (elf_mmix_reloc_type)
|
||||
RELOC_NUMBER (R_MMIX_NONE, 0)
|
||||
|
||||
/* Standard absolute relocations. */
|
||||
RELOC_NUMBER (R_MMIX_8, 1)
|
||||
RELOC_NUMBER (R_MMIX_16, 2)
|
||||
RELOC_NUMBER (R_MMIX_24, 3)
|
||||
RELOC_NUMBER (R_MMIX_32, 4)
|
||||
RELOC_NUMBER (R_MMIX_64, 5)
|
||||
|
||||
/* Standard relative relocations. */
|
||||
RELOC_NUMBER (R_MMIX_PC_8, 6)
|
||||
RELOC_NUMBER (R_MMIX_PC_16, 7)
|
||||
RELOC_NUMBER (R_MMIX_PC_24, 8)
|
||||
RELOC_NUMBER (R_MMIX_PC_32, 9)
|
||||
RELOC_NUMBER (R_MMIX_PC_64, 10)
|
||||
|
||||
/* GNU extensions for C++ vtables. */
|
||||
RELOC_NUMBER (R_MMIX_GNU_VTINHERIT, 11)
|
||||
RELOC_NUMBER (R_MMIX_GNU_VTENTRY, 12)
|
||||
|
||||
/* A GETA instruction. */
|
||||
RELOC_NUMBER (R_MMIX_GETA, 13)
|
||||
RELOC_NUMBER (R_MMIX_GETA_1, 14)
|
||||
RELOC_NUMBER (R_MMIX_GETA_2, 15)
|
||||
RELOC_NUMBER (R_MMIX_GETA_3, 16)
|
||||
|
||||
/* A conditional branch instruction. */
|
||||
RELOC_NUMBER (R_MMIX_CBRANCH, 17)
|
||||
RELOC_NUMBER (R_MMIX_CBRANCH_J, 18)
|
||||
RELOC_NUMBER (R_MMIX_CBRANCH_1, 19)
|
||||
RELOC_NUMBER (R_MMIX_CBRANCH_2, 20)
|
||||
RELOC_NUMBER (R_MMIX_CBRANCH_3, 21)
|
||||
|
||||
/* A PUSHJ instruction. */
|
||||
RELOC_NUMBER (R_MMIX_PUSHJ, 22)
|
||||
RELOC_NUMBER (R_MMIX_PUSHJ_1, 23)
|
||||
RELOC_NUMBER (R_MMIX_PUSHJ_2, 24)
|
||||
RELOC_NUMBER (R_MMIX_PUSHJ_3, 25)
|
||||
|
||||
/* A JMP instruction. */
|
||||
RELOC_NUMBER (R_MMIX_JMP, 26)
|
||||
RELOC_NUMBER (R_MMIX_JMP_1, 27)
|
||||
RELOC_NUMBER (R_MMIX_JMP_2, 28)
|
||||
RELOC_NUMBER (R_MMIX_JMP_3, 29)
|
||||
|
||||
/* A relative address such as in a GETA or a branch. */
|
||||
RELOC_NUMBER (R_MMIX_ADDR19, 30)
|
||||
|
||||
/* A relative address such as in a JMP (only). */
|
||||
RELOC_NUMBER (R_MMIX_ADDR27, 31)
|
||||
|
||||
/* A general register or a number 0..255. */
|
||||
RELOC_NUMBER (R_MMIX_REG_OR_BYTE, 32)
|
||||
|
||||
/* A general register. */
|
||||
RELOC_NUMBER (R_MMIX_REG, 33)
|
||||
|
||||
/* A global register and an offset, the global register (allocated at
|
||||
link time) contents plus the offset made equivalent to the relocation
|
||||
expression at link time. The relocation must point at the Y field of
|
||||
an instruction. */
|
||||
RELOC_NUMBER (R_MMIX_BASE_PLUS_OFFSET, 34)
|
||||
|
||||
/* A LOCAL assertion. */
|
||||
RELOC_NUMBER (R_MMIX_LOCAL, 35)
|
||||
END_RELOC_NUMBERS (R_MMIX_max)
|
||||
|
||||
|
||||
/* Section Attributes. */
|
||||
/* A section containing necessary information for relaxation. */
|
||||
#define SHF_MMIX_CANRELAX 0x80000000
|
||||
|
||||
/* Symbol attributes. */
|
||||
/* A symbol with this section-index is a register. */
|
||||
#define SHN_REGISTER SHN_LOPROC
|
||||
|
||||
/* This section holds contents for each initialized register, at VMA
|
||||
regno*8. A symbol relative to this section will be transformed to an
|
||||
absolute symbol with the value corresponding to the register number at
|
||||
final link time. A symbol with a value outside the inclusive range
|
||||
32*8 .. 254*8 is an error. It is highly recommended to only use an
|
||||
upper bound of 253*8 or lower as specified in the (currently
|
||||
unspecified) ABI. */
|
||||
#define MMIX_REG_CONTENTS_SECTION_NAME ".MMIX.reg_contents"
|
||||
|
||||
/* At link time, a section by this name is created, expected to be
|
||||
included in MMIX_REG_CONTENTS_SECTION_NAME in the output. */
|
||||
#define MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME \
|
||||
".MMIX.reg_contents.linker_allocated"
|
||||
|
||||
/* This is a faked section holding symbols with SHN_REGISTER. Don't
|
||||
confuse it with MMIX_REG_CONTENTS_SECTION_NAME; this one has no
|
||||
contents, just values. It is an error for a value in this section to
|
||||
be outside the range 32..255 and it must never become an actual section
|
||||
in an object file. */
|
||||
#define MMIX_REG_SECTION_NAME "*REG*"
|
||||
|
||||
/* Appended with a number N=0..65535, this is a representation of the
|
||||
mmixal "BSPEC N" ... "ESPEC" directive pair; the contents go into an
|
||||
ELF section by name ".MMIX.spec_data.N". */
|
||||
#define MMIX_OTHER_SPEC_SECTION_PREFIX ".MMIX.spec_data."
|
||||
|
||||
/* A section SECNAME is noted to start at "__.MMIX.start.SECNAME" by the
|
||||
presence of this symbol. Currently only implemented for ".text"
|
||||
through the symbol "__.MMIX.start..text". */
|
||||
#define MMIX_LOC_SECTION_START_SYMBOL_PREFIX "__.MMIX.start."
|
||||
|
||||
/* This symbol is always a function. */
|
||||
#define MMIX_START_SYMBOL_NAME "Main"
|
||||
|
||||
|
||||
/* We smuggle in a few MMO specifics here. We don't make a specific MMO
|
||||
file, since we can't reasonably support MMO without ELF; we have to
|
||||
include this file anyway. */
|
||||
|
||||
#define MMO_TEXT_SECTION_NAME ".text"
|
||||
#define MMO_DATA_SECTION_NAME ".data"
|
||||
|
||||
/* A definition for the flags we put in spec data in files. A copy of our
|
||||
own of some flags to keep immune to BFD flag changes. See section.c of
|
||||
2001-07-18 for flag documentation. */
|
||||
#define MMO_SEC_ALLOC 0x001
|
||||
#define MMO_SEC_LOAD 0x002
|
||||
#define MMO_SEC_RELOC 0x004
|
||||
#define MMO_SEC_READONLY 0x010
|
||||
#define MMO_SEC_CODE 0x020
|
||||
#define MMO_SEC_DATA 0x040
|
||||
#define MMO_SEC_NEVER_LOAD 0x400
|
||||
#define MMO_SEC_IS_COMMON 0x8000
|
||||
#define MMO_SEC_DEBUGGING 0x10000
|
||||
|
||||
#ifdef BFD_ARCH_SIZE
|
||||
extern boolean _bfd_mmix_prepare_linker_allocated_gregs
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean _bfd_mmix_finalize_linker_allocated_gregs
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean _bfd_mmix_check_all_relocs
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
#endif
|
||||
|
||||
#endif /* ELF_MMIX_H */
|
||||
@@ -1,39 +0,0 @@
|
||||
/* OpenRISC ELF support for BFD.
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF_OPENRISC_H
|
||||
#define _ELF_OPENRISC_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocations. */
|
||||
START_RELOC_NUMBERS (elf_openrisc_reloc_type)
|
||||
RELOC_NUMBER (R_OPENRISC_NONE, 0)
|
||||
RELOC_NUMBER (R_OPENRISC_INSN_REL_26, 1)
|
||||
RELOC_NUMBER (R_OPENRISC_INSN_ABS_26, 2)
|
||||
RELOC_NUMBER (R_OPENRISC_LO_16_IN_INSN, 3)
|
||||
RELOC_NUMBER (R_OPENRISC_HI_16_IN_INSN, 4)
|
||||
RELOC_NUMBER (R_OPENRISC_8, 5)
|
||||
RELOC_NUMBER (R_OPENRISC_16, 6)
|
||||
RELOC_NUMBER (R_OPENRISC_32, 7)
|
||||
RELOC_NUMBER (R_OPENRISC_GNU_VTINHERIT, 8)
|
||||
RELOC_NUMBER (R_OPENRISC_GNU_VTENTRY, 9)
|
||||
END_RELOC_NUMBERS (R_OPENRISC_max)
|
||||
|
||||
#endif /* _ELF_OPENRISC_H */
|
||||
@@ -1,62 +0,0 @@
|
||||
/* OR1K ELF support for BFD. Derived from ppc.h.
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Contributed by Ivan Guzvinec <ivang@opencores.org>
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF_OR1K_H
|
||||
#define _ELF_OR1K_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocations. */
|
||||
START_RELOC_NUMBERS (elf_or32_reloc_type)
|
||||
RELOC_NUMBER (R_OR32_NONE, 0)
|
||||
RELOC_NUMBER (R_OR32_32, 1)
|
||||
RELOC_NUMBER (R_OR32_16, 2)
|
||||
RELOC_NUMBER (R_OR32_8, 3)
|
||||
RELOC_NUMBER (R_OR32_CONST, 4)
|
||||
RELOC_NUMBER (R_OR32_CONSTH, 5)
|
||||
RELOC_NUMBER (R_OR32_JUMPTARG, 6)
|
||||
RELOC_NUMBER (R_OR32_GNU_VTENTRY, 7)
|
||||
RELOC_NUMBER (R_OR32_GNU_VTINHERIT, 8)
|
||||
END_RELOC_NUMBERS (R_OR32_max)
|
||||
|
||||
/* Four bit OR32 machine type field. */
|
||||
#define EF_OR32_MACH 0x0000000f
|
||||
|
||||
/* Various CPU types. */
|
||||
#define E_OR32_MACH_BASE 0x00000000
|
||||
#define E_OR32_MACH_UNUSED1 0x00000001
|
||||
#define E_OR32_MACH_UNUSED2 0x00000002
|
||||
#define E_OR32_MACH_UNUSED4 0x00000003
|
||||
|
||||
/* Processor specific section headers, sh_type field */
|
||||
#define SHT_ORDERED SHT_HIPROC /* Link editor is to sort the \
|
||||
entries in this section \
|
||||
based on the address \
|
||||
specified in the associated \
|
||||
symbol table entry. */
|
||||
|
||||
/* Processor specific section flags, sh_flags field */
|
||||
#define SHF_EXCLUDE 0x80000000 /* Link editor is to exclude \
|
||||
this section from executable \
|
||||
and shared objects that it \
|
||||
builds when those objects \
|
||||
are not to be furhter \
|
||||
relocated. */
|
||||
#endif /* _ELF_OR1K_H */
|
||||
@@ -1,73 +0,0 @@
|
||||
/* 390 ELF support for BFD.
|
||||
Copyright 2000, 2001 Free Software Foundation, Inc.
|
||||
Contributed by Carl B. Pedersen and Martin Schwidefsky.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF_390_H
|
||||
#define _ELF_390_H
|
||||
|
||||
/* Processor specific flags for the ELF header e_flags field. */
|
||||
|
||||
/* Symbol types. */
|
||||
|
||||
#define STACK_REG 15 /* Global Stack reg */
|
||||
#define BACKL_REG 14 /* Global Backlink reg */
|
||||
#define BASE_REG 13 /* Global Base reg */
|
||||
#define GOT_REG 12 /* Holds addr of GOT */
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocation types. */
|
||||
|
||||
START_RELOC_NUMBERS (elf_s390_reloc_type)
|
||||
RELOC_NUMBER (R_390_NONE, 0) /* No reloc. */
|
||||
RELOC_NUMBER (R_390_8, 1) /* Direct 8 bit. */
|
||||
RELOC_NUMBER (R_390_12, 2) /* Direct 12 bit. */
|
||||
RELOC_NUMBER (R_390_16, 3) /* Direct 16 bit. */
|
||||
RELOC_NUMBER (R_390_32, 4) /* Direct 32 bit. */
|
||||
RELOC_NUMBER (R_390_PC32, 5) /* PC relative 32 bit. */
|
||||
RELOC_NUMBER (R_390_GOT12, 6) /* 12 bit GOT offset. */
|
||||
RELOC_NUMBER (R_390_GOT32, 7) /* 32 bit GOT offset. */
|
||||
RELOC_NUMBER (R_390_PLT32, 8) /* 32 bit PC relative PLT address. */
|
||||
RELOC_NUMBER (R_390_COPY, 9) /* Copy symbol at runtime. */
|
||||
RELOC_NUMBER (R_390_GLOB_DAT, 10) /* Create GOT entry. */
|
||||
RELOC_NUMBER (R_390_JMP_SLOT, 11) /* Create PLT entry. */
|
||||
RELOC_NUMBER (R_390_RELATIVE, 12) /* Adjust by program base. */
|
||||
RELOC_NUMBER (R_390_GOTOFF, 13) /* 32 bit offset to GOT. */
|
||||
RELOC_NUMBER (R_390_GOTPC, 14) /* 32 bit PC relative offset to GOT. */
|
||||
RELOC_NUMBER (R_390_GOT16, 15) /* 16 bit GOT offset. */
|
||||
RELOC_NUMBER (R_390_PC16, 16) /* PC relative 16 bit. */
|
||||
RELOC_NUMBER (R_390_PC16DBL, 17) /* PC relative 16 bit shifted by 1. */
|
||||
RELOC_NUMBER (R_390_PLT16DBL, 18) /* 16 bit PC rel. PLT shifted by 1. */
|
||||
RELOC_NUMBER (R_390_PC32DBL, 19) /* PC relative 32 bit shifted by 1. */
|
||||
RELOC_NUMBER (R_390_PLT32DBL, 20) /* 32 bit PC rel. PLT shifted by 1. */
|
||||
RELOC_NUMBER (R_390_GOTPCDBL, 21) /* 32 bit PC rel. GOT shifted by 1. */
|
||||
RELOC_NUMBER (R_390_64, 22) /* Direct 64 bit. */
|
||||
RELOC_NUMBER (R_390_PC64, 23) /* PC relative 64 bit. */
|
||||
RELOC_NUMBER (R_390_GOT64, 24) /* 64 bit GOT offset. */
|
||||
RELOC_NUMBER (R_390_PLT64, 25) /* 64 bit PC relative PLT address. */
|
||||
RELOC_NUMBER (R_390_GOTENT, 26) /* 32 bit PC rel. to GOT entry >> 1. */
|
||||
/* These are GNU extensions to enable C++ vtable garbage collection. */
|
||||
RELOC_NUMBER (R_390_GNU_VTINHERIT, 250)
|
||||
RELOC_NUMBER (R_390_GNU_VTENTRY, 251)
|
||||
END_RELOC_NUMBERS (R_390_max)
|
||||
|
||||
#endif /* _ELF_390_H */
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/* XSTORMY16 ELF support for BFD.
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
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 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, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _ELF_XSTORMY16_H
|
||||
#define _ELF_XSTORMY16_H
|
||||
|
||||
#include "elf/reloc-macros.h"
|
||||
|
||||
/* Relocations. */
|
||||
START_RELOC_NUMBERS (elf_xstormy16_reloc_type)
|
||||
RELOC_NUMBER (R_XSTORMY16_NONE, 0)
|
||||
|
||||
RELOC_NUMBER (R_XSTORMY16_32, 1)
|
||||
RELOC_NUMBER (R_XSTORMY16_16, 2)
|
||||
RELOC_NUMBER (R_XSTORMY16_8, 3)
|
||||
RELOC_NUMBER (R_XSTORMY16_PC32, 4)
|
||||
RELOC_NUMBER (R_XSTORMY16_PC16, 5)
|
||||
RELOC_NUMBER (R_XSTORMY16_PC8, 6)
|
||||
|
||||
RELOC_NUMBER (R_XSTORMY16_REL_12, 7)
|
||||
RELOC_NUMBER (R_XSTORMY16_24, 8)
|
||||
RELOC_NUMBER (R_XSTORMY16_FPTR16, 9)
|
||||
|
||||
RELOC_NUMBER (R_XSTORMY16_GNU_VTINHERIT, 128)
|
||||
RELOC_NUMBER (R_XSTORMY16_GNU_VTENTRY, 129)
|
||||
END_RELOC_NUMBERS (R_XSTORMY16_max)
|
||||
|
||||
/* Define the data & instruction memory discriminator. In a linked
|
||||
executable, an symbol should be deemed to point to an instruction
|
||||
if ((address & XSTORMY16_INSN_MASK) == XSTORMY16_INSN_VALUE), and similarly
|
||||
for the data space. See also `ld/emulparams/elf32xstormy16.sh'. */
|
||||
#define XSTORMY16_DATA_MASK 0xffc00000
|
||||
#define XSTORMY16_DATA_VALUE 0x00000000
|
||||
#define XSTORMY16_INSN_MASK 0xffc00000
|
||||
#define XSTORMY16_INSN_VALUE 0x00400000
|
||||
|
||||
#endif /* _ELF_XSTORMY16_H */
|
||||
@@ -1,81 +0,0 @@
|
||||
/* A Fibonacci heap datatype.
|
||||
Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
Contributed by Daniel Berlin (dan@cgsoftware.com).
|
||||
|
||||
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 2, 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 COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Fibonacci heaps are somewhat complex, but, there's an article in
|
||||
DDJ that explains them pretty well:
|
||||
|
||||
http://www.ddj.com/articles/1997/9701/9701o/9701o.htm?topic=algoritms
|
||||
|
||||
Introduction to algorithms by Corman and Rivest also goes over them.
|
||||
|
||||
The original paper that introduced them is "Fibonacci heaps and their
|
||||
uses in improved network optimization algorithms" by Tarjan and
|
||||
Fredman (JACM 34(3), July 1987).
|
||||
|
||||
Amortized and real worst case time for operations:
|
||||
|
||||
ExtractMin: O(lg n) amortized. O(n) worst case.
|
||||
DecreaseKey: O(1) amortized. O(lg n) worst case.
|
||||
Insert: O(2) amortized. O(1) actual.
|
||||
Union: O(1) amortized. O(1) actual. */
|
||||
|
||||
#ifndef _FIBHEAP_H_
|
||||
#define _FIBHEAP_H_
|
||||
|
||||
#include <ansidecl.h>
|
||||
|
||||
typedef long fibheapkey_t;
|
||||
|
||||
typedef struct fibheap
|
||||
{
|
||||
size_t nodes;
|
||||
struct fibnode *min;
|
||||
struct fibnode *root;
|
||||
} *fibheap_t;
|
||||
|
||||
typedef struct fibnode
|
||||
{
|
||||
struct fibnode *parent;
|
||||
struct fibnode *child;
|
||||
struct fibnode *left;
|
||||
struct fibnode *right;
|
||||
fibheapkey_t key;
|
||||
void *data;
|
||||
unsigned int degree : 31;
|
||||
unsigned int mark : 1;
|
||||
} *fibnode_t;
|
||||
|
||||
extern fibheap_t fibheap_new PARAMS ((void));
|
||||
extern fibnode_t fibheap_insert PARAMS ((fibheap_t, fibheapkey_t, void *));
|
||||
extern int fibheap_empty PARAMS ((fibheap_t));
|
||||
extern fibheapkey_t fibheap_min_key PARAMS ((fibheap_t));
|
||||
extern fibheapkey_t fibheap_replace_key PARAMS ((fibheap_t, fibnode_t,
|
||||
fibheapkey_t));
|
||||
extern void *fibheap_replace_key_data PARAMS ((fibheap_t, fibnode_t,
|
||||
fibheapkey_t, void *));
|
||||
extern void *fibheap_extract_min PARAMS ((fibheap_t));
|
||||
extern void *fibheap_min PARAMS ((fibheap_t));
|
||||
extern void *fibheap_replace_data PARAMS ((fibheap_t, fibnode_t, void *));
|
||||
extern void *fibheap_delete_node PARAMS ((fibheap_t, fibnode_t));
|
||||
extern void fibheap_delete PARAMS ((fibheap_t));
|
||||
extern fibheap_t fibheap_union PARAMS ((fibheap_t, fibheap_t));
|
||||
|
||||
#endif /* _FIBHEAP_H_ */
|
||||
@@ -1,51 +0,0 @@
|
||||
/* ternary.h - Ternary Search Trees
|
||||
Copyright 2001 Free Software Foundation, Inc.
|
||||
|
||||
Contributed by Daniel Berlin (dan@cgsoftware.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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
#ifndef TERNARY_H_
|
||||
#define TERNARY_H_
|
||||
/* Ternary search trees */
|
||||
|
||||
typedef struct ternary_node_def *ternary_tree;
|
||||
|
||||
typedef struct ternary_node_def
|
||||
{
|
||||
char splitchar;
|
||||
ternary_tree lokid;
|
||||
ternary_tree eqkid;
|
||||
ternary_tree hikid;
|
||||
}
|
||||
ternary_node;
|
||||
|
||||
/* Insert string S into tree P, associating it with DATA.
|
||||
Return the data in the tree associated with the string if it's
|
||||
already there, and replace is 0.
|
||||
Otherwise, replaces if it it exists, inserts if it doesn't, and
|
||||
returns the data you passed in. */
|
||||
PTR ternary_insert PARAMS ((ternary_tree *p, const char *s,
|
||||
PTR data, int replace));
|
||||
|
||||
/* Delete the ternary search tree rooted at P.
|
||||
Does NOT delete the data you associated with the strings. */
|
||||
void ternary_cleanup PARAMS ((ternary_tree p));
|
||||
|
||||
/* Search the ternary tree for string S, returning the data associated
|
||||
with it if found. */
|
||||
PTR ternary_search PARAMS ((const ternary_node *p, const char *s));
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
/* This file redefines all regex external names before including
|
||||
a renamed copy of glibc's regex.h. */
|
||||
|
||||
#ifndef _XREGEX_H
|
||||
#define _XREGEX_H 1
|
||||
|
||||
# define regfree xregfree
|
||||
# define regexec xregexec
|
||||
# define regcomp xregcomp
|
||||
# define regerror xregerror
|
||||
# define re_set_registers xre_set_registers
|
||||
# define re_match_2 xre_match_2
|
||||
# define re_match xre_match
|
||||
# define re_search xre_search
|
||||
# define re_compile_pattern xre_compile_pattern
|
||||
# define re_set_syntax xre_set_syntax
|
||||
# define re_search_2 xre_search_2
|
||||
# define re_compile_fastmap xre_compile_fastmap
|
||||
# define re_syntax_options xre_syntax_options
|
||||
# define re_max_failures xre_max_failures
|
||||
|
||||
# define _REGEX_RE_COMP
|
||||
# define re_comp xre_comp
|
||||
# define re_exec xre_exec
|
||||
|
||||
#include "xregex2.h"
|
||||
|
||||
#endif /* xregex.h */
|
||||
@@ -1,565 +0,0 @@
|
||||
/* Definitions for data structures and routines for the regular
|
||||
expression library, version 0.12.
|
||||
Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library. Its master source is NOT part of
|
||||
the C library, however. The master source lives in /gd/gnu/lib.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
02111-1307 USA. */
|
||||
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* POSIX says that <sys/types.h> must be included (by the caller) before
|
||||
<regex.h>. */
|
||||
|
||||
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
|
||||
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
|
||||
should be there. */
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* The following two types have to be signed and unsigned integer type
|
||||
wide enough to hold a value of a pointer. For most ANSI compilers
|
||||
ptrdiff_t and size_t should be likely OK. Still size of these two
|
||||
types is 2 for Microsoft C. Ugh... */
|
||||
typedef long int s_reg_t;
|
||||
typedef unsigned long int active_reg_t;
|
||||
|
||||
/* The following bits are used to determine the regexp syntax we
|
||||
recognize. The set/not-set meanings are chosen so that Emacs syntax
|
||||
remains the value 0. The bits are given in alphabetical order, and
|
||||
the definitions shifted by one from the previous bit; thus, when we
|
||||
add or remove a bit, only one other definition need change. */
|
||||
typedef unsigned long int reg_syntax_t;
|
||||
|
||||
/* If this bit is not set, then \ inside a bracket expression is literal.
|
||||
If set, then such a \ quotes the following character. */
|
||||
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
|
||||
|
||||
/* If this bit is not set, then + and ? are operators, and \+ and \? are
|
||||
literals.
|
||||
If set, then \+ and \? are operators and + and ? are literals. */
|
||||
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
|
||||
|
||||
/* If this bit is set, then character classes are supported. They are:
|
||||
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
|
||||
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
|
||||
If not set, then character classes are not supported. */
|
||||
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
|
||||
|
||||
/* If this bit is set, then ^ and $ are always anchors (outside bracket
|
||||
expressions, of course).
|
||||
If this bit is not set, then it depends:
|
||||
^ is an anchor if it is at the beginning of a regular
|
||||
expression or after an open-group or an alternation operator;
|
||||
$ is an anchor if it is at the end of a regular expression, or
|
||||
before a close-group or an alternation operator.
|
||||
|
||||
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
|
||||
POSIX draft 11.2 says that * etc. in leading positions is undefined.
|
||||
We already implemented a previous draft which made those constructs
|
||||
invalid, though, so we haven't changed the code back. */
|
||||
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
|
||||
|
||||
/* If this bit is set, then special characters are always special
|
||||
regardless of where they are in the pattern.
|
||||
If this bit is not set, then special characters are special only in
|
||||
some contexts; otherwise they are ordinary. Specifically,
|
||||
* + ? and intervals are only special when not after the beginning,
|
||||
open-group, or alternation operator. */
|
||||
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
|
||||
|
||||
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
|
||||
immediately after an alternation or begin-group operator. */
|
||||
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . matches newline.
|
||||
If not set, then it doesn't. */
|
||||
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
|
||||
|
||||
/* If this bit is set, then . doesn't match NUL.
|
||||
If not set, then it does. */
|
||||
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, nonmatching lists [^...] do not match newline.
|
||||
If not set, they do. */
|
||||
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
|
||||
|
||||
/* If this bit is set, either \{...\} or {...} defines an
|
||||
interval, depending on RE_NO_BK_BRACES.
|
||||
If not set, \{, \}, {, and } are literals. */
|
||||
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
|
||||
|
||||
/* If this bit is set, +, ? and | aren't recognized as operators.
|
||||
If not set, they are. */
|
||||
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
|
||||
|
||||
/* If this bit is set, newline is an alternation operator.
|
||||
If not set, newline is literal. */
|
||||
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
|
||||
|
||||
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
|
||||
are literals.
|
||||
If not set, then `\{...\}' defines an interval. */
|
||||
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
|
||||
|
||||
/* If this bit is set, (...) defines a group, and \( and \) are literals.
|
||||
If not set, \(...\) defines a group, and ( and ) are literals. */
|
||||
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
|
||||
|
||||
/* If this bit is set, then \<digit> matches <digit>.
|
||||
If not set, then \<digit> is a back-reference. */
|
||||
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
|
||||
|
||||
/* If this bit is set, then | is an alternation operator, and \| is literal.
|
||||
If not set, then \| is an alternation operator, and | is literal. */
|
||||
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
|
||||
|
||||
/* If this bit is set, then an ending range point collating higher
|
||||
than the starting range point, as in [z-a], is invalid.
|
||||
If not set, then when ending range point collates higher than the
|
||||
starting range point, the range is ignored. */
|
||||
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
|
||||
|
||||
/* If this bit is set, then an unmatched ) is ordinary.
|
||||
If not set, then an unmatched ) is invalid. */
|
||||
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
|
||||
|
||||
/* If this bit is set, succeed as soon as we match the whole pattern,
|
||||
without further backtracking. */
|
||||
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
|
||||
|
||||
/* If this bit is set, do not process the GNU regex operators.
|
||||
If not set, then the GNU regex operators are recognized. */
|
||||
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
|
||||
|
||||
/* If this bit is set, turn on internal regex debugging.
|
||||
If not set, and debugging was on, turn it off.
|
||||
This only works if regex.c is compiled -DDEBUG.
|
||||
We define this bit always, so that all that's needed to turn on
|
||||
debugging is to recompile regex.c; the calling code can always have
|
||||
this bit set, and it won't affect anything in the normal case. */
|
||||
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
|
||||
|
||||
/* If this bit is set, a syntactically invalid interval is treated as
|
||||
a string of ordinary characters. For example, the ERE 'a{1' is
|
||||
treated as 'a\{1'. */
|
||||
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
|
||||
|
||||
/* This global variable defines the particular regexp syntax to use (for
|
||||
some interfaces). When a regexp is compiled, the syntax used is
|
||||
stored in the pattern buffer, so changing this does not affect
|
||||
already-compiled regexps. */
|
||||
extern reg_syntax_t re_syntax_options;
|
||||
|
||||
/* Define combinations of the above bits for the standard possibilities.
|
||||
(The [[[ comments delimit what gets put into the Texinfo file, so
|
||||
don't delete them!) */
|
||||
/* [[[begin syntaxes]]] */
|
||||
#define RE_SYNTAX_EMACS 0
|
||||
|
||||
#define RE_SYNTAX_AWK \
|
||||
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
|
||||
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GNU_AWK \
|
||||
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
|
||||
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
|
||||
|
||||
#define RE_SYNTAX_POSIX_AWK \
|
||||
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
|
||||
| RE_INTERVALS | RE_NO_GNU_OPS)
|
||||
|
||||
#define RE_SYNTAX_GREP \
|
||||
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
|
||||
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
|
||||
| RE_NEWLINE_ALT)
|
||||
|
||||
#define RE_SYNTAX_EGREP \
|
||||
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
|
||||
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
|
||||
| RE_NO_BK_VBAR)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EGREP \
|
||||
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
|
||||
| RE_INVALID_INTERVAL_ORD)
|
||||
|
||||
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
|
||||
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
|
||||
|
||||
/* Syntax bits common to both basic and extended POSIX regex syntax. */
|
||||
#define _RE_SYNTAX_POSIX_COMMON \
|
||||
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
|
||||
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
|
||||
|
||||
#define RE_SYNTAX_POSIX_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
|
||||
|
||||
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
|
||||
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
|
||||
isn't minimal, since other operators, such as \`, aren't disabled. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
|
||||
|
||||
#define RE_SYNTAX_POSIX_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
|
||||
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
|
||||
removed and RE_NO_BK_REFS is added. */
|
||||
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
|
||||
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
|
||||
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
|
||||
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
|
||||
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
|
||||
/* [[[end syntaxes]]] */
|
||||
|
||||
/* Maximum number of duplicates an interval can allow. Some systems
|
||||
(erroneously) define this in other header files, but we want our
|
||||
value, so remove any previous define. */
|
||||
#ifdef RE_DUP_MAX
|
||||
# undef RE_DUP_MAX
|
||||
#endif
|
||||
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
|
||||
#define RE_DUP_MAX (0x7fff)
|
||||
|
||||
|
||||
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
|
||||
|
||||
/* If this bit is set, then use extended regular expression syntax.
|
||||
If not set, then use basic regular expression syntax. */
|
||||
#define REG_EXTENDED 1
|
||||
|
||||
/* If this bit is set, then ignore case when matching.
|
||||
If not set, then case is significant. */
|
||||
#define REG_ICASE (REG_EXTENDED << 1)
|
||||
|
||||
/* If this bit is set, then anchors do not match at newline
|
||||
characters in the string.
|
||||
If not set, then anchors do match at newlines. */
|
||||
#define REG_NEWLINE (REG_ICASE << 1)
|
||||
|
||||
/* If this bit is set, then report only success or fail in regexec.
|
||||
If not set, then returns differ between not matching and errors. */
|
||||
#define REG_NOSUB (REG_NEWLINE << 1)
|
||||
|
||||
|
||||
/* POSIX `eflags' bits (i.e., information for regexec). */
|
||||
|
||||
/* If this bit is set, then the beginning-of-line operator doesn't match
|
||||
the beginning of the string (presumably because it's not the
|
||||
beginning of a line).
|
||||
If not set, then the beginning-of-line operator does match the
|
||||
beginning of the string. */
|
||||
#define REG_NOTBOL 1
|
||||
|
||||
/* Like REG_NOTBOL, except for the end-of-line. */
|
||||
#define REG_NOTEOL (1 << 1)
|
||||
|
||||
|
||||
/* If any error codes are removed, changed, or added, update the
|
||||
`re_error_msg' table in regex.c. */
|
||||
typedef enum
|
||||
{
|
||||
#ifdef _XOPEN_SOURCE
|
||||
REG_ENOSYS = -1, /* This will never happen for this implementation. */
|
||||
#endif
|
||||
|
||||
REG_NOERROR = 0, /* Success. */
|
||||
REG_NOMATCH, /* Didn't find a match (for regexec). */
|
||||
|
||||
/* POSIX regcomp return error codes. (In the order listed in the
|
||||
standard.) */
|
||||
REG_BADPAT, /* Invalid pattern. */
|
||||
REG_ECOLLATE, /* Not implemented. */
|
||||
REG_ECTYPE, /* Invalid character class name. */
|
||||
REG_EESCAPE, /* Trailing backslash. */
|
||||
REG_ESUBREG, /* Invalid back reference. */
|
||||
REG_EBRACK, /* Unmatched left bracket. */
|
||||
REG_EPAREN, /* Parenthesis imbalance. */
|
||||
REG_EBRACE, /* Unmatched \{. */
|
||||
REG_BADBR, /* Invalid contents of \{\}. */
|
||||
REG_ERANGE, /* Invalid range end. */
|
||||
REG_ESPACE, /* Ran out of memory. */
|
||||
REG_BADRPT, /* No preceding re for repetition op. */
|
||||
|
||||
/* Error codes we've added. */
|
||||
REG_EEND, /* Premature end. */
|
||||
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
|
||||
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
|
||||
} reg_errcode_t;
|
||||
|
||||
/* This data structure represents a compiled pattern. Before calling
|
||||
the pattern compiler, the fields `buffer', `allocated', `fastmap',
|
||||
`translate', and `no_sub' can be set. After the pattern has been
|
||||
compiled, the `re_nsub' field is available. All other fields are
|
||||
private to the regex routines. */
|
||||
|
||||
#ifndef RE_TRANSLATE_TYPE
|
||||
# define RE_TRANSLATE_TYPE char *
|
||||
#endif
|
||||
|
||||
struct re_pattern_buffer
|
||||
{
|
||||
/* [[[begin pattern_buffer]]] */
|
||||
/* Space that holds the compiled pattern. It is declared as
|
||||
`unsigned char *' because its elements are
|
||||
sometimes used as array indexes. */
|
||||
unsigned char *buffer;
|
||||
|
||||
/* Number of bytes to which `buffer' points. */
|
||||
unsigned long int allocated;
|
||||
|
||||
/* Number of bytes actually used in `buffer'. */
|
||||
unsigned long int used;
|
||||
|
||||
/* Syntax setting with which the pattern was compiled. */
|
||||
reg_syntax_t syntax;
|
||||
|
||||
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
|
||||
the fastmap, if there is one, to skip over impossible
|
||||
starting points for matches. */
|
||||
char *fastmap;
|
||||
|
||||
/* Either a translate table to apply to all characters before
|
||||
comparing them, or zero for no translation. The translation
|
||||
is applied to a pattern when it is compiled and to a string
|
||||
when it is matched. */
|
||||
RE_TRANSLATE_TYPE translate;
|
||||
|
||||
/* Number of subexpressions found by the compiler. */
|
||||
size_t re_nsub;
|
||||
|
||||
/* Zero if this pattern cannot match the empty string, one else.
|
||||
Well, in truth it's used only in `re_search_2', to see
|
||||
whether or not we should use the fastmap, so we don't set
|
||||
this absolutely perfectly; see `re_compile_fastmap' (the
|
||||
`duplicate' case). */
|
||||
unsigned can_be_null : 1;
|
||||
|
||||
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
|
||||
for `max (RE_NREGS, re_nsub + 1)' groups.
|
||||
If REGS_REALLOCATE, reallocate space if necessary.
|
||||
If REGS_FIXED, use what's there. */
|
||||
#define REGS_UNALLOCATED 0
|
||||
#define REGS_REALLOCATE 1
|
||||
#define REGS_FIXED 2
|
||||
unsigned regs_allocated : 2;
|
||||
|
||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
||||
by `re_compile_fastmap' if it updates the fastmap. */
|
||||
unsigned fastmap_accurate : 1;
|
||||
|
||||
/* If set, `re_match_2' does not return information about
|
||||
subexpressions. */
|
||||
unsigned no_sub : 1;
|
||||
|
||||
/* If set, a beginning-of-line anchor doesn't match at the
|
||||
beginning of the string. */
|
||||
unsigned not_bol : 1;
|
||||
|
||||
/* Similarly for an end-of-line anchor. */
|
||||
unsigned not_eol : 1;
|
||||
|
||||
/* If true, an anchor at a newline matches. */
|
||||
unsigned newline_anchor : 1;
|
||||
|
||||
/* [[[end pattern_buffer]]] */
|
||||
};
|
||||
|
||||
typedef struct re_pattern_buffer regex_t;
|
||||
|
||||
/* Type for byte offsets within the string. POSIX mandates this. */
|
||||
typedef int regoff_t;
|
||||
|
||||
|
||||
/* This is the structure we store register match data in. See
|
||||
regex.texinfo for a full description of what registers match. */
|
||||
struct re_registers
|
||||
{
|
||||
unsigned num_regs;
|
||||
regoff_t *start;
|
||||
regoff_t *end;
|
||||
};
|
||||
|
||||
|
||||
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
|
||||
`re_match_2' returns information about at least this many registers
|
||||
the first time a `regs' structure is passed. */
|
||||
#ifndef RE_NREGS
|
||||
# define RE_NREGS 30
|
||||
#endif
|
||||
|
||||
|
||||
/* POSIX specification for registers. Aside from the different names than
|
||||
`re_registers', POSIX uses an array of structures, instead of a
|
||||
structure of arrays. */
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
|
||||
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
|
||||
} regmatch_t;
|
||||
|
||||
/* Declarations for routines. */
|
||||
|
||||
/* To avoid duplicating every routine declaration -- once with a
|
||||
prototype (if we are ANSI), and once without (if we aren't) -- we
|
||||
use the following macro to declare argument types. This
|
||||
unfortunately clutters up the declarations a bit, but I think it's
|
||||
worth it. */
|
||||
|
||||
#if __STDC__
|
||||
|
||||
# define _RE_ARGS(args) args
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
# define _RE_ARGS(args) ()
|
||||
|
||||
#endif /* not __STDC__ */
|
||||
|
||||
/* Sets the current default syntax to SYNTAX, and return the old syntax.
|
||||
You can also simply assign to the `re_syntax_options' variable. */
|
||||
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
|
||||
|
||||
/* Compile the regular expression PATTERN, with length LENGTH
|
||||
and syntax given by the global `re_syntax_options', into the buffer
|
||||
BUFFER. Return NULL if successful, and an error string if not. */
|
||||
extern const char *re_compile_pattern
|
||||
_RE_ARGS ((const char *pattern, size_t length,
|
||||
struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Compile a fastmap for the compiled pattern in BUFFER; used to
|
||||
accelerate searches. Return 0 if successful and -2 if was an
|
||||
internal error. */
|
||||
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
|
||||
|
||||
|
||||
/* Search in the string STRING (with length LENGTH) for the pattern
|
||||
compiled into BUFFER. Start searching at position START, for RANGE
|
||||
characters. Return the starting position of the match, -1 for no
|
||||
match, or -2 for an internal error. Also return register
|
||||
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
|
||||
extern int re_search
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, int range, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Like `re_search', but search in the concatenation of STRING1 and
|
||||
STRING2. Also, stop searching at index START + STOP. */
|
||||
extern int re_search_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, int range, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Like `re_search', but return how many characters in STRING the regexp
|
||||
in BUFFER matched, starting at position START. */
|
||||
extern int re_match
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
|
||||
int length, int start, struct re_registers *regs));
|
||||
|
||||
|
||||
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
|
||||
extern int re_match_2
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
|
||||
int length1, const char *string2, int length2,
|
||||
int start, struct re_registers *regs, int stop));
|
||||
|
||||
|
||||
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
|
||||
ENDS. Subsequent matches using BUFFER and REGS will use this memory
|
||||
for recording register information. STARTS and ENDS must be
|
||||
allocated with malloc, and must each be at least `NUM_REGS * sizeof
|
||||
(regoff_t)' bytes long.
|
||||
|
||||
If NUM_REGS == 0, then subsequent matches should allocate their own
|
||||
register data.
|
||||
|
||||
Unless this function is called, the first search or match using
|
||||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
extern void re_set_registers
|
||||
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends));
|
||||
|
||||
#if defined _REGEX_RE_COMP || defined _LIBC
|
||||
# ifndef _CRAY
|
||||
/* 4.2 bsd compatibility. */
|
||||
extern char *re_comp _RE_ARGS ((const char *));
|
||||
extern int re_exec _RE_ARGS ((const char *));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||
"restrict", and "configure" may have defined "restrict". */
|
||||
#ifndef __restrict
|
||||
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
||||
# if defined restrict || 199901L <= __STDC_VERSION__
|
||||
# define __restrict restrict
|
||||
# else
|
||||
# define __restrict
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
/* For now unconditionally define __restrict_arr to expand to nothing.
|
||||
Ideally we would have a test for the compiler which allows defining
|
||||
it to restrict. */
|
||||
#define __restrict_arr
|
||||
|
||||
/* POSIX compatibility. */
|
||||
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
|
||||
const char *__restrict __pattern,
|
||||
int __cflags));
|
||||
|
||||
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
|
||||
const char *__restrict __string, size_t __nmatch,
|
||||
regmatch_t __pmatch[__restrict_arr],
|
||||
int __eflags));
|
||||
|
||||
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
|
||||
char *__errbuf, size_t __errbuf_size));
|
||||
|
||||
extern void regfree _RE_ARGS ((regex_t *__preg));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
||||
#endif /* regex.h */
|
||||
|
||||
/*
|
||||
Local variables:
|
||||
make-backup-files: t
|
||||
version-control: t
|
||||
trim-versions-without-asking: nil
|
||||
End:
|
||||
*/
|
||||
@@ -1,2 +0,0 @@
|
||||
. ${srcdir}/emulparams/elf64alpha.sh
|
||||
. ${srcdir}/emulparams/elf_fbsd.sh
|
||||
@@ -1,2 +0,0 @@
|
||||
. ${srcdir}/emulparams/elf64alpha.sh
|
||||
ENTRY=__start
|
||||
@@ -1 +0,0 @@
|
||||
ELF_INTERPRETER_NAME=\"/usr/libexec/ld-elf.so.1\"
|
||||
@@ -1,2 +0,0 @@
|
||||
. ${srcdir}/emulparams/elf_i386.sh
|
||||
. ${srcdir}/emulparams/elf_fbsd.sh
|
||||
@@ -1,12 +0,0 @@
|
||||
SCRIPT_NAME=elf
|
||||
OUTPUT_FORMAT="elf32-i386"
|
||||
TEXT_START_ADDR=0x08048000
|
||||
MAXPAGESIZE=0x1000
|
||||
NONPAGED_TEXT_START_ADDR=0x08048000
|
||||
ARCH=i386
|
||||
MACHINE=
|
||||
NOP=0x90909090
|
||||
TEMPLATE_NAME=elf32
|
||||
GENERATE_SHLIB_SCRIPT=yes
|
||||
ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\"
|
||||
NO_SMALL_DATA=yes
|
||||
@@ -1,40 +0,0 @@
|
||||
# This shell script emits a C file. -*- C -*-
|
||||
# Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GLD, the Gnu Linker.
|
||||
#
|
||||
# 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 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, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
|
||||
# This file is sourced from elf32.em. It is used by targets for
|
||||
# which relaxation is not just an optimization, but for correctness.
|
||||
|
||||
LDEMUL_BEFORE_ALLOCATION=need_relax_${EMULATION_NAME}_before_allocation
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
static void need_relax_${EMULATION_NAME}_before_allocation PARAMS ((void));
|
||||
|
||||
static void
|
||||
need_relax_${EMULATION_NAME}_before_allocation ()
|
||||
{
|
||||
/* Call main function; we're just extending it. */
|
||||
gld${EMULATION_NAME}_before_allocation ();
|
||||
|
||||
/* Force -relax on if not doing a relocatable link. */
|
||||
if (! link_info.relocateable)
|
||||
command_line.relax = true;
|
||||
}
|
||||
EOF
|
||||
@@ -1,303 +0,0 @@
|
||||
/* Provide a version of _doprnt in terms of fprintf.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
Contributed by Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
|
||||
|
||||
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, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "config.h"
|
||||
#include "ansidecl.h"
|
||||
#include "safe-ctype.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#undef _doprnt
|
||||
|
||||
#ifdef HAVE__DOPRNT
|
||||
#define TEST
|
||||
#endif
|
||||
|
||||
#ifdef TEST /* Make sure to use the internal one. */
|
||||
#define _doprnt my_doprnt
|
||||
#endif
|
||||
|
||||
#define COPY_VA_INT \
|
||||
do { \
|
||||
const int value = abs (va_arg (ap, int)); \
|
||||
char buf[32]; \
|
||||
ptr++; /* Go past the asterisk. */ \
|
||||
*sptr = '\0'; /* NULL terminate sptr. */ \
|
||||
sprintf(buf, "%d", value); \
|
||||
strcat(sptr, buf); \
|
||||
while (*sptr) sptr++; \
|
||||
} while (0)
|
||||
|
||||
#define PRINT_CHAR(CHAR) \
|
||||
do { \
|
||||
putc(CHAR, stream); \
|
||||
ptr++; \
|
||||
total_printed++; \
|
||||
continue; \
|
||||
} while (0)
|
||||
|
||||
#define PRINT_TYPE(TYPE) \
|
||||
do { \
|
||||
int result; \
|
||||
TYPE value = va_arg (ap, TYPE); \
|
||||
*sptr++ = *ptr++; /* Copy the type specifier. */ \
|
||||
*sptr = '\0'; /* NULL terminate sptr. */ \
|
||||
result = fprintf(stream, specifier, value); \
|
||||
if (result == -1) \
|
||||
return -1; \
|
||||
else \
|
||||
{ \
|
||||
total_printed += result; \
|
||||
continue; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
_doprnt (format, ap, stream)
|
||||
const char * format;
|
||||
va_list ap;
|
||||
FILE * stream;
|
||||
{
|
||||
const char * ptr = format;
|
||||
char specifier[128];
|
||||
int total_printed = 0;
|
||||
|
||||
while (*ptr != '\0')
|
||||
{
|
||||
if (*ptr != '%') /* While we have regular characters, print them. */
|
||||
PRINT_CHAR(*ptr);
|
||||
else /* We got a format specifier! */
|
||||
{
|
||||
char * sptr = specifier;
|
||||
int wide_width = 0, short_width = 0;
|
||||
|
||||
*sptr++ = *ptr++; /* Copy the % and move forward. */
|
||||
|
||||
while (strchr ("-+ #0", *ptr)) /* Move past flags. */
|
||||
*sptr++ = *ptr++;
|
||||
|
||||
if (*ptr == '*')
|
||||
COPY_VA_INT;
|
||||
else
|
||||
while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
|
||||
*sptr++ = *ptr++;
|
||||
|
||||
if (*ptr == '.')
|
||||
{
|
||||
*sptr++ = *ptr++; /* Copy and go past the period. */
|
||||
if (*ptr == '*')
|
||||
COPY_VA_INT;
|
||||
else
|
||||
while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
|
||||
*sptr++ = *ptr++;
|
||||
}
|
||||
while (strchr ("hlL", *ptr))
|
||||
{
|
||||
switch (*ptr)
|
||||
{
|
||||
case 'h':
|
||||
short_width = 1;
|
||||
break;
|
||||
case 'l':
|
||||
wide_width++;
|
||||
break;
|
||||
case 'L':
|
||||
wide_width = 2;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
*sptr++ = *ptr++;
|
||||
}
|
||||
|
||||
switch (*ptr)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'c':
|
||||
{
|
||||
/* Short values are promoted to int, so just copy it
|
||||
as an int and trust the C library printf to cast it
|
||||
to the right width. */
|
||||
if (short_width)
|
||||
PRINT_TYPE(int);
|
||||
else
|
||||
{
|
||||
switch (wide_width)
|
||||
{
|
||||
case 0:
|
||||
PRINT_TYPE(int);
|
||||
break;
|
||||
case 1:
|
||||
PRINT_TYPE(long);
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
|
||||
PRINT_TYPE(long long);
|
||||
#else
|
||||
PRINT_TYPE(long); /* Fake it and hope for the best. */
|
||||
#endif
|
||||
break;
|
||||
} /* End of switch (wide_width) */
|
||||
} /* End of else statement */
|
||||
} /* End of integer case */
|
||||
break;
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
if (wide_width == 0)
|
||||
PRINT_TYPE(double);
|
||||
else
|
||||
{
|
||||
#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
|
||||
PRINT_TYPE(long double);
|
||||
#else
|
||||
PRINT_TYPE(double); /* Fake it and hope for the best. */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
PRINT_TYPE(char *);
|
||||
break;
|
||||
case 'p':
|
||||
PRINT_TYPE(void *);
|
||||
break;
|
||||
case '%':
|
||||
PRINT_CHAR('%');
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
} /* End of switch (*ptr) */
|
||||
} /* End of else statement */
|
||||
}
|
||||
|
||||
return total_printed;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
#define M_PI (3.1415926535897932385)
|
||||
#endif
|
||||
|
||||
#define RESULT(x) do \
|
||||
{ \
|
||||
int i = (x); \
|
||||
printf ("printed %d characters\n", i); \
|
||||
fflush(stdin); \
|
||||
} while (0)
|
||||
|
||||
static int checkit PARAMS ((const char * format, ...)) ATTRIBUTE_PRINTF_1;
|
||||
|
||||
static int
|
||||
checkit VPARAMS ((const char* format, ...))
|
||||
{
|
||||
int result;
|
||||
VA_OPEN (args, format);
|
||||
VA_FIXEDARG (args, char *, format);
|
||||
|
||||
result = _doprnt (format, args, stdout);
|
||||
VA_CLOSE (args);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
RESULT(checkit ("<%d>\n", 0x12345678));
|
||||
RESULT(printf ("<%d>\n", 0x12345678));
|
||||
|
||||
RESULT(checkit ("<%200d>\n", 5));
|
||||
RESULT(printf ("<%200d>\n", 5));
|
||||
|
||||
RESULT(checkit ("<%.300d>\n", 6));
|
||||
RESULT(printf ("<%.300d>\n", 6));
|
||||
|
||||
RESULT(checkit ("<%100.150d>\n", 7));
|
||||
RESULT(printf ("<%100.150d>\n", 7));
|
||||
|
||||
RESULT(checkit ("<%s>\n",
|
||||
"jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
|
||||
777777777777777777333333333333366666666666622222222222777777777777733333"));
|
||||
RESULT(printf ("<%s>\n",
|
||||
"jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
|
||||
777777777777777777333333333333366666666666622222222222777777777777733333"));
|
||||
|
||||
RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
|
||||
1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
|
||||
RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
|
||||
1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
|
||||
|
||||
RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
|
||||
RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
|
||||
|
||||
RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
|
||||
RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
|
||||
|
||||
RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
|
||||
75, 75, 75, 75, 75, 75, 75));
|
||||
RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
|
||||
75, 75, 75, 75, 75, 75, 75));
|
||||
|
||||
RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
|
||||
75, 75, 75, 75, 75, 75, 75));
|
||||
RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
|
||||
75, 75, 75, 75, 75, 75, 75));
|
||||
|
||||
RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
|
||||
RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
|
||||
|
||||
#if defined(__GNUC__) || defined (HAVE_LONG_LONG)
|
||||
RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
|
||||
RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
|
||||
RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
|
||||
RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
|
||||
RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
|
||||
1.23456, 1.234567890123456789L, 1.23456));
|
||||
RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
|
||||
1.23456, 1.234567890123456789L, 1.23456));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST */
|
||||
@@ -1,565 +0,0 @@
|
||||
@node Library Copying
|
||||
@appendixsec GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
@cindex LGPL, Lesser General Public License
|
||||
@center Version 2.1, February 1999
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence the
|
||||
version number 2.1.]
|
||||
@end display
|
||||
|
||||
@appendixsubsec Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software---to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software---typically libraries---of the Free
|
||||
Software Foundation and other authors who decide to use it. You can use
|
||||
it too, but we suggest you first think carefully about whether this
|
||||
license or the ordinary General Public License is the better strategy to
|
||||
use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of it
|
||||
in new free programs; and that you are informed that you can do these
|
||||
things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the @dfn{Lesser} General Public License because it
|
||||
does @emph{Less} to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
``work based on the library'' and a ``work that uses the library''. The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
@iftex
|
||||
@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center GNU LESSER GENERAL PUBLIC LICENSE
|
||||
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
@end ifinfo
|
||||
|
||||
@enumerate 0
|
||||
@item
|
||||
This License Agreement applies to any software library or other program
|
||||
which contains a notice placed by the copyright holder or other
|
||||
authorized party saying it may be distributed under the terms of this
|
||||
Lesser General Public License (also called ``this License''). Each
|
||||
licensee is addressed as ``you''.
|
||||
|
||||
A ``library'' means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The ``Library'', below, refers to any such software library or work
|
||||
which has been distributed under these terms. A ``work based on the
|
||||
Library'' means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term ``modification''.)
|
||||
|
||||
``Source code'' for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
@item
|
||||
You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
@item
|
||||
You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
@enumerate a
|
||||
@item
|
||||
The modified work must itself be a software library.
|
||||
|
||||
@item
|
||||
You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
@item
|
||||
You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
@item
|
||||
If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
@end enumerate
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
@item
|
||||
You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
@item
|
||||
You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
@item
|
||||
A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a ``work that uses the Library''. Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a ``work that uses the Library'' with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a ``work that uses the
|
||||
library''. The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a ``work that uses the Library'' uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
@item
|
||||
As an exception to the Sections above, you may also combine or
|
||||
link a ``work that uses the Library'' with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
@enumerate a
|
||||
@item
|
||||
Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable ``work that
|
||||
uses the Library'', as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
@item
|
||||
Use a suitable shared library mechanism for linking with the Library. A
|
||||
suitable mechanism is one that (1) uses at run time a copy of the
|
||||
library already present on the user's computer system, rather than
|
||||
copying library functions into the executable, and (2) will operate
|
||||
properly with a modified version of the library, if the user installs
|
||||
one, as long as the modified version is interface-compatible with the
|
||||
version that the work was made with.
|
||||
|
||||
@item
|
||||
Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
@item
|
||||
If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
@item
|
||||
Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
@end enumerate
|
||||
|
||||
For an executable, the required form of the ``work that uses the
|
||||
Library'' must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies the
|
||||
executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
@item
|
||||
You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
@enumerate a
|
||||
@item
|
||||
Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
@item
|
||||
Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
@end enumerate
|
||||
|
||||
@item
|
||||
You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
@item
|
||||
You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
@item
|
||||
Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
@item
|
||||
If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
@item
|
||||
If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
@item
|
||||
The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
``any later version'', you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
@item
|
||||
If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
@iftex
|
||||
@heading NO WARRANTY
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center NO WARRANTY
|
||||
@end ifinfo
|
||||
|
||||
@item
|
||||
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY ``AS IS'' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
@item
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
@end enumerate
|
||||
|
||||
@iftex
|
||||
@heading END OF TERMS AND CONDITIONS
|
||||
@end iftex
|
||||
@ifinfo
|
||||
@center END OF TERMS AND CONDITIONS
|
||||
@end ifinfo
|
||||
|
||||
@page
|
||||
@appendixsubsec How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
``copyright'' line and a pointer to where the full notice is found.
|
||||
|
||||
@smallexample
|
||||
@var{one line to give the library's name and an idea of what it does.}
|
||||
Copyright (C) @var{year} @var{name of author}
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
|
||||
USA.
|
||||
@end smallexample
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a ``copyright disclaimer'' for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
@smallexample
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the library
|
||||
`Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
@var{signature of Ty Coon}, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
@end smallexample
|
||||
|
||||
That's all there is to it!
|
||||
@@ -1,27 +0,0 @@
|
||||
/* ffs -- Find the first bit set in the parameter
|
||||
|
||||
@deftypefn Supplemental int ffs (int @var{valu})
|
||||
|
||||
Find the first (least significant) bit set in @var{valu}. Bits are
|
||||
numbered from right to left, starting with bit 1 (corresponding to the
|
||||
value 1). If @var{valu} is zero, zero is returned.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
ffs (valu)
|
||||
register int valu;
|
||||
{
|
||||
register int bit;
|
||||
|
||||
if (valu == 0)
|
||||
return 0;
|
||||
|
||||
for (bit = 1; !(valu & 1); bit++)
|
||||
valu >>= 1;
|
||||
|
||||
return bit;
|
||||
}
|
||||
|
||||
@@ -1,523 +0,0 @@
|
||||
/* A Fibonacci heap datatype.
|
||||
Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
Contributed by Daniel Berlin (dan@cgsoftware.com).
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC 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.
|
||||
|
||||
GNU CC 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 GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "libiberty.h"
|
||||
#include "fibheap.h"
|
||||
|
||||
|
||||
#define FIBHEAPKEY_MIN LONG_MIN
|
||||
|
||||
static void fibheap_ins_root PARAMS ((fibheap_t, fibnode_t));
|
||||
static void fibheap_rem_root PARAMS ((fibheap_t, fibnode_t));
|
||||
static void fibheap_consolidate PARAMS ((fibheap_t));
|
||||
static void fibheap_link PARAMS ((fibheap_t, fibnode_t, fibnode_t));
|
||||
static void fibheap_cut PARAMS ((fibheap_t, fibnode_t, fibnode_t));
|
||||
static void fibheap_cascading_cut PARAMS ((fibheap_t, fibnode_t));
|
||||
static fibnode_t fibheap_extr_min_node PARAMS ((fibheap_t));
|
||||
static int fibheap_compare PARAMS ((fibheap_t, fibnode_t, fibnode_t));
|
||||
static int fibheap_comp_data PARAMS ((fibheap_t, fibheapkey_t, void *,
|
||||
fibnode_t));
|
||||
static fibnode_t fibnode_new PARAMS ((void));
|
||||
static void fibnode_insert_after PARAMS ((fibnode_t, fibnode_t));
|
||||
#define fibnode_insert_before(a, b) fibnode_insert_after (a->left, b)
|
||||
static fibnode_t fibnode_remove PARAMS ((fibnode_t));
|
||||
|
||||
|
||||
/* Create a new fibonacci heap. */
|
||||
fibheap_t
|
||||
fibheap_new ()
|
||||
{
|
||||
return (fibheap_t) xcalloc (1, sizeof (struct fibheap));
|
||||
}
|
||||
|
||||
/* Create a new fibonacci heap node. */
|
||||
static fibnode_t
|
||||
fibnode_new ()
|
||||
{
|
||||
fibnode_t node;
|
||||
|
||||
node = xcalloc (1, sizeof *node);
|
||||
node->left = node;
|
||||
node->right = node;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static inline int
|
||||
fibheap_compare (heap, a, b)
|
||||
fibheap_t heap ATTRIBUTE_UNUSED;
|
||||
fibnode_t a;
|
||||
fibnode_t b;
|
||||
{
|
||||
if (a->key < b->key)
|
||||
return -1;
|
||||
if (a->key > b->key)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
fibheap_comp_data (heap, key, data, b)
|
||||
fibheap_t heap;
|
||||
fibheapkey_t key;
|
||||
void *data;
|
||||
fibnode_t b;
|
||||
{
|
||||
struct fibnode a;
|
||||
|
||||
a.key = key;
|
||||
a.data = data;
|
||||
|
||||
return fibheap_compare (heap, &a, b);
|
||||
}
|
||||
|
||||
/* Insert DATA, with priority KEY, into HEAP. */
|
||||
fibnode_t
|
||||
fibheap_insert (heap, key, data)
|
||||
fibheap_t heap;
|
||||
fibheapkey_t key;
|
||||
void *data;
|
||||
{
|
||||
fibnode_t node;
|
||||
|
||||
/* Create the new node. */
|
||||
node = fibnode_new ();
|
||||
|
||||
/* Set the node's data. */
|
||||
node->data = data;
|
||||
node->key = key;
|
||||
|
||||
/* Insert it into the root list. */
|
||||
fibheap_ins_root (heap, node);
|
||||
|
||||
/* If their was no minimum, or this key is less than the min,
|
||||
it's the new min. */
|
||||
if (heap->min == NULL || node->key < heap->min->key)
|
||||
heap->min = node;
|
||||
|
||||
heap->nodes++;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/* Return the data of the minimum node (if we know it). */
|
||||
void *
|
||||
fibheap_min (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
/* If there is no min, we can't easily return it. */
|
||||
if (heap->min == NULL)
|
||||
return NULL;
|
||||
return heap->min->data;
|
||||
}
|
||||
|
||||
/* Return the key of the minimum node (if we know it). */
|
||||
fibheapkey_t
|
||||
fibheap_min_key (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
/* If there is no min, we can't easily return it. */
|
||||
if (heap->min == NULL)
|
||||
return 0;
|
||||
return heap->min->key;
|
||||
}
|
||||
|
||||
/* Union HEAPA and HEAPB into a new heap. */
|
||||
fibheap_t
|
||||
fibheap_union (heapa, heapb)
|
||||
fibheap_t heapa;
|
||||
fibheap_t heapb;
|
||||
{
|
||||
fibnode_t a_root, b_root, temp;
|
||||
|
||||
/* If one of the heaps is empty, the union is just the other heap. */
|
||||
if ((a_root = heapa->root) == NULL)
|
||||
{
|
||||
free (heapa);
|
||||
return heapb;
|
||||
}
|
||||
if ((b_root = heapb->root) == NULL)
|
||||
{
|
||||
free (heapb);
|
||||
return heapa;
|
||||
}
|
||||
|
||||
/* Merge them to the next nodes on the opposite chain. */
|
||||
a_root->left->right = b_root;
|
||||
b_root->left->right = a_root;
|
||||
temp = a_root->left;
|
||||
a_root->left = b_root->left;
|
||||
b_root->left = temp;
|
||||
heapa->nodes += heapb->nodes;
|
||||
|
||||
/* And set the new minimum, if it's changed. */
|
||||
if (fibheap_compare (heapa, heapb->min, heapa->min) < 0)
|
||||
heapa->min = heapb->min;
|
||||
|
||||
free (heapb);
|
||||
return heapa;
|
||||
}
|
||||
|
||||
/* Extract the data of the minimum node from HEAP. */
|
||||
void *
|
||||
fibheap_extract_min (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
fibnode_t z;
|
||||
void *ret = NULL;
|
||||
|
||||
/* If we don't have a min set, it means we have no nodes. */
|
||||
if (heap->min != NULL)
|
||||
{
|
||||
/* Otherwise, extract the min node, free the node, and return the
|
||||
node's data. */
|
||||
z = fibheap_extr_min_node (heap);
|
||||
ret = z->data;
|
||||
free (z);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Replace both the KEY and the DATA associated with NODE. */
|
||||
void *
|
||||
fibheap_replace_key_data (heap, node, key, data)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
fibheapkey_t key;
|
||||
void *data;
|
||||
{
|
||||
void *odata;
|
||||
int okey;
|
||||
fibnode_t y;
|
||||
|
||||
/* If we wanted to, we could actually do a real increase by redeleting and
|
||||
inserting. However, this would require O (log n) time. So just bail out
|
||||
for now. */
|
||||
if (fibheap_comp_data (heap, key, data, node) > 0)
|
||||
return NULL;
|
||||
|
||||
odata = node->data;
|
||||
okey = node->key;
|
||||
node->data = data;
|
||||
node->key = key;
|
||||
y = node->parent;
|
||||
|
||||
if (okey == key)
|
||||
return odata;
|
||||
|
||||
/* These two compares are specifically <= 0 to make sure that in the case
|
||||
of equality, a node we replaced the data on, becomes the new min. This
|
||||
is needed so that delete's call to extractmin gets the right node. */
|
||||
if (y != NULL && fibheap_compare (heap, node, y) <= 0)
|
||||
{
|
||||
fibheap_cut (heap, node, y);
|
||||
fibheap_cascading_cut (heap, y);
|
||||
}
|
||||
|
||||
if (fibheap_compare (heap, node, heap->min) <= 0)
|
||||
heap->min = node;
|
||||
|
||||
return odata;
|
||||
}
|
||||
|
||||
/* Replace the DATA associated with NODE. */
|
||||
void *
|
||||
fibheap_replace_data (heap, node, data)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
void *data;
|
||||
{
|
||||
return fibheap_replace_key_data (heap, node, node->key, data);
|
||||
}
|
||||
|
||||
/* Replace the KEY associated with NODE. */
|
||||
fibheapkey_t
|
||||
fibheap_replace_key (heap, node, key)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
fibheapkey_t key;
|
||||
{
|
||||
int okey = node->key;
|
||||
fibheap_replace_key_data (heap, node, key, node->data);
|
||||
return okey;
|
||||
}
|
||||
|
||||
/* Delete NODE from HEAP. */
|
||||
void *
|
||||
fibheap_delete_node (heap, node)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
{
|
||||
void *ret = node->data;
|
||||
|
||||
/* To perform delete, we just make it the min key, and extract. */
|
||||
fibheap_replace_key (heap, node, FIBHEAPKEY_MIN);
|
||||
fibheap_extract_min (heap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Delete HEAP. */
|
||||
void
|
||||
fibheap_delete (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
while (heap->min != NULL)
|
||||
free (fibheap_extr_min_node (heap));
|
||||
|
||||
free (heap);
|
||||
}
|
||||
|
||||
/* Determine if HEAP is empty. */
|
||||
int
|
||||
fibheap_empty (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
return heap->nodes == 0;
|
||||
}
|
||||
|
||||
/* Extract the minimum node of the heap. */
|
||||
static fibnode_t
|
||||
fibheap_extr_min_node (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
fibnode_t ret = heap->min;
|
||||
fibnode_t x, y, orig;
|
||||
|
||||
/* Attach the child list of the minimum node to the root list of the heap.
|
||||
If there is no child list, we don't do squat. */
|
||||
for (x = ret->child, orig = NULL; x != orig && x != NULL; x = y)
|
||||
{
|
||||
if (orig == NULL)
|
||||
orig = x;
|
||||
y = x->right;
|
||||
x->parent = NULL;
|
||||
fibheap_ins_root (heap, x);
|
||||
}
|
||||
|
||||
/* Remove the old root. */
|
||||
fibheap_rem_root (heap, ret);
|
||||
heap->nodes--;
|
||||
|
||||
/* If we are left with no nodes, then the min is NULL. */
|
||||
if (heap->nodes == 0)
|
||||
heap->min = NULL;
|
||||
else
|
||||
{
|
||||
/* Otherwise, consolidate to find new minimum, as well as do the reorg
|
||||
work that needs to be done. */
|
||||
heap->min = ret->right;
|
||||
fibheap_consolidate (heap);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Insert NODE into the root list of HEAP. */
|
||||
static void
|
||||
fibheap_ins_root (heap, node)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
{
|
||||
/* If the heap is currently empty, the new node becomes the singleton
|
||||
circular root list. */
|
||||
if (heap->root == NULL)
|
||||
{
|
||||
heap->root = node;
|
||||
node->left = node;
|
||||
node->right = node;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Otherwise, insert it in the circular root list between the root
|
||||
and it's right node. */
|
||||
fibnode_insert_after (heap->root, node);
|
||||
}
|
||||
|
||||
/* Remove NODE from the rootlist of HEAP. */
|
||||
static void
|
||||
fibheap_rem_root (heap, node)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
{
|
||||
if (node->left == node)
|
||||
heap->root = NULL;
|
||||
else
|
||||
heap->root = fibnode_remove (node);
|
||||
}
|
||||
|
||||
/* Consolidate the heap. */
|
||||
static void
|
||||
fibheap_consolidate (heap)
|
||||
fibheap_t heap;
|
||||
{
|
||||
fibnode_t a[1 + 8 * sizeof (long)];
|
||||
fibnode_t w;
|
||||
fibnode_t y;
|
||||
fibnode_t x;
|
||||
int i;
|
||||
int d;
|
||||
int D;
|
||||
|
||||
D = 1 + 8 * sizeof (long);
|
||||
|
||||
memset (a, 0, sizeof (fibnode_t) * D);
|
||||
|
||||
while ((w = heap->root) != NULL)
|
||||
{
|
||||
x = w;
|
||||
fibheap_rem_root (heap, w);
|
||||
d = x->degree;
|
||||
while (a[d] != NULL)
|
||||
{
|
||||
y = a[d];
|
||||
if (fibheap_compare (heap, x, y) > 0)
|
||||
{
|
||||
fibnode_t temp;
|
||||
temp = x;
|
||||
x = y;
|
||||
y = temp;
|
||||
}
|
||||
fibheap_link (heap, y, x);
|
||||
a[d] = NULL;
|
||||
d++;
|
||||
}
|
||||
a[d] = x;
|
||||
}
|
||||
heap->min = NULL;
|
||||
for (i = 0; i < D; i++)
|
||||
if (a[i] != NULL)
|
||||
{
|
||||
fibheap_ins_root (heap, a[i]);
|
||||
if (heap->min == NULL || fibheap_compare (heap, a[i], heap->min) < 0)
|
||||
heap->min = a[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Make NODE a child of PARENT. */
|
||||
static void
|
||||
fibheap_link (heap, node, parent)
|
||||
fibheap_t heap ATTRIBUTE_UNUSED;
|
||||
fibnode_t node;
|
||||
fibnode_t parent;
|
||||
{
|
||||
if (parent->child == NULL)
|
||||
parent->child = node;
|
||||
else
|
||||
fibnode_insert_before (parent->child, node);
|
||||
node->parent = parent;
|
||||
parent->degree++;
|
||||
node->mark = 0;
|
||||
}
|
||||
|
||||
/* Remove NODE from PARENT's child list. */
|
||||
static void
|
||||
fibheap_cut (heap, node, parent)
|
||||
fibheap_t heap;
|
||||
fibnode_t node;
|
||||
fibnode_t parent;
|
||||
{
|
||||
fibnode_remove (node);
|
||||
parent->degree--;
|
||||
fibheap_ins_root (heap, node);
|
||||
node->parent = NULL;
|
||||
node->mark = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
fibheap_cascading_cut (heap, y)
|
||||
fibheap_t heap;
|
||||
fibnode_t y;
|
||||
{
|
||||
fibnode_t z;
|
||||
|
||||
while ((z = y->parent) != NULL)
|
||||
{
|
||||
if (y->mark == 0)
|
||||
{
|
||||
y->mark = 1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fibheap_cut (heap, y, z);
|
||||
y = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fibnode_insert_after (a, b)
|
||||
fibnode_t a;
|
||||
fibnode_t b;
|
||||
{
|
||||
if (a == a->right)
|
||||
{
|
||||
a->right = b;
|
||||
a->left = b;
|
||||
b->right = a;
|
||||
b->left = a;
|
||||
}
|
||||
else
|
||||
{
|
||||
b->right = a->right;
|
||||
a->right->left = b;
|
||||
a->right = b;
|
||||
b->left = a;
|
||||
}
|
||||
}
|
||||
|
||||
static fibnode_t
|
||||
fibnode_remove (node)
|
||||
fibnode_t node;
|
||||
{
|
||||
fibnode_t ret;
|
||||
|
||||
if (node == node->left)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = node->left;
|
||||
|
||||
if (node->parent != NULL && node->parent->child == node)
|
||||
node->parent->child = ret;
|
||||
|
||||
node->right->left = node->left;
|
||||
node->left->right = node->right;
|
||||
|
||||
node->parent = NULL;
|
||||
node->left = node;
|
||||
node->right = node;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})
|
||||
|
||||
Matches @var{string} against @var{pattern}, returning zero if it
|
||||
matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the
|
||||
wildcards @code{?} to match any one character, @code{*} to match any
|
||||
zero or more characters, or a set of alternate characters in square
|
||||
brackets, like @samp{[a-gt8]}, which match one character (@code{a}
|
||||
through @code{g}, or @code{t}, or @code{8}, in this example) if that one
|
||||
character is in the set. A set may be inverted (i.e., match anything
|
||||
except what's in the set) by giving @code{^} or @code{!} as the first
|
||||
character in the set. To include those characters in the set, list them
|
||||
as anything other than the first character of the set. To include a
|
||||
dash in the set, list it last in the set. A backslash character makes
|
||||
the following character not special, so for example you could match
|
||||
against a literal asterisk with @samp{\*}. To match a literal
|
||||
backslash, use @samp{\\}.
|
||||
|
||||
@code{flags} controls various aspects of the matching process, and is a
|
||||
boolean OR of zero or more of the following values (defined in
|
||||
@code{<fnmatch.h>}):
|
||||
|
||||
@table @code
|
||||
|
||||
@item FNM_PATHNAME
|
||||
@itemx FNM_FILE_NAME
|
||||
@var{string} is assumed to be a path name. No wildcard will ever match
|
||||
@code{/}.
|
||||
|
||||
@item FNM_NOESCAPE
|
||||
Do not interpret backslashes as quoting the following special character.
|
||||
|
||||
@item FNM_PERIOD
|
||||
A leading period (at the beginning of @var{string}, or if
|
||||
@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
|
||||
@code{?} but must be matched explicitly.
|
||||
|
||||
@item FNM_LEADING_DIR
|
||||
Means that @var{string} also matches @var{pattern} if some initial part
|
||||
of @var{string} matches, and is followed by @code{/} and zero or more
|
||||
characters. For example, @samp{foo*} would match either @samp{foobar}
|
||||
or @samp{foobar/grill}.
|
||||
|
||||
@item FNM_CASEFOLD
|
||||
Ignores case when performing the comparison.
|
||||
|
||||
@end table
|
||||
|
||||
@end deftypefn
|
||||
Loaded 100 of 1825 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user