Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
- Fix for default mtree style
- Update libelf
- Importing libexecinfo
- Resynchronize GCC, mpc, gmp, mpfr
- build.sh: Replace params with show-params.
This has been done as the make target has been renamed in the same
way, while a new target named params has been added. This new
target generates a file containing all the parameters, instead of
printing it on the console.
- Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
get getservbyport() out of the inner loop
Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR= \
|
||||
fingerd ftpd \
|
||||
ld.elf_so \
|
||||
getty
|
||||
fingerd ftpd getty \
|
||||
ld.elf_so \
|
||||
\
|
||||
|
||||
|
||||
|
||||
.if defined(__MINIX)
|
||||
SUBDIR+= makewhatis
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# $NetBSD: Makefile.inc,v 1.9 2012/06/19 06:10:09 dholland Exp $
|
||||
# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
|
||||
.if defined(__MINIX)
|
||||
USE_FORT?= no
|
||||
.else
|
||||
|
||||
USE_FORT?= yes # network server
|
||||
.endif
|
||||
|
||||
BINDIR?= /usr/libexec
|
||||
WARNS?= 5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cmds.c,v 1.31 2012/06/19 06:06:34 dholland Exp $ */
|
||||
/* $NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: cmds.c,v 1.31 2012/06/19 06:06:34 dholland Exp $");
|
||||
__RCSID("$NetBSD: cmds.c,v 1.33 2013/07/03 14:15:47 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -878,7 +878,7 @@ discover_path(char *last_path, const char *new_path)
|
||||
cp = tp;
|
||||
nomorelink = 1;
|
||||
|
||||
while ((cp = strstr(++cp, "/")) != NULL) {
|
||||
while ((cp = strstr(cp + 1, "/")) != NULL) {
|
||||
sz1 = (unsigned long)cp - (unsigned long)tp;
|
||||
if (sz1 > MAXPATHLEN)
|
||||
goto bad;
|
||||
@@ -951,8 +951,8 @@ discover_path(char *last_path, const char *new_path)
|
||||
tp[strlen(tp) - 1] = '\0';
|
||||
|
||||
/* check that the path is correct */
|
||||
stat(tp, &st1);
|
||||
stat(".", &st2);
|
||||
if (stat(tp, &st1) == -1 || stat(".", &st2) == -1)
|
||||
goto bad;
|
||||
if ((st1.st_dev != st2.st_dev) || (st1.st_ino != st2.st_ino))
|
||||
goto bad;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $ */
|
||||
/* $NetBSD: conf.c,v 1.64 2012/11/04 20:46:46 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $");
|
||||
__RCSID("$NetBSD: conf.c,v 1.64 2012/11/04 20:46:46 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: conf.c,v 1.63 2011/08/14 11:46:28 christos Exp $");
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <glob.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.62 2011/08/29 20:41:06 joerg Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.63 2013/03/21 05:53:01 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@@ -118,7 +118,7 @@ void closedataconn(FILE *);
|
||||
char *conffilename(const char *);
|
||||
void count_users(void);
|
||||
void cprintf(FILE *, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
__printflike(2, 3);
|
||||
void cwd(const char *);
|
||||
FILE *dataconn(const char *, off_t, const char *);
|
||||
void delete(const char *);
|
||||
@@ -155,7 +155,7 @@ void removedir(const char *);
|
||||
void renamecmd(const char *, const char *);
|
||||
char *renamefrom(const char *);
|
||||
void reply(int, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
__printflike(2, 3);
|
||||
void retrieve(const char *[], const char *);
|
||||
void send_file_list(const char *);
|
||||
void show_chdir_messages(int);
|
||||
@@ -295,7 +295,7 @@ struct ftpclass {
|
||||
LLT sendlowat; /* SO_SNDLOWAT size */
|
||||
};
|
||||
|
||||
extern void ftp_loop(void) __attribute__ ((noreturn));
|
||||
__dead extern void ftp_loop(void);
|
||||
extern void ftp_handle_line(char *);
|
||||
|
||||
#ifndef GLOBAL
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $ */
|
||||
/* $NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
|
||||
@@ -97,7 +97,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: ftpd.c,v 1.198 2012/06/19 06:06:34 dholland Exp $");
|
||||
__RCSID("$NetBSD: ftpd.c,v 1.200 2013/07/31 19:50:47 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -261,11 +261,11 @@ static int write_data(int, char *, size_t, off_t *, struct timeval *,
|
||||
int);
|
||||
static enum send_status
|
||||
send_data_with_read(int, int, const struct stat *, int);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
static enum send_status
|
||||
send_data_with_mmap(int, int, const struct stat *, int);
|
||||
static void logrusage(const struct rusage *, const struct rusage *);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
static void logout_utmp(void);
|
||||
|
||||
int main(int, char *[]);
|
||||
@@ -482,7 +482,7 @@ main(int argc, char *argv[])
|
||||
#endif
|
||||
}
|
||||
errno = 0;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
l = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
if (l == -1 && errno != 0) {
|
||||
syslog(LOG_ERR, "sysconf _SC_LOGIN_NAME_MAX: %m");
|
||||
@@ -494,7 +494,7 @@ main(int argc, char *argv[])
|
||||
curname_len = (size_t)l;
|
||||
#else
|
||||
curname_len = _POSIX_LOGIN_NAME_MAX;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
curname = malloc(curname_len);
|
||||
if (curname == NULL) {
|
||||
syslog(LOG_ERR, "malloc: %m");
|
||||
@@ -704,7 +704,7 @@ main(int argc, char *argv[])
|
||||
sa.sa_handler = toolong;
|
||||
(void) sigaction(SIGALRM, &sa, NULL);
|
||||
sa.sa_handler = sigurg;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void) sigaction(SIGURG, &sa, NULL);
|
||||
|
||||
/* Try to handle urgent data inline */
|
||||
@@ -719,7 +719,7 @@ main(int argc, char *argv[])
|
||||
sizeof(int)) < 0)
|
||||
syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
#ifdef F_SETOWN
|
||||
if (fcntl(fileno(stdin), F_SETOWN, getpid()) == -1)
|
||||
@@ -1606,10 +1606,10 @@ do_pass(int pass_checked, int pass_rval, const char *passwd)
|
||||
}
|
||||
#ifndef LOGIN_CAP
|
||||
setsid();
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
setlogin(pw->pw_name);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
if (dropprivs ||
|
||||
(curclass.type != CLASS_REAL &&
|
||||
ntohs(ctrl_addr.su_port) > IPPORT_RESERVED + 1)) {
|
||||
@@ -1694,9 +1694,9 @@ retrieve(const char *argv[], const char *name)
|
||||
int (*closefunc)(FILE *) = NULL;
|
||||
int dolog, sendrv, closerv, stderrfd, isconversion, isdata, isls;
|
||||
struct timeval start, finish, td, *tdp;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
struct rusage rusage_before, rusage_after;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
const char *dispname;
|
||||
const char *error;
|
||||
|
||||
@@ -1777,25 +1777,25 @@ retrieve(const char *argv[], const char *name)
|
||||
if (dout == NULL)
|
||||
goto done;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)getrusage(RUSAGE_SELF, &rusage_before);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
(void)gettimeofday(&start, NULL);
|
||||
sendrv = send_data(fin, dout, &st, isdata);
|
||||
(void)gettimeofday(&finish, NULL);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)getrusage(RUSAGE_SELF, &rusage_after);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
closedataconn(dout); /* close now to affect timing stats */
|
||||
timersub(&finish, &start, &td);
|
||||
tdp = &td;
|
||||
done:
|
||||
if (dolog) {
|
||||
logxfer("get", byte_count, name, NULL, tdp, error);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (tdp != NULL)
|
||||
logrusage(&rusage_before, &rusage_after);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
}
|
||||
closerv = (*closefunc)(fin);
|
||||
if (sendrv == 0) {
|
||||
@@ -2014,7 +2014,7 @@ dataconn(const char *name, off_t size, const char *fmode)
|
||||
}
|
||||
(void) close(pdata);
|
||||
pdata = s;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
switch (from.su_family) {
|
||||
case AF_INET:
|
||||
#ifdef IP_TOS
|
||||
@@ -2026,7 +2026,7 @@ dataconn(const char *name, off_t size, const char *fmode)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
/* Set keepalives on the socket to detect dropped conns. */
|
||||
#ifdef SO_KEEPALIVE
|
||||
keepalive = 1;
|
||||
@@ -2169,7 +2169,7 @@ send_data_with_read(int filefd, int netfd, const struct stat *st, int isdata)
|
||||
(void)gettimeofday(&then, NULL);
|
||||
} else
|
||||
bufrem = readsize;
|
||||
while (1) {
|
||||
for (;;) {
|
||||
(void) alarm(curclass.timeout);
|
||||
c = read(filefd, buf, readsize);
|
||||
if (c == 0)
|
||||
@@ -2232,7 +2232,7 @@ send_data_with_mmap(int filefd, int netfd, const struct stat *st, int isdata)
|
||||
(void)gettimeofday(&then, NULL);
|
||||
} else
|
||||
bufrem = winsize;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
while (1) {
|
||||
mapsize = MIN(filesize - off, winsize);
|
||||
if (mapsize == 0)
|
||||
@@ -2257,7 +2257,7 @@ send_data_with_mmap(int filefd, int netfd, const struct stat *st, int isdata)
|
||||
}
|
||||
return (SS_SUCCESS);
|
||||
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
try_read:
|
||||
return (send_data_with_read(filefd, netfd, st, isdata));
|
||||
}
|
||||
@@ -2414,7 +2414,7 @@ receive_data(FILE *instr, FILE *outstr)
|
||||
(void) alarm(curclass.timeout);
|
||||
if (curclass.readsize)
|
||||
readsize = curclass.readsize;
|
||||
else if (fstat(filefd, &st))
|
||||
else if (fstat(filefd, &st) != -1)
|
||||
readsize = (ssize_t)st.st_blksize;
|
||||
else
|
||||
readsize = BUFSIZ;
|
||||
@@ -2852,7 +2852,6 @@ reply(int n, const char *fmt, ...)
|
||||
size_t b;
|
||||
va_list ap;
|
||||
|
||||
b = 0;
|
||||
if (n == 0)
|
||||
b = snprintf(msg, sizeof(msg), " ");
|
||||
else if (n < 0)
|
||||
@@ -3671,7 +3670,7 @@ logxfer(const char *command, off_t bytes, const char *file1, const char *file2,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
/*
|
||||
* Log the resource usage.
|
||||
*
|
||||
@@ -3696,7 +3695,7 @@ logrusage(const struct rusage *rusage_before,
|
||||
rusage_after->ru_majflt - rusage_before->ru_majflt,
|
||||
rusage_after->ru_nswap - rusage_before->ru_nswap);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/*
|
||||
* Determine if `password' is valid for user given in `pw'.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* $NetBSD: version.h,v 1.74 2010/03/21 20:27:26 lukem Exp $ */
|
||||
/* $NetBSD: version.h,v 1.75 2013/03/21 00:17:26 lukem Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1999-2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@@ -29,5 +29,5 @@
|
||||
*/
|
||||
|
||||
#ifndef FTPD_VERSION
|
||||
#define FTPD_VERSION "NetBSD-ftpd 20100320"
|
||||
#define FTPD_VERSION "NetBSD-ftpd 20110904"
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.19 2010/02/03 15:34:43 roy Exp $
|
||||
# $NetBSD: Makefile,v 1.20 2013/08/11 05:42:41 dholland Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
|
||||
|
||||
WARNS?= 2 # XXX: many const & sign-compare issues
|
||||
|
||||
PROG= getty
|
||||
SRCS= main.c init.c subr.c
|
||||
DPADD+= ${LIBUTIL} ${LIBTERMINFO}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.6 2003/08/07 09:46:41 agc Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.7 2013/08/11 05:42:41 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993
|
||||
@@ -34,17 +34,17 @@
|
||||
struct delayval;
|
||||
|
||||
int adelay(int, struct delayval *);
|
||||
char *autobaud(void);
|
||||
const char *autobaud(void);
|
||||
int delaybits(void);
|
||||
void edithost(char *);
|
||||
void edithost(const char *);
|
||||
void gendefaults(void);
|
||||
int getent(char *, char *);
|
||||
int getflag(char *);
|
||||
long getnum(char *);
|
||||
char *getstr(char *, char **);
|
||||
void gettable(char *, char *);
|
||||
void gettable(const char *, char *);
|
||||
void makeenv(char *[]);
|
||||
char *portselector(void);
|
||||
const char *portselector(void);
|
||||
void set_ttydefaults(int);
|
||||
void setchars(void);
|
||||
void setdefaults(void);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: getty.8,v 1.17 2003/08/07 09:46:42 agc Exp $
|
||||
.\" $NetBSD: getty.8,v 1.18 2013/05/29 15:02:12 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -29,7 +29,7 @@
|
||||
.\"
|
||||
.\" from: @(#)getty.8 8.1 (Berkeley) 6/4/93
|
||||
.\"
|
||||
.Dd December 12, 1998
|
||||
.Dd May 29, 2013
|
||||
.Dt GETTY 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -145,6 +145,7 @@ of processes that dial out on that tty.
|
||||
.Bl -tag -width /var/spool/lock/LCK..ttyXX -compact
|
||||
.It Pa /etc/gettytab
|
||||
.It Pa /etc/ttys
|
||||
.It Pa /usr/libexec/getty
|
||||
.It Pa /var/spool/lock/LCK..ttyXX
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gettytab.h,v 1.16 2006/11/16 04:31:24 christos Exp $ */
|
||||
/* $NetBSD: gettytab.h,v 1.17 2013/08/11 05:42:41 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993, 1994
|
||||
@@ -35,20 +35,20 @@
|
||||
* Getty description definitions.
|
||||
*/
|
||||
struct gettystrs {
|
||||
char *field; /* name to lookup in gettytab */
|
||||
char *defalt; /* value we find by looking in defaults */
|
||||
const char *field; /* name to lookup in gettytab */
|
||||
const char *defalt; /* value we find by looking in defaults */
|
||||
char *value; /* value that we find there */
|
||||
};
|
||||
|
||||
struct gettynums {
|
||||
char *field; /* name to lookup */
|
||||
const char *field; /* name to lookup */
|
||||
long defalt; /* number we find in defaults */
|
||||
long value; /* number we find there */
|
||||
int set; /* we actually got this one */
|
||||
};
|
||||
|
||||
struct gettyflags {
|
||||
char *field; /* name to lookup */
|
||||
const char *field; /* name to lookup */
|
||||
char invrt; /* name existing in gettytab --> false */
|
||||
char defalt; /* true/false in defaults */
|
||||
char value; /* true/false flag */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init.c,v 1.17 2007/12/03 09:54:24 isaki Exp $ */
|
||||
/* $NetBSD: init.c,v 1.18 2013/08/11 05:42:41 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: init.c,v 1.17 2007/12/03 09:54:24 isaki Exp $");
|
||||
__RCSID("$NetBSD: init.c,v 1.18 2013/08/11 05:42:41 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@@ -44,6 +44,7 @@ __RCSID("$NetBSD: init.c,v 1.17 2007/12/03 09:54:24 isaki Exp $");
|
||||
* Melbourne getty.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "gettytab.h"
|
||||
@@ -55,92 +56,92 @@ extern char hostname[];
|
||||
#define M(a) ((char *)&tmode.c_cc[a])
|
||||
|
||||
struct gettystrs gettystrs[] = {
|
||||
{ "nx" }, /* next table */
|
||||
{ "cl" }, /* screen clear characters */
|
||||
{ "im" }, /* initial message */
|
||||
{ "lm", "login: " }, /* login message */
|
||||
{ "er", M(VERASE) }, /* erase character */
|
||||
{ "kl", M(VKILL) }, /* kill character */
|
||||
{ "et", M(VEOF) }, /* eof chatacter (eot) */
|
||||
{ "pc", "" }, /* pad character */
|
||||
{ "tt" }, /* terminal type */
|
||||
{ "ev" }, /* environment */
|
||||
{ "lo", _PATH_LOGIN }, /* login program */
|
||||
{ "hn", hostname }, /* host name */
|
||||
{ "he" }, /* host name edit */
|
||||
{ "in", M(VINTR) }, /* interrupt char */
|
||||
{ "qu", M(VQUIT) }, /* quit char */
|
||||
{ "xn", M(VSTART) }, /* XON (start) char */
|
||||
{ "xf", M(VSTOP) }, /* XOFF (stop) char */
|
||||
{ "bk", M(VEOL) }, /* brk char (alt \n) */
|
||||
{ "su", M(VSUSP) }, /* suspend char */
|
||||
{ "ds", M(VDSUSP) }, /* delayed suspend */
|
||||
{ "rp", M(VREPRINT) }, /* reprint char */
|
||||
{ "fl", M(VDISCARD) }, /* flush output */
|
||||
{ "we", M(VWERASE) }, /* word erase */
|
||||
{ "ln", M(VLNEXT) }, /* literal next */
|
||||
{ "st", M(VSTATUS) }, /* status */
|
||||
{ "b2", M(VEOL2) }, /* alt brk char */
|
||||
{ "pp" }, /* ppp login program */
|
||||
{ "if" }, /* sysv-like 'issue' filename */
|
||||
{ "al" }, /* user to auto-login */
|
||||
{ 0 }
|
||||
{ "nx", NULL, NULL }, /* next table */
|
||||
{ "cl", NULL, NULL }, /* screen clear characters */
|
||||
{ "im", NULL, NULL }, /* initial message */
|
||||
{ "lm", "login: ", NULL }, /* login message */
|
||||
{ "er", M(VERASE), NULL }, /* erase character */
|
||||
{ "kl", M(VKILL), NULL }, /* kill character */
|
||||
{ "et", M(VEOF), NULL }, /* eof chatacter (eot) */
|
||||
{ "pc", "", NULL }, /* pad character */
|
||||
{ "tt", NULL, NULL }, /* terminal type */
|
||||
{ "ev", NULL, NULL }, /* environment */
|
||||
{ "lo", _PATH_LOGIN, NULL }, /* login program */
|
||||
{ "hn", hostname, NULL }, /* host name */
|
||||
{ "he", NULL, NULL }, /* host name edit */
|
||||
{ "in", M(VINTR), NULL }, /* interrupt char */
|
||||
{ "qu", M(VQUIT), NULL }, /* quit char */
|
||||
{ "xn", M(VSTART), NULL }, /* XON (start) char */
|
||||
{ "xf", M(VSTOP), NULL }, /* XOFF (stop) char */
|
||||
{ "bk", M(VEOL), NULL }, /* brk char (alt \n) */
|
||||
{ "su", M(VSUSP), NULL }, /* suspend char */
|
||||
{ "ds", M(VDSUSP), NULL }, /* delayed suspend */
|
||||
{ "rp", M(VREPRINT), NULL }, /* reprint char */
|
||||
{ "fl", M(VDISCARD), NULL }, /* flush output */
|
||||
{ "we", M(VWERASE), NULL }, /* word erase */
|
||||
{ "ln", M(VLNEXT), NULL }, /* literal next */
|
||||
{ "st", M(VSTATUS), NULL }, /* status */
|
||||
{ "b2", M(VEOL2), NULL }, /* alt brk char */
|
||||
{ "pp", NULL, NULL }, /* ppp login program */
|
||||
{ "if", NULL, NULL }, /* sysv-like 'issue' filename */
|
||||
{ "al", NULL, NULL }, /* user to auto-login */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
struct gettynums gettynums[] = {
|
||||
{ "is" }, /* input speed */
|
||||
{ "os" }, /* output speed */
|
||||
{ "sp" }, /* both speeds */
|
||||
{ "nd" }, /* newline delay */
|
||||
{ "cd" }, /* carriage-return delay */
|
||||
{ "td" }, /* tab delay */
|
||||
{ "fd" }, /* form-feed delay */
|
||||
{ "bd" }, /* backspace delay */
|
||||
{ "to" }, /* timeout */
|
||||
{ "f0" }, /* output flags */
|
||||
{ "f1" }, /* input flags */
|
||||
{ "f2" }, /* user mode flags */
|
||||
{ "pf" }, /* delay before flush at 1st prompt */
|
||||
{ "c0" }, /* output c_flags */
|
||||
{ "c1" }, /* input c_flags */
|
||||
{ "c2" }, /* user mode c_flags */
|
||||
{ "i0" }, /* output i_flags */
|
||||
{ "i1" }, /* input i_flags */
|
||||
{ "i2" }, /* user mode i_flags */
|
||||
{ "l0" }, /* output l_flags */
|
||||
{ "l1" }, /* input l_flags */
|
||||
{ "l2" }, /* user mode l_flags */
|
||||
{ "o0" }, /* output o_flags */
|
||||
{ "o1" }, /* input o_flags */
|
||||
{ "o2" }, /* user mode o_flags */
|
||||
{ 0 }
|
||||
{ "is", 0,0,0 }, /* input speed */
|
||||
{ "os", 0,0,0 }, /* output speed */
|
||||
{ "sp", 0,0,0 }, /* both speeds */
|
||||
{ "nd", 0,0,0 }, /* newline delay */
|
||||
{ "cd", 0,0,0 }, /* carriage-return delay */
|
||||
{ "td", 0,0,0 }, /* tab delay */
|
||||
{ "fd", 0,0,0 }, /* form-feed delay */
|
||||
{ "bd", 0,0,0 }, /* backspace delay */
|
||||
{ "to", 0,0,0 }, /* timeout */
|
||||
{ "f0", 0,0,0 }, /* output flags */
|
||||
{ "f1", 0,0,0 }, /* input flags */
|
||||
{ "f2", 0,0,0 }, /* user mode flags */
|
||||
{ "pf", 0,0,0 }, /* delay before flush at 1st prompt */
|
||||
{ "c0", 0,0,0 }, /* output c_flags */
|
||||
{ "c1", 0,0,0 }, /* input c_flags */
|
||||
{ "c2", 0,0,0 }, /* user mode c_flags */
|
||||
{ "i0", 0,0,0 }, /* output i_flags */
|
||||
{ "i1", 0,0,0 }, /* input i_flags */
|
||||
{ "i2", 0,0,0 }, /* user mode i_flags */
|
||||
{ "l0", 0,0,0 }, /* output l_flags */
|
||||
{ "l1", 0,0,0 }, /* input l_flags */
|
||||
{ "l2", 0,0,0 }, /* user mode l_flags */
|
||||
{ "o0", 0,0,0 }, /* output o_flags */
|
||||
{ "o1", 0,0,0 }, /* input o_flags */
|
||||
{ "o2", 0,0,0 }, /* user mode o_flags */
|
||||
{ 0,0,0,0 }
|
||||
};
|
||||
|
||||
struct gettyflags gettyflags[] = {
|
||||
{ "ht", 0 }, /* has tabs */
|
||||
{ "nl", 1 }, /* has newline char */
|
||||
{ "ep", 0 }, /* even parity */
|
||||
{ "op", 0 }, /* odd parity */
|
||||
{ "ap", 0 }, /* any parity */
|
||||
{ "ec", 1 }, /* no echo */
|
||||
{ "co", 0 }, /* console special */
|
||||
{ "cb", 0 }, /* crt backspace */
|
||||
{ "ck", 0 }, /* crt kill */
|
||||
{ "ce", 0 }, /* crt erase */
|
||||
{ "pe", 0 }, /* printer erase */
|
||||
{ "rw", 1 }, /* don't use raw */
|
||||
{ "xc", 1 }, /* don't ^X ctl chars */
|
||||
{ "lc", 0 }, /* terminal las lower case */
|
||||
{ "uc", 0 }, /* terminal has no lower case */
|
||||
{ "ig", 0 }, /* ignore garbage */
|
||||
{ "ps", 0 }, /* do port selector speed select */
|
||||
{ "hc", 1 }, /* don't set hangup on close */
|
||||
{ "ub", 0 }, /* unbuffered output */
|
||||
{ "ab", 0 }, /* auto-baud detect with '\r' */
|
||||
{ "dx", 0 }, /* set decctlq */
|
||||
{ "np", 0 }, /* no parity at all (8bit chars) */
|
||||
{ "mb", 0 }, /* do MDMBUF flow control */
|
||||
{ "cs", 0 }, /* clear screen based on term type */
|
||||
{ "nn", 0 }, /* don't prompt for login name */
|
||||
{ 0 }
|
||||
{ "ht", 0, 0,0,0 }, /* has tabs */
|
||||
{ "nl", 1, 0,0,0 }, /* has newline char */
|
||||
{ "ep", 0, 0,0,0 }, /* even parity */
|
||||
{ "op", 0, 0,0,0 }, /* odd parity */
|
||||
{ "ap", 0, 0,0,0 }, /* any parity */
|
||||
{ "ec", 1, 0,0,0 }, /* no echo */
|
||||
{ "co", 0, 0,0,0 }, /* console special */
|
||||
{ "cb", 0, 0,0,0 }, /* crt backspace */
|
||||
{ "ck", 0, 0,0,0 }, /* crt kill */
|
||||
{ "ce", 0, 0,0,0 }, /* crt erase */
|
||||
{ "pe", 0, 0,0,0 }, /* printer erase */
|
||||
{ "rw", 1, 0,0,0 }, /* don't use raw */
|
||||
{ "xc", 1, 0,0,0 }, /* don't ^X ctl chars */
|
||||
{ "lc", 0, 0,0,0 }, /* terminal las lower case */
|
||||
{ "uc", 0, 0,0,0 }, /* terminal has no lower case */
|
||||
{ "ig", 0, 0,0,0 }, /* ignore garbage */
|
||||
{ "ps", 0, 0,0,0 }, /* do port selector speed select */
|
||||
{ "hc", 1, 0,0,0 }, /* don't set hangup on close */
|
||||
{ "ub", 0, 0,0,0 }, /* unbuffered output */
|
||||
{ "ab", 0, 0,0,0 }, /* auto-baud detect with '\r' */
|
||||
{ "dx", 0, 0,0,0 }, /* set decctlq */
|
||||
{ "np", 0, 0,0,0 }, /* no parity at all (8bit chars) */
|
||||
{ "mb", 0, 0,0,0 }, /* do MDMBUF flow control */
|
||||
{ "cs", 0, 0,0,0 }, /* clear screen based on term type */
|
||||
{ "nn", 0, 0,0,0 }, /* don't prompt for login name */
|
||||
{ NULL,0,0,0,0 }
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.59 2012/06/28 08:55:10 roy Exp $ */
|
||||
/* $NetBSD: main.c,v 1.64 2013/08/12 13:54:33 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1980, 1993
|
||||
@@ -40,13 +40,11 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.59 2012/06/28 08:55:10 roy Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.64 2013/08/12 13:54:33 joerg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
@@ -58,10 +56,12 @@ __RCSID("$NetBSD: main.c,v 1.59 2012/06/28 08:55:10 roy Exp $");
|
||||
#include <pwd.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <term.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
#include <ttyent.h>
|
||||
#include <unistd.h>
|
||||
@@ -135,34 +135,34 @@ const unsigned char partab[] = {
|
||||
|
||||
static void clearscreen(void);
|
||||
|
||||
jmp_buf timeout;
|
||||
sigjmp_buf timeout;
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
/*ARGSUSED*/
|
||||
dingdong(int signo)
|
||||
{
|
||||
|
||||
(void)alarm(0);
|
||||
(void)signal(SIGALRM, SIG_DFL);
|
||||
longjmp(timeout, 1);
|
||||
siglongjmp(timeout, 1);
|
||||
}
|
||||
|
||||
jmp_buf intrupt;
|
||||
sigjmp_buf intrupt;
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
/*ARGSUSED*/
|
||||
interrupt(int signo)
|
||||
{
|
||||
|
||||
(void)signal(SIGINT, interrupt);
|
||||
longjmp(intrupt, 1);
|
||||
siglongjmp(intrupt, 1);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
/*
|
||||
* Action to take when getty is running too long.
|
||||
*/
|
||||
static void
|
||||
__dead static void
|
||||
/*ARGSUSED*/
|
||||
timeoverrun(int signo)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ timeoverrun(int signo)
|
||||
syslog(LOG_ERR, "getty exiting due to excessive running time");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
static int getname(void);
|
||||
static void oflush(void);
|
||||
@@ -185,11 +185,14 @@ int
|
||||
main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
const char *progname;
|
||||
char *tname;
|
||||
int repcnt = 0, failopenlogged = 0, uugetty = 0, first_time = 1;
|
||||
int repcnt = 0, failopenlogged = 0, first_time = 1;
|
||||
struct rlimit limit;
|
||||
struct passwd *pw;
|
||||
int rval;
|
||||
/* this is used past the siglongjmp, so make sure it is not cached
|
||||
in registers that might become invalid. */
|
||||
volatile int uugetty = 0;
|
||||
const char * volatile tname = "default";
|
||||
|
||||
(void)signal(SIGINT, SIG_IGN);
|
||||
openlog("getty", LOG_PID, LOG_AUTH);
|
||||
@@ -214,12 +217,12 @@ main(int argc, char *argv[], char *envp[])
|
||||
/*
|
||||
* Limit running time to deal with broken or dead lines.
|
||||
*/
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)signal(SIGXCPU, timeoverrun);
|
||||
limit.rlim_max = RLIM_INFINITY;
|
||||
limit.rlim_cur = GETTY_TIMEOUT;
|
||||
(void)setrlimit(RLIMIT_CPU, &limit);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/*
|
||||
* The following is a work around for vhangup interactions
|
||||
@@ -257,9 +260,9 @@ main(int argc, char *argv[], char *envp[])
|
||||
if (strcmp(argv[0], "+") != 0) {
|
||||
(void)chown(ttyn, ttyowner, 0);
|
||||
(void)chmod(ttyn, 0600);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)revoke(ttyn);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
if (ttyaction(ttyn, "getty", "root"))
|
||||
syslog(LOG_WARNING, "%s: ttyaction failed",
|
||||
ttyn);
|
||||
@@ -298,7 +301,6 @@ main(int argc, char *argv[], char *envp[])
|
||||
|
||||
gettable("default", defent);
|
||||
gendefaults();
|
||||
tname = "default";
|
||||
if (argc > 1)
|
||||
tname = argv[1];
|
||||
for (;;) {
|
||||
@@ -314,7 +316,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
#ifndef __minix
|
||||
(void)ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
|
||||
(void)ioctl(0, FIOASYNC, &off); /* ditto for async mode */
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (IS)
|
||||
(void)cfsetispeed(&tmode, (speed_t)IS);
|
||||
@@ -363,7 +365,7 @@ main(int argc, char *argv[], char *envp[])
|
||||
if (IM && *IM)
|
||||
putf(IM);
|
||||
oflush();
|
||||
if (setjmp(timeout)) {
|
||||
if (sigsetjmp(timeout, 1)) {
|
||||
tmode.c_ispeed = tmode.c_ospeed = 0;
|
||||
(void)tcsetattr(0, TCSANOW, &tmode);
|
||||
exit(1);
|
||||
@@ -430,9 +432,9 @@ main(int argc, char *argv[], char *envp[])
|
||||
|
||||
limit.rlim_max = RLIM_INFINITY;
|
||||
limit.rlim_cur = RLIM_INFINITY;
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
(void)setrlimit(RLIMIT_CPU, &limit);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
if (NN)
|
||||
(void)execle(LO, "login", AL ? "-fp" : "-p",
|
||||
NULL, env);
|
||||
@@ -463,7 +465,7 @@ getname(void)
|
||||
/*
|
||||
* Interrupt may happen if we use CBREAK mode
|
||||
*/
|
||||
if (setjmp(intrupt)) {
|
||||
if (sigsetjmp(intrupt, 1)) {
|
||||
(void)signal(SIGINT, SIG_IGN);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr.c,v 1.33 2006/11/16 04:31:24 christos Exp $ */
|
||||
/* $NetBSD: subr.c,v 1.35 2013/08/11 16:36:30 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@@ -34,26 +34,25 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)subr.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: subr.c,v 1.33 2006/11/16 04:31:24 christos Exp $");
|
||||
__RCSID("$NetBSD: subr.c,v 1.35 2013/08/11 16:36:30 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Melbourne getty.
|
||||
*/
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
#define COMPAT_43
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "extern.h"
|
||||
#include "gettytab.h"
|
||||
@@ -61,15 +60,15 @@ __RCSID("$NetBSD: subr.c,v 1.33 2006/11/16 04:31:24 christos Exp $");
|
||||
|
||||
extern struct termios tmode, omode;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
static void compatflags(long);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
/*
|
||||
* Get a table entry.
|
||||
*/
|
||||
void
|
||||
gettable(char *name, char *buf)
|
||||
gettable(const char *name, char *buf)
|
||||
{
|
||||
struct gettystrs *sp;
|
||||
struct gettynums *np;
|
||||
@@ -77,7 +76,7 @@ gettable(char *name, char *buf)
|
||||
long n;
|
||||
const char *dba[2];
|
||||
dba[0] = _PATH_GETTYTAB;
|
||||
dba[1] = 0;
|
||||
dba[1] = NULL;
|
||||
|
||||
if (cgetent(&buf, dba, name) != 0)
|
||||
return;
|
||||
@@ -142,7 +141,7 @@ setdefaults(void)
|
||||
|
||||
for (sp = gettystrs; sp->field; sp++)
|
||||
if (!sp->value)
|
||||
sp->value = sp->defalt;
|
||||
sp->value = sp->defalt ? estrdup(sp->defalt) : NULL;
|
||||
for (np = gettynums; np->field; np++)
|
||||
if (!np->set)
|
||||
np->value = np->defalt;
|
||||
@@ -284,12 +283,12 @@ setflags(int n)
|
||||
else
|
||||
CLR(cflag, HUPCL);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (MB)
|
||||
SET(cflag, MDMBUF);
|
||||
else
|
||||
CLR(cflag, MDMBUF);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (NL) {
|
||||
SET(iflag, ICRNL);
|
||||
@@ -299,12 +298,12 @@ setflags(int n)
|
||||
CLR(oflag, ONLCR);
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (!HT)
|
||||
SET(oflag, OXTABS|OPOST);
|
||||
else
|
||||
CLR(oflag, OXTABS);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
#ifdef XXX_DELAY
|
||||
SET(f, delaybits());
|
||||
@@ -336,7 +335,7 @@ setflags(int n)
|
||||
else
|
||||
CLR(lflag, ECHOE);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (CK)
|
||||
SET(lflag, ECHOKE);
|
||||
else
|
||||
@@ -346,19 +345,19 @@ setflags(int n)
|
||||
SET(lflag, ECHOPRT);
|
||||
else
|
||||
CLR(lflag, ECHOPRT);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (EC)
|
||||
SET(lflag, ECHO);
|
||||
else
|
||||
CLR(lflag, ECHO);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (XC)
|
||||
SET(lflag, ECHOCTL);
|
||||
else
|
||||
CLR(lflag, ECHOCTL);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
if (DX)
|
||||
SET(lflag, IXANY);
|
||||
@@ -448,25 +447,24 @@ compatflags(long flags)
|
||||
SET(lflag, ECHOE);
|
||||
else
|
||||
CLR(lflag, ECHOE);
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
/* Nothing we can do with TILDE. */
|
||||
if (ISSET(flags, MDMBUF))
|
||||
SET(cflag, MDMBUF);
|
||||
else
|
||||
CLR(cflag, MDMBUF);
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
if (ISSET(flags, NOHANG))
|
||||
CLR(cflag, HUPCL);
|
||||
else
|
||||
SET(cflag, HUPCL);
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (ISSET(flags, CRTKIL))
|
||||
SET(lflag, ECHOKE);
|
||||
else
|
||||
CLR(lflag, ECHOKE);
|
||||
#endif
|
||||
|
||||
#endif /* !defined(__minix) */
|
||||
if (ISSET(flags, CTLECH))
|
||||
SET(lflag, ECHOCTL);
|
||||
else
|
||||
@@ -576,7 +574,7 @@ adelay(int ms, struct delayval *dp)
|
||||
char editedhost[MAXHOSTNAMELEN];
|
||||
|
||||
void
|
||||
edithost(char *pat)
|
||||
edithost(const char *pat)
|
||||
{
|
||||
char *host = HN;
|
||||
char *res = editedhost;
|
||||
@@ -647,8 +645,8 @@ makeenv(char *env[])
|
||||
* The routine below returns the terminal type mapped from derived speed.
|
||||
*/
|
||||
struct portselect {
|
||||
char *ps_baud;
|
||||
char *ps_type;
|
||||
const char *ps_baud;
|
||||
const char *ps_type;
|
||||
} portspeeds[] = {
|
||||
{ "B110", "std.110" },
|
||||
{ "B134", "std.134" },
|
||||
@@ -660,15 +658,16 @@ struct portselect {
|
||||
{ "B4800", "std.4800" },
|
||||
{ "B9600", "std.9600" },
|
||||
{ "B19200", "std.19200" },
|
||||
{ 0 }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
char *
|
||||
const char *
|
||||
portselector(void)
|
||||
{
|
||||
char c, baud[20], *type = "default";
|
||||
char c, baud[20];
|
||||
const char *type = "default";
|
||||
struct portselect *ps;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
(void)alarm(5*60);
|
||||
for (len = 0; len < sizeof (baud) - 1; len++) {
|
||||
@@ -698,12 +697,13 @@ portselector(void)
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
|
||||
char *
|
||||
const char *
|
||||
autobaud(void)
|
||||
{
|
||||
struct pollfd set[1];
|
||||
struct timespec timeout;
|
||||
char c, *type = "9600-baud";
|
||||
char c;
|
||||
const char *type = "9600-baud";
|
||||
|
||||
(void)tcflush(0, TCIOFLUSH);
|
||||
set[0].fd = STDIN_FILENO;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.114 2012/08/23 21:21:15 joerg Exp $
|
||||
# $NetBSD: Makefile,v 1.125 2013/11/16 17:14:06 skrll Exp $
|
||||
#
|
||||
# NOTE: when changing ld.so, ensure that ldd still compiles.
|
||||
#
|
||||
@@ -7,6 +7,8 @@ USE_BITCODE=no
|
||||
|
||||
WARNS?=4
|
||||
|
||||
LDELFSO_MACHINE_ARCH?= ${MACHINE_ARCH}
|
||||
|
||||
# This needs to be before bsd.init.mk
|
||||
.if defined(BSD_MK_COMPAT_FILE)
|
||||
.include <${BSD_MK_COMPAT_FILE}>
|
||||
@@ -26,23 +28,24 @@ ARCHSUBDIR= ${MACHINE_CPU}
|
||||
.endif
|
||||
M= ${.CURDIR}/arch/${ARCHSUBDIR}
|
||||
|
||||
.if ((${MACHINE_ARCH} == "alpha") || \
|
||||
.if ((${LDELFSO_MACHINE_ARCH} == "alpha") || \
|
||||
(${MACHINE_CPU} == "arm") || \
|
||||
(${MACHINE_ARCH} == "hppa") || \
|
||||
(${MACHINE_ARCH} == "i386") || \
|
||||
(${MACHINE_ARCH} == "m68k") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "coldfire") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "hppa") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "i386") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "m68k") || \
|
||||
(${MACHINE_CPU} == "mips") || \
|
||||
(${MACHINE_ARCH} == "powerpc") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "powerpc") || \
|
||||
(${MACHINE_CPU} == "sh3") || \
|
||||
(${MACHINE_ARCH} == "sparc") || \
|
||||
(${MACHINE_ARCH} == "sparc64") || \
|
||||
(${MACHINE_ARCH} == "x86_64") || \
|
||||
(${MACHINE_ARCH} == "vax")) && \
|
||||
(${LDELFSO_MACHINE_ARCH} == "sparc") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "sparc64") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "x86_64") || \
|
||||
(${LDELFSO_MACHINE_ARCH} == "vax")) && \
|
||||
${MKPIC} != "no"
|
||||
|
||||
LDFLAGS+= ${${ACTIVE_CC} == "clang":? -Wl,-Bsymbolic : -symbolic} \
|
||||
-shared -nostartfiles -nodefaultlibs
|
||||
.if defined(__MINIX) && ${HAVE_GOLD:U} != ""
|
||||
.if defined(__MINIX) && ${HAVE_GOLD:Uno} != "yes"
|
||||
LDFLAGS+= -Wl,--script ${LDS_SHARED_LIB}
|
||||
.else
|
||||
LDFLAGS+= -Wl,-static
|
||||
@@ -69,7 +72,11 @@ CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
|
||||
|
||||
SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
|
||||
map_object.c load.c search.c headers.c paths.c expand.c \
|
||||
tls.c symver.c diagassert.c map_object_fallback.c
|
||||
tls.c symver.c diagassert.c
|
||||
|
||||
.if defined(__MINIX)
|
||||
SRCS+= map_object_fallback.c
|
||||
.endif # defined(__MINIX)
|
||||
|
||||
.if ${USE_FORT} == "yes"
|
||||
.PATH.c: ${NETBSDSRCDIR}/lib/libc/misc
|
||||
@@ -97,10 +104,17 @@ CPPFLAGS+= -DCOMBRELOC
|
||||
#CPPFLAGS+= -DDEBUG
|
||||
#CPPFLAGS+= -DRTLD_DEBUG
|
||||
#CPPFLAGS+= -DRTLD_DEBUG_RELOC
|
||||
.if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
|
||||
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libexecinfo
|
||||
.endif
|
||||
#DBG= -g
|
||||
COPTS= -O3 -fomit-frame-pointer
|
||||
COPTS+= -O3
|
||||
|
||||
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
|
||||
.if ${MACHINE_CPU} != "m68k" && ${MACHINE_CPU} != "sh3" && ${MACHINE_ARCH} != "vax"
|
||||
COPTS+= -fomit-frame-pointer
|
||||
.endif
|
||||
|
||||
.if ${LDELFSO_MACHINE_ARCH} == "i386" || ${LDELFSO_MACHINE_ARCH} == "x86_64"
|
||||
COPTS+= -mno-3dnow -mno-mmx -mno-sse -mno-sse2 -mno-sse3
|
||||
.endif
|
||||
|
||||
@@ -135,12 +149,26 @@ STRIPFLAG=
|
||||
|
||||
.PATH: $M
|
||||
|
||||
|
||||
${PROG}: ${OBJS} ${DPADD}
|
||||
${_MKMSG_LINK} ${PROG}
|
||||
${CC} ${LDFLAGS} -o ${PROG} ${OBJS} ${LDADD}
|
||||
.if ${MKDEBUG} != "no"
|
||||
( ${OBJCOPY} --only-keep-debug ${.TARGET} ${.TARGET}.debug \
|
||||
&& ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \
|
||||
--add-gnu-debuglink=${.TARGET}.debug ${.TARGET} \
|
||||
) || (rm -f ${.TARGET}.debug; false)
|
||||
|
||||
_PROGDEBUG.${PROG} := ${PROG}.debug
|
||||
.endif
|
||||
|
||||
|
||||
.if ${SHLINKINSTALLDIR} != "/usr/libexec"
|
||||
SYMLINKS+= ${SHLINKINSTALLDIR}/${PROG} /usr/libexec/${PROG}
|
||||
.if ${MKDEBUG} != "no"
|
||||
SYMLINKS+= ${DEBUGDIR}${BINDIR}/${PROG}.debug \
|
||||
${DEBUGDIR}/usr${BINDIR}/${PROG}.debug
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
# $NetBSD: Makefile.inc,v 1.12 2012/08/15 03:46:07 matt Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.20 2013/09/10 16:35:10 matt Exp $
|
||||
|
||||
SRCS+= rtld_start.S mdreloc.c
|
||||
#CPUFLAGS.rtld_start.S+= -marm
|
||||
|
||||
# XXX Should not be in CPPFLAGS!
|
||||
CPPFLAGS+= -fpic
|
||||
|
||||
CPPFLAGS+= -DELFSIZE=32
|
||||
.if ${MACHINE_ARCH} == "earm" || ${MACHINE_ARCH} == "earmeb"
|
||||
.if !empty(LDELFSO_MACHINE_ARCH:Mearm*)
|
||||
CPPFLAGS+= -DHAVE_INITFINI_ARRAY
|
||||
CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${LDELFSO_MACHINE_ARCH}\"
|
||||
SRCS+= find_exidx.c
|
||||
.endif
|
||||
|
||||
LDFLAGS+= -Wl,-e,_rtld_start
|
||||
|
||||
86
libexec/ld.elf_so/arch/arm/find_exidx.c
Normal file
86
libexec/ld.elf_so/arch/arm/find_exidx.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: find_exidx.c,v 1.3 2013/05/03 10:27:06 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "debug.h"
|
||||
#include "rtld.h"
|
||||
|
||||
_Unwind_Ptr
|
||||
__gnu_Unwind_Find_exidx(_Unwind_Ptr pc, int * pcount)
|
||||
{
|
||||
const Obj_Entry *obj;
|
||||
_Unwind_Ptr start = NULL;
|
||||
int count = 0;
|
||||
|
||||
dbg(("__gnu_Unwind_Find_exidx"));
|
||||
|
||||
_rtld_shared_enter();
|
||||
|
||||
vaddr_t va = (vaddr_t)pc;
|
||||
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
|
||||
/*
|
||||
* If the address we are looking for is inside this object,
|
||||
* we've found the object to inspect.
|
||||
*/
|
||||
if ((vaddr_t)obj->mapbase <= va
|
||||
&& va < (vaddr_t)obj->mapbase + obj->mapsize)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we found an object and it has some exception data, we
|
||||
* need to see if the address matches a PT_LOAD section.
|
||||
*/
|
||||
if (obj != NULL && obj->exidx_start != NULL) {
|
||||
va -= (vaddr_t)obj->relocbase;
|
||||
const Elf_Phdr *ph = obj->phdr;
|
||||
const Elf_Phdr * const phlimit = ph + obj->phsize / sizeof(*ph);
|
||||
for (; ph < phlimit; ph++) {
|
||||
if (ph->p_type == PT_LOAD
|
||||
&& ph->p_vaddr <= va
|
||||
&& va < ph->p_vaddr + ph->p_memsz) {
|
||||
count = obj->exidx_sz / 8;
|
||||
start = obj->exidx_start;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_rtld_shared_exit();
|
||||
|
||||
/*
|
||||
* deal with the return values.
|
||||
*/
|
||||
*pcount = count;
|
||||
return start;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/* $NetBSD: mdreloc.c,v 1.34 2011/03/25 18:07:05 joerg Exp $ */
|
||||
/* $NetBSD: mdreloc.c,v 1.35 2012/11/07 07:24:46 apb Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: mdreloc.c,v 1.34 2011/03/25 18:07:05 joerg Exp $");
|
||||
__RCSID("$NetBSD: mdreloc.c,v 1.35 2012/11/07 07:24:46 apb Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -130,13 +130,28 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
|
||||
_rtld_tls_offset_allocate(obj))
|
||||
return -1;
|
||||
|
||||
*where = (Elf_Addr)(def->st_value - defobj->tlsoffset);
|
||||
*where += (Elf_Addr)(def->st_value - defobj->tlsoffset);
|
||||
|
||||
rdbg(("TLS_TPOFF %s in %s --> %p",
|
||||
obj->strtab + obj->symtab[symnum].st_name,
|
||||
obj->path, (void *)*where));
|
||||
break;
|
||||
|
||||
case R_TYPE(TLS_TPOFF32):
|
||||
def = _rtld_find_symdef(symnum, obj, &defobj, false);
|
||||
if (def == NULL)
|
||||
return -1;
|
||||
|
||||
if (!defobj->tls_done &&
|
||||
_rtld_tls_offset_allocate(obj))
|
||||
return -1;
|
||||
|
||||
*where += (Elf_Addr)(defobj->tlsoffset - def->st_value);
|
||||
rdbg(("TLS_TPOFF32 %s in %s --> %p",
|
||||
obj->strtab + obj->symtab[symnum].st_name,
|
||||
obj->path, (void *)*where));
|
||||
break;
|
||||
|
||||
case R_TYPE(TLS_DTPMOD32):
|
||||
def = _rtld_find_symdef(symnum, obj, &defobj, false);
|
||||
if (def == NULL)
|
||||
|
||||
@@ -46,17 +46,6 @@
|
||||
leal _DYNAMIC-1b(%edx),%ecx # &_DYNAMIC
|
||||
movl %ecx,%ebx
|
||||
subl _GLOBAL_OFFSET_TABLE_-1b(%edx),%ebx
|
||||
#ifdef HAVE_GOLD
|
||||
/* Adjust the offset when using the gold linker, because it's off.
|
||||
* Using '_DYNAMIC' this way produces the warning
|
||||
* 'shared library text segment is not shareable', produced by '--warn-shared-textrel'
|
||||
* to avoid the warning, add a '_MY_DYNAMIC = .;' before the dynamic section in the
|
||||
* linkerscript that is used, and replace '_DYNAMIC' with '_MY_DYNAMIC' here.
|
||||
* However, this way, you end up with a custom linker script that you have to maintain.
|
||||
*/
|
||||
leal _DYNAMIC,%eax
|
||||
subl %eax,%ebx
|
||||
#endif
|
||||
|
||||
pushl %ebx # relocbase
|
||||
pushl %ecx # &_DYNAMIC
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtld_start.S,v 1.9 2008/04/28 20:23:03 martin Exp $ */
|
||||
/* $NetBSD: rtld_start.S,v 1.10 2013/07/18 21:57:42 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
@@ -38,8 +38,9 @@
|
||||
.rtld_start:
|
||||
subql #8,%sp | storage for obj and cleanup
|
||||
|
||||
lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a0
|
||||
lea (%pc,_DYNAMIC),%a1
|
||||
GOT_SETUP(%a0)
|
||||
LEA_LCL(_DYNAMIC,%a1)
|
||||
|
||||
movel %a1,%a5
|
||||
subl (%a0),%a5
|
||||
|
||||
@@ -63,7 +64,7 @@
|
||||
.globl _rtld_bind_start
|
||||
.type _rtld_bind_start,@function
|
||||
_rtld_bind_start:
|
||||
moveml %d0-%d1/%a0-%a1,-(%sp) | preserve caller-saved registers
|
||||
INTERRUPT_SAVEREG
|
||||
movel 20(%sp),-(%sp) | push reloff
|
||||
movel (16+4)(%sp),-(%sp) | push obj
|
||||
jbsr _rtld_bind@PLTPC | %a0 = _rtld_bind(obj, reloff)
|
||||
@@ -73,7 +74,7 @@ _rtld_bind_start:
|
||||
#else
|
||||
movel %d0,(16+4)(%sp) | write fake `return' address over obj
|
||||
#endif
|
||||
moveml (%sp)+,%d0-%d1/%a0-%a1 | restore caller-saved registers
|
||||
INTERRUPT_RESTOREREG | restore caller-saved registers
|
||||
addql #4,%sp | skip reloff
|
||||
rts | `return' right into function
|
||||
.size _rtld_bind_start,.-_rtld_bind_start
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
# $NetBSD: Makefile.inc,v 1.19 2010/07/11 07:43:12 mrg Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.20 2013/07/10 15:08:38 matt Exp $
|
||||
|
||||
SRCS+= rtld_start.S mips_reloc.c
|
||||
|
||||
COPTS+= -G0
|
||||
|
||||
ABI64?= ${CFLAGS:M-mabi=64} ${CPPFLAGS:M-mabi=64} ${COPTS:M-mabi=64}
|
||||
ABIO64?= ${CFLAGS:M-mabi=o64} ${CPPFLAGS:M-mabi=o64} ${COPTS:M-mabi=o64}
|
||||
.if !empty(ABI64) || !empty(ABIO64)
|
||||
CPPFLAGS+= -DELFSIZE=64
|
||||
.else
|
||||
CPPFLAGS+= -DELFSIZE=32
|
||||
.endif
|
||||
CPPFLAGS+= -DELFSIZE=_MIPS_SZPTR
|
||||
CPPFLAGS+= -DRTLD_INHIBIT_COPY_RELOCS
|
||||
AFLAGS+= -Wa,--fatal-warnings
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mdreloc.c,v 1.53 2012/07/22 09:21:03 martin Exp $ */
|
||||
/* $NetBSD: mdreloc.c,v 1.55 2013/10/03 10:45:57 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 Eduardo Horvath.
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: mdreloc.c,v 1.53 2012/07/22 09:21:03 martin Exp $");
|
||||
__RCSID("$NetBSD: mdreloc.c,v 1.55 2013/10/03 10:45:57 martin Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <errno.h>
|
||||
@@ -180,10 +180,10 @@ static const long reloc_target_bitmask[] = {
|
||||
_BM(22), _BM(10), _BM(22), /* _PC_HH22, _PC_HM10, _PC_LM22 */
|
||||
_BM(16), _BM(19), /* _WDISP16, _WDISP19 */
|
||||
-1, /* GLOB_JMP */
|
||||
_BM(7), _BM(5), _BM(6) /* _7, _5, _6 */
|
||||
_BM(7), _BM(5), _BM(6), /* _7, _5, _6 */
|
||||
-1, -1, /* DISP64, PLT64 */
|
||||
_BM(22), _BM(13), /* HIX22, LOX10 */
|
||||
_BM(22), _BM(10), _BM(13), /* H44, M44, L44 */
|
||||
_BM(22), _BM(10), _BM(12), /* H44, M44, L44 */
|
||||
-1, -1, _BM(16), /* REGISTER, UA64, UA16 */
|
||||
#undef _BM
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: debug.h,v 1.5 2002/09/12 22:56:28 mycroft Exp $ */
|
||||
/* $NetBSD: debug.h,v 1.7 2013/08/03 13:17:05 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -35,7 +35,7 @@
|
||||
* Support for printing debugging messages.
|
||||
*/
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ extern void debug_printf __P((const char *, ...))
|
||||
extern int debug;
|
||||
|
||||
# define dbg(a) debug_printf a
|
||||
#else
|
||||
#else
|
||||
# define dbg(a) ((void) 0)
|
||||
#endif
|
||||
#ifdef RTLD_DEBUG_RELOC
|
||||
@@ -55,4 +55,10 @@ extern int debug;
|
||||
# define rdbg(a) ((void) 0)
|
||||
#endif
|
||||
|
||||
#if ELFSIZE == 64
|
||||
#define PRImemsz PRIu64
|
||||
#else
|
||||
#define PRImemsz PRIu32
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: expand.c,v 1.5 2008/04/28 20:23:03 martin Exp $ */
|
||||
/* $NetBSD: expand.c,v 1.6 2013/05/06 08:02:20 skrll Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: expand.c,v 1.5 2008/04/28 20:23:03 martin Exp $");
|
||||
__RCSID("$NetBSD: expand.c,v 1.6 2013/05/06 08:02:20 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -62,13 +62,13 @@ static const struct {
|
||||
ADD(PLATFORM) /* uname -p */
|
||||
};
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
static int mib[3][2] = {
|
||||
{ CTL_KERN, KERN_OSTYPE },
|
||||
{ CTL_KERN, KERN_OSRELEASE },
|
||||
{ CTL_HW, HW_MACHINE_ARCH },
|
||||
};
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
static size_t
|
||||
expand(char *buf, const char *execname, int what, size_t bl)
|
||||
@@ -92,18 +92,18 @@ expand(char *buf, const char *execname, int what, size_t bl)
|
||||
xerr(1, "bad execname `%s' in AUX vector", execname);
|
||||
break;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
case 3: /* OSNAME */
|
||||
case 4: /* OSREL */
|
||||
case 5: /* PLATFORM */
|
||||
len = sizeof(name);
|
||||
len = sizeof(name);
|
||||
if (sysctl(mib[what - 3], 2, name, &len, NULL, 0) == -1) {
|
||||
xwarn("sysctl");
|
||||
return 0;
|
||||
}
|
||||
ep = (p = name) + len - 1;
|
||||
break;
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ expand(char *buf, const char *execname, int what, size_t bl)
|
||||
|
||||
return bp - buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t
|
||||
_rtld_expand_path(char *buf, size_t bufsize, const char *execname,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: headers.c,v 1.43 2012/08/15 03:46:06 matt Exp $ */
|
||||
/* $NetBSD: headers.c,v 1.52 2013/08/03 13:17:05 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: headers.c,v 1.43 2012/08/15 03:46:06 matt Exp $");
|
||||
__RCSID("$NetBSD: headers.c,v 1.52 2013/08/03 13:17:05 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@@ -68,6 +68,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
{
|
||||
Elf_Dyn *dynp;
|
||||
Needed_Entry **needed_tail = &obj->needed;
|
||||
const Elf_Dyn *dyn_soname = NULL;
|
||||
const Elf_Dyn *dyn_rpath = NULL;
|
||||
bool use_pltrel = false;
|
||||
bool use_pltrela = false;
|
||||
@@ -75,7 +76,9 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
Elf_Addr pltrel = 0, pltrelsz = 0;
|
||||
Elf_Addr init = 0, fini = 0;
|
||||
|
||||
dbg(("headers: digesting PT_DYNAMIC at %p", obj->dynamic));
|
||||
for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; ++dynp) {
|
||||
dbg((" d_tag %ld at %p", (long)dynp->d_tag, dynp));
|
||||
switch (dynp->d_tag) {
|
||||
|
||||
case DT_REL:
|
||||
@@ -220,7 +223,7 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
break;
|
||||
|
||||
case DT_SONAME:
|
||||
/* Not used by the dynamic linker. */
|
||||
dyn_soname = dynp;
|
||||
break;
|
||||
|
||||
case DT_INIT:
|
||||
@@ -231,10 +234,14 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
case DT_INIT_ARRAY:
|
||||
obj->init_array =
|
||||
(fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
dbg(("headers: DT_INIT_ARRAY at %p",
|
||||
obj->init_array));
|
||||
break;
|
||||
|
||||
case DT_INIT_ARRAYSZ:
|
||||
obj->init_arraysz = dynp->d_un.d_val / sizeof(fptr_t);
|
||||
dbg(("headers: DT_INIT_ARRAYZ %zu",
|
||||
obj->init_arraysz));
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -246,10 +253,14 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
case DT_FINI_ARRAY:
|
||||
obj->fini_array =
|
||||
(fptr_t *)(obj->relocbase + dynp->d_un.d_ptr);
|
||||
dbg(("headers: DT_FINI_ARRAY at %p",
|
||||
obj->fini_array));
|
||||
break;
|
||||
|
||||
case DT_FINI_ARRAYSZ:
|
||||
obj->fini_arraysz = dynp->d_un.d_val / sizeof(fptr_t);
|
||||
obj->fini_arraysz = dynp->d_un.d_val / sizeof(fptr_t);
|
||||
dbg(("headers: DT_FINI_ARRAYZ %zu",
|
||||
obj->fini_arraysz));
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -348,6 +359,10 @@ _rtld_digest_dynamic(const char *execname, Obj_Entry *obj)
|
||||
_rtld_add_paths(execname, &obj->rpaths, obj->strtab +
|
||||
dyn_rpath->d_un.d_val);
|
||||
}
|
||||
if (dyn_soname != NULL) {
|
||||
_rtld_object_add_name(obj, obj->strtab +
|
||||
dyn_soname->d_un.d_val);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -370,21 +385,24 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry)
|
||||
for (ph = phdr; ph < phlimit; ++ph) {
|
||||
if (ph->p_type != PT_PHDR)
|
||||
continue;
|
||||
|
||||
obj->phdr = (void *)(uintptr_t)phdr->p_vaddr;
|
||||
obj->phsize = phdr->p_memsz;
|
||||
|
||||
obj->phdr = (void *)(uintptr_t)ph->p_vaddr;
|
||||
obj->phsize = ph->p_memsz;
|
||||
obj->relocbase = (caddr_t)((uintptr_t)phdr - (uintptr_t)ph->p_vaddr);
|
||||
dbg(("headers: phdr %p phsize %zu relocbase %lx", obj->phdr,
|
||||
obj->phsize, (long)obj->relocbase));
|
||||
dbg(("headers: phdr %p (%p) phsize %zu relocbase %p",
|
||||
obj->phdr, phdr, obj->phsize, obj->relocbase));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for (ph = phdr; ph < phlimit; ++ph) {
|
||||
vaddr = (Elf_Addr)(uintptr_t)(obj->relocbase + ph->p_vaddr);
|
||||
switch (ph->p_type) {
|
||||
|
||||
case PT_INTERP:
|
||||
obj->interp = (const char *)(uintptr_t)vaddr;
|
||||
dbg(("headers: %s %p phsize %" PRImemsz,
|
||||
"PT_INTERP", (void *)(uintptr_t)vaddr,
|
||||
ph->p_memsz));
|
||||
break;
|
||||
|
||||
case PT_LOAD:
|
||||
@@ -399,10 +417,16 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry)
|
||||
obj->vaddrbase;
|
||||
}
|
||||
++nsegs;
|
||||
dbg(("headers: %s %p phsize %" PRImemsz,
|
||||
"PT_LOAD", (void *)(uintptr_t)vaddr,
|
||||
ph->p_memsz));
|
||||
break;
|
||||
|
||||
case PT_DYNAMIC:
|
||||
obj->dynamic = (Elf_Dyn *)(uintptr_t)vaddr;
|
||||
dbg(("headers: %s %p phsize %" PRImemsz,
|
||||
"PT_DYNAMIC", (void *)(uintptr_t)vaddr,
|
||||
ph->p_memsz));
|
||||
break;
|
||||
|
||||
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
||||
@@ -412,6 +436,18 @@ _rtld_digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry)
|
||||
obj->tlsalign = ph->p_align;
|
||||
obj->tlsinitsize = ph->p_filesz;
|
||||
obj->tlsinit = (void *)(uintptr_t)ph->p_vaddr;
|
||||
dbg(("headers: %s %p phsize %" PRImemsz,
|
||||
"PT_TLS", (void *)(uintptr_t)vaddr,
|
||||
ph->p_memsz));
|
||||
break;
|
||||
#endif
|
||||
#ifdef __ARM_EABI__
|
||||
case PT_ARM_EXIDX:
|
||||
obj->exidx_start = (void *)(uintptr_t)vaddr;
|
||||
obj->exidx_sz = ph->p_memsz;
|
||||
dbg(("headers: %s %p phsize %" PRImemsz,
|
||||
"PT_ARM_EXIDX", (void *)(uintptr_t)vaddr,
|
||||
ph->p_memsz));
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: load.c,v 1.42 2010/12/24 12:41:43 skrll Exp $ */
|
||||
/* $NetBSD: load.c,v 1.47 2013/11/27 18:01:33 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: load.c,v 1.42 2010/12/24 12:41:43 skrll Exp $");
|
||||
__RCSID("$NetBSD: load.c,v 1.47 2013/11/27 18:01:33 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@@ -68,7 +68,7 @@ Objlist _rtld_list_main = /* Objects loaded at program startup */
|
||||
SIMPLEQ_HEAD_INITIALIZER(_rtld_list_main);
|
||||
Objlist _rtld_list_global = /* Objects dlopened with RTLD_GLOBAL */
|
||||
SIMPLEQ_HEAD_INITIALIZER(_rtld_list_global);
|
||||
|
||||
|
||||
void
|
||||
_rtld_objlist_push_head(Objlist *list, Obj_Entry *obj)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ _rtld_load_object(const char *filepath, int flags)
|
||||
size_t pathlen = strlen(filepath);
|
||||
|
||||
for (obj = _rtld_objlist->next; obj != NULL; obj = obj->next)
|
||||
if (pathlen == obj->pathlen && !strcmp(obj->path, filepath))
|
||||
if (pathlen == obj->pathlen && !strcmp(obj->path, filepath))
|
||||
break;
|
||||
|
||||
/*
|
||||
@@ -146,6 +146,14 @@ _rtld_load_object(const char *filepath, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RTLD_LOADER
|
||||
if (pathlen == _rtld_objself.pathlen &&
|
||||
strcmp(_rtld_objself.path, filepath) == 0) {
|
||||
close(fd);
|
||||
return &_rtld_objself;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (obj == NULL) { /* First use of this object, so we must map it in */
|
||||
obj = _rtld_map_object(filepath, fd, &sb);
|
||||
(void)close(fd);
|
||||
@@ -200,7 +208,9 @@ _rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
|
||||
{
|
||||
#if !defined(__minix)
|
||||
Library_Xform *x = _rtld_xforms;
|
||||
Obj_Entry *o = NULL;
|
||||
#endif /* !defined(__minix) */
|
||||
Obj_Entry *o;
|
||||
#if !defined(__minix)
|
||||
size_t j;
|
||||
ssize_t i;
|
||||
#endif /* !defined(__minix) */
|
||||
@@ -211,10 +221,17 @@ _rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
|
||||
u_quad_t q;
|
||||
char s[16];
|
||||
} val;
|
||||
|
||||
dbg(("load by name %s %p", name, x));
|
||||
#endif /* !defined(__minix) */
|
||||
for (o = _rtld_objlist->next; o != NULL; o = o->next)
|
||||
if (_rtld_object_match_name(o, name)) {
|
||||
++o->refcount;
|
||||
(*needed)->obj = o;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(__minix)
|
||||
dbg(("load by name %s %p", name, x));
|
||||
for (; x; x = x->next) {
|
||||
if (strcmp(x->name, name) != 0)
|
||||
continue;
|
||||
@@ -276,9 +293,9 @@ _rtld_load_by_name(const char *name, Obj_Entry *obj, Needed_Entry **needed,
|
||||
(*needed)->next = ne;
|
||||
*needed = ne;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $ */
|
||||
/* $NetBSD: map_object.c,v 1.52 2013/08/03 13:17:05 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $");
|
||||
__RCSID("$NetBSD: map_object.c,v 1.52 2013/08/03 13:17:05 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <errno.h>
|
||||
@@ -49,18 +49,19 @@ __RCSID("$NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $");
|
||||
#include "debug.h"
|
||||
#include "rtld.h"
|
||||
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
#define MINIXVERBOSE 0
|
||||
|
||||
#ifndef MAP_SHARED
|
||||
#define MAP_SHARED MAP_PRIVATE /* minix: MAP_SHARED should be MAP_PRIVATE */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MINIXVERBOSE 0
|
||||
|
||||
#if MINIXVERBOSE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#endif /* defined(__minix) */
|
||||
|
||||
static int protflags(int); /* Elf flags -> mmap protection */
|
||||
|
||||
#define EA_UNDEF (~(Elf_Addr)0)
|
||||
@@ -117,7 +118,9 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
caddr_t clear_addr;
|
||||
size_t nclear;
|
||||
#endif
|
||||
size_t bsslen;
|
||||
#if defined(__minix)
|
||||
Elf_Addr bsslen;
|
||||
#endif /* defined(__minix) */
|
||||
|
||||
if (sb != NULL && sb->st_size < (off_t)sizeof (Elf_Ehdr)) {
|
||||
_rtld_error("%s: not ELF file (too short)", path);
|
||||
@@ -136,7 +139,7 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
(off_t)0);
|
||||
obj->ehdr = ehdr;
|
||||
if (ehdr == MAP_FAILED) {
|
||||
#if defined(__minix) && (defined(RTLD_LOADER) || defined(LDD))
|
||||
#if defined(__minix)
|
||||
return _rtld_map_object_fallback(path, fd, sb);
|
||||
#else
|
||||
_rtld_error("%s: read error: %s", path, xstrerror(errno));
|
||||
@@ -208,11 +211,6 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
segs[nsegs] = phdr;
|
||||
++nsegs;
|
||||
|
||||
#if ELFSIZE == 64
|
||||
#define PRImemsz PRIu64
|
||||
#else
|
||||
#define PRImemsz PRIu32
|
||||
#endif
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_LOAD",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
@@ -223,7 +221,7 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_PHDR",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
|
||||
|
||||
case PT_DYNAMIC:
|
||||
obj->dynamic = (void *)(uintptr_t)phdr->p_vaddr;
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_DYNAMIC",
|
||||
@@ -236,6 +234,12 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_TLS",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
#endif
|
||||
#ifdef __ARM_EABI__
|
||||
case PT_ARM_EXIDX:
|
||||
obj->exidx_start = (void *)(uintptr_t)phdr->p_vaddr;
|
||||
obj->exidx_sz = phdr->p_memsz;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -331,8 +335,6 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
|
||||
/* Unmap header if it overlaps the first load section. */
|
||||
if (base_offset < _rtld_pagesz) {
|
||||
dbg(("error; base_offset = 0x%lx, pagesize 0x%lx\n",
|
||||
base_offset, _rtld_pagesz));
|
||||
munmap(ehdr, _rtld_pagesz);
|
||||
obj->ehdr = MAP_FAILED;
|
||||
}
|
||||
@@ -356,10 +358,8 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
base_addr = NULL;
|
||||
#endif
|
||||
mapsize = base_vlimit - base_vaddr;
|
||||
|
||||
mapbase = mmap(base_addr, mapsize, text_flags,
|
||||
mapflags | MAP_FILE | MAP_PRIVATE, fd, base_offset);
|
||||
|
||||
if (mapbase == MAP_FAILED) {
|
||||
_rtld_error("mmap of entire address space failed: %s",
|
||||
xstrerror(errno));
|
||||
@@ -368,7 +368,6 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
|
||||
/* Overlay the data segment onto the proper region. */
|
||||
data_addr = mapbase + (data_vaddr - base_vaddr);
|
||||
|
||||
if (mmap(data_addr, data_vlimit - data_vaddr, data_flags,
|
||||
MAP_FILE | MAP_PRIVATE | MAP_FIXED, fd, data_offset) ==
|
||||
MAP_FAILED) {
|
||||
@@ -377,13 +376,13 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
}
|
||||
|
||||
/* Overlay the bss segment onto the proper region. */
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
bsslen = base_vlimit - data_vlimit;
|
||||
if (bsslen > 0 &&
|
||||
mmap(mapbase + data_vlimit - base_vaddr, bsslen,
|
||||
#else
|
||||
if (mmap(mapbase + data_vlimit - base_vaddr, base_vlimit - data_vlimit,
|
||||
#endif
|
||||
#endif /* defined(__minix) */
|
||||
data_flags, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) ==
|
||||
MAP_FAILED) {
|
||||
_rtld_error("mmap of bss failed: %s", xstrerror(errno));
|
||||
@@ -391,7 +390,7 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
}
|
||||
|
||||
/* Unmap the gap between the text and data. */
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
gap_addr = mapbase + round_up(text_vlimit - base_vaddr);
|
||||
gap_size = data_addr - gap_addr;
|
||||
if (gap_size != 0 && mprotect(gap_addr, gap_size, PROT_NONE) == -1) {
|
||||
@@ -399,7 +398,7 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
xstrerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
#ifdef RTLD_LOADER
|
||||
/* Clear any BSS in the last page of the data segment. */
|
||||
@@ -427,6 +426,10 @@ _rtld_map_object(const char *path, int fd, const struct stat *sb)
|
||||
obj->interp = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->interp);
|
||||
if (obj->phdr_loaded)
|
||||
obj->phdr = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->phdr);
|
||||
#ifdef __ARM_EABI__
|
||||
if (obj->exidx_start)
|
||||
obj->exidx_start = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->exidx_start);
|
||||
#endif
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -443,6 +446,7 @@ void
|
||||
_rtld_obj_free(Obj_Entry *obj)
|
||||
{
|
||||
Objlist_Entry *elm;
|
||||
Name_Entry *entry;
|
||||
|
||||
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
||||
if (obj->tls_done)
|
||||
@@ -454,6 +458,10 @@ _rtld_obj_free(Obj_Entry *obj)
|
||||
obj->needed = needed->next;
|
||||
xfree(needed);
|
||||
}
|
||||
while ((entry = SIMPLEQ_FIRST(&obj->names)) != NULL) {
|
||||
SIMPLEQ_REMOVE_HEAD(&obj->names, link);
|
||||
xfree(entry);
|
||||
}
|
||||
while ((elm = SIMPLEQ_FIRST(&obj->dldags)) != NULL) {
|
||||
SIMPLEQ_REMOVE_HEAD(&obj->dldags, link);
|
||||
xfree(elm);
|
||||
@@ -476,6 +484,7 @@ _rtld_obj_new(void)
|
||||
Obj_Entry *obj;
|
||||
|
||||
obj = CNEW(Obj_Entry);
|
||||
SIMPLEQ_INIT(&obj->names);
|
||||
SIMPLEQ_INIT(&obj->dldags);
|
||||
SIMPLEQ_INIT(&obj->dagmembers);
|
||||
return obj;
|
||||
@@ -498,11 +507,11 @@ protflags(int elfflags)
|
||||
#endif
|
||||
if (elfflags & PF_X)
|
||||
prot |= PROT_EXEC;
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
/* Minix has to map it writable so we can do relocations
|
||||
* as we don't have mprotect() yet.
|
||||
*/
|
||||
prot |= PROT_WRITE;
|
||||
#endif
|
||||
#endif /* defined(__minix) */
|
||||
return prot;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $ */
|
||||
/* $NetBSD: map_object.c,v 1.52 2013/08/03 13:17:05 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $");
|
||||
__RCSID("$NetBSD: map_object.c,v 1.52 2013/08/03 13:17:05 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <errno.h>
|
||||
@@ -213,11 +213,6 @@ _rtld_map_object_fallback(const char *path, int fd, const struct stat *sb)
|
||||
segs[nsegs] = phdr;
|
||||
++nsegs;
|
||||
|
||||
#if ELFSIZE == 64
|
||||
#define PRImemsz PRIu64
|
||||
#else
|
||||
#define PRImemsz PRIu32
|
||||
#endif
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_LOAD",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
@@ -228,7 +223,7 @@ _rtld_map_object_fallback(const char *path, int fd, const struct stat *sb)
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_PHDR",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
|
||||
|
||||
case PT_DYNAMIC:
|
||||
obj->dynamic = (void *)(uintptr_t)phdr->p_vaddr;
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_DYNAMIC",
|
||||
@@ -241,6 +236,12 @@ _rtld_map_object_fallback(const char *path, int fd, const struct stat *sb)
|
||||
dbg(("%s: %s %p phsize %" PRImemsz, obj->path, "PT_TLS",
|
||||
(void *)(uintptr_t)phdr->p_vaddr, phdr->p_memsz));
|
||||
break;
|
||||
#endif
|
||||
#ifdef __ARM_EABI__
|
||||
case PT_ARM_EXIDX:
|
||||
obj->exidx_start = (void *)(uintptr_t)phdr->p_vaddr;
|
||||
obj->exidx_sz = phdr->p_memsz;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -433,6 +434,10 @@ _rtld_map_object_fallback(const char *path, int fd, const struct stat *sb)
|
||||
obj->interp = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->interp);
|
||||
if (obj->phdr_loaded)
|
||||
obj->phdr = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->phdr);
|
||||
#ifdef __ARM_EABI__
|
||||
if (obj->exidx_start)
|
||||
obj->exidx_start = (void *)(obj->relocbase + (Elf_Addr)(uintptr_t)obj->exidx_start);
|
||||
#endif
|
||||
|
||||
return obj;
|
||||
|
||||
@@ -462,5 +467,11 @@ protflags(int elfflags)
|
||||
#endif
|
||||
if (elfflags & PF_X)
|
||||
prot |= PROT_EXEC;
|
||||
#if defined(__minix)
|
||||
/* Minix has to map it writable so we can do relocations
|
||||
* as we don't have mprotect() yet.
|
||||
*/
|
||||
prot |= PROT_WRITE;
|
||||
#endif /* defined(__minix) */
|
||||
return prot;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: paths.c,v 1.40 2009/05/19 20:44:52 christos Exp $ */
|
||||
/* $NetBSD: paths.c,v 1.41 2013/05/06 08:02:20 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 Matt Thomas <matt@3am-software.com>
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: paths.c,v 1.40 2009/05/19 20:44:52 christos Exp $");
|
||||
__RCSID("$NetBSD: paths.c,v 1.41 2013/05/06 08:02:20 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@@ -49,9 +49,9 @@ __RCSID("$NetBSD: paths.c,v 1.40 2009/05/19 20:44:52 christos Exp $");
|
||||
#include <sys/gmon.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/mount.h>
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
#include <sys/mbuf.h>
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
#include <sys/resource.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
@@ -237,7 +237,7 @@ _rtld_add_paths(const char *execname, Search_Path **path_p, const char *pathstr)
|
||||
#if !defined(__minix)
|
||||
/*
|
||||
* Process library mappings of the form:
|
||||
* <library_name> <machdep_variable> <value,...:library_name,...> ...
|
||||
* <library_name> <machdep_variable> <value,...:library_name,...> ...
|
||||
*/
|
||||
static void
|
||||
_rtld_process_mapping(Library_Xform **lib_p, const char *bp, const char *ep)
|
||||
@@ -245,7 +245,7 @@ _rtld_process_mapping(Library_Xform **lib_p, const char *bp, const char *ep)
|
||||
Library_Xform *hwptr = NULL;
|
||||
const char *ptr, *key, *ekey, *lib, *elib, *l;
|
||||
int i, j;
|
||||
|
||||
|
||||
dbg((" processing mapping \"%.*s\"", (int)(ep - bp), bp));
|
||||
|
||||
if ((ptr = getword(&bp, ep, WS)) == NULL || ptr == bp)
|
||||
@@ -318,7 +318,7 @@ no_more:
|
||||
if (i == RTLD_MAX_ENTRY)
|
||||
goto no_more;
|
||||
if (i != j)
|
||||
(void)memcpy(hwptr->entry[i].library,
|
||||
(void)memcpy(hwptr->entry[i].library,
|
||||
hwptr->entry[j].library,
|
||||
sizeof(hwptr->entry[j].library));
|
||||
hwptr->entry[i].value = exstrdup(l, key);
|
||||
@@ -347,7 +347,7 @@ _rtld_process_hints(const char *execname, Search_Path **path_p,
|
||||
Library_Xform **lib_p, const char *fname)
|
||||
{
|
||||
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
/* Minix doesn't support MAP_SHARED. */
|
||||
return;
|
||||
#else
|
||||
@@ -421,10 +421,10 @@ _rtld_process_hints(const char *execname, Search_Path **path_p,
|
||||
|
||||
if (buf != small)
|
||||
(void)munmap(buf, sz);
|
||||
#endif
|
||||
#endif /* defined(__minix) */
|
||||
}
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
/* Basic name -> sysctl MIB translation */
|
||||
int
|
||||
_rtld_sysctl(const char *name, void *oldp, size_t *oldlen)
|
||||
@@ -493,4 +493,4 @@ bad:
|
||||
xfree(result);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(__minix) */
|
||||
|
||||
@@ -169,7 +169,7 @@ _rtld_relocate_objects(Obj_Entry *first, bool bind_now)
|
||||
(long)(obj->pltrellim - obj->pltrel),
|
||||
(long)(obj->pltrelalim - obj->pltrela)));
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (obj->textrel) {
|
||||
/*
|
||||
* There are relocations to the write-protected text
|
||||
@@ -182,13 +182,12 @@ _rtld_relocate_objects(Obj_Entry *first, bool bind_now)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(__minix) */
|
||||
dbg(("doing non-PLT relocations"));
|
||||
if (_rtld_relocate_nonplt_objects(obj) < 0)
|
||||
ok = 0;
|
||||
|
||||
#ifndef __minix
|
||||
#if !defined(__minix)
|
||||
if (obj->textrel) { /* Re-protected the text segment. */
|
||||
if (mprotect(obj->mapbase, obj->textsize,
|
||||
PROT_READ | PROT_EXEC) == -1) {
|
||||
@@ -197,8 +196,7 @@ _rtld_relocate_objects(Obj_Entry *first, bool bind_now)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(__minix) */
|
||||
dbg(("doing lazy PLT binding"));
|
||||
if (_rtld_relocate_plt_lazy(obj) < 0)
|
||||
ok = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtld.c,v 1.159 2012/10/01 03:03:46 riastradh Exp $ */
|
||||
/* $NetBSD: rtld.c,v 1.171 2013/11/20 07:18:23 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: rtld.c,v 1.159 2012/10/01 03:03:46 riastradh Exp $");
|
||||
__RCSID("$NetBSD: rtld.c,v 1.171 2013/11/20 07:18:23 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -157,7 +157,7 @@ _rtld_call_fini_function(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
|
||||
dbg (("calling fini function %s at %p%s", obj->path,
|
||||
(void *)obj->fini,
|
||||
obj->z_initfirst ? " (DF_1_INITFIRST)" : ""));
|
||||
obj->fini_called = 1;
|
||||
obj->fini_called = 1;
|
||||
_rtld_call_initfini_function(obj->fini, mask);
|
||||
}
|
||||
#ifdef HAVE_INITFINI_ARRAY
|
||||
@@ -340,7 +340,7 @@ _rtld_init(caddr_t mapbase, caddr_t relocbase, const char *execname)
|
||||
#else
|
||||
_rtld_relocate_plt_objects(&_rtld_objself);
|
||||
#endif
|
||||
#if !defined(__mips__) && !defined(__hppa__) && !defined(HAVE_GOLD)
|
||||
#if !defined(__mips__) && !defined(__hppa__)
|
||||
assert(!_rtld_objself.pltgot);
|
||||
#endif
|
||||
#if !defined(__arm__) && !defined(__mips__) && !defined(__sh__)
|
||||
@@ -356,12 +356,7 @@ _rtld_init(caddr_t mapbase, caddr_t relocbase, const char *execname)
|
||||
RTLD_DEFAULT_LIBRARY_PATH "/" RTLD_ARCH_SUBDIR);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up the _rtld_objlist pointer, so that rtld symbols can be found.
|
||||
*/
|
||||
_rtld_objlist = &_rtld_objself;
|
||||
|
||||
/* Make the object list empty again. */
|
||||
/* Make the object list empty. */
|
||||
_rtld_objlist = NULL;
|
||||
_rtld_objtail = &_rtld_objlist;
|
||||
_rtld_objcount = 0;
|
||||
@@ -447,11 +442,10 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
|
||||
debug = 1;
|
||||
dbg(("sp = %p, argc = %ld, argv = %p <%s> relocbase %p", sp,
|
||||
(long)sp[2], &sp[3], (char *) sp[3], (void *)relocbase));
|
||||
#if 0
|
||||
#ifndef __x86_64__
|
||||
dbg(("got is at %p, dynamic is at %p", _GLOBAL_OFFSET_TABLE_,
|
||||
&_DYNAMIC));
|
||||
#endif
|
||||
dbg(("_ctype_ is %p", _ctype_));
|
||||
#endif
|
||||
|
||||
sp += 2; /* skip over return argument space */
|
||||
@@ -638,7 +632,7 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
|
||||
}
|
||||
|
||||
_rtld_objmain->mainprog = true;
|
||||
|
||||
|
||||
/*
|
||||
* Get the actual dynamic linker pathname from the executable if
|
||||
* possible. (It should always be possible.) That ensures that
|
||||
@@ -646,10 +640,12 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
|
||||
* one is being used.
|
||||
*/
|
||||
if (_rtld_objmain->interp != NULL &&
|
||||
strcmp(_rtld_objmain->interp, _rtld_objself.path) != 0)
|
||||
strcmp(_rtld_objmain->interp, _rtld_objself.path) != 0) {
|
||||
_rtld_objself.path = xstrdup(_rtld_objmain->interp);
|
||||
_rtld_objself.pathlen = strlen(_rtld_objself.path);
|
||||
}
|
||||
dbg(("actual dynamic linker is %s", _rtld_objself.path));
|
||||
|
||||
|
||||
_rtld_digest_dynamic(execname, _rtld_objmain);
|
||||
|
||||
/* Link the main program into the list of objects. */
|
||||
@@ -997,7 +993,7 @@ dlopen(const char *name, int mode)
|
||||
|
||||
flags |= (mode & RTLD_GLOBAL) ? _RTLD_GLOBAL : 0;
|
||||
flags |= (mode & RTLD_NOLOAD) ? _RTLD_NOLOAD : 0;
|
||||
|
||||
|
||||
nodelete = (mode & RTLD_NODELETE) ? true : false;
|
||||
now = ((mode & RTLD_MODEMASK) == RTLD_NOW) ? true : false;
|
||||
|
||||
@@ -1108,7 +1104,7 @@ do_dlsym(void *handle, const char *name, const Ver_Entry *ventry, void *retaddr)
|
||||
hash = _rtld_elf_hash(name);
|
||||
def = NULL;
|
||||
defobj = NULL;
|
||||
|
||||
|
||||
switch ((intptr_t)handle) {
|
||||
case (intptr_t)NULL:
|
||||
case (intptr_t)RTLD_NEXT:
|
||||
@@ -1178,7 +1174,7 @@ do_dlsym(void *handle, const char *name, const Ver_Entry *ventry, void *retaddr)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (def != NULL) {
|
||||
void *p;
|
||||
#ifdef __HAVE_FUNCTION_DESCRIPTORS
|
||||
@@ -1193,7 +1189,7 @@ do_dlsym(void *handle, const char *name, const Ver_Entry *ventry, void *retaddr)
|
||||
lookup_mutex_exit();
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
_rtld_error("Undefined symbol \"%s\"", name);
|
||||
lookup_mutex_exit();
|
||||
return NULL;
|
||||
@@ -1270,7 +1266,7 @@ dladdr(const void *addr, Dl_info *info)
|
||||
info->dli_fbase = obj->mapbase;
|
||||
info->dli_saddr = (void *)0;
|
||||
info->dli_sname = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Walk the symbol list looking for the symbol whose address is
|
||||
* closest to the address sent in.
|
||||
@@ -1300,6 +1296,7 @@ dladdr(const void *addr, Dl_info *info)
|
||||
info->dli_saddr = symbol_addr;
|
||||
best_def = def;
|
||||
|
||||
|
||||
/* Exact match? */
|
||||
if (info->dli_saddr == addr)
|
||||
break;
|
||||
@@ -1307,8 +1304,10 @@ dladdr(const void *addr, Dl_info *info)
|
||||
|
||||
#ifdef __HAVE_FUNCTION_DESCRIPTORS
|
||||
if (best_def != NULL && ELF_ST_TYPE(best_def->st_info) == STT_FUNC)
|
||||
info->dli_saddr = (void *)_rtld_function_descriptor_alloc(obj,
|
||||
info->dli_saddr = (void *)_rtld_function_descriptor_alloc(obj,
|
||||
best_def, 0);
|
||||
#else
|
||||
__USE(best_def);
|
||||
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
|
||||
|
||||
lookup_mutex_exit();
|
||||
@@ -1377,8 +1376,9 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), void *pa
|
||||
|
||||
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
|
||||
phdr_info.dlpi_addr = (Elf_Addr)obj->relocbase;
|
||||
phdr_info.dlpi_name = STAILQ_FIRST(&obj->names) ?
|
||||
STAILQ_FIRST(&obj->names)->name : obj->path;
|
||||
/* XXX: wrong but not fixing it yet */
|
||||
phdr_info.dlpi_name = SIMPLEQ_FIRST(&obj->names) ?
|
||||
SIMPLEQ_FIRST(&obj->names)->name : obj->path;
|
||||
phdr_info.dlpi_phdr = obj->phdr;
|
||||
phdr_info.dlpi_phnum = obj->phsize / sizeof(obj->phdr[0]);
|
||||
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
||||
@@ -1478,7 +1478,7 @@ static Obj_Entry *
|
||||
_rtld_obj_from_addr(const void *addr)
|
||||
{
|
||||
Obj_Entry *obj;
|
||||
|
||||
|
||||
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
|
||||
if (addr < (void *) obj->mapbase)
|
||||
continue;
|
||||
@@ -1502,7 +1502,7 @@ static void
|
||||
_rtld_objlist_remove(Objlist *list, Obj_Entry *obj)
|
||||
{
|
||||
Objlist_Entry *elm;
|
||||
|
||||
|
||||
if ((elm = _rtld_objlist_find(list, obj)) != NULL) {
|
||||
SIMPLEQ_REMOVE(list, elm, Struct_Objlist_Entry, link);
|
||||
xfree(elm);
|
||||
@@ -1556,7 +1556,7 @@ _rtld_shared_enter(void)
|
||||
*/
|
||||
if ((_rtld_mutex & RTLD_EXCLUSIVE_MASK) ||
|
||||
_rtld_waiter_exclusive)
|
||||
_lwp_park(NULL, -1, __UNVOLATILE(&_rtld_mutex), NULL);
|
||||
_lwp_park(NULL, 0, __UNVOLATILE(&_rtld_mutex), NULL);
|
||||
/* Try to remove us from the waiter list. */
|
||||
atomic_cas_uint(&_rtld_waiter_shared, self, 0);
|
||||
if (waiter)
|
||||
@@ -1612,7 +1612,7 @@ _rtld_exclusive_enter(sigset_t *mask)
|
||||
_rtld_die();
|
||||
}
|
||||
if (cur)
|
||||
_lwp_park(NULL, -1, __UNVOLATILE(&_rtld_mutex), NULL);
|
||||
_lwp_park(NULL, 0, __UNVOLATILE(&_rtld_mutex), NULL);
|
||||
atomic_cas_uint(&_rtld_waiter_exclusive, self, 0);
|
||||
if (waiter)
|
||||
_lwp_unpark(waiter, __UNVOLATILE(&_rtld_mutex));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtld.h,v 1.110 2012/08/15 03:46:06 matt Exp $ */
|
||||
/* $NetBSD: rtld.h,v 1.116 2013/05/09 15:38:14 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -48,6 +48,10 @@
|
||||
|
||||
#if defined(_RTLD_SOURCE)
|
||||
|
||||
#ifdef __ARM_EABI__
|
||||
#include "unwind.h"
|
||||
#endif
|
||||
|
||||
#ifndef RTLD_DEFAULT_LIBRARY_PATH
|
||||
#define RTLD_DEFAULT_LIBRARY_PATH "/usr/lib"
|
||||
#endif
|
||||
@@ -88,7 +92,7 @@ typedef struct Struct_Objlist_Entry {
|
||||
typedef SIMPLEQ_HEAD(Struct_Objlist, Struct_Objlist_Entry) Objlist;
|
||||
|
||||
typedef struct Struct_Name_Entry {
|
||||
STAILQ_ENTRY(Struct_Name_Entry) link;
|
||||
SIMPLEQ_ENTRY(Struct_Name_Entry) link;
|
||||
char name[1];
|
||||
} Name_Entry;
|
||||
|
||||
@@ -215,9 +219,9 @@ typedef struct Struct_Obj_Entry {
|
||||
mainref:1, /* True if on _rtld_list_main */
|
||||
globalref:1, /* True if on _rtld_list_global */
|
||||
init_done:1, /* True if .init has been added */
|
||||
init_called:1, /* True if .init function has been
|
||||
init_called:1, /* True if .init function has been
|
||||
* called */
|
||||
fini_called:1, /* True if .fini function has been
|
||||
fini_called:1, /* True if .fini function has been
|
||||
* called */
|
||||
z_now:1, /* True if object's symbols should be
|
||||
bound immediately */
|
||||
@@ -251,8 +255,8 @@ typedef struct Struct_Obj_Entry {
|
||||
uint8_t nbuckets_s1;
|
||||
uint8_t nbuckets_s2;
|
||||
size_t pathlen; /* Pathname length */
|
||||
STAILQ_HEAD(, Struct_Name_Entry) names; /* List of names for this object we
|
||||
know about. */
|
||||
SIMPLEQ_HEAD(, Struct_Name_Entry) names; /* List of names for this
|
||||
* object we know about. */
|
||||
|
||||
#ifdef __powerpc__
|
||||
Elf_Addr *gotptr; /* GOT table (secure-plt only) */
|
||||
@@ -284,6 +288,10 @@ typedef struct Struct_Obj_Entry {
|
||||
size_t init_arraysz; /* # of entries in it */
|
||||
fptr_t *fini_array; /* start of fini array */
|
||||
size_t fini_arraysz; /* # of entries in it */
|
||||
#ifdef __ARM_EABI__
|
||||
void *exidx_start;
|
||||
size_t exidx_sz;
|
||||
#endif
|
||||
} Obj_Entry;
|
||||
|
||||
typedef struct Struct_DoneList {
|
||||
@@ -340,10 +348,17 @@ __dso_public int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
|
||||
|
||||
__dso_public void *_dlauxinfo(void) __pure;
|
||||
|
||||
#ifdef __ARM_EABI__
|
||||
/*
|
||||
* This is used by libgcc to find the start and length of the exception table
|
||||
* associated with a PC.
|
||||
*/
|
||||
__dso_public _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr, int *);
|
||||
#endif
|
||||
|
||||
/* These aren't exported */
|
||||
void _rtld_error(const char *, ...)
|
||||
__attribute__((__format__(__printf__,1,2)));
|
||||
void _rtld_die(void) __attribute__((__noreturn__));
|
||||
void _rtld_error(const char *, ...) __printflike(1,2);
|
||||
void _rtld_die(void) __dead;
|
||||
void *_rtld_objmain_sym(const char *);
|
||||
__dso_public void _rtld_debug_state(void) __noinline;
|
||||
void _rtld_linkmap_add(Obj_Entry *);
|
||||
@@ -395,7 +410,7 @@ const Elf_Sym *_rtld_symlook_obj(const char *, unsigned long,
|
||||
const Obj_Entry *, u_int, const Ver_Entry *);
|
||||
const Elf_Sym *_rtld_find_symdef(unsigned long, const Obj_Entry *,
|
||||
const Obj_Entry **, u_int);
|
||||
const Elf_Sym *_rtld_find_plt_symdef(unsigned long, const Obj_Entry *,
|
||||
const Elf_Sym *_rtld_find_plt_symdef(unsigned long, const Obj_Entry *,
|
||||
const Obj_Entry **, bool);
|
||||
|
||||
const Elf_Sym *_rtld_symlook_list(const char *, unsigned long,
|
||||
@@ -410,6 +425,7 @@ void _rtld_combreloc_reset(const Obj_Entry *);
|
||||
#endif
|
||||
|
||||
/* symver.c */
|
||||
void _rtld_object_add_name(Obj_Entry *, const char *);
|
||||
int _rtld_object_match_name(const Obj_Entry *, const char *);
|
||||
int _rtld_verify_object_versions(Obj_Entry *);
|
||||
|
||||
@@ -451,13 +467,15 @@ __dso_public extern void *___tls_get_addr(void *)
|
||||
/* map_object.c */
|
||||
struct stat;
|
||||
Obj_Entry *_rtld_map_object(const char *, int, const struct stat *);
|
||||
#if defined(__minix)
|
||||
Obj_Entry *_rtld_map_object_fallback(const char *, int, const struct stat *);
|
||||
#endif /* defined(__minix) */
|
||||
void _rtld_obj_free(Obj_Entry *);
|
||||
Obj_Entry *_rtld_obj_new(void);
|
||||
|
||||
/* function descriptors */
|
||||
#ifdef __HAVE_FUNCTION_DESCRIPTORS
|
||||
Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *,
|
||||
Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *,
|
||||
const Elf_Sym *, Elf_Addr);
|
||||
const void *_rtld_function_descriptor_function(const void *);
|
||||
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rtldenv.h,v 1.11 2011/12/11 11:05:11 joerg Exp $ */
|
||||
/* $NetBSD: rtldenv.h,v 1.12 2013/05/06 08:02:20 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 Matt Thomas <matt@3am-software.com>
|
||||
@@ -70,7 +70,7 @@ int xunsetenv(const char *);
|
||||
# include <assert.h>
|
||||
# include <stdio.h>
|
||||
# include <err.h>
|
||||
|
||||
|
||||
# define xprintf printf
|
||||
# define xvprintf vprintf
|
||||
# define xsnprintf snprintf
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: search.c,v 1.23 2010/12/24 12:41:43 skrll Exp $ */
|
||||
/* $NetBSD: search.c,v 1.24 2013/05/06 08:02:20 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 Matt Thomas <matt@3am-software.com>
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: search.c,v 1.23 2010/12/24 12:41:43 skrll Exp $");
|
||||
__RCSID("$NetBSD: search.c,v 1.24 2013/05/06 08:02:20 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@@ -140,7 +140,7 @@ _rtld_load_library(const char *name, const Obj_Entry *refobj, int flags)
|
||||
strncpy(tmperror, tmperrorp, sizeof tmperror);
|
||||
tmperrorp = tmperror;
|
||||
}
|
||||
|
||||
|
||||
namelen = strlen(name);
|
||||
|
||||
for (sp = _rtld_paths; sp != NULL; sp = sp->sp_next)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: symbol.c,v 1.61 2012/08/15 03:46:07 matt Exp $ */
|
||||
/* $NetBSD: symbol.c,v 1.63 2013/05/03 10:27:05 skrll Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: symbol.c,v 1.61 2012/08/15 03:46:07 matt Exp $");
|
||||
__RCSID("$NetBSD: symbol.c,v 1.63 2013/05/03 10:27:05 skrll Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@@ -100,6 +100,9 @@ _rtld_is_exported(const Elf_Sym *def)
|
||||
#ifdef __i386__
|
||||
(fptr_t)___tls_get_addr,
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __ARM_EABI__
|
||||
(fptr_t)__gnu_Unwind_Find_exidx, /* for gcc EHABI */
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
@@ -146,7 +149,7 @@ _rtld_symlook_list(const char *name, unsigned long hash, const Objlist *objlist,
|
||||
const Elf_Sym *def;
|
||||
const Obj_Entry *defobj;
|
||||
const Objlist_Entry *elm;
|
||||
|
||||
|
||||
def = NULL;
|
||||
defobj = NULL;
|
||||
SIMPLEQ_FOREACH(elm, objlist, link) {
|
||||
@@ -430,7 +433,7 @@ _rtld_find_symdef(unsigned long symnum, const Obj_Entry *refobj,
|
||||
def = ref;
|
||||
defobj = refobj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If we found no definition and the reference is weak, treat the
|
||||
* symbol as having the value zero.
|
||||
@@ -543,7 +546,7 @@ _rtld_symlook_default(const char *name, unsigned long hash,
|
||||
defobj = obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Search all dlopened DAGs containing the referencing object. */
|
||||
SIMPLEQ_FOREACH(elm, &refobj->dldags, link) {
|
||||
if (def != NULL && ELF_ST_BIND(def->st_info) != STB_WEAK)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $ */
|
||||
/* $NetBSD: symver.c,v 1.4 2013/05/09 15:38:14 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
|
||||
@@ -59,7 +59,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $");
|
||||
__RCSID("$NetBSD: symver.c,v 1.4 2013/05/09 15:38:14 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/exec_elf.h>
|
||||
@@ -68,13 +68,27 @@ __RCSID("$NetBSD: symver.c,v 1.1 2011/06/25 05:45:12 nonaka Exp $");
|
||||
#include "debug.h"
|
||||
#include "rtld.h"
|
||||
|
||||
void
|
||||
_rtld_object_add_name(Obj_Entry *obj, const char *name)
|
||||
{
|
||||
Name_Entry *entry;
|
||||
size_t len;
|
||||
|
||||
len = strlen(name);
|
||||
entry = xmalloc(sizeof(Name_Entry) + len);
|
||||
|
||||
if (entry != NULL) {
|
||||
strcpy(entry->name, name);
|
||||
SIMPLEQ_INSERT_TAIL(&obj->names, entry, link);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_rtld_object_match_name(const Obj_Entry *obj, const char *name)
|
||||
{
|
||||
Name_Entry *entry;
|
||||
|
||||
STAILQ_FOREACH(entry, &obj->names, link) {
|
||||
SIMPLEQ_FOREACH(entry, &obj->names, link) {
|
||||
dbg(("name: %s, entry->name: %s", name, entry->name));
|
||||
if (strcmp(name, entry->name) == 0)
|
||||
return 1;
|
||||
@@ -82,6 +96,7 @@ _rtld_object_match_name(const Obj_Entry *obj, const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RTLD_LOADER
|
||||
static Obj_Entry *
|
||||
locate_dependency(const Obj_Entry *obj, const char *name)
|
||||
{
|
||||
@@ -315,3 +330,4 @@ _rtld_verify_object_versions(Obj_Entry *obj)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* $NetBSD: sysident.h,v 1.14 2007/06/24 20:35:36 christos Exp $ */
|
||||
/* $NetBSD: sysident.h,v 1.16 2013/09/10 16:35:10 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christopher G. Demetriou
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@@ -19,7 +19,7 @@
|
||||
* information about NetBSD.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
@@ -30,7 +30,7 @@
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
|
||||
*/
|
||||
|
||||
@@ -89,3 +89,20 @@ __asm(
|
||||
"\t.previous\n"
|
||||
"\t.p2align\t2\n"
|
||||
);
|
||||
|
||||
#ifdef ELF_NOTE_MARCH_DESC
|
||||
__asm(
|
||||
".section\t\".note.netbsd.march\", \"a\"\n"
|
||||
"\t.p2align\t2\n\n"
|
||||
|
||||
"\t.long\t" __S(ELF_NOTE_MARCH_NAMESZ) "\n"
|
||||
"\t.long\t2f-1f\n"
|
||||
"\t.long\t" __S(ELF_NOTE_TYPE_MARCH_TAG) "\n"
|
||||
"\t.ascii\t" __S(ELF_NOTE_MARCH_NAME) "\n"
|
||||
"1:\t.asciz\t" __S(ELF_NOTE_MARCH_DESC) "\n"
|
||||
"2:\n"
|
||||
|
||||
"\t.previous\n"
|
||||
"\t.p2align\t2\n"
|
||||
);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tls.c,v 1.7 2011/04/23 16:40:08 joerg Exp $ */
|
||||
/* $NetBSD: tls.c,v 1.9 2013/10/21 19:14:15 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@@ -29,12 +29,13 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: tls.c,v 1.7 2011/04/23 16:40:08 joerg Exp $");
|
||||
__RCSID("$NetBSD: tls.c,v 1.9 2013/10/21 19:14:15 joerg Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ucontext.h>
|
||||
#include <lwp.h>
|
||||
#include <string.h>
|
||||
#include "debug.h"
|
||||
#include "rtld.h"
|
||||
|
||||
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
||||
@@ -100,6 +101,7 @@ _rtld_tls_initial_allocation(void)
|
||||
_rtld_tls_static_space = roundup2(_rtld_tls_static_space,
|
||||
sizeof(void *));
|
||||
#endif
|
||||
dbg(("_rtld_tls_static_space %zu", _rtld_tls_static_space));
|
||||
|
||||
tcb = _rtld_tls_allocate_locked();
|
||||
#ifdef __HAVE___LWP_SETTCB
|
||||
@@ -132,18 +134,21 @@ _rtld_tls_allocate_locked(void)
|
||||
tcb = (struct tls_tcb *)p;
|
||||
tcb->tcb_self = tcb;
|
||||
#endif
|
||||
dbg(("tcb %p", tcb));
|
||||
tcb->tcb_dtv = xcalloc(sizeof(*tcb->tcb_dtv) * (2 + _rtld_tls_max_index));
|
||||
++tcb->tcb_dtv;
|
||||
SET_DTV_MAX_INDEX(tcb->tcb_dtv, _rtld_tls_max_index);
|
||||
SET_DTV_GENERATION(tcb->tcb_dtv, _rtld_tls_dtv_generation);
|
||||
|
||||
for (obj = _rtld_objlist; obj != NULL; obj = obj->next) {
|
||||
if (obj->tlssize) {
|
||||
if (obj->tlsinitsize && obj->tls_done) {
|
||||
#ifdef __HAVE_TLS_VARIANT_I
|
||||
q = p + obj->tlsoffset;
|
||||
#else
|
||||
q = p - obj->tlsoffset;
|
||||
#endif
|
||||
dbg(("obj %p dtv %p tlsoffset %zu",
|
||||
obj, q, obj->tlsoffset));
|
||||
memcpy(q, obj->tlsinit, obj->tlsinitsize);
|
||||
tcb->tcb_dtv[obj->tlsindex] = q;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $ */
|
||||
/* $NetBSD: xmalloc.c,v 1.12 2013/01/24 17:57:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1996 John D. Polstra.
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: xmalloc.c,v 1.11 2011/05/25 14:41:46 christos Exp $");
|
||||
__RCSID("$NetBSD: xmalloc.c,v 1.12 2013/01/24 17:57:29 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -369,12 +369,13 @@ irealloc(void *cp, size_t nbytes)
|
||||
*(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
|
||||
#endif
|
||||
return(cp);
|
||||
} else
|
||||
xfree(cp);
|
||||
}
|
||||
if ((res = imalloc(nbytes)) == NULL)
|
||||
return (NULL);
|
||||
if (cp != res) /* common optimization if "compacting" */
|
||||
if (cp != res) { /* common optimization if "compacting" */
|
||||
memcpy(res, cp, (nbytes < onb) ? nbytes : onb);
|
||||
xfree(cp);
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: makewhatis.8,v 1.12 2008/04/30 13:10:52 martin Exp $
|
||||
.\" $NetBSD: makewhatis.8,v 1.13 2013/07/20 21:39:57 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@@ -107,9 +107,9 @@ is called without arguments
|
||||
first appeared in
|
||||
.Nx 1.0 ,
|
||||
as a shell script written by
|
||||
.An J.T. Conklin Aq jtc@NetBSD.org
|
||||
.An J.T. Conklin Aq Mt jtc@NetBSD.org
|
||||
and
|
||||
.An Thorsten Frueauf Aq frueauf@ira.uka.de .
|
||||
.An Thorsten Frueauf Aq Mt frueauf@ira.uka.de .
|
||||
Further work was done by
|
||||
.An Matthew Green ,
|
||||
.An Luke Mewburn ,
|
||||
@@ -122,4 +122,4 @@ has reimplemented
|
||||
in C in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
.An Matthias Scheler Aq tron@NetBSD.org
|
||||
.An Matthias Scheler Aq Mt tron@NetBSD.org
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: makewhatis.c,v 1.48 2013/06/24 12:56:22 christos Exp $ */
|
||||
/* $NetBSD: makewhatis.c,v 1.49 2013/06/24 20:57:47 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@@ -37,7 +37,7 @@
|
||||
#if !defined(lint)
|
||||
__COPYRIGHT("@(#) Copyright (c) 1999\
|
||||
The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: makewhatis.c,v 1.48 2013/06/24 12:56:22 christos Exp $");
|
||||
__RCSID("$NetBSD: makewhatis.c,v 1.49 2013/06/24 20:57:47 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -107,9 +107,9 @@ static void dumpwhatis(FILE *, whatis *);
|
||||
static int makewhatis(char * const *manpath);
|
||||
|
||||
static char * const default_manpath[] = {
|
||||
#ifdef __minix
|
||||
#if defined(__minix)
|
||||
"/usr/man",
|
||||
#endif
|
||||
#endif /* defined(__minix) */
|
||||
"/usr/share/man",
|
||||
NULL
|
||||
};
|
||||
@@ -886,10 +886,7 @@ parsemanpage(const char *name, gzFile *in, int defaultsection)
|
||||
|
||||
/*
|
||||
* Skip over lines in man pages that have been generated
|
||||
* by Pod, until we find the TITLE. This makewhatis cannot
|
||||
* deal with it (and as * a result the man page would not
|
||||
* appear in whatis.db)
|
||||
* Modified by Robert Kovacic, June 23 2013.
|
||||
* by Pod, until we find the TITLE.
|
||||
*/
|
||||
if (strncasecmp(buffer, POD, sizeof(POD) - 1) == 0) {
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user