Merge ^/head r339813 through r340125.

This commit is contained in:
dim 2018-11-04 15:49:06 +00:00
commit 4b4bc3c457
477 changed files with 318258 additions and 304726 deletions

View File

@ -183,7 +183,7 @@ CROSS_BINUTILS_PREFIX?=${CROSS_TOOLCHAIN_PREFIX}
# support the target architecture), provide a default cross-binutils prefix.
# This allows riscv64 builds, for example, to automatically use the
# riscv64-binutils port or package.
.if !make(showconfig)
.if !make(showconfig) && !defined(_NO_INCLUDE_COMPILERMK)
.if !empty(BROKEN_OPTIONS:MBINUTILS_BOOTSTRAP) && \
${MK_LLD_BOOTSTRAP} == "no" && \
!defined(CROSS_BINUTILS_PREFIX)
@ -950,7 +950,7 @@ _worldtmp: .PHONY
.else
${_+_}@if [ -e "${WORLDTMP}" ]; then \
echo ">>> Deleting stale files in build tree..."; \
cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES _NO_INCLUDE_COMPILERMK=t \
delete-old delete-old-libs >/dev/null; \
fi
rm -rf ${WORLDTMP}/legacy/usr/include
@ -1003,19 +1003,21 @@ _cleanobj:
@echo "--------------------------------------------------------------"
@echo ">>> stage 2.1: cleaning up the object tree"
@echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} ${CLEANDIR}
# Avoid including bsd.compiler.mk in clean and obj with _NO_INCLUDE_COMPILERMK
# since the restricted $PATH might not contain a valid cc binary
${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t ${CLEANDIR}
.if defined(LIBCOMPAT)
${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} -f Makefile.inc1 ${CLEANDIR}
${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f Makefile.inc1 ${CLEANDIR}
.endif
.else
${_+_}cd ${.CURDIR}; ${WMAKE} _cleanobj_fast_depend_hack
${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t _cleanobj_fast_depend_hack
.endif # !defined(NO_CLEAN)
_obj:
@echo
@echo "--------------------------------------------------------------"
@echo ">>> stage 2.2: rebuilding the object tree"
@echo "--------------------------------------------------------------"
${_+_}cd ${.CURDIR}; ${WMAKE} obj
${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t obj
_build-tools:
@echo
@echo "--------------------------------------------------------------"

View File

@ -200,7 +200,8 @@ build${libcompat}: .PHONY
OBJTOP=${LIBCOMPAT_OBJTOP} \
OBJROOT='$${OBJTOP}/' \
MAKEOBJDIRPREFIX= \
DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \
MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \
${_t}
.endfor
.endfor

View File

@ -174,6 +174,8 @@ OLD_FILES+=usr/lib/clang/6.0.1/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
OLD_DIRS+=usr/lib/clang/6.0.1/lib/freebsd
OLD_DIRS+=usr/lib/clang/6.0.1/lib
OLD_DIRS+=usr/lib/clang/6.0.1
# 20181030: malloc_domain(9) KPI change
OLD_FILES+=share/man/man9/malloc_domain.9.gz
# 20181026: joy(4) removal
OLD_FILES+=usr/share/man/man4/joy.4.gz
# 20181025: OpenSSL libraries version bump to avoid conflict with ports

View File

@ -88,7 +88,7 @@ getgname(gid_t gid)
* contained in struct stat
*/
static acl_t
acl_from_stat(struct stat sb)
acl_from_stat(const struct stat *sb)
{
acl_t acl;
acl_entry_t entry;
@ -111,13 +111,13 @@ acl_from_stat(struct stat sb)
return NULL;
/* calculate user mode */
if (sb.st_mode & S_IRUSR)
if (sb->st_mode & S_IRUSR)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
if (sb.st_mode & S_IWUSR)
if (sb->st_mode & S_IWUSR)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
if (sb.st_mode & S_IXUSR)
if (sb->st_mode & S_IXUSR)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@ -135,13 +135,13 @@ acl_from_stat(struct stat sb)
return NULL;
/* calculate group mode */
if (sb.st_mode & S_IRGRP)
if (sb->st_mode & S_IRGRP)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
if (sb.st_mode & S_IWGRP)
if (sb->st_mode & S_IWGRP)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
if (sb.st_mode & S_IXGRP)
if (sb->st_mode & S_IXGRP)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@ -159,13 +159,13 @@ acl_from_stat(struct stat sb)
return NULL;
/* calculate other mode */
if (sb.st_mode & S_IROTH)
if (sb->st_mode & S_IROTH)
if (acl_add_perm(perms, ACL_READ) == -1)
return NULL;
if (sb.st_mode & S_IWOTH)
if (sb->st_mode & S_IWOTH)
if (acl_add_perm(perms, ACL_WRITE) == -1)
return NULL;
if (sb.st_mode & S_IXOTH)
if (sb->st_mode & S_IXOTH)
if (acl_add_perm(perms, ACL_EXECUTE) == -1)
return NULL;
if (acl_set_permset(entry, perms) == -1)
@ -229,7 +229,7 @@ print_acl(char *path, acl_type_t type, int hflag, int iflag, int nflag,
errno = 0;
if (type == ACL_TYPE_DEFAULT)
return(0);
acl = acl_from_stat(sb);
acl = acl_from_stat(&sb);
if (!acl) {
warn("%s: acl_from_stat() failed", path);
return(-1);

View File

@ -29,7 +29,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
.Dd March 13, 2018
.Dd October 31, 2018
.Dt PS 1
.Os
.Sh NAME
@ -346,7 +346,7 @@ the include file
.It Dv "P_HWPMC" Ta No "0x800000" Ta "Process is using HWPMCs"
.It Dv "P_JAILED" Ta No "0x1000000" Ta "Process is in jail"
.It Dv "P_TOTAL_STOP" Ta No "0x2000000" Ta "Stopped for system suspend"
.It Dv "P_INEXEC" Ta No "0x4000000" Ta "Process is in execve()"
.It Dv "P_INEXEC" Ta No "0x4000000" Ta Process is in Xr execve 2
.It Dv "P_STATCHILD" Ta No "0x8000000" Ta "Child process stopped or exited"
.It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory"
.It Dv "P_SWAPPINGOUT" Ta No "0x20000000" Ta "Process is being swapped out"
@ -361,8 +361,8 @@ the include file
.In sys/proc.h :
.Bl -column P2_INHERIT_PROTECTED 0x00000001
.It Dv "P2_INHERIT_PROTECTED" Ta No "0x00000001" Ta "New children get P_PROTECTED"
.It Dv "P2_NOTRACE" Ta No "0x00000002" Ta "No ptrace(2) attach or coredumps"
.It Dv "P2_NOTRACE_EXEC" Ta No "0x00000004" Ta "Keep P2_NOPTRACE on exec(2)"
.It Dv "P2_NOTRACE" Ta No "0x00000002" Ta "No" Xr ptrace 2 attach or coredumps
.It Dv "P2_NOTRACE_EXEC" Ta No "0x00000004" Ta Keep P2_NOPTRACE on Xr execve 2
.It Dv "P2_AST_SU" Ta No "0x00000008" Ta "Handles SU ast for kthreads"
.It Dv "P2_PTRACE_FSTP" Ta No "0x00000010" Ta "SIGSTOP from PT_ATTACH not yet handled"
.El
@ -453,8 +453,7 @@ Marks a process which is in
The hostname of the prison can be found in
.Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status .
.It Li L
The process has pages locked in core (for example, for raw
.Tn I/O ) .
The process has pages locked in core (for example, for raw I/O).
.It Li N
The process has reduced CPU scheduling priority (see
.Xr setpriority 2 ) .
@ -553,9 +552,11 @@ data size (in Kbytes)
system-call emulation environment (ABI)
.It Cm etime
elapsed running time, format
.Do
.Op days- Ns
.Op hours: Ns
minutes:seconds.
.Op hours\&: Ns
minutes:seconds
.Dc
.It Cm etimes
elapsed running time, in decimal integer seconds
.It Cm fib
@ -750,6 +751,8 @@ attempts to automatically determine the terminal width.
.It Pa /boot/kernel/kernel
default system namelist
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Display information on all system processes:
.Pp

View File

@ -468,7 +468,8 @@ evalredir(union node *n, int flags)
popredir();
if (e == EXERROR || e == EXEXEC) {
if (in_redirect) {
exitstatus = 2;
if (e == EXERROR)
exitstatus = 2;
FORCEINTON;
return;
}
@ -669,8 +670,10 @@ evalbackcmd(union node *n, struct backcmd *result)
forcelocal++;
savehandler = handler;
if (setjmp(jmploc.loc)) {
if (exception == EXERROR || exception == EXEXEC)
if (exception == EXERROR)
exitstatus = 2;
else if (exception == EXEXEC)
/* nothing */;
else if (exception != 0) {
handler = savehandler;
forcelocal--;
@ -1089,7 +1092,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
e = exception;
if (e == EXINT)
exitstatus = SIGINT+128;
else if (e != EXEXIT)
else if (e != EXEXEC && e != EXEXIT)
exitstatus = 2;
goto cmddone;
}

View File

@ -91,7 +91,6 @@ struct tblentry {
static struct tblentry *cmdtable[CMDTABLESIZE];
static int cmdtable_cd = 0; /* cmdtable contains cd-dependent entries */
int exerrno = 0; /* Last exec error */
static void tryexec(char *, char **, char **);
@ -135,10 +134,10 @@ shellexec(char **argv, char **envp, const char *path, int idx)
/* Map to POSIX errors */
if (e == ENOENT || e == ENOTDIR) {
exerrno = 127;
exitstatus = 127;
exerror(EXEXEC, "%s: not found", argv[0]);
} else {
exerrno = 126;
exitstatus = 126;
exerror(EXEXEC, "%s: %s", argv[0], strerror(e));
}
}

View File

@ -61,8 +61,6 @@ struct cmdentry {
#define DO_ERR 0x01 /* prints errors */
#define DO_NOFUNC 0x02 /* don't return shell functions, for command */
extern int exerrno; /* last exec error */
void shellexec(char **, char **, const char *, int) __dead2;
char *padvance(const char **, const char **, const char *);
void find_command(const char *, struct cmdentry *, int, const char *);

View File

@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include "mystring.h"
#include "var.h"
#include "builtins.h"
#include "eval.h"
/*
@ -1005,7 +1006,7 @@ vforkexecshell(struct job *jp, char **argv, char **envp, const char *path, int i
if (pid == 0) {
TRACE(("Child shell %d\n", (int)getpid()));
if (setjmp(jmploc.loc))
_exit(exception == EXEXEC ? exerrno : 2);
_exit(exception == EXEXEC ? exitstatus : 2);
if (pip != NULL) {
close(pip[0]);
if (pip[1] != 1) {

View File

@ -106,10 +106,6 @@ main(int argc, char *argv[])
state = 0;
if (setjmp(main_handler.loc)) {
switch (exception) {
case EXEXEC:
exitstatus = exerrno;
break;
case EXERROR:
exitstatus = 2;
break;

View File

@ -20,7 +20,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 16, 2018
.Dd October 30, 2018
.Dt DTRACE 1
.Os
.Sh NAME
@ -778,7 +778,6 @@ Invalid command line options or arguments were specified.
.El
.Sh SEE ALSO
.Xr cpp 1 ,
.Xr dtruss 1 ,
.Xr elf 5 ,
.Xr SDT 9
.Rs

View File

@ -402,6 +402,8 @@ elftc_reloc_type_str(unsigned int mach, unsigned int type)
case 22: return "R_MIPS_GOT_HI16";
case 23: return "R_MIPS_GOT_LO16";
case 24: return "R_MIPS_SUB";
case 28: return "R_MIPS_HIGHER";
case 29: return "R_MIPS_HIGHEST";
case 30: return "R_MIPS_CALLHI16";
case 31: return "R_MIPS_CALLLO16";
case 37: return "R_MIPS_JALR";

View File

@ -1121,6 +1121,7 @@ note_type_freebsd(unsigned int nt)
case 1: return "NT_FREEBSD_ABI_TAG";
case 2: return "NT_FREEBSD_NOINIT_TAG";
case 3: return "NT_FREEBSD_ARCH_TAG";
case 4: return "NT_FREEBSD_FEATURE_CTL";
default: return (note_type_unknown(nt));
}
}

View File

@ -64,6 +64,9 @@ ATF_TC_HEAD(mktime_negyear, tc)
ATF_TC_BODY(mktime_negyear, tc)
{
#ifdef __FreeBSD__
atf_tc_expect_fail("needs work");
#endif
struct tm tms;
time_t t;

View File

@ -103,6 +103,7 @@ static struct {
const char *name;
long offs;
} zt[] = {
#ifndef __FreeBSD__
{ "Z", 0 },
{ "UT", 0 },
{ "UTC", 0 },
@ -173,6 +174,7 @@ static struct {
{ "EST4EDT", -14400 },
{ "Bogus", -1 },
#endif
};
static void
@ -188,9 +190,11 @@ ztest1(const char *name, const char *fmt, long value)
value = 0;
switch (value) {
#ifndef __FreeBSD__
case -2:
value = -timezone;
break;
#endif
case -1:
if (fmt[1] == 'Z')
value = 0;
@ -210,9 +214,11 @@ static void
ztest(const char *fmt)
{
setenv("TZ", "US/Eastern", 1);
#ifndef __FreeBSD__
ztest1("GMT", fmt, 0);
ztest1("UTC", fmt, 0);
ztest1("US/Eastern", fmt, -18000);
#endif
for (size_t i = 0; i < __arraycount(zt); i++)
ztest1(zt[i].name, fmt, zt[i].offs);
}
@ -228,10 +234,6 @@ ATF_TC_HEAD(common, tc)
ATF_TC_BODY(common, tc)
{
#ifdef __FreeBSD__
atf_tc_expect_fail("There are various issues with strptime on FreeBSD");
#endif
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
24, 46, 27, 23, 20, 0, 98, 2, 19);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
@ -305,6 +307,10 @@ ATF_TC_BODY(day, tc)
#else
h_pass("SaturDay", "%OA", 8, -1, -1, -1, -1, -1, -1, 6, -1);
#endif
#ifdef __FreeBSD__
h_fail("00", "%d");
#endif
}
ATF_TC(hour);
@ -313,7 +319,11 @@ ATF_TC_HEAD(hour, tc)
{
atf_tc_set_md_var(tc, "descr",
#ifdef __FreeBSD__
"Checks strptime(3) hour conversions [HIkl]");
#else
"Checks strptime(3) hour conversions [IH]");
#endif
}
ATF_TC_BODY(hour, tc)
@ -322,6 +332,21 @@ ATF_TC_BODY(hour, tc)
h_fail("00", "%I");
h_fail("13", "%I");
#ifdef __FreeBSD__
h_pass("0", "%k", 1, -1, -1, 0, -1, -1, -1, -1, -1);
h_pass("04", "%k", 2, -1, -1, 4, -1, -1, -1, -1, -1);
h_pass(" 8", "%k", 2, -1, -1, 8, -1, -1, -1, -1, -1);
h_pass("23", "%k", 2, -1, -1, 23, -1, -1, -1, -1, -1);
h_fail("24", "%k");
h_fail("0", "%l");
h_pass("1", "%l", 1, -1, -1, 1, -1, -1, -1, -1, -1);
h_pass("05", "%l", 2, -1, -1, 5, -1, -1, -1, -1, -1);
h_pass(" 9", "%l", 2, -1, -1, 9, -1, -1, -1, -1, -1);
h_pass("12", "%l", 2, -1, -1, 12, -1, -1, -1, -1, -1);
h_fail("13", "%l");
#endif
h_pass("00", "%H", 2, -1, -1, 0, -1, -1, -1, -1, -1);
h_pass("12", "%H", 2, -1, -1, 12, -1, -1, -1, -1, -1);
h_pass("23", "%H", 2, -1, -1, 23, -1, -1, -1, -1, -1);
@ -413,7 +438,18 @@ ATF_TC_BODY(seconds, tc)
h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
#ifdef __FreeBSD__
/*
* (Much) older versions of the standard (up to the Issue 6) allowed for
* [0;61] range in %S conversion for double-leap seconds, and it's
* apparently what NetBSD and glibc are expecting, however current
* version defines allowed values to be [0;60], and that is what our
* strptime() implementation expects.
*/
h_fail("61", "%S");
#else
h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
#endif
h_fail("62", "%S");
}
@ -434,7 +470,9 @@ ATF_TC_BODY(year, tc)
h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
#ifndef __FreeBSD__
h_fail("%", "%E%");
#endif
h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
@ -467,7 +505,7 @@ ATF_TC_HEAD(Zone, tc)
ATF_TC_BODY(Zone, tc)
{
ztest("%z");
ztest("%Z");
}
ATF_TP_ADD_TCS(tp)

View File

@ -1177,10 +1177,14 @@ int main(int argc, char *argv[])
cb->server = -1;
cb->state = IDLE;
cb->size = 64;
cb->sin.ss_family = PF_INET;
cb->port = htobe16(7174);
sem_init(&cb->sem, 0, 0);
/* initialize sockaddr structure with defaults */
ret = get_addr("0.0.0.0", (struct sockaddr *) &cb->sin);
if (ret)
goto out;
opterr = 0;
while ((op=getopt(argc, argv, "a:I:Pp:C:S:t:scvVd")) != -1) {
switch (op) {

View File

@ -352,9 +352,13 @@ Patterns are arbitrary Boolean combinations
of regular expressions and
relational expressions.
Regular expressions are as in
.IR egrep ;
see
.IR grep (1).
.IR egrep (1)
except numeric quantifiers are not supported beyond the basic
.B +
and
.B ?
for quantities \&\f(CW"0 or 1"\fP and \&\f(CW"1 or more"\fP
respectively.
Isolated regular expressions
in a pattern apply to the entire line.
Regular expressions may also occur in

View File

@ -1,6 +1,6 @@
.\" $Id: mount_smbfs.8,v 1.10 2002/04/16 02:47:41 bp Exp $
.\" $FreeBSD$
.Dd September 17, 2011
.Dd November 1, 2018
.Dt MOUNT_SMBFS 8
.Os
.Sh NAME
@ -8,12 +8,12 @@
.Nd "mount a shared resource from an SMB file server"
.Sh SYNOPSIS
.Nm
.Op Fl E Ar cs1 : Ns Ar cs2
.Op Fl E Ar cs1 Ns Cm \&: Ns Ar cs2
.Op Fl I Ar host
.Op Fl L Ar locale
.Op Fl M Ar crights : Ns Ar srights
.Op Fl M Ar crights Ns Cm \&: Ns Ar srights
.Op Fl N
.Op Fl O Ar cowner : Ns Ar cgroup Ns / Ns Ar sowner : Ns Ar sgroup
.Op Fl O Ar cowner Ns Cm \&: Ns Ar cgroup Ns Cm \&/ Ns Ar sowner Ns Cm \&: Ns Ar sgroup
.Op Fl R Ar retrycount
.Op Fl T Ar timeout
.Op Fl U Ar username
@ -25,9 +25,9 @@
.Op Fl n Ar opt
.Op Fl u Ar uid
.Sm off
.No // Ar user No @ Ar server
.Op Ar :port1 Op Ar :port2
.No / Ar share
.Cm \&// Ns Ar user Cm \&@ Ar server
.Op Cm \&: Ar port1 Op Cm \&: Ar port2
.Cm \&/ Ar share
.Sm on
.Ar node
.Sh DESCRIPTION
@ -37,7 +37,7 @@ command mounts a share from a remote server using SMB/CIFS protocol.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl E Ar cs1 : Ns Ar cs2
.It Fl E Ar cs1 Ns Cm \&: Ns Ar cs2
Specifies local
.Pq Ar cs1
and server's
@ -57,7 +57,7 @@ By default,
tries to use an environment variable
.Ev LC_*
to determine it.
.It Fl M Ar crights : Ns Ar srights
.It Fl M Ar crights Ns Cm \&: Ns Ar srights
Assign access rights to the newly created connection.
.It Fl N
Do not ask for a password.
@ -69,7 +69,7 @@ file for additional configuration parameters and a password.
If no password is found,
.Nm
prompts for it.
.It Fl O Ar cowner : Ns Ar cgroup Ns / Ns Ar sowner : Ns Ar sgroup
.It Fl O Ar cowner Ns Cm \&: Ns Ar cgroup Ns Cm \&/ Ns Ar sowner Ns Cm \&: Ns Ar sgroup
Assign owner/group attributes to the newly created connection.
.It Fl R Ar retrycount
How many retries should be done before the SMB requester decides to drop
@ -111,7 +111,7 @@ server.
User ID and group ID assigned to files.
The default are owner and group IDs from
the directory where the volume is mounted.
.It No // Ns Ar user Ns @ Ns Ar server Ns Oo Ar :port1 Ns Oo Ar :port2 Oc Oc Ns No / Ns Ar share
.It Cm \&// Ns Ar user Ns Cm \&@ Ns Ar server Ns Oo Cm \&: Ns Ar port1 Ns Oo Cm \&: Ns Ar port2 Oc Oc Ns Cm \&/ Ns Ar share
The
.Nm
command will use
@ -136,22 +136,24 @@ are 137.
Path to mount point.
.El
.Sh FILES
.Bl -tag -width ".Pa ~/.nsmbrc" -compact
.Bl -tag -width ".Pa /etc/nsmb.conf" -compact
.It Pa ~/.nsmbrc
Keeps static parameters for connections and other information.
Keeps user-specific static parameters for connections and other information.
See
.Pa /usr/share/examples/smbfs/dot.nsmbrc
for details.
.It Pa /etc/nsmb.conf
Keeps system-wide static parameters for connections and other information.
.El
.Sh EXAMPLES
The following example illustrates how to connect to SMB server
.Em SAMBA
.Dq SAMBA
as user
.Em GUEST ,
.Dq GUEST ,
and mount shares
.Em PUBLIC
.Dq PUBLIC
and
.Em TMP :
.Dq TMP :
.Bd -literal -offset indent
mount_smbfs -I samba.mydomain.com //guest@samba/public /smb/public
mount_smbfs -I 192.168.20.3 -E koi8-r:cp866 //guest@samba/tmp /smb/tmp
@ -159,9 +161,43 @@ mount_smbfs -I 192.168.20.3 -E koi8-r:cp866 //guest@samba/tmp /smb/tmp
.Pp
It is also possible to use
.Xr fstab 5
for smbfs mounts (the example below doesn't prompt for a password):
for smbfs mounts (the example below does not prompt for a password):
.Pp
.Dl "//guest@samba/public /smb/public smbfs rw,noauto,-N 0 0"
.Sh SEE ALSO
.Xr smbutil 1 ,
.Xr nsmb.conf 5
.Pp
Other resources:
.Bl -dash -compact
.It
Chapter dedicated to Samba configuration in the
.Fx
Handbook:
.Lk "https://www.freebsd.org/doc/handbook/network-samba.html"
.El
.Sh STANDARDS
.Nm
offers support for SMB/CIFS/SMB1.
It does not support newer versions of the protocol like SMB2 and SMB3.
SMB2 and SMB3 are supported by software available in the
.Xr ports 7
collection.
.Pp
The list of supported SMB servers includes:
.Bl -dash -compact
.It
Samba
.It
Windows 95/98/ME/2000/NT4.0 (SPs 4, 5, 6)
.It
IBM LanManager
.It
NetApp
.El
.Sh HISTORY
SMB/CIFS protocol and SMB/CIFS file system implementation first appeared in
.Fx 4.5 .
.Sh AUTHORS
.An Boris Popov Aq bp@butya.kz ,
.Aq bp@FreeBSD.org

View File

@ -1,5 +1,5 @@
.\" $Id: smbutil.1,v 1.5 2002/04/16 02:48:16 bp Exp $
.Dd February 14, 2000
.Dd November 1, 2018
.Dt SMBUTIL 1
.Os
.Sh NAME
@ -127,6 +127,9 @@ See
.Pa ./examples/dot.nsmbrc
for details.
.El
.Sh SEE ALSO
.Xr nsmb.conf 5 ,
.Xr mount_smbfs 8
.Sh AUTHORS
.An Boris Popov Aq bp@butya.kz ,
.Aq bp@FreeBSD.org

View File

@ -390,7 +390,6 @@ register const int doextend;
res = -1;
sp->goback = sp->goahead = FALSE;
/* XXX The following is from OpenBSD, and I'm not sure it is correct */
if (name != NULL && issetugid() != 0)
if ((name[0] == ':' && name[1] == '/') ||
name[0] == '/' || strchr(name, '.'))
@ -398,7 +397,6 @@ register const int doextend;
if (name == NULL && (name = TZDEFAULT) == NULL)
return -1;
{
int doaccess;
struct stat stab;
/*
** Section 4.9.1 of the C standard says that
@ -415,8 +413,7 @@ register const int doextend;
if (name[0] == ':')
++name;
doaccess = name[0] == '/';
if (!doaccess) {
if (name[0] != '/') {
if ((p = TZDIR) == NULL) {
free(fullname);
return -1;
@ -428,17 +425,8 @@ register const int doextend;
(void) strcpy(fullname, p);
(void) strcat(fullname, "/");
(void) strcat(fullname, name);
/*
** Set doaccess if '.' (as in "../") shows up in name.
*/
if (strchr(name, '.') != NULL)
doaccess = TRUE;
name = fullname;
}
if (doaccess && access(name, R_OK) != 0) {
free(fullname);
return -1;
}
if ((fid = _open(name, OPEN_MODE)) == -1) {
free(fullname);
return -1;

View File

@ -1,5 +1,40 @@
News for the tz database
Release 2018g - 2018-10-26 22:22:45 -0700
Briefly:
Morocco switches to permanent +01 on 2018-10-27.
Changes to future timestamps
Morocco switches from +00/+01 to permanent +01 effective 2018-10-27,
so its clocks will not fall back on 2018-10-28 as previously scheduled.
(Thanks to Mohamed Essedik Najd and Brian Inglis.)
Changes to code
When generating TZif files with leap seconds, zic no longer uses a
format that trips up older 32-bit clients, fixing a bug introduced
in 2018f. (Reported by Daniel Fischer.) Also, the zic workaround
for QTBUG-53071 now also works for TZif files with leap seconds.
The translator to rearguard format now rewrites the line
"Rule Japan 1948 1951 - Sep Sat>=8 25:00 0 S" to
"Rule Japan 1948 1951 - Sep Sun>=9 1:00 0 S".
This caters to zic before 2007 and to Oracle TZUpdater 2.2.0
and earlier. (Reported by Christos Zoulas.)
Changes to past time zone abbreviations
Change HDT to HWT/HPT for WWII-era abbreviations in Hawaii.
This reverts to 2011h, as the abbreviation change in 2011i was
likely inadvertent.
Changes to documentation
tzfile.5 has new sections on interoperability issues.
Release 2018f - 2018-10-18 00:14:18 -0700
Briefly:

View File

@ -844,94 +844,61 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis
# <https://lnt.ma/le-maroc-reculera-dune-heure-le-dimanche-14-juin/> agrees
# with the patch.
# From Paul Eggert (2015-06-08):
# For now, guess that later spring and fall transitions will use 2015's rules,
# and guess that Morocco will switch to standard time at 03:00 the last
# Sunday before Ramadan, and back to DST at 02:00 the first Sunday after
# Ramadan. To implement this, transition dates for 2016 through 2037 were
# determined by running the following program under GNU Emacs 24.3, with the
# results integrated by hand into the table below.
# (let ((islamic-year 1437))
# (require 'cal-islam)
# (while (< islamic-year 1460)
# (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
# (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
# (sunday 0))
# (while (/= sunday (mod (setq a (1- a)) 7)))
# (while (/= sunday (mod b 7))
# (setq b (1+ b)))
# (setq a (calendar-gregorian-from-absolute a))
# (setq b (calendar-gregorian-from-absolute b))
# (insert
# (format
# (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 3:00\t0\t-\n"
# "Rule\tMorocco\t%d\tonly\t-\t%s\t%2d\t 2:00\t1:00\tS\n")
# (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
# (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
# (setq islamic-year (+ 1 islamic-year))))
# From Mohamed Essedik Najd (2018-10-26):
# Today, a Moroccan government council approved the perpetual addition
# of 60 minutes to the regular Moroccan timezone.
# From Brian Inglis (2018-10-26):
# http://www.maroc.ma/fr/actualites/le-conseil-de-gouvernement-adopte-un-projet-de-decret-relatif-lheure-legale-stipulant-le
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Morocco 1939 only - Sep 12 0:00 1:00 S
Rule Morocco 1939 only - Sep 12 0:00 1:00 -
Rule Morocco 1939 only - Nov 19 0:00 0 -
Rule Morocco 1940 only - Feb 25 0:00 1:00 S
Rule Morocco 1940 only - Feb 25 0:00 1:00 -
Rule Morocco 1945 only - Nov 18 0:00 0 -
Rule Morocco 1950 only - Jun 11 0:00 1:00 S
Rule Morocco 1950 only - Jun 11 0:00 1:00 -
Rule Morocco 1950 only - Oct 29 0:00 0 -
Rule Morocco 1967 only - Jun 3 12:00 1:00 S
Rule Morocco 1967 only - Jun 3 12:00 1:00 -
Rule Morocco 1967 only - Oct 1 0:00 0 -
Rule Morocco 1974 only - Jun 24 0:00 1:00 S
Rule Morocco 1974 only - Jun 24 0:00 1:00 -
Rule Morocco 1974 only - Sep 1 0:00 0 -
Rule Morocco 1976 1977 - May 1 0:00 1:00 S
Rule Morocco 1976 1977 - May 1 0:00 1:00 -
Rule Morocco 1976 only - Aug 1 0:00 0 -
Rule Morocco 1977 only - Sep 28 0:00 0 -
Rule Morocco 1978 only - Jun 1 0:00 1:00 S
Rule Morocco 1978 only - Jun 1 0:00 1:00 -
Rule Morocco 1978 only - Aug 4 0:00 0 -
Rule Morocco 2008 only - Jun 1 0:00 1:00 S
Rule Morocco 2008 only - Jun 1 0:00 1:00 -
Rule Morocco 2008 only - Sep 1 0:00 0 -
Rule Morocco 2009 only - Jun 1 0:00 1:00 S
Rule Morocco 2009 only - Jun 1 0:00 1:00 -
Rule Morocco 2009 only - Aug 21 0:00 0 -
Rule Morocco 2010 only - May 2 0:00 1:00 S
Rule Morocco 2010 only - May 2 0:00 1:00 -
Rule Morocco 2010 only - Aug 8 0:00 0 -
Rule Morocco 2011 only - Apr 3 0:00 1:00 S
Rule Morocco 2011 only - Apr 3 0:00 1:00 -
Rule Morocco 2011 only - Jul 31 0:00 0 -
Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 S
Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 -
Rule Morocco 2012 only - Jul 20 3:00 0 -
Rule Morocco 2012 only - Aug 20 2:00 1:00 S
Rule Morocco 2012 only - Aug 20 2:00 1:00 -
Rule Morocco 2012 only - Sep 30 3:00 0 -
Rule Morocco 2013 only - Jul 7 3:00 0 -
Rule Morocco 2013 only - Aug 10 2:00 1:00 S
Rule Morocco 2013 max - Oct lastSun 3:00 0 -
Rule Morocco 2014 2021 - Mar lastSun 2:00 1:00 S
Rule Morocco 2013 only - Aug 10 2:00 1:00 -
Rule Morocco 2013 2018 - Oct lastSun 3:00 0 -
Rule Morocco 2014 2018 - Mar lastSun 2:00 1:00 -
Rule Morocco 2014 only - Jun 28 3:00 0 -
Rule Morocco 2014 only - Aug 2 2:00 1:00 S
Rule Morocco 2014 only - Aug 2 2:00 1:00 -
Rule Morocco 2015 only - Jun 14 3:00 0 -
Rule Morocco 2015 only - Jul 19 2:00 1:00 S
Rule Morocco 2015 only - Jul 19 2:00 1:00 -
Rule Morocco 2016 only - Jun 5 3:00 0 -
Rule Morocco 2016 only - Jul 10 2:00 1:00 S
Rule Morocco 2016 only - Jul 10 2:00 1:00 -
Rule Morocco 2017 only - May 21 3:00 0 -
Rule Morocco 2017 only - Jul 2 2:00 1:00 S
Rule Morocco 2017 only - Jul 2 2:00 1:00 -
Rule Morocco 2018 only - May 13 3:00 0 -
Rule Morocco 2018 only - Jun 17 2:00 1:00 S
Rule Morocco 2019 only - May 5 3:00 0 -
Rule Morocco 2019 only - Jun 9 2:00 1:00 S
Rule Morocco 2020 only - Apr 19 3:00 0 -
Rule Morocco 2020 only - May 24 2:00 1:00 S
Rule Morocco 2021 only - Apr 11 3:00 0 -
Rule Morocco 2021 only - May 16 2:00 1:00 S
Rule Morocco 2022 only - May 8 2:00 1:00 S
Rule Morocco 2023 only - Apr 23 2:00 1:00 S
Rule Morocco 2024 only - Apr 14 2:00 1:00 S
Rule Morocco 2025 only - Apr 6 2:00 1:00 S
Rule Morocco 2026 max - Mar lastSun 2:00 1:00 S
Rule Morocco 2036 only - Oct 19 3:00 0 -
Rule Morocco 2037 only - Oct 4 3:00 0 -
Rule Morocco 2018 only - Jun 17 2:00 1:00 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
0:00 Morocco WE%sT 1984 Mar 16
1:00 - CET 1986
0:00 Morocco WE%sT
0:00 Morocco +00/+01 1984 Mar 16
1:00 - +01 1986
0:00 Morocco +00/+01 2018 Oct 27
1:00 - +01
# Western Sahara
#
@ -946,7 +913,8 @@ Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan # El Aaiún
-1:00 - -01 1976 Apr 14
0:00 Morocco WE%sT
0:00 Morocco +00/+01 2018 Oct 27
1:00 - +01
# Mozambique
#

View File

@ -3440,7 +3440,8 @@ Rule Spain 1978 only - Oct 1 2:00s 0 -
#Rule NatSpain 1937 only - May 22 23:00 1:00 S
#Rule NatSpain 1937 1938 - Oct Sat>=1 24:00s 0 -
#Rule NatSpain 1938 only - Mar 26 23:00 1:00 S
# The following rules are copied from Morocco from 1967 through 1978.
# The following rules are copied from Morocco from 1967 through 1978,
# except with "S" letters.
Rule SpainAfrica 1967 only - Jun 3 12:00 1:00 S
Rule SpainAfrica 1967 only - Oct 1 0:00 0 -
Rule SpainAfrica 1974 only - Jun 24 0:00 1:00 S

View File

@ -439,6 +439,19 @@ Zone America/North_Dakota/Beulah -6:47:07 - LMT 1883 Nov 18 12:12:53
# western South Dakota, far western Texas (El Paso County, Hudspeth County,
# and Pine Springs and Nickel Creek in Culberson County), Utah, Wyoming
#
# From Paul Eggert (2018-10-25):
# On 1921-03-04 federal law placed all of Texas into the central time zone.
# However, El Paso ignored the law for decades and continued to observe
# mountain time, on the grounds that that's what they had always done
# and they weren't about to let the federal government tell them what to do.
# Eventually the federal government gave in and changed the law on
# 1970-04-10 to match what El Paso was actually doing. Although
# that's slightly after our 1970 cutoff, there is no need to create a
# separate zone for El Paso since they were ignoring the law anyway. See:
# Long T. El Pasoans were time rebels, fought to stay in Mountain zone.
# El Paso Times. 2018-10-24 06:40 -06.
# https://www.elpasotimes.com/story/news/local/el-paso/2018/10/24/el-pasoans-were-time-rebels-fought-stay-mountain-zone/1744509002/
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER
Rule Denver 1920 1921 - Mar lastSun 2:00 1:00 D
Rule Denver 1920 only - Oct lastSun 2:00 0 S
@ -708,9 +721,7 @@ Zone America/Adak 12:13:22 - LMT 1867 Oct 19 12:44:35
Zone Pacific/Honolulu -10:31:26 - LMT 1896 Jan 13 12:00
-10:30 - HST 1933 Apr 30 2:00
-10:30 1:00 HDT 1933 May 21 12:00
-10:30 - HST 1942 Feb 9 2:00
-10:30 1:00 HDT 1945 Sep 30 2:00
-10:30 - HST 1947 Jun 8 2:00
-10:30 US H%sT 1947 Jun 8 2:00
-10:00 - HST
# Now we turn to US areas that have diverged from the consensus since 1970.

View File

@ -407,7 +407,7 @@ in decreasing order of importance:
EST/EDT/EWT/EPT/EDDT Eastern [North America],
EET/EEST Eastern European,
GST Guam,
HST/HDT Hawaii,
HST/HDT/HWT/HPT Hawaii,
HKT/HKST Hong Kong,
IST India,
IST/GMT Irish,

View File

@ -1 +1 @@
2018f
2018g

View File

@ -80,6 +80,13 @@ DATAFORM != "main" {
if (comment_out) {
sub(/^/, "#")
}
# In rearguard format, change the Japan rule line with "Sat>=8 25:00"
# to "Sun>=9 1:00", to cater to zic before 2007 and to older Java.
if (!vanguard && $1 == "Rule" && $7 == "Sat>=8" && $8 == "25:00") {
sub(/Sat>=8/, "Sun>=9")
sub(/25:00/, " 1:00")
}
}
# If a Link line is followed by a Zone line for the same data, comment

View File

@ -172,11 +172,6 @@ function process_input_line(line, field, end, i, n, startdef)
if (line ~ /^R /) return
line = substr(line, 1, RSTART) substr(line, RSTART + 5)
}
# Replace SpainAfrica rules with Morocco, as they are duplicates.
if (match(line, / SpainAfrica /)) {
if (line ~ /^R /) return
line = substr(line, 1, RSTART) "Morocco" substr(line, RSTART + RLENGTH - 1)
}
# Abbreviate times.
while (match(line, /[: ]0+[0-9]/))

View File

@ -664,6 +664,9 @@
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
/* if REUSEPORT is enabled by default */
#define REUSEPORT_DEFAULT 0
/* default rootkey location */
#define ROOT_ANCHOR_FILE "/var/unbound/root.key"

View File

@ -663,6 +663,9 @@
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* if REUSEPORT is enabled by default */
#undef REUSEPORT_DEFAULT
/* default rootkey location */
#undef ROOT_ANCHOR_FILE

View File

@ -15966,6 +15966,17 @@ fi
done
# check if we can use SO_REUSEPORT
if echo "$host" | grep -i -e linux -e dragonfly >/dev/null; then
$as_echo "#define REUSEPORT_DEFAULT 1" >>confdefs.h
else
$as_echo "#define REUSEPORT_DEFAULT 0" >>confdefs.h
fi
# set memory allocation checking if requested
# Check whether --enable-alloc-checks was given.
if test "${enable_alloc_checks+set}" = set; then :

View File

@ -461,6 +461,13 @@ ACX_CHECK_NONBLOCKING_BROKEN
ACX_MKDIR_ONE_ARG
AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
# check if we can use SO_REUSEPORT
if echo "$host" | grep -i -e linux -e dragonfly >/dev/null; then
AC_DEFINE(REUSEPORT_DEFAULT, 1, [if REUSEPORT is enabled by default])
else
AC_DEFINE(REUSEPORT_DEFAULT, 0, [if REUSEPORT is enabled by default])
fi
# set memory allocation checking if requested
AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
[ enable to memory allocation statistics, for debug purposes ]),

View File

@ -177,7 +177,7 @@ config_create(void)
cfg->if_automatic = 0;
cfg->so_rcvbuf = 0;
cfg->so_sndbuf = 0;
cfg->so_reuseport = 1;
cfg->so_reuseport = REUSEPORT_DEFAULT;
cfg->ip_transparent = 0;
cfg->ip_freebind = 0;
cfg->num_ifs = 0;

View File

@ -4,6 +4,8 @@
.include <src.opts.mk>
FILESGROUPS= FILES
NLS_ALIASES= POSIX C \
en_US.US_ASCII C
# No need as it is empty and just causes rebuilds since this file does so much.
UPDATE_DEPENDFILE= no
@ -157,42 +159,34 @@ distrib-cleanup: .PHONY
done
distrib-dirs: ${MTREES:N/*} distrib-cleanup .PHONY
@set ${MTREES}; \
while test $$# -ge 2; do \
m=${.CURDIR}/$$1; \
shift; \
d=${DESTDIR}$$1; \
shift; \
test -d $$d || mkdir -p $$d; \
${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
${MTREE_FILTER} $$m | \
${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
-p $$d; \
done; true
.for _m _d in ${MTREES}
@m=${.CURDIR}/${_m}; \
d=${DESTDIR}${_d}; \
test -d $$d || mkdir -p $$d; \
${ECHO} ${MTREE_CMD} -deU ${MTREE_FSCHG} \
${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \
${MTREE_FILTER} $$m | \
${MTREE_CMD} -deU ${MTREE_FSCHG} ${MTREE_FOLLOWS_SYMLINKS} \
-p $$d
.endfor
.if defined(NO_ROOT)
@set ${MTREES}; \
while test $$# -ge 2; do \
m=${.CURDIR}/$$1; \
shift; \
d=$$1; \
test "$$d" == "/" && d=""; \
d=${DISTBASE}$$d; \
shift; \
test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
"sed s#^\.#.$$d# | ${METALOG.add}" ; \
${MTREE_FILTER} $$m | \
${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
${METALOG.add} ; \
done; true
.for _m _d in ${MTREES}
@m=${.CURDIR}/${_m}; \
d=${_d}; \
test "$$d" == "/" && d=""; \
d=${DISTBASE}$$d; \
test -d ${DESTDIR}/$$d || mkdir -p ${DESTDIR}/$$d; \
${ECHO} "${MTREE_CMD:N-W} -C -f $$m -K all | " \
"sed s#^\.#.$$d# | ${METALOG.add}" ; \
${MTREE_FILTER} $$m | \
${MTREE_CMD:N-W} -C -K all | sed s#^\.#.$$d# | \
${METALOG.add}
.endfor
.endif
.if ${MK_NLS} != "no"
set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \
while [ $$# -gt 0 ] ; do \
${INSTALL_SYMLINK} "$$2" "${DESTDIR}${SHAREDIR}/nls/$$1"; \
shift; shift; \
done
.for alias nls in ${NLS_ALIASES}
${INSTALL_SYMLINK} "${nls}" "${DESTDIR}${SHAREDIR}/nls/${alias}"
.endfor
.endif
etc-examples: ${META_DEPS}

View File

@ -270,6 +270,14 @@
test-programs
..
..
csu
dynamic
..
dynamiclib
..
static
..
..
libarchive
..
libc

View File

@ -1,4 +0,0 @@
# $FreeBSD$
POSIX C
en_US.US-ASCII C

View File

@ -8,10 +8,7 @@ SUBDIR+= ${MACHINE_ARCH}
SUBDIR+= ${MACHINE_CPUARCH}
.endif
.if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" || \
${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc64"
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
.endif
.include <bsd.subdir.mk>

2
lib/csu/arm/crt.h Normal file
View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
/* Empty so we can include this unconditionally */

View File

@ -45,10 +45,10 @@ void *__dso_handle = 0;
#ifdef HAVE_CTORS
static void __do_global_dtors_aux(void) __used;
crt_func __CTOR_LIST__[] __section(".ctors") __hidden = {
static crt_func __CTOR_LIST__[] __section(".ctors") __used = {
(crt_func)-1
};
crt_func __DTOR_LIST__[] __section(".dtors") __hidden = {
static crt_func __DTOR_LIST__[] __section(".dtors") __used = {
(crt_func)-1
};
@ -81,7 +81,7 @@ asm (
extern void _Jv_RegisterClasses(void *) __weak_symbol;
static void register_classes(void) __used;
crt_func __JCR_LIST__[] __section(".jcr") __used __hidden = { };
static crt_func __JCR_LIST__[] __section(".jcr") __used = { };
#ifndef CTORS_CONSTRUCTORS
__attribute__((constructor))

View File

@ -35,10 +35,10 @@ typedef void (*crt_func)(void);
*/
static void __do_global_ctors_aux(void) __used;
crt_func __CTOR_END__[] __section(".ctors") __used __hidden = {
static crt_func __CTOR_END__[] __section(".ctors") __used = {
(crt_func)0
};
crt_func __DTOR_END__[] __section(".dtors") __used __hidden = {
static crt_func __DTOR_END__[] __section(".dtors") __used = {
(crt_func)0
};

31
lib/csu/mips/crt.h Normal file
View File

@ -0,0 +1,31 @@
/*-
* SPDX-License-Identifier: BSD-1-Clause
*
* Copyright 2018 Andrew Turner
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _CRT_H_
#define _CRT_H_
#define HAVE_CTORS
#endif

33
lib/csu/powerpc/crt.h Normal file
View File

@ -0,0 +1,33 @@
/*-
* SPDX-License-Identifier: BSD-1-Clause
*
* Copyright 2018 Andrew Turner
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _CRT_H_
#define _CRT_H_
#define HAVE_CTORS
#define CTORS_CONSTRUCTORS
#define INIT_CALL_SEQ(func) "bl " __STRING(func) "; nop"
#endif

2
lib/csu/riscv/crt.h Normal file
View File

@ -0,0 +1,2 @@
/* $FreeBSD$ */
/* Empty so we can include this unconditionally */

31
lib/csu/sparc64/crt.h Normal file
View File

@ -0,0 +1,31 @@
/*-
* SPDX-License-Identifier: BSD-1-Clause
*
* Copyright 2018 Andrew Turner
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _CRT_H_
#define _CRT_H_
#define HAVE_CTORS
#endif

View File

@ -1,6 +1,8 @@
# $FreeBSD$
SUBDIR= dso
TESTS_SUBDIRS= dynamic
TESTS_SUBDIRS+= dynamiclib
TESTS_SUBDIRS+= static
.include <bsd.test.mk>

View File

@ -4,7 +4,7 @@ ATF_TESTS_C+= init_test
ATF_TESTS_C+= fini_test
ATF_TESTS_CXX+= cxx_constructors
WARNS?= 5
WARNS?= 3
.if exists(${.CURDIR:H:H}/${MACHINE_ARCH})
CFLAGS+= -I${.CURDIR:H:H}/${MACHINE_ARCH}

View File

@ -39,10 +39,18 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <unistd.h>
#ifndef DSO_LIB
#include <atf-c++.hpp>
#endif
extern volatile int constructor_run;
extern bool run_destructor_test;
#ifndef DSO_BASE
volatile int constructor_run;
bool run_destructor_test = false;
#endif
static volatile int constructor_run;
static bool run_destructor_test = false;
struct Foo {
Foo() {
constructor_run = 1;
@ -53,8 +61,12 @@ struct Foo {
}
};
extern Foo foo;
Foo foo;
#ifndef DSO_BASE
Foo foo;
#endif
#ifndef DSO_LIB
ATF_TEST_CASE_WITHOUT_HEAD(cxx_constructor);
ATF_TEST_CASE_BODY(cxx_constructor)
{
@ -90,3 +102,4 @@ ATF_INIT_TEST_CASES(tcs)
ATF_ADD_TEST_CASE(tcs, cxx_constructor);
ATF_ADD_TEST_CASE(tcs, cxx_destructor);
}
#endif

View File

@ -0,0 +1,25 @@
# $FreeBSD$
.PATH: ${.CURDIR:H}
SHLIB= h_csu
SHLIB_NAME= libh_csu.so
SHLIB_MAJOR= 1
WITHOUT_STATIC=
WITHOUT_PROFILE=
WITHOUT_PIC=
CFLAGS+= -DDSO_LIB
.include "../Makefile.tests"
SRCS=
.for src in ${ATF_TESTS_C}
SRCS+= ${src}.c
.endfor
.for src in ${ATF_TESTS_CXX}
SRCS+= ${src}.cc
.endfor
LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib/
.include <bsd.lib.mk>

View File

@ -0,0 +1,17 @@
# $FreeBSD$
.PATH: ${.CURDIR:H}
CFLAGS+= -DDSO_BASE
DPADD+= ${.OBJDIR:H}/dso/libh_csu.so
LDFLAGS+= -Wl,-rpath,${TESTSDIR} -L${.OBJDIR:H}/dso
LDADD+= -lh_csu
.include "../Makefile.tests"
.for test in ${ATF_TESTS_C}
ATF_TESTS_CXX+= ${test}
SRCS.${test}= ${test}.c
.endfor
ATF_TESTS_C:=
.include <bsd.test.mk>

View File

@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/wait.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
@ -43,10 +44,16 @@ __FBSDID("$FreeBSD$");
#include <crt.h>
extern bool run_dtors_test;
extern bool run_fini_array_test;
void dso_handle_check(void);
#ifndef DSO_BASE
typedef void (*func_ptr)(void);
static bool run_dtors_test = false;
static bool run_fini_array_test = false;
bool run_dtors_test = false;
bool run_fini_array_test = false;
static void
dtors_handler(void)
@ -57,7 +64,9 @@ dtors_handler(void)
}
__section(".dtors") __used static func_ptr dtors_func =
&dtors_handler;
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(dtors_test);
ATF_TC_BODY(dtors_test, tc)
{
@ -85,7 +94,9 @@ ATF_TC_BODY(dtors_test, tc)
break;
}
}
#endif
#ifndef DSO_BASE
static void
fini_array_handler(void)
{
@ -95,7 +106,9 @@ fini_array_handler(void)
}
__section(".fini_array") __used static func_ptr fini_array_func =
&fini_array_handler;
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(fini_array_test);
ATF_TC_BODY(fini_array_test, tc)
{
@ -118,12 +131,41 @@ ATF_TC_BODY(fini_array_test, tc)
break;
}
}
#endif
#ifndef DSO_BASE
extern void *__dso_handle;
void
dso_handle_check(void)
{
void *dso = __dso_handle;
#ifdef DSO_LIB
ATF_REQUIRE_MSG(dso != NULL,
"Null __dso_handle in DSO");
#else
ATF_REQUIRE_MSG(dso == NULL,
"Invalid __dso_handle in non-DSO");
#endif
}
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(dso_handle_test);
ATF_TC_BODY(dso_handle_test, tc)
{
dso_handle_check();
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, dtors_test);
ATF_TP_ADD_TC(tp, fini_array_test);
ATF_TP_ADD_TC(tp, dso_handle_test);
return (atf_no_error());
}
#endif

View File

@ -32,41 +32,58 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef DSO_LIB
#include <atf-c.h>
#endif
#include <crt.h>
typedef void (*func_ptr)(void);
static volatile int jcr_run;
static const func_ptr *jcr_ptr;
static volatile int ctors_run;
static volatile int preinit_array_run;
static volatile int preinit_array_state = -1;
static volatile int init_array_run;
static volatile int init_array_state = -1;
extern volatile int jcr_run;
extern const func_ptr *jcr_ptr;
extern const void *jcr_func_ptr;
extern volatile int ctors_run;
extern volatile int preinit_array_run;
extern volatile int preinit_array_state;
extern volatile int init_array_run;
extern volatile int init_array_state;
#ifndef DSO_BASE
volatile int jcr_run;
const func_ptr *jcr_ptr;
volatile int ctors_run;
volatile int preinit_array_run;
volatile int preinit_array_state = -1;
volatile int init_array_run;
volatile int init_array_state = -1;
void _Jv_RegisterClasses(const func_ptr *);
__section(".jcr") __used static func_ptr jcr_func = (func_ptr)1;
const void *jcr_func_ptr = &jcr_func;
void
_Jv_RegisterClasses(const func_ptr *jcr __unused)
_Jv_RegisterClasses(const func_ptr *jcr)
{
jcr_run = 1;
jcr_ptr = jcr;
}
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(jcr_test);
ATF_TC_BODY(jcr_test, tc)
{
ATF_REQUIRE_MSG(jcr_run == 1, ".jcr not run");
ATF_REQUIRE_MSG(jcr_ptr == &jcr_func,
ATF_REQUIRE_MSG(jcr_ptr == jcr_func_ptr,
"Incorrect pointer passed to _Jv_RegisterClasses");
}
#endif
#ifndef DSO_BASE
static void
ctors_handler(void)
{
@ -75,7 +92,9 @@ ctors_handler(void)
}
__section(".ctors") __used static func_ptr ctors_func =
&ctors_handler;
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(ctors_test);
ATF_TC_BODY(ctors_test, tc)
{
@ -86,7 +105,9 @@ ATF_TC_BODY(ctors_test, tc)
ATF_REQUIRE_MSG(ctors_run == 0, ".ctors run");
#endif
}
#endif
#if !defined(DSO_BASE) && !defined(DSO_LIB)
static void
preinit_array_handler(void)
{
@ -96,16 +117,25 @@ preinit_array_handler(void)
}
__section(".preinit_array") __used static func_ptr preinit_array_func =
&preinit_array_handler;
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(preinit_array_test);
ATF_TC_BODY(preinit_array_test, tc)
{
#ifdef DSO_BASE
/* Check .preinit_array wasn't run in a DSO */
ATF_REQUIRE_MSG(preinit_array_run == 0, ".preinit_array run in DSO");
#else
ATF_REQUIRE_MSG(preinit_array_run == 1, ".preinit_array not run");
ATF_REQUIRE_MSG(preinit_array_state == 0,
".preinit_array was not run before .init_array");
#endif
}
#endif
#ifndef DSO_BASE
static void
init_array_handler(void)
{
@ -115,14 +145,18 @@ init_array_handler(void)
}
__section(".init_array") __used static func_ptr init_array_func =
&init_array_handler;
#endif
#ifndef DSO_LIB
ATF_TC_WITHOUT_HEAD(init_array_test);
ATF_TC_BODY(init_array_test, tc)
{
ATF_REQUIRE_MSG(init_array_run == 1, ".init_array not run");
#ifndef DSO_BASE
ATF_REQUIRE_MSG(init_array_state == 1,
".init_array was not run after .preinit_array");
#endif
}
ATF_TP_ADD_TCS(tp)
@ -135,3 +169,4 @@ ATF_TP_ADD_TCS(tp)
return (atf_no_error());
}
#endif

View File

@ -928,7 +928,8 @@ be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary)
{
char be_path[BE_MAXPATHLEN];
char buf[BE_MAXPATHLEN];
nvlist_t *config, *vdevs;
nvlist_t *config, *dsprops, *vdevs;
char *origin;
uint64_t pool_guid;
zfs_handle_t *zhp;
int err;
@ -969,7 +970,18 @@ be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary)
if (zhp == NULL)
return (-1);
err = zfs_promote(zhp);
if (be_prop_list_alloc(&dsprops) != 0)
return (-1);
if (be_get_dataset_props(lbh, be_path, dsprops) != 0) {
nvlist_free(dsprops);
return (-1);
}
if (nvlist_lookup_string(dsprops, "origin", &origin) == 0)
err = zfs_promote(zhp);
nvlist_free(dsprops);
zfs_close(zhp);
if (err)

View File

@ -2,7 +2,6 @@
# $FreeBSD$
SRCS+= \
amd64_detect_rdfsgsbase.c \
amd64_get_fsbase.c \
amd64_get_gsbase.c \
amd64_set_fsbase.c \

View File

@ -1,63 +0,0 @@
/*-
* Copyright (c) 2017 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define IN_RTLD 1
#include <sys/param.h>
#undef IN_RTLD
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include "amd64_detect_rdfsgsbase.h"
#include "libc_private.h"
static int state = RDFSGS_UNKNOWN;
int
amd64_detect_rdfsgsbase(void)
{
u_int p[4];
if (__predict_true(state != RDFSGS_UNKNOWN))
return (state);
if (__getosreldate() >= P_OSREL_WRFSBASE) {
do_cpuid(0x0, p);
if (p[0] >= 0x7) {
cpuid_count(0x7, 0x0, p);
if ((p[1] & CPUID_STDEXT_FSGSBASE) != 0) {
state = RDFSGS_SUPPORTED;
return (state);
}
}
}
state = RDFSGS_UNSUPPORTED;
return (state);
}

View File

@ -1,43 +0,0 @@
/*-
* Copyright (c) 2017 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _AMD64_DETECT_RDFSGSBASE_H_
#define _AMD64_DETECT_RDFSGSBASE_H_
enum {
RDFSGS_UNKNOWN,
RDFSGS_SUPPORTED,
RDFSGS_UNSUPPORTED,
};
int amd64_detect_rdfsgsbase(void);
#endif

View File

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Peter Wemm
* Copyright (c) 2017 The FreeBSD Foundation
* Copyright (c) 2017, 2018 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Konstantin Belousov
@ -33,18 +33,35 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#define IN_RTLD 1
#include <sys/param.h>
#undef IN_RTLD
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#include "amd64_detect_rdfsgsbase.h"
#include <x86/ifunc.h>
#include "libc_private.h"
int
amd64_get_fsbase(void **addr)
static int
amd64_get_fsbase_cpu(void **addr)
{
*addr = (void *)rdfsbase();
return (0);
}
static int
amd64_get_fsbase_syscall(void **addr)
{
if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) {
*addr = (void *)rdfsbase();
return (0);
}
return (sysarch(AMD64_GET_FSBASE, addr));
}
DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **), static)
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_get_fsbase_cpu);
return (amd64_get_fsbase_syscall);
}

View File

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Peter Wemm
* Copyright (c) 2017 The FreeBSD Foundation
* Copyright (c) 2017, 2018 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Konstantin Belousov
@ -33,18 +33,35 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#define IN_RTLD 1
#include <sys/param.h>
#undef IN_RTLD
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#include "amd64_detect_rdfsgsbase.h"
#include <x86/ifunc.h>
#include "libc_private.h"
int
amd64_get_gsbase(void **addr)
static int
amd64_get_gsbase_cpu(void **addr)
{
*addr = (void *)rdgsbase();
return (0);
}
static int
amd64_get_gsbase_syscall(void **addr)
{
if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) {
*addr = (void *)rdgsbase();
return (0);
}
return (sysarch(AMD64_GET_GSBASE, addr));
}
DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **), static)
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_get_gsbase_cpu);
return (amd64_get_gsbase_syscall);
}

View File

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Peter Wemm
* Copyright (c) 2017 The FreeBSD Foundation
* Copyright (c) 2017, 2018 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Konstantin Belousov
@ -33,18 +33,35 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#define IN_RTLD 1
#include <sys/param.h>
#undef IN_RTLD
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#include "amd64_detect_rdfsgsbase.h"
#include <x86/ifunc.h>
#include "libc_private.h"
int
amd64_set_fsbase(void *addr)
static int
amd64_set_fsbase_cpu(void *addr)
{
wrfsbase((uintptr_t)addr);
return (0);
}
static int
amd64_set_fsbase_syscall(void *addr)
{
if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) {
wrfsbase((uintptr_t)addr);
return (0);
}
return (sysarch(AMD64_SET_FSBASE, &addr));
}
DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *), static)
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_set_fsbase_cpu);
return (amd64_set_fsbase_syscall);
}

View File

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Peter Wemm
* Copyright (c) 2017 The FreeBSD Foundation
* Copyright (c) 2017, 2018 The FreeBSD Foundation
* All rights reserved.
*
* Portions of this software were developed by Konstantin Belousov
@ -33,18 +33,35 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#define IN_RTLD 1
#include <sys/param.h>
#undef IN_RTLD
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#include "amd64_detect_rdfsgsbase.h"
#include <x86/ifunc.h>
#include "libc_private.h"
int
amd64_set_gsbase(void *addr)
static int
amd64_set_gsbase_cpu(void *addr)
{
wrgsbase((uintptr_t)addr);
return (0);
}
static int
amd64_set_gsbase_syscall(void *addr)
{
if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) {
wrgsbase((uintptr_t)addr);
return (0);
}
return (sysarch(AMD64_SET_GSBASE, &addr));
}
DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *), static)
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_set_gsbase_cpu);
return (amd64_set_gsbase_syscall);
}

View File

@ -272,17 +272,24 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
case 'k':
case 'l':
/*
* Of these, %l is the only specifier explicitly
* documented as not being zero-padded. However,
* there is no harm in allowing zero-padding.
* %k and %l specifiers are documented as being
* blank-padded. However, there is no harm in
* allowing zero-padding.
*
* XXX The %l specifier may gobble one too many
* XXX %k and %l specifiers may gobble one too many
* digits if used incorrectly.
*/
len = 2;
if ((c == 'k' || c == 'l') &&
isblank_l((unsigned char)*buf, locale)) {
buf++;
len = 1;
}
if (!isdigit_l((unsigned char)*buf, locale))
return (NULL);
len = 2;
for (i = 0; len && *buf != 0 &&
isdigit_l((unsigned char)*buf, locale); buf++) {
i *= 10;

View File

@ -28,7 +28,7 @@
.\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95
.\" $FreeBSD$
.\"
.Dd August 4, 2018
.Dd October 27, 2018
.Dt GETTIMEOFDAY 2
.Os
.Sh NAME
@ -89,6 +89,11 @@ structure indicates the local time zone
and a flag that, if nonzero, indicates that
Daylight Saving time applies locally during
the appropriate part of the year.
The kernel generally does not track these values and they
are usually returned as zero.
Use
.Xr localtime 3
to find the offset for the currently active timezone.
.Pp
Only the super-user may set the time of day or time zone.
If the system is running at securelevel >= 2 (see

View File

@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 13, 2014
.Dd November 1, 2018
.Dt POLL 2
.Os
.Sh NAME
@ -232,7 +232,15 @@ points outside the process's allocated address space.
A signal was delivered before the time limit expired and
before any of the selected events occurred.
.It Bq Er EINVAL
The specified time limit is invalid. One of its components is negative or too large.
The specified time limit is invalid.
One of its components is negative or too large.
.It Bq Er EINVAL
The number of pollfd structures specified by
.Fa nfds
exceeds the system tunable
.Va kern.maxfilesperproc
and
.Dv FD_SETSIZE .
.El
.Sh SEE ALSO
.Xr accept 2 ,

View File

@ -20,6 +20,7 @@ TESTS_SUBDIRS+= stdlib
TESTS_SUBDIRS+= string
TESTS_SUBDIRS+= sys
TESTS_SUBDIRS+= termios
TESTS_SUBDIRS+= time
TESTS_SUBDIRS+= tls
TESTS_SUBDIRS+= ttyio

View File

@ -28,7 +28,7 @@
.\" @(#)ftime.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd June 4, 1993
.Dd August 4, 2018
.Dt FTIME 3
.Os
.Sh NAME
@ -67,9 +67,8 @@ struct timeb
.Pp
The structure contains the time since the epoch in seconds,
up to 1000 milliseconds of more-precise interval,
the local time zone (measured in minutes of time westward from Greenwich),
and a flag that, if nonzero, indicates that
Daylight Saving time applies locally during the appropriate part of the year.
The kernel no longer maintains the timezone and dstflag info, so 0 is
always returned for these fields.
.Sh SEE ALSO
.Xr gettimeofday 2 ,
.Xr settimeofday 2 ,
@ -79,4 +78,4 @@ Daylight Saving time applies locally during the appropriate part of the year.
The
.Nm
function appeared in
.Bx 4.2 .
.At v7 .

View File

@ -146,6 +146,8 @@ pmu_alias_get(const char *name)
struct pmu_event_desc {
uint64_t ped_period;
uint64_t ped_offcore_rsp;
uint64_t ped_l3_thread;
uint64_t ped_l3_slice;
uint32_t ped_event;
uint32_t ped_frontend;
uint32_t ped_ldlat;
@ -270,6 +272,10 @@ pmu_parse_event(struct pmu_event_desc *ped, const char *eventin)
ped->ped_ch_mask = strtol(value, NULL, 16);
else if (strcmp(key, "config1") == 0)
ped->ped_config1 = strtol(value, NULL, 16);
else if (strcmp(key, "l3_thread_mask") == 0)
ped->ped_l3_thread = strtol(value, NULL, 16);
else if (strcmp(key, "l3_slice_mask") == 0)
ped->ped_l3_slice = strtol(value, NULL, 16);
else {
debug = getenv("PMUDEBUG");
if (debug != NULL && strcmp(debug, "true") == 0 && value != NULL)
@ -407,33 +413,50 @@ pmc_pmu_print_counter_full(const char *ev)
}
static int
pmc_pmu_amd_pmcallocate(const char *event_name __unused, struct pmc_op_pmcallocate *pm,
pmc_pmu_amd_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
struct pmu_event_desc *ped)
{
struct pmc_md_amd_op_pmcallocate *amd;
const struct pmu_event *pe;
int idx = -1;
amd = &pm->pm_md.pm_amd;
amd->pm_amd_config = AMD_PMC_TO_EVENTMASK(ped->ped_event);
if (ped->ped_umask > 0) {
pm->pm_caps |= PMC_CAP_QUALIFIER;
amd->pm_amd_config |= AMD_PMC_TO_UNITMASK(ped->ped_umask);
}
pm->pm_class = PMC_CLASS_K8;
pe = pmu_event_get(NULL, event_name, &idx);
if ((pm->pm_caps & (PMC_CAP_USER|PMC_CAP_SYSTEM)) == 0 ||
(pm->pm_caps & (PMC_CAP_USER|PMC_CAP_SYSTEM)) ==
(PMC_CAP_USER|PMC_CAP_SYSTEM))
amd->pm_amd_config |= (AMD_PMC_USR | AMD_PMC_OS);
else if (pm->pm_caps & PMC_CAP_USER)
amd->pm_amd_config |= AMD_PMC_USR;
else if (pm->pm_caps & PMC_CAP_SYSTEM)
amd->pm_amd_config |= AMD_PMC_OS;
if (ped->ped_edge)
amd->pm_amd_config |= AMD_PMC_EDGE;
if (ped->ped_inv)
amd->pm_amd_config |= AMD_PMC_EDGE;
if (pm->pm_caps & PMC_CAP_INTERRUPT)
amd->pm_amd_config |= AMD_PMC_INT;
if (strcmp("l3cache", pe->topic) == 0){
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK(ped->ped_event);
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_L3_CACHE;
amd->pm_amd_config |= AMD_PMC_TO_L3SLICE(ped->ped_l3_slice);
amd->pm_amd_config |= AMD_PMC_TO_L3CORE(ped->ped_l3_thread);
}
else if (strcmp("data fabric", pe->topic) == 0){
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK_DF(ped->ped_event);
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_DATA_FABRIC;
}
else{
amd->pm_amd_config |= AMD_PMC_TO_EVENTMASK(ped->ped_event);
amd->pm_amd_sub_class = PMC_AMD_SUB_CLASS_CORE;
if ((pm->pm_caps & (PMC_CAP_USER|PMC_CAP_SYSTEM)) == 0 ||
(pm->pm_caps & (PMC_CAP_USER|PMC_CAP_SYSTEM)) ==
(PMC_CAP_USER|PMC_CAP_SYSTEM))
amd->pm_amd_config |= (AMD_PMC_USR | AMD_PMC_OS);
else if (pm->pm_caps & PMC_CAP_USER)
amd->pm_amd_config |= AMD_PMC_USR;
else if (pm->pm_caps & PMC_CAP_SYSTEM)
amd->pm_amd_config |= AMD_PMC_OS;
if (ped->ped_edge)
amd->pm_amd_config |= AMD_PMC_EDGE;
if (ped->ped_inv)
amd->pm_amd_config |= AMD_PMC_EDGE;
if (pm->pm_caps & PMC_CAP_INTERRUPT)
amd->pm_amd_config |= AMD_PMC_INT;
}
return (0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@
*/
#include <sys/stddef.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@ -54,8 +54,6 @@
#include "json.h"
#include "jevents.h"
int snprintf(char * __restrict, size_t, const char * __restrict,
...) __printflike(3, 4);
_Noreturn void _Exit(int);
int verbose;
@ -186,6 +184,8 @@ static struct field {
{ "SampleAfterValue", "period=" },
{ "FCMask", "fc_mask=" },
{ "PortMask", "ch_mask=" },
{ "L3ThreadMask", "l3_thread_mask=" },
{ "L3SliceMask", "l3_slice_mask=" },
{ NULL, NULL }
};
@ -859,8 +859,11 @@ static int get_maxfds(void)
{
struct rlimit rlim;
if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
return min((int)rlim.rlim_max / 2, 512);
if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
if (rlim.rlim_max == RLIM_INFINITY)
return 512;
return min((unsigned)rlim.rlim_max / 2, 512);
}
return 512;
}
@ -1121,8 +1124,8 @@ int main(int argc, char *argv[])
mapfile = NULL;
rc = nftw(ldirname, preprocess_arch_std_files, maxfds, 0);
if (rc && verbose) {
pr_info("%s: Error preprocessing arch standard files %s\n",
prog, ldirname);
pr_info("%s: Error preprocessing arch standard files %s: %s\n",
prog, ldirname, strerror(errno));
goto empty_map;
} else if (rc < 0) {
/* Make build fail */

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 30, 2008
.Dd November 4, 2018
.Dt CSQRT 3
.Os
.Sh NAME
@ -78,7 +78,7 @@ k + \*(Na*I \*(Na + \*(Na*I \&
.Pp
For numbers with negative imaginary parts, the above special cases
apply given the identity:
.Dl csqrt(conj(z) = conj(sqrt(z))
.Dl csqrt(conj(z)) = conj(csqrt(z))
Note that the sign of \*(Na is indeterminate.
Also, if the real or imaginary part of the input is finite and
an \*(Na is generated, an invalid exception will be thrown.

View File

@ -47,10 +47,10 @@ done
dirs=`echo $dirs | sed 's/:/ /g'`
case X"$dirs" in X) echo "usage: $0 [options] directories ..."; exit 1;; esac
localdirs=`find -H $dirs -fstype local -type d -prune -print`
localdirs=`find -H $dirs -fstype local \! -fstype rdonly -type d -prune -print`
case X"$localdirs" in
X) echo "$0: no local-mounted manual directories found: $dirs"
X) echo "$0: no local rw-mounted manual directories found: $dirs"
exit 1;;
*) exec `basename $0 .local` $opt $localdirs;;
esac

View File

@ -617,6 +617,7 @@ savecore_enable="YES" # Extract core from dump devices if any
savecore_flags="-m 10" # Used if dumpdev is enabled above, and present.
# By default, only the 10 most recent kernel dumps
# are saved.
service_delete_empty="NO" # Have 'service delete' remove empty rc.conf.d files.
crashinfo_enable="YES" # Automatically generate crash dump summary.
crashinfo_program="/usr/sbin/crashinfo" # Script to generate crash dump summary.
quota_enable="NO" # turn on quotas on startup (or NO).

View File

@ -92,7 +92,7 @@ local_unbound_prestart()
fi
# Retrieve DNSSEC root key
if [ ! -f ${local_unbound_anchor} ] ; then
if [ ! -s ${local_unbound_anchor} ] ; then
run_rc_command anchor
fi
}

View File

@ -55,4 +55,22 @@ fi
/usr/bin/logger -t $subsystem resumed at `/bin/date +'%Y%m%d %H:%M:%S'`
/bin/sync && /bin/sync && /bin/sync
. /etc/rc.subr
load_rc_config
rcorder_opts="-k resume"
case ${local_startup} in
[Nn][Oo] | '') ;;
*) find_local_scripts_new ;;
esac
files=`rcorder ${rcorder_opts} /etc/rc.d/* ${local_rc} 2>/dev/null`
for _rc_elem in $files; do
debug "run_rc_script $_rc_elem resume"
run_rc_script $_rc_elem resume
done
exit 0

View File

@ -922,7 +922,7 @@ run_rc_command()
eval _override_command=\$${name}_program
command=${_override_command:-$command}
_keywords="start stop restart rcvar enabled describe extracommands $extra_commands"
_keywords="start stop restart rcvar enable disable delete enabled describe extracommands $extra_commands"
rc_pid=
_pidcmd=
_procname=${procname:-${command}}
@ -977,12 +977,13 @@ run_rc_command()
if [ "$_elem" != "$rc_arg" ]; then
continue
fi
# if ${rcvar} is set, $1 is not "rcvar" and not "describe"
# and ${rc_pid} is not set, then run
# if ${rcvar} is set, $1 is not "rcvar", "describe",
# "enable" or "delete", and ${rc_pid} is not set, run:
# checkyesno ${rcvar}
# and return if that failed
#
if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != "stop" \
-a "$rc_arg" != "delete" -a "$rc_arg" != "enable" \
-a "$rc_arg" != "describe" ] ||
[ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z "${rc_pid}" ]; then
if ! checkyesno ${rcvar}; then
@ -1030,6 +1031,31 @@ run_rc_command()
echo "$extra_commands"
;;
enable)
_out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=YES") &&
echo "$name enabled in ${_out%%:*}"
;;
disable)
_out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=NO") &&
echo "$name disabled in ${_out%%:*}"
;;
delete)
_files=
for _file in $(sysrc -lEs "$name"); do
_out=$(sysrc -Fif $_file "$rcvar") && _files="$_files $_file"
done
/usr/sbin/sysrc -x "$rcvar" && echo "$rcvar deleted in ${_files# }"
# delete file in rc.conf.d if desired and empty.
checkyesno service_delete_empty || _files=
for _file in $_files; do
[ "$_file" = "${_file#*/rc.conf.d/}" ] && continue
[ $(/usr/bin/stat -f%z $_file) -gt 0 ] && continue
/bin/rm "$_file" && echo "Empty file $_file removed"
done
;;
status)
_run_rc_precmd || return 1
if [ -n "$rc_pid" ]; then

View File

@ -31,7 +31,9 @@ LDFLAGS+= -nostdlib -e _rtld_start
.else
LDFLAGS+= -nostdlib -e .rtld_start
.endif
WARNS?= 2
NO_WCAST_ALIGN= yes
WARNS?= 6
INSTALLFLAGS= -C -b
PRECIOUSPROG=
BINDIR= /libexec
@ -95,3 +97,13 @@ SUBDIR.${MK_TESTS}+= tests
.include <bsd.prog.mk>
${PROG_FULL}: ${VERSION_MAP}
.include <bsd.symver.mk>
.if ${COMPILER_TYPE} == "gcc"
# GCC warns about redeclarations even though they have __exported
# and are therefore not identical to the ones from the system headers.
CFLAGS+= -Wno-redundant-decls
.if ${COMPILER_VERSION} < 40300
# Silence -Wshadow false positives in ancient GCC
CFLAGS+= -Wno-shadow
.endif
.endif

View File

@ -84,7 +84,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *)((char *)dstobj->rela +
relalim = (const Elf_Rela *)((const char *)dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) != R_AARCH64_COPY)
@ -128,6 +128,8 @@ struct tls_data {
const Elf_Rela *rela;
};
int64_t rtld_tlsdesc_handle(struct tls_data *tlsdesc, int flags);
static struct tls_data *
reloc_tlsdesc_alloc(Obj_Entry *obj, const Elf_Rela *rela)
{
@ -205,7 +207,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -243,7 +245,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Sym *def;
struct tls_data *tlsdesc;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
@ -289,7 +291,7 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
if (!obj->irelative)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_AARCH64_IRELATIVE) {
ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend);
@ -316,7 +318,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
if (!obj->gnu_ifunc)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_AARCH64_JUMP_SLOT) {
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -338,8 +340,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_AARCH64_JUMP_SLOT ||
@ -386,7 +389,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
/*
* First, resolve symbol for relocations which
@ -471,7 +474,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);

View File

@ -35,8 +35,9 @@
#include <sys/param.h>
#include <sys/mman.h>
#include <machine/sysarch.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
#include <dlfcn.h>
#include <err.h>
@ -67,7 +68,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela + dstobj->relasize);
relalim = (const Elf_Rela *)((const char *) dstobj->rela + dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_X86_64_COPY) {
void *dstaddr;
@ -80,7 +81,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -104,7 +105,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return -1;
}
srcaddr = (const void *) (defobj->relocbase + srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase + srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
}
}
@ -147,7 +148,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char*)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
/*
* First, resolve symbol for relocations which
@ -254,7 +255,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -274,7 +276,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -322,7 +325,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -355,7 +358,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (obj->jmpslots_done)
return 0;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
const Elf_Sym *def;
@ -392,8 +395,9 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
/* Fixup the jump slot at "where" to transfer control to "target". */
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj,
const Elf_Rel *rel)
const struct Struct_Obj_Entry *obj __unused,
const struct Struct_Obj_Entry *refobj __unused,
const Elf_Rel *rel __unused)
{
#ifdef dbg
dbg("reloc_jmpslot: *%p = %p", where, (void *)target);
@ -411,7 +415,7 @@ reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
if (!obj->irelative)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target, *ptr;
@ -441,7 +445,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (!obj->gnu_ifunc)
return (0);
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where, target;
const Elf_Sym *def;
@ -492,17 +496,26 @@ pre_init(void)
}
int __getosreldate(void);
void
allocate_initial_tls(Obj_Entry *objs)
{
/*
* Fix the size of the static TLS block by using the maximum
* offset allocated so far and adding a bit for dynamic modules to
* use.
*/
tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
amd64_set_fsbase(allocate_tls(objs, 0,
3*sizeof(Elf_Addr), sizeof(Elf_Addr)));
void *addr;
/*
* Fix the size of the static TLS block by using the maximum
* offset allocated so far and adding a bit for dynamic
* modules to use.
*/
tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
addr = allocate_tls(objs, 0, 3 * sizeof(Elf_Addr), sizeof(Elf_Addr));
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
wrfsbase((uintptr_t)addr);
else
sysarch(AMD64_SET_FSBASE, &addr);
}
void *__tls_get_addr(tls_index *ti)

View File

@ -75,7 +75,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *) dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) == R_ARM_COPY) {
void *dstaddr;
@ -88,7 +88,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
dstaddr = (void *)(dstobj->relocbase + rel->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -125,8 +125,6 @@ do_copy_relocations(Obj_Entry *dstobj)
void _rtld_bind_start(void);
void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
int open();
int _open();
void
_rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
{
@ -145,7 +143,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
break;
}
}
rellim = (const Elf_Rel *)((caddr_t)rel + relsz);
rellim = (const Elf_Rel *)((const char *)rel + relsz);
size = (rellim - 1)->r_offset - rel->r_offset;
for (; rel < rellim; rel++) {
where = (Elf_Addr *)(relocbase + rel->r_offset);
@ -375,7 +373,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
if (reloc_nonplt_object(obj, rel, cache, flags, lockstate) < 0)
goto done;
@ -396,7 +394,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel +
rellim = (const Elf_Rel *)((const char *)obj->pltrel +
obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -423,7 +421,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
@ -445,7 +443,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -453,8 +452,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -462,8 +461,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_ARM_JUMP_SLOT);

View File

@ -67,7 +67,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *)dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) == R_386_COPY) {
void *dstaddr;
@ -80,7 +80,7 @@ do_copy_relocations(Obj_Entry *dstobj)
SymLook req;
int res;
dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
dstaddr = (void *)(dstobj->relocbase + rel->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -104,7 +104,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return -1;
}
srcaddr = (const void *) (defobj->relocbase + srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase + srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
}
}
@ -146,7 +146,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
rellim = (const Elf_Rel *)((caddr_t) obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
switch (ELF_R_TYPE(rel->r_info)) {
case R_386_32:
@ -239,7 +239,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* of space, we generate an error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available "
"for static Thread Local Storage",
obj->path);
@ -278,7 +279,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where/*, val*/;
@ -311,7 +312,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (obj->jmpslots_done)
return 0;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where, target;
const Elf_Sym *def;
@ -349,8 +350,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
/* Fixup the jump slot at "where" to transfer control to "target". */
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *obj, const struct Struct_Obj_Entry *refobj,
const Elf_Rel *rel)
const Obj_Entry *obj __unused, const Obj_Entry *refobj __unused,
const Elf_Rel *rel __unused)
{
#ifdef dbg
dbg("reloc_jmpslot: *%p = %p", where, (void *)target);
@ -369,7 +370,7 @@ reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
if (!obj->irelative)
return (0);
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
switch (ELF_R_TYPE(rel->r_info)) {
case R_386_IRELATIVE:
@ -393,7 +394,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (!obj->gnu_ifunc)
return (0);
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where, target;
const Elf_Sym *def;

View File

@ -58,7 +58,7 @@ extern uint32_t cpu_feature2;
extern uint32_t cpu_stdext_feature;
extern uint32_t cpu_stdext_feature2;
#define call_ifunc_resolver(ptr) \
(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))ptr)( \
(((Elf_Addr (*)(uint32_t, uint32_t, uint32_t, uint32_t))(ptr))( \
cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2))
#define round(size, align) \

View File

@ -25,7 +25,7 @@ struct lm {
TAILQ_ENTRY(lm) lm_link;
};
TAILQ_HEAD(lmp_list, lmp) lmp_head = TAILQ_HEAD_INITIALIZER(lmp_head);
static TAILQ_HEAD(lmp_list, lmp) lmp_head = TAILQ_HEAD_INITIALIZER(lmp_head);
struct lmp {
char *p;
enum { T_EXACT=0, T_BASENAME, T_DIRECTORY } type;
@ -44,8 +44,8 @@ struct lmc {
static int lm_count;
static void lmc_parse(char *, size_t);
static void lmc_parse_file(char *);
static void lmc_parse_dir(char *);
static void lmc_parse_file(const char *);
static void lmc_parse_dir(const char *);
static void lm_add(const char *, const char *, const char *);
static void lm_free(struct lm_list *);
static char *lml_find(struct lm_list *, const char *);
@ -96,7 +96,7 @@ lm_init(char *libmap_override)
}
static void
lmc_parse_file(char *path)
lmc_parse_file(const char *path)
{
struct lmc *p;
char *lm_map;
@ -149,7 +149,7 @@ lmc_parse_file(char *path)
}
static void
lmc_parse_dir(char *idir)
lmc_parse_dir(const char *idir)
{
DIR *d;
struct dirent *dp;
@ -199,8 +199,7 @@ lmc_parse(char *lm_p, size_t lm_len)
char prog[MAXPATHLEN];
/* allow includedir + full length path */
char line[MAXPATHLEN + 13];
size_t cnt;
int i;
size_t cnt, i;
cnt = 0;
p = NULL;
@ -403,7 +402,7 @@ lm_find(const char *p, const char *f)
* replacement library, or NULL.
*/
char *
lm_findn(const char *p, const char *f, const int n)
lm_findn(const char *p, const char *f, const size_t n)
{
char pathbuf[64], *s, *t;

View File

@ -5,4 +5,4 @@
int lm_init (char *);
void lm_fini (void);
char * lm_find (const char *, const char *);
char * lm_findn (const char *, const char *, const int);
char * lm_findn (const char *, const char *, const size_t);

View File

@ -60,15 +60,11 @@ static char *rcsid = "$FreeBSD$";
#include "rtld_printf.h"
#include "paths.h"
static void morecore();
static int findbucket();
/*
* Pre-allocate mmap'ed pages
*/
#define NPOOLPAGES (128*1024/pagesz)
static caddr_t pagepool_start, pagepool_end;
static int morepages();
/*
* The overhead on a block is at least 4 bytes. When free, this space
@ -96,6 +92,11 @@ union overhead {
#define ov_size ovu.ovu_size
};
static void morecore(int bucket);
static int morepages(int n);
static int findbucket(union overhead *freep, int srchlen);
#define MAGIC 0xef /* magic # on accounting info */
#define RMAGIC 0x5555 /* magic # on range info */
@ -150,16 +151,14 @@ botch(s)
* must contain at least one page size. The page sizes must be stored in
* increasing order.
*/
extern size_t *pagesizes;
void *
malloc(nbytes)
size_t nbytes;
malloc(size_t nbytes)
{
register union overhead *op;
register int bucket;
register long n;
register unsigned amt;
union overhead *op;
int bucket;
ssize_t n;
size_t amt;
/*
* First time malloc is called, setup page size and
@ -256,11 +255,10 @@ calloc(size_t num, size_t size)
* Allocate more memory to the indicated bucket.
*/
static void
morecore(bucket)
int bucket;
morecore(int bucket)
{
register union overhead *op;
register int sz; /* size of desired block */
union overhead *op;
int sz; /* size of desired block */
int amt; /* amount to allocate */
int nblks; /* how many blocks we get */
@ -300,11 +298,10 @@ morecore(bucket)
}
void
free(cp)
void *cp;
free(void * cp)
{
register int size;
register union overhead *op;
int size;
union overhead *op;
if (cp == NULL)
return;
@ -339,15 +336,13 @@ free(cp)
* is extern so the caller can modify it). If that fails we just copy
* however many bytes was given to realloc() and hope it's not huge.
*/
int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
static int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
void *
realloc(cp, nbytes)
void *cp;
size_t nbytes;
realloc(void *cp, size_t nbytes)
{
register u_int onb;
register int i;
u_int onb;
int i;
union overhead *op;
char *res;
int was_alloced = 0;
@ -413,12 +408,10 @@ realloc(cp, nbytes)
* Return bucket number, or -1 if not found.
*/
static int
findbucket(freep, srchlen)
union overhead *freep;
int srchlen;
findbucket(union overhead *freep, int srchlen)
{
register union overhead *p;
register int i, j;
union overhead *p;
int i, j;
for (i = 0; i < NBUCKETS; i++) {
j = 0;
@ -439,11 +432,10 @@ findbucket(freep, srchlen)
* for each size category, the second showing the number of mallocs -
* frees for each size category.
*/
mstats(s)
char *s;
mstats(char * s)
{
register int i, j;
register union overhead *p;
int i, j;
union overhead *p;
int totfree = 0,
totused = 0;
@ -466,8 +458,7 @@ mstats(s)
static int
morepages(n)
int n;
morepages(int n)
{
int fd = -1;
int offset;

View File

@ -93,6 +93,7 @@ map_object(int fd, const char *path, const struct stat *sb)
Elf_Addr note_end;
char *note_map;
size_t note_map_len;
Elf_Addr text_end;
hdr = get_elf_header(fd, path, sb);
if (hdr == NULL)
@ -103,7 +104,7 @@ map_object(int fd, const char *path, const struct stat *sb)
*
* We expect that the loadable segments are ordered by load address.
*/
phdr = (Elf_Phdr *) ((char *)hdr + hdr->e_phoff);
phdr = (Elf_Phdr *)((char *)hdr + hdr->e_phoff);
phsize = hdr->e_phnum * sizeof (phdr[0]);
phlimit = phdr + hdr->e_phnum;
nsegs = -1;
@ -114,8 +115,10 @@ map_object(int fd, const char *path, const struct stat *sb)
note_start = 0;
note_end = 0;
note_map = NULL;
note_map_len = 0;
segs = alloca(sizeof(segs[0]) * hdr->e_phnum);
stack_flags = RTLD_DEFAULT_STACK_PF_EXEC | PF_R | PF_W;
text_end = 0;
while (phdr < phlimit) {
switch (phdr->p_type) {
@ -130,6 +133,10 @@ map_object(int fd, const char *path, const struct stat *sb)
path, nsegs);
goto error;
}
if ((segs[nsegs]->p_flags & PF_X) == PF_X) {
text_end = MAX(text_end,
round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_memsz));
}
break;
case PT_PHDR:
@ -280,15 +287,13 @@ map_object(int fd, const char *path, const struct stat *sb)
}
obj->mapbase = mapbase;
obj->mapsize = mapsize;
obj->textsize = round_page(segs[0]->p_vaddr + segs[0]->p_memsz) -
base_vaddr;
obj->vaddrbase = base_vaddr;
obj->relocbase = mapbase - base_vaddr;
obj->dynamic = (const Elf_Dyn *) (obj->relocbase + phdyn->p_vaddr);
obj->dynamic = (const Elf_Dyn *)(obj->relocbase + phdyn->p_vaddr);
if (hdr->e_entry != 0)
obj->entry = (caddr_t) (obj->relocbase + hdr->e_entry);
obj->entry = (caddr_t)(obj->relocbase + hdr->e_entry);
if (phdr_vaddr != 0) {
obj->phdr = (const Elf_Phdr *) (obj->relocbase + phdr_vaddr);
obj->phdr = (const Elf_Phdr *)(obj->relocbase + phdr_vaddr);
} else {
obj->phdr = malloc(phsize);
if (obj->phdr == NULL) {
@ -296,12 +301,12 @@ map_object(int fd, const char *path, const struct stat *sb)
_rtld_error("%s: cannot allocate program header", path);
goto error1;
}
memcpy((char *)obj->phdr, (char *)hdr + hdr->e_phoff, phsize);
memcpy(__DECONST(char *, obj->phdr), (char *)hdr + hdr->e_phoff, phsize);
obj->phdr_alloc = true;
}
obj->phsize = phsize;
if (phinterp != NULL)
obj->interp = (const char *) (obj->relocbase + phinterp->p_vaddr);
obj->interp = (const char *)(obj->relocbase + phinterp->p_vaddr);
if (phtls != NULL) {
tls_dtv_generation++;
obj->tlsindex = ++tls_max_index;
@ -335,7 +340,7 @@ get_elf_header(int fd, const char *path, const struct stat *sbp)
Elf_Ehdr *hdr;
/* Make sure file has enough data for the ELF header */
if (sbp != NULL && sbp->st_size < sizeof(Elf_Ehdr)) {
if (sbp != NULL && sbp->st_size < (off_t)sizeof(Elf_Ehdr)) {
_rtld_error("%s: invalid file format", path);
return (NULL);
}
@ -425,13 +430,13 @@ obj_free(Obj_Entry *obj)
if (obj->origin_path)
free(obj->origin_path);
if (obj->z_origin)
free(obj->rpath);
free(__DECONST(void*, obj->rpath));
if (obj->priv)
free(obj->priv);
if (obj->path)
free(obj->path);
if (obj->phdr_alloc)
free((void *)obj->phdr);
free(__DECONST(void *, obj->phdr));
free(obj);
}

View File

@ -126,7 +126,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
rellim = (const Elf_Rel *)((caddr_t)dstobj->rel + dstobj->relsize);
rellim = (const Elf_Rel *)((const char *)dstobj->rel + dstobj->relsize);
for (rel = dstobj->rel; rel < rellim; rel++) {
if (ELF_R_TYPE(rel->r_info) != R_MIPS_COPY)
continue;
@ -265,7 +265,7 @@ _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
++got;
}
rellim = (const Elf_Rel *)((caddr_t)rel + relsz);
rellim = (const Elf_Rel *)((const char *)rel + relsz);
for (; rel < rellim; rel++) {
Elf_Word r_symndx, r_type;
@ -469,7 +469,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
}
got = obj->pltgot;
rellim = (const Elf_Rel *)((caddr_t)obj->rel + obj->relsize);
rellim = (const Elf_Rel *)((const char *)obj->rel + obj->relsize);
for (rel = obj->rel; rel < rellim; rel++) {
Elf_Word r_symndx, r_type;
void *where;
@ -657,7 +657,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rel *rellim;
const Elf_Rel *rel;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -687,7 +687,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Rel *rel;
const Elf_Sym *def;
rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
rellim = (const Elf_Rel *)((const char *)obj->pltrel + obj->pltrelsize);
for (rel = obj->pltrel; rel < rellim; rel++) {
Elf_Addr *where;
@ -714,7 +714,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -722,8 +723,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -731,8 +732,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_MIPS_JUMP_SLOT);

View File

@ -43,6 +43,9 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
Elf_Addr _mips_rtld_bind(struct Struct_Obj_Entry *obj, Elf_Size reloff);
void *_mips_get_tls(void);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -69,10 +69,10 @@
#define SOFT_STANDARD_LIBRARY_PATH "/usr/libsoft"
#define LD_SOFT_ "LD_SOFT_"
extern char *ld_elf_hints_default;
extern char *ld_path_libmap_conf;
extern char *ld_path_rtld;
extern char *ld_standard_library_path;
extern char *ld_env_prefix;
extern const char *ld_elf_hints_default;
extern const char *ld_path_libmap_conf;
extern const char *ld_path_rtld;
extern const char *ld_standard_library_path;
extern const char *ld_env_prefix;
#endif /* PATHS_H */

View File

@ -71,7 +71,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
relalim = (const Elf_Rela *)((const char *) dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
void *dstaddr;
@ -88,7 +88,7 @@ do_copy_relocations(Obj_Entry *dstobj)
continue;
}
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -113,7 +113,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return (-1);
}
srcaddr = (const void *) (defobj->relocbase+srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase+srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
dbg("copy_reloc: src=%p,dst=%p,size=%d\n",srcaddr,dstaddr,size);
}
@ -149,7 +149,7 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
/*
* Relocate these values
*/
relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
relalim = (const Elf_Rela *)((const char *)rela + relasz);
for (; rela < relalim; rela++) {
where = (Elf_Addr *)(relocbase + rela->r_offset);
*where = (Elf_Addr)(relocbase + rela->r_addend);
@ -161,8 +161,8 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
* Relocate a non-PLT object with addend.
*/
static int
reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
SymCache *cache, int flags, RtldLockState *lockstate)
reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
{
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
const Elf_Sym *def;
@ -249,7 +249,8 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for static "
"Thread Local Storage", obj->path);
return (-1);
@ -293,6 +294,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
{
const Elf_Rela *relalim;
const Elf_Rela *rela;
const Elf_Phdr *phdr;
SymCache *cache;
int r = -1;
@ -315,7 +317,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* "The PowerPC family uses only the Elf32_Rela relocation
* entries with explicit addends."
*/
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj_rtld, obj, rela, cache, flags,
lockstate) < 0)
@ -326,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
if (cache != NULL)
free(cache);
/* Synchronize icache for text seg in case we made any changes */
__syncicache(obj->mapbase, obj->textsize);
/*
* Synchronize icache for executable segments in case we made
* any changes.
*/
for (phdr = obj->phdr;
(const char *)phdr < (const char *)obj->phdr + obj->phsize;
phdr++) {
if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) {
__syncicache(obj->relocbase + phdr->p_vaddr,
phdr->p_memsz);
}
}
return (r);
}
@ -398,7 +410,7 @@ reloc_plt(Obj_Entry *obj)
if (obj->pltrelasize != 0) {
relalim = (const Elf_Rela *)((char *)obj->pltrela +
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
@ -433,7 +445,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -469,8 +482,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
* trampoline call and jump table.
*/
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj, const Elf_Rel *rel)
{
Elf_Addr offset;
const Elf_Rela *rela = (const Elf_Rela *) rel;
@ -529,7 +542,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -537,8 +551,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -650,7 +664,7 @@ allocate_initial_tls(Obj_Entry *list)
tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8)
tp = (Elf_Addr **)((char *) allocate_tls(list, NULL, TLS_TCB_SIZE, 8)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
/*

View File

@ -42,6 +42,7 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -67,7 +67,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *) ((caddr_t) dstobj->rela +
relalim = (const Elf_Rela *)((const char *) dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
void *dstaddr;
@ -84,7 +84,7 @@ do_copy_relocations(Obj_Entry *dstobj)
continue;
}
dstaddr = (void *) (dstobj->relocbase + rela->r_offset);
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
dstsym = dstobj->symtab + ELF_R_SYM(rela->r_info);
name = dstobj->strtab + dstsym->st_name;
size = dstsym->st_size;
@ -109,7 +109,7 @@ do_copy_relocations(Obj_Entry *dstobj)
return (-1);
}
srcaddr = (const void *) (defobj->relocbase+srcsym->st_value);
srcaddr = (const void *)(defobj->relocbase+srcsym->st_value);
memcpy(dstaddr, srcaddr, size);
dbg("copy_reloc: src=%p,dst=%p,size=%zd\n",srcaddr,dstaddr,size);
}
@ -145,7 +145,7 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
/*
* Relocate these values
*/
relalim = (const Elf_Rela *)((caddr_t)rela + relasz);
relalim = (const Elf_Rela *)((const char *)rela + relasz);
for (; rela < relalim; rela++) {
where = (Elf_Addr *)(relocbase + rela->r_offset);
*where = (Elf_Addr)(relocbase + rela->r_addend);
@ -157,8 +157,8 @@ reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
* Relocate a non-PLT object with addend.
*/
static int
reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
SymCache *cache, int flags, RtldLockState *lockstate)
reloc_nonplt_object(Obj_Entry *obj_rtld __unused, Obj_Entry *obj,
const Elf_Rela *rela, SymCache *cache, int flags, RtldLockState *lockstate)
{
Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
const Elf_Sym *def;
@ -246,7 +246,8 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for static "
"Thread Local Storage", obj->path);
return (-1);
@ -290,6 +291,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
{
const Elf_Rela *relalim;
const Elf_Rela *rela;
const Elf_Phdr *phdr;
SymCache *cache;
int bytes = obj->dynsymcount * sizeof(SymCache);
int r = -1;
@ -315,7 +317,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* "The PowerPC family uses only the Elf32_Rela relocation
* entries with explicit addends."
*/
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj_rtld, obj, rela, cache, flags,
lockstate) < 0)
@ -326,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
if (cache)
munmap(cache, bytes);
/* Synchronize icache for text seg in case we made any changes */
__syncicache(obj->mapbase, obj->textsize);
/*
* Synchronize icache for executable segments in case we made
* any changes.
*/
for (phdr = obj->phdr;
(const char *)phdr < (const char *)obj->phdr + obj->phsize;
phdr++) {
if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) {
__syncicache(obj->relocbase + phdr->p_vaddr,
phdr->p_memsz);
}
}
return (r);
}
@ -370,7 +382,7 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *rela;
if (obj->pltrelasize != 0) {
relalim = (const Elf_Rela *)((char *)obj->pltrela +
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
@ -398,7 +410,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF_R_TYPE(rela->r_info) == R_PPC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -435,7 +448,7 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
*/
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
const Obj_Entry *obj __unused, const Elf_Rel *rel __unused)
{
/*
@ -494,7 +507,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -502,8 +516,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -555,7 +569,7 @@ allocate_initial_tls(Obj_Entry *list)
tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *)allocate_tls(list, NULL, TLS_TCB_SIZE, 16)
tp = (Elf_Addr **)((char *)allocate_tls(list, NULL, TLS_TCB_SIZE, 16)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
__asm __volatile("mr 13,%0" :: "r"(tp));

View File

@ -42,6 +42,7 @@ struct Struct_Obj_Entry;
Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const struct Struct_Obj_Entry *defobj, const struct Struct_Obj_Entry *obj,
const Elf_Rel *rel);
void reloc_non_plt_self(Elf_Dyn *dynp, Elf_Addr relocbase);
#define make_function_pointer(def, defobj) \
((defobj)->relocbase + (def)->st_value)

View File

@ -50,8 +50,6 @@ __FBSDID("$FreeBSD$");
#define RELOC_ALIGNED_P(x) \
(((uintptr_t)(x) & (sizeof(void *) - 1)) == 0)
void _exit(int);
uint64_t
set_gp(Obj_Entry *obj)
{
@ -105,7 +103,7 @@ do_copy_relocations(Obj_Entry *dstobj)
*/
assert(dstobj->mainprog);
relalim = (const Elf_Rela *)((char *)dstobj->rela +
relalim = (const Elf_Rela *)((const char *)dstobj->rela +
dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) != R_RISCV_COPY)
@ -152,7 +150,8 @@ reloc_plt(Obj_Entry *obj)
const Elf_Rela *relalim;
const Elf_Rela *rela;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -176,7 +175,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
const Elf_Rela *rela;
const Elf_Sym *def;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
@ -203,7 +203,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -211,8 +212,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -220,8 +221,9 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *where, Elf_Addr target, const Obj_Entry *defobj,
const Obj_Entry *obj, const Elf_Rel *rel)
reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
const Obj_Entry *defobj __unused, const Obj_Entry *obj __unused,
const Elf_Rel *rel)
{
assert(ELF_R_TYPE(rel->r_info) == R_RISCV_JUMP_SLOT);
@ -260,7 +262,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
cache = calloc(obj->dynsymcount, sizeof(SymCache));
/* No need to check for NULL here */
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
symnum = ELF_R_SYM(rela->r_info);
@ -315,7 +317,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);
@ -341,7 +344,8 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
* error.
*/
if (!defobj->tls_done) {
if (!allocate_tls_offset((Obj_Entry*) defobj)) {
if (!allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error(
"%s: No space available for static "
"Thread Local Storage", obj->path);
@ -390,7 +394,7 @@ allocate_initial_tls(Obj_Entry *objs)
tls_static_space = tls_last_offset + tls_last_size +
RTLD_STATIC_TLS_EXTRA;
tp = (Elf_Addr **) ((char *)allocate_tls(objs, NULL, TLS_TCB_SIZE, 16)
tp = (Elf_Addr **)((char *)allocate_tls(objs, NULL, TLS_TCB_SIZE, 16)
+ TLS_TP_OFFSET + TLS_TCB_SIZE);
__asm __volatile("mv tp, %0" :: "r"(tp));
@ -407,5 +411,5 @@ __tls_get_addr(tls_index* ti)
p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)_tp - TLS_TP_OFFSET
- TLS_TCB_SIZE), ti->ti_module, ti->ti_offset);
return (p + TLS_DTV_OFFSET);
return ((char*)p + TLS_DTV_OFFSET);
}

View File

@ -70,9 +70,17 @@ __FBSDID("$FreeBSD$");
#include "notes.h"
/* Types. */
typedef void (*func_ptr_type)();
typedef void (*func_ptr_type)(void);
typedef void * (*path_enum_proc) (const char *path, size_t len, void *arg);
/* Variables that cannot be static: */
extern struct r_debug r_debug; /* For GDB */
extern int _thread_autoinit_dummy_decl;
extern char* __progname;
extern void (*__cleanup)(void);
/*
* Function declarations.
*/
@ -159,7 +167,7 @@ static void unref_dag(Obj_Entry *);
static void ref_dag(Obj_Entry *);
static char *origin_subst_one(Obj_Entry *, char *, const char *,
const char *, bool);
static char *origin_subst(Obj_Entry *, char *);
static char *origin_subst(Obj_Entry *, const char *);
static bool obj_resolve_origin(Obj_Entry *obj);
static void preinit_main(void);
static int rtld_verify_versions(const Objlist *);
@ -196,8 +204,8 @@ static char *ld_library_path; /* Environment variable for search path */
static char *ld_library_dirs; /* Environment variable for library descriptors */
static char *ld_preload; /* Environment variable for libraries to
load first */
static char *ld_elf_hints_path; /* Environment variable for alternative hints path */
static char *ld_tracing; /* Called from ldd to print libs */
static const char *ld_elf_hints_path; /* Environment variable for alternative hints path */
static const char *ld_tracing; /* Called from ldd to print libs */
static char *ld_utrace; /* Use utrace() to log events. */
static struct obj_entry_q obj_list; /* Queue of all loaded objects */
static Obj_Entry *obj_main; /* The main program shared object */
@ -236,7 +244,15 @@ int _rtld_get_stack_prot(void) __exported;
int _rtld_is_dlopened(void *) __exported;
void _rtld_error(const char *, ...) __exported;
int npagesizes, osreldate;
/* Only here to fix -Wmissing-prototypes warnings */
int __getosreldate(void);
void __pthread_cxa_finalize(struct dl_phdr_info *a);
func_ptr_type _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp);
Elf_Addr _rtld_bind(Obj_Entry *obj, Elf_Size reloff);
int npagesizes;
static int osreldate;
size_t *pagesizes;
static int stack_prot = PROT_READ | PROT_WRITE | RTLD_DEFAULT_STACK_EXEC;
@ -261,20 +277,20 @@ char **main_argv;
size_t tls_last_offset; /* Static TLS offset of last module */
size_t tls_last_size; /* Static TLS size of last module */
size_t tls_static_space; /* Static TLS space allocated */
size_t tls_static_max_align;
int tls_dtv_generation = 1; /* Used to detect when dtv size changes */
static size_t tls_static_max_align;
Elf_Addr tls_dtv_generation = 1; /* Used to detect when dtv size changes */
int tls_max_index = 1; /* Largest module index allocated */
bool ld_library_path_rpath = false;
static bool ld_library_path_rpath = false;
/*
* Globals for path names, and such
*/
char *ld_elf_hints_default = _PATH_ELF_HINTS;
char *ld_path_libmap_conf = _PATH_LIBMAP_CONF;
char *ld_path_rtld = _PATH_RTLD;
char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
char *ld_env_prefix = LD_;
const char *ld_elf_hints_default = _PATH_ELF_HINTS;
const char *ld_path_libmap_conf = _PATH_LIBMAP_CONF;
const char *ld_path_rtld = _PATH_RTLD;
const char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
const char *ld_env_prefix = LD_;
/*
* Fill in a DoneList with an allocation large enough to hold all of
@ -356,7 +372,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
RtldLockState lockstate;
struct stat st;
Elf_Addr *argcp;
char **argv, *argv0, **env, **envp, *kexecpath, *library_path_rpath;
char **argv, **env, **envp, *kexecpath, *library_path_rpath;
const char *argv0;
caddr_t imgentry;
char buf[MAXPATHLEN];
int argc, fd, i, phnum, rtld_argc;
@ -692,6 +709,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
exit (0);
}
ifunc_init(aux);
/*
* Setup TLS for main thread. This must be done after the
* relocations are processed, since tls initialization section
@ -713,7 +732,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
r_debug_state(NULL, &obj_main->linkmap); /* say hello to gdb! */
map_stacks_exec(NULL);
ifunc_init(aux);
dbg("resolving ifuncs");
if (resolve_objects_ifunc(obj_main,
@ -790,11 +808,11 @@ _rtld_bind(Obj_Entry *obj, Elf_Size reloff)
if (sigsetjmp(lockstate.env, 0) != 0)
lock_upgrade(rtld_bind_lock, &lockstate);
if (obj->pltrel)
rel = (const Elf_Rel *) ((caddr_t) obj->pltrel + reloff);
rel = (const Elf_Rel *)((const char *)obj->pltrel + reloff);
else
rel = (const Elf_Rel *) ((caddr_t) obj->pltrela + reloff);
rel = (const Elf_Rel *)((const char *)obj->pltrela + reloff);
where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, SYMLOOK_IN_PLT,
NULL, &lockstate);
if (def == NULL)
@ -937,7 +955,7 @@ origin_subst_one(Obj_Entry *obj, char *real, const char *kw,
}
static char *
origin_subst(Obj_Entry *obj, char *real)
origin_subst(Obj_Entry *obj, const char *real)
{
char *res1, *res2, *res3, *res4;
@ -949,7 +967,9 @@ origin_subst(Obj_Entry *obj, char *real)
return (NULL);
}
}
res1 = origin_subst_one(obj, real, "$ORIGIN", NULL, false);
/* __DECONST is safe here since without may_free real is unchanged */
res1 = origin_subst_one(obj, __DECONST(char *, real), "$ORIGIN", NULL,
false);
res2 = origin_subst_one(NULL, res1, "$OSNAME", uts.sysname, true);
res3 = origin_subst_one(NULL, res2, "$OSREL", uts.release, true);
res4 = origin_subst_one(NULL, res3, "$PLATFORM", uts.machine, true);
@ -996,7 +1016,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
switch (dynp->d_tag) {
case DT_REL:
obj->rel = (const Elf_Rel *) (obj->relocbase + dynp->d_un.d_ptr);
obj->rel = (const Elf_Rel *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_RELSZ:
@ -1017,7 +1037,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_RELA:
obj->rela = (const Elf_Rela *) (obj->relocbase + dynp->d_un.d_ptr);
obj->rela = (const Elf_Rela *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_RELASZ:
@ -1043,7 +1063,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_STRTAB:
obj->strtab = (const char *) (obj->relocbase + dynp->d_un.d_ptr);
obj->strtab = (const char *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_STRSZ:
@ -1051,7 +1071,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_VERNEED:
obj->verneed = (const Elf_Verneed *) (obj->relocbase +
obj->verneed = (const Elf_Verneed *)(obj->relocbase +
dynp->d_un.d_val);
break;
@ -1060,7 +1080,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_VERDEF:
obj->verdef = (const Elf_Verdef *) (obj->relocbase +
obj->verdef = (const Elf_Verdef *)(obj->relocbase +
dynp->d_un.d_val);
break;
@ -1096,7 +1116,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords;
obj->maskwords_bm_gnu = nmaskwords - 1;
obj->shift2_gnu = hashtab[3];
obj->bloom_gnu = (Elf_Addr *) (hashtab + 4);
obj->bloom_gnu = (const Elf_Addr *)(hashtab + 4);
obj->buckets_gnu = hashtab + 4 + bloom_size32;
obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu -
obj->symndx_gnu;
@ -1143,7 +1163,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_PLTGOT:
obj->pltgot = (Elf_Addr *) (obj->relocbase + dynp->d_un.d_ptr);
obj->pltgot = (Elf_Addr *)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_TEXTREL:
@ -1171,7 +1191,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_INIT:
obj->init = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->init = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_PREINIT_ARRAY:
@ -1191,7 +1211,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_FINI:
obj->fini = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->fini = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
case DT_FINI_ARRAY:
@ -1211,7 +1231,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
case DT_DEBUG:
if (!early)
dbg("Filling in DT_DEBUG entry");
((Elf_Dyn*)dynp)->d_un.d_ptr = (Elf_Addr) &r_debug;
(__DECONST(Elf_Dyn *, dynp))->d_un.d_ptr = (Elf_Addr)&r_debug;
break;
#endif
@ -1245,7 +1265,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
break;
case DT_MIPS_PLTGOT:
obj->mips_pltgot = (Elf_Addr *) (obj->relocbase +
obj->mips_pltgot = (Elf_Addr *)(obj->relocbase +
dynp->d_un.d_ptr);
break;
@ -1253,7 +1273,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
#ifdef __powerpc64__
case DT_PPC64_GLINK:
obj->glink = (Elf_Addr) (obj->relocbase + dynp->d_un.d_ptr);
obj->glink = (Elf_Addr)(obj->relocbase + dynp->d_un.d_ptr);
break;
#endif
@ -1330,10 +1350,10 @@ digest_dynamic2(Obj_Entry *obj, const Elf_Dyn *dyn_rpath,
rtld_die();
if (dyn_runpath != NULL) {
obj->runpath = (char *)obj->strtab + dyn_runpath->d_un.d_val;
obj->runpath = (const char *)obj->strtab + dyn_runpath->d_un.d_val;
obj->runpath = origin_subst(obj, obj->runpath);
} else if (dyn_rpath != NULL) {
obj->rpath = (char *)obj->strtab + dyn_rpath->d_un.d_val;
obj->rpath = (const char *)obj->strtab + dyn_rpath->d_un.d_val;
obj->rpath = origin_subst(obj, obj->rpath);
}
if (dyn_soname != NULL)
@ -1373,7 +1393,7 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
obj->phdr = phdr;
obj->phsize = ph->p_memsz;
obj->relocbase = (caddr_t)phdr - ph->p_vaddr;
obj->relocbase = __DECONST(char *, phdr) - ph->p_vaddr;
break;
}
@ -1390,8 +1410,6 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
if (nsegs == 0) { /* First load segment */
obj->vaddrbase = trunc_page(ph->p_vaddr);
obj->mapbase = obj->vaddrbase + obj->relocbase;
obj->textsize = round_page(ph->p_vaddr + ph->p_memsz) -
obj->vaddrbase;
} else { /* Last load segment */
obj->mapsize = round_page(ph->p_vaddr + ph->p_memsz) -
obj->vaddrbase;
@ -1577,14 +1595,15 @@ gnu_hash(const char *s)
static char *
find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
{
char *name, *pathname, *refobj_path;
char *pathname, *refobj_path;
const char *name;
bool nodeflib, objgiven;
objgiven = refobj != NULL;
if (libmap_disable || !objgiven ||
(name = lm_find(refobj->path, xname)) == NULL)
name = (char *)xname;
name = xname;
if (strchr(name, '/') != NULL) { /* Hard coded pathname */
if (name[0] != '/' && !trust) {
@ -1773,7 +1792,8 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
static const char *
gethints(bool nostdlib)
{
static char *hints, *filtered_path;
static char *filtered_path;
static const char *hints;
static struct elfhints_hdr hdr;
struct fill_search_info_args sargs, hargs;
struct dl_serinfo smeta, hmeta, *SLPinfo, *hintinfo;
@ -2509,7 +2529,7 @@ obj_from_addr(const void *addr)
continue;
if (addr < (void *) obj->mapbase)
continue;
if (addr < (void *) (obj->mapbase + obj->mapsize))
if (addr < (void *)(obj->mapbase + obj->mapsize))
return obj;
}
return NULL;
@ -3206,12 +3226,12 @@ dlerror(void)
*/
void
dllockinit(void *context,
void *(*lock_create)(void *context),
void (*rlock_acquire)(void *lock),
void (*wlock_acquire)(void *lock),
void (*lock_release)(void *lock),
void (*lock_destroy)(void *lock),
void (*context_destroy)(void *context))
void *(*_lock_create)(void *context) __unused,
void (*_rlock_acquire)(void *lock) __unused,
void (*_wlock_acquire)(void *lock) __unused,
void (*_lock_release)(void *lock) __unused,
void (*_lock_destroy)(void *lock) __unused,
void (*context_destroy)(void *context))
{
static void *cur_context;
static void (*cur_context_destroy)(void *);
@ -3249,7 +3269,7 @@ rtld_dlopen(const char *name, int fd, int mode)
rlock_acquire(rtld_bind_lock, &lockstate);
if (sigsetjmp(lockstate.env, 0) != 0)
lock_upgrade(rtld_bind_lock, &lockstate);
environ = (char **)*get_program_var_addr("environ", &lockstate);
environ = __DECONST(char **, *get_program_var_addr("environ", &lockstate));
lock_release(rtld_bind_lock, &lockstate);
}
lo_flags = RTLD_LO_DLOPEN;
@ -3962,7 +3982,7 @@ linkmap_delete(Obj_Entry *obj)
* +0 RetAddr
*/
void
r_debug_state(struct r_debug* rd, struct link_map *m)
r_debug_state(struct r_debug* rd __unused, struct link_map *m __unused)
{
/*
* The following is a hack to force the compiler to emit calls to
@ -3980,7 +4000,7 @@ r_debug_state(struct r_debug* rd, struct link_map *m)
* main is not available in the symbol table.
*/
void
_r_debug_postinit(struct link_map *m)
_r_debug_postinit(struct link_map *m __unused)
{
/* See r_debug_state(). */
@ -4301,8 +4321,8 @@ matched_symbol(SymLook *req, const Obj_Entry *obj, Sym_Match_Result *result,
else if (((req->flags & SYMLOOK_IN_PLT) == 0) &&
(ELF_ST_TYPE(symp->st_info) == STT_FUNC))
break;
/* fallthrough */
#endif
/* fallthrough */
default:
return (false);
}
@ -4471,8 +4491,8 @@ symlook_obj1_gnu(SymLook *req, const Obj_Entry *obj)
static void
trace_loaded_objects(Obj_Entry *obj)
{
char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
const char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
main_local = "";
@ -4486,9 +4506,9 @@ trace_loaded_objects(Obj_Entry *obj)
list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL"));
for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
Needed_Entry *needed;
char *name, *path;
bool is_lib;
Needed_Entry *needed;
const char *name, *path;
bool is_lib;
if (obj->marker)
continue;
@ -4503,7 +4523,7 @@ trace_loaded_objects(Obj_Entry *obj)
} else
path = "not found";
name = (char *)obj->strtab + needed->name;
name = obj->strtab + needed->name;
is_lib = strncmp(name, "lib", 3) == 0; /* XXX - bogus */
fmt = is_lib ? fmt1 : fmt2;
@ -4743,7 +4763,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
char *tls_block;
Elf_Addr *dtv, **tcb;
Elf_Addr addr;
int i;
Elf_Addr i;
size_t extra_size, maxalign, post_size, pre_size, tls_block_size;
size_t tls_init_align;
@ -4791,7 +4811,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
if (obj->tlsinitsize > 0)
memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
if (obj->tlssize > obj->tlsinitsize)
memset((void*) (addr + obj->tlsinitsize), 0,
memset((void*)(addr + obj->tlsinitsize), 0,
obj->tlssize - obj->tlsinitsize);
dtv[obj->tlsindex + 1] = addr;
}
@ -4802,7 +4822,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
}
void
free_tls(void *tcb, size_t tcbsize, size_t tcbalign)
free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
{
Elf_Addr *dtv;
Elf_Addr tlsstart, tlsend;
@ -4844,7 +4864,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
char *tls;
Elf_Addr *dtv, *olddtv;
Elf_Addr segbase, oldsegbase, addr;
int i;
size_t i;
ralign = tcbalign;
if (tls_static_max_align > ralign)
@ -4893,7 +4913,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
if (obj->marker || obj->tlsoffset == 0)
continue;
addr = segbase - obj->tlsoffset;
memset((void*) (addr + obj->tlsinitsize),
memset((void*)(addr + obj->tlsinitsize),
0, obj->tlssize - obj->tlsinitsize);
if (obj->tlsinit)
memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
@ -4905,7 +4925,7 @@ allocate_tls(Obj_Entry *objs, void *oldtls, size_t tcbsize, size_t tcbalign)
}
void
free_tls(void *tls, size_t tcbsize, size_t tcbalign)
free_tls(void *tls, size_t tcbsize __unused, size_t tcbalign)
{
Elf_Addr* dtv;
size_t size, ralign;
@ -5121,13 +5141,13 @@ check_object_provided_version(Obj_Entry *refobj, const Obj_Entry *depobj,
}
if (vna->vna_hash == vd->vd_hash) {
const Elf_Verdaux *aux = (const Elf_Verdaux *)
((char *)vd + vd->vd_aux);
((const char *)vd + vd->vd_aux);
if (strcmp(vername, depobj->strtab + aux->vda_name) == 0)
return (0);
}
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
if (vna->vna_flags & VER_FLG_WEAK)
return (0);
@ -5163,18 +5183,18 @@ rtld_verify_object_versions(Obj_Entry *obj)
obj->path, vn->vn_version);
return (-1);
}
vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux);
vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
for (;;) {
vernum = VER_NEED_IDX(vna->vna_other);
if (vernum > maxvernum)
maxvernum = vernum;
if (vna->vna_next == 0)
break;
vna = (const Elf_Vernaux *) ((char *)vna + vna->vna_next);
vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next);
}
if (vn->vn_next == 0)
break;
vn = (const Elf_Verneed *) ((char *)vn + vn->vn_next);
vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next);
}
vd = obj->verdef;
@ -5189,7 +5209,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
maxvernum = vernum;
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
if (maxvernum == 0)
@ -5208,7 +5228,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
if ((vd->vd_flags & VER_FLG_BASE) == 0) {
vernum = VER_DEF_IDX(vd->vd_ndx);
assert(vernum <= maxvernum);
vda = (const Elf_Verdaux *)((char *)vd + vd->vd_aux);
vda = (const Elf_Verdaux *)((const char *)vd + vd->vd_aux);
obj->vertab[vernum].hash = vd->vd_hash;
obj->vertab[vernum].name = obj->strtab + vda->vda_name;
obj->vertab[vernum].file = NULL;
@ -5216,7 +5236,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
}
if (vd->vd_next == 0)
break;
vd = (const Elf_Verdef *) ((char *)vd + vd->vd_next);
vd = (const Elf_Verdef *)((const char *)vd + vd->vd_next);
}
vn = obj->verneed;
@ -5224,7 +5244,7 @@ rtld_verify_object_versions(Obj_Entry *obj)
depobj = locate_dependency(obj, obj->strtab + vn->vn_file);
if (depobj == NULL)
return (-1);
vna = (const Elf_Vernaux *) ((char *)vn + vn->vn_aux);
vna = (const Elf_Vernaux *)((const char *)vn + vn->vn_aux);
for (;;) {
if (check_object_provided_version(obj, depobj, vna))
return (-1);
@ -5237,11 +5257,11 @@ rtld_verify_object_versions(Obj_Entry *obj)
VER_INFO_HIDDEN : 0;
if (vna->vna_next == 0)
break;
vna = (const Elf_Vernaux *) ((char *)vna + vna->vna_next);
vna = (const Elf_Vernaux *)((const char *)vna + vna->vna_next);
}
if (vn->vn_next == 0)
break;
vn = (const Elf_Verneed *) ((char *)vn + vn->vn_next);
vn = (const Elf_Verneed *)((const char *)vn + vn->vn_next);
}
return 0;
}
@ -5568,7 +5588,7 @@ int _thread_autoinit_dummy_decl = 1;
* No unresolved symbols for rtld.
*/
void
__pthread_cxa_finalize(struct dl_phdr_info *a)
__pthread_cxa_finalize(struct dl_phdr_info *a __unused)
{
}

View File

@ -54,7 +54,7 @@ typedef unsigned char bool;
extern size_t tls_last_offset;
extern size_t tls_last_size;
extern size_t tls_static_space;
extern int tls_dtv_generation;
extern Elf_Addr tls_dtv_generation;
extern int tls_max_index;
extern int npagesizes;
@ -151,7 +151,6 @@ typedef struct Struct_Obj_Entry {
/* These items are computed by map_object() or by digest_phdr(). */
caddr_t mapbase; /* Base address of mapped region */
size_t mapsize; /* Size of mapped region in bytes */
size_t textsize; /* Size of text segment in bytes */
Elf_Addr vaddrbase; /* Base address in shared object file */
caddr_t relocbase; /* Relocation constant = mapbase - vaddrbase */
const Elf_Dyn *dynamic; /* Dynamic section */
@ -211,12 +210,12 @@ typedef struct Struct_Obj_Entry {
Elf32_Word maskwords_bm_gnu; /* Bloom filter words - 1 (bitmask) */
Elf32_Word shift2_gnu; /* Bloom filter shift count */
Elf32_Word dynsymcount; /* Total entries in dynsym table */
Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */
const Elf_Addr *bloom_gnu; /* Bloom filter used by GNU hash func */
const Elf_Hashelt *buckets_gnu; /* GNU hash table bucket array */
const Elf_Hashelt *chain_zero_gnu; /* GNU hash table value array (Zeroed) */
char *rpath; /* Search path specified in object */
char *runpath; /* Search path with different priority */
const char *rpath; /* Search path specified in object */
const char *runpath; /* Search path with different priority */
Needed_Entry *needed; /* Shared objects needed by this one (%) */
Needed_Entry *needed_filtees;
Needed_Entry *needed_aux_filtees;

View File

@ -184,7 +184,7 @@ thread_mask_clear(int mask)
}
#define RTLD_LOCK_CNT 3
struct rtld_lock {
static struct rtld_lock {
void *handle;
int mask;
} rtld_locks[RTLD_LOCK_CNT];

View File

@ -187,6 +187,7 @@ reswitch: switch (ch = (u_char)*fmt++) {
padc = '0';
goto reswitch;
}
/* FALLTHROUGH */
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
for (n = 0;; ++fmt) {
@ -324,6 +325,7 @@ reswitch: switch (ch = (u_char)*fmt++) {
goto handle_nosign;
case 'X':
upper = 1;
/* FALLTHROUGH */
case 'x':
base = 16;
goto handle_nosign;

View File

@ -256,7 +256,7 @@ do_copy_relocations(Obj_Entry *dstobj)
assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
relalim = (const Elf_Rela *)((caddr_t)dstobj->rela + dstobj->relasize);
relalim = (const Elf_Rela *)((const char *)dstobj->rela + dstobj->relasize);
for (rela = dstobj->rela; rela < relalim; rela++) {
if (ELF_R_TYPE(rela->r_info) == R_SPARC_COPY) {
dstaddr = (void *)(dstobj->relocbase + rela->r_offset);
@ -316,7 +316,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
} else
cache = NULL;
relalim = (const Elf_Rela *)((caddr_t)obj->rela + obj->relasize);
relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize);
for (rela = obj->rela; rela < relalim; rela++) {
if (reloc_nonplt_object(obj, rela, cache, flags, lockstate) < 0)
goto done;
@ -408,8 +408,8 @@ reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache,
* of) static TLS in dynamically loaded modules. If
* we run out of space, we generate an error.
*/
if (!defobj->tls_done &&
!allocate_tls_offset((Obj_Entry*)defobj)) {
if (!defobj->tls_done && !allocate_tls_offset(
__DECONST(Obj_Entry *, defobj))) {
_rtld_error("%s: No space available for "
"static Thread Local Storage", obj->path);
return (-1);
@ -487,7 +487,7 @@ reloc_nonplt_object(Obj_Entry *obj, const Elf_Rela *rela, SymCache *cache,
}
int
reloc_plt(Obj_Entry *obj)
reloc_plt(Obj_Entry *obj __unused)
{
#if 0
const Obj_Entry *defobj;
@ -542,7 +542,8 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
Elf_Addr *where;
Elf_Addr target;
relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
relalim = (const Elf_Rela *)((const char *)obj->pltrela +
obj->pltrelasize);
for (rela = obj->pltrela; rela < relalim; rela++) {
assert(ELF64_R_TYPE_ID(rela->r_info) == R_SPARC_JMP_SLOT);
where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
@ -551,14 +552,16 @@ reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
if (def == NULL)
return -1;
target = (Elf_Addr)(defobj->relocbase + def->st_value);
reloc_jmpslot(where, target, defobj, obj, (Elf_Rel *)rela);
reloc_jmpslot(where, target, defobj, obj,
(const Elf_Rel *)rela);
}
obj->jmpslots_done = true;
return (0);
}
int
reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
reloc_iresolve(Obj_Entry *obj __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -566,8 +569,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
reloc_gnu_ifunc(Obj_Entry *obj, int flags,
struct Struct_RtldLockState *lockstate)
reloc_gnu_ifunc(Obj_Entry *obj __unused, int flags __unused,
struct Struct_RtldLockState *lockstate __unused)
{
/* XXX not implemented */
@ -575,7 +578,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flags,
}
Elf_Addr
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj __unused,
const Obj_Entry *refobj, const Elf_Rel *rel)
{
const Elf_Rela *rela = (const Elf_Rela *)rel;
@ -612,7 +615,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
*/
where = (Elf_Word *)wherep;
offset = ((Elf_Addr)where) - target;
if (offset <= (1L<<20) && offset >= -(1L<<20)) {
if (offset <= (1UL<<20) && offset >= -(1UL<<20)) {
/*
* We're within 1MB -- we can use a direct branch
* instruction.
@ -631,7 +634,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
*/
where[1] = BAA | ((offset >> 2) &0x3fffff);
flush(where, 4);
} else if (target >= 0 && target < (1L<<32)) {
} else if (target < (1UL<<32)) {
/*
* We're within 32-bits of address zero.
*
@ -651,7 +654,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(target, 10);
flush(where, 4);
} else if (target <= 0 && target > -(1L<<32)) {
} else if (target > -(1UL<<32)) {
/*
* We're within 32-bits of address -1.
*
@ -673,7 +676,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(~target, 10);
flush(where, 4);
} else if (offset <= (1L<<32) && offset >= -((1L<<32) - 4)) {
} else if (offset <= (1UL<<32) && offset >= -((1UL<<32) - 4)) {
/*
* We're within 32-bits -- we can use a direct call
* insn
@ -696,7 +699,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = MOV71;
flush(where, 4);
} else if (offset >= 0 && offset < (1L<<44)) {
} else if (offset < (1L<<44)) {
/*
* We're within 44 bits. We can generate this
* pattern:
@ -721,7 +724,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *obj,
flush(where, 8);
where[1] = SETHI | HIVAL(offset, 22);
flush(where, 4);
} else if (offset < 0 && offset > -(1L<<44)) {
} else if (offset > -(1UL<<44)) {
/*
* We're within 44 bits. We can generate this
* pattern:

View File

@ -174,6 +174,7 @@ reldoc:
cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \
env MAN4DIR=${WORLDDIR}/share/man/man4 \
SVN=${SVN} \
_BRANCH=${BRANCH} \
${MAKE} all install clean "FORMATS=html txt" \
INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \
WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc

View File

@ -287,9 +287,9 @@ extra_chroot_setup() {
PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
PBUILD_FLAGS="${PBUILD_FLAGS} WRKDIRPREFIX=/tmp/ports"
PBUILD_FLAGS="${PBUILD_FLAGS} DISTDIR=/tmp/distfiles"
chroot ${CHROOTDIR} env ${PBUILD_FLAGS} make -C \
chroot ${CHROOTDIR} env ${PBUILD_FLAGS} \
OPTIONS_UNSET="AVAHI FOP IGOR" make -C \
/usr/ports/textproc/docproj \
OPTIONS_UNSET="FOP IGOR" \
FORCE_PKG_REGISTER=1 \
install clean distclean
fi

View File

@ -116,6 +116,7 @@ CRUNCH_PROGS_sbin+= routed rtquery
.endif
.if ${MK_ZFS} != "no"
CRUNCH_PROGS_sbin+= bectl
CRUNCH_PROGS_sbin+= zfs
CRUNCH_PROGS_sbin+= zpool
CRUNCH_PROGS_usr.sbin+= zdb
@ -127,6 +128,7 @@ CRUNCH_PROGS_usr.sbin+= zdb
CRUNCH_LIBS+= -l80211 -lalias -lcam -lncursesw -ldevstat -lipsec -llzma
.if ${MK_ZFS} != "no"
CRUNCH_LIBS+= -lavl -lzpool -lzfs_core -lzfs -lnvpair -lpthread -luutil -lumem
CRUNCH_LIBS+= -lbe
.else
# liblzma needs pthread
CRUNCH_LIBS+= -lpthread

Some files were not shown because too many files have changed in this diff Show More