svn commit: r339383 - in projects/power8_bringup_hacks: . contrib/elftoolchain/elfcopy lib/csu/aarch64 lib/csu/amd64 lib/csu/arm lib/csu/common lib/csu/i386 lib/csu/mips lib/csu/powerpc lib/csu/pow...

Leandro Lupori luporl at FreeBSD.org
Tue Oct 16 16:45:27 UTC 2018


Author: luporl
Date: Tue Oct 16 16:45:21 2018
New Revision: 339383
URL: https://svnweb.freebsd.org/changeset/base/339383

Log:
  Merge power8_bringup_hacks with HEAD.

Added:
  projects/power8_bringup_hacks/lib/csu/amd64/reloc.c
     - copied unchanged from r339382, head/lib/csu/amd64/reloc.c
  projects/power8_bringup_hacks/lib/csu/i386/reloc.c
     - copied unchanged from r339382, head/lib/csu/i386/reloc.c
  projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c
     - copied unchanged from r339382, head/lib/libc/amd64/string/bcopy.c
  projects/power8_bringup_hacks/share/man/man4/iavf.4
     - copied unchanged from r339382, head/share/man/man4/iavf.4
  projects/power8_bringup_hacks/sys/dev/ixl/iavf.h
     - copied unchanged from r339382, head/sys/dev/ixl/iavf.h
  projects/power8_bringup_hacks/sys/dev/ixl/iavf_vc.c
     - copied unchanged from r339382, head/sys/dev/ixl/iavf_vc.c
  projects/power8_bringup_hacks/sys/dev/ixl/if_iavf.c
     - copied unchanged from r339382, head/sys/dev/ixl/if_iavf.c
  projects/power8_bringup_hacks/sys/dev/uart/uart_dev_lowrisc.c
     - copied unchanged from r339382, head/sys/dev/uart/uart_dev_lowrisc.c
  projects/power8_bringup_hacks/sys/dev/uart/uart_dev_lowrisc.h
     - copied unchanged from r339382, head/sys/dev/uart/uart_dev_lowrisc.h
  projects/power8_bringup_hacks/sys/kern/subr_early.c
     - copied unchanged from r339382, head/sys/kern/subr_early.c
  projects/power8_bringup_hacks/sys/modules/iavf/
     - copied from r339382, head/sys/modules/iavf/
Deleted:
  projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.S
  projects/power8_bringup_hacks/share/man/man4/ixlv.4
  projects/power8_bringup_hacks/sys/dev/ixl/README
  projects/power8_bringup_hacks/sys/dev/ixl/if_ixlv.c
  projects/power8_bringup_hacks/sys/dev/ixl/ixlv.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixlv_vc_mgr.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixlvc.c
  projects/power8_bringup_hacks/sys/modules/ixlv/
Modified:
  projects/power8_bringup_hacks/Makefile.inc1
  projects/power8_bringup_hacks/ObsoleteFiles.inc
  projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c
  projects/power8_bringup_hacks/lib/csu/aarch64/Makefile
  projects/power8_bringup_hacks/lib/csu/amd64/Makefile
  projects/power8_bringup_hacks/lib/csu/amd64/crt1.c
  projects/power8_bringup_hacks/lib/csu/arm/Makefile
  projects/power8_bringup_hacks/lib/csu/common/ignore_init.c
  projects/power8_bringup_hacks/lib/csu/i386/Makefile
  projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c
  projects/power8_bringup_hacks/lib/csu/mips/Makefile
  projects/power8_bringup_hacks/lib/csu/powerpc/Makefile
  projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile
  projects/power8_bringup_hacks/lib/csu/riscv/Makefile
  projects/power8_bringup_hacks/lib/csu/sparc64/Makefile
  projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc
  projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S
  projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S
  projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3
  projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c
  projects/power8_bringup_hacks/lib/libc/net/nslexer.l
  projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c
  projects/power8_bringup_hacks/lib/libc/string/memmem.c
  projects/power8_bringup_hacks/lib/libc/sys/pdfork.2
  projects/power8_bringup_hacks/lib/libc/sys/sendfile.2
  projects/power8_bringup_hacks/lib/libldns/Makefile
  projects/power8_bringup_hacks/lib/libmemstat/memstat_malloc.c
  projects/power8_bringup_hacks/share/man/man4/Makefile
  projects/power8_bringup_hacks/share/man/man4/dtrace_ip.4
  projects/power8_bringup_hacks/share/man/man4/ixl.4
  projects/power8_bringup_hacks/share/man/man4/procdesc.4
  projects/power8_bringup_hacks/share/man/man9/MODULE_PNP_INFO.9
  projects/power8_bringup_hacks/share/mk/src.libnames.mk
  projects/power8_bringup_hacks/stand/efi/loader/main.c
  projects/power8_bringup_hacks/sys/amd64/amd64/machdep.c
  projects/power8_bringup_hacks/sys/amd64/amd64/support.S
  projects/power8_bringup_hacks/sys/amd64/amd64/trap.c
  projects/power8_bringup_hacks/sys/amd64/amd64/vm_machdep.c
  projects/power8_bringup_hacks/sys/amd64/conf/GENERIC
  projects/power8_bringup_hacks/sys/amd64/conf/NOTES
  projects/power8_bringup_hacks/sys/amd64/include/cpu.h
  projects/power8_bringup_hacks/sys/amd64/include/proc.h
  projects/power8_bringup_hacks/sys/amd64/vmm/amd/svm.c
  projects/power8_bringup_hacks/sys/amd64/vmm/vmm_instruction_emul.c
  projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c
  projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
  projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
  projects/power8_bringup_hacks/sys/cddl/dev/fbt/riscv/fbt_isa.c
  projects/power8_bringup_hacks/sys/compat/freebsd32/syscalls.master
  projects/power8_bringup_hacks/sys/conf/files
  projects/power8_bringup_hacks/sys/conf/files.amd64
  projects/power8_bringup_hacks/sys/conf/files.riscv
  projects/power8_bringup_hacks/sys/conf/newvers.sh
  projects/power8_bringup_hacks/sys/contrib/ck/src/ck_epoch.c
  projects/power8_bringup_hacks/sys/dev/bxe/bxe.c
  projects/power8_bringup_hacks/sys/dev/bxe/bxe.h
  projects/power8_bringup_hacks/sys/dev/bxe/bxe_stats.c
  projects/power8_bringup_hacks/sys/dev/cxgbe/t4_sge.c
  projects/power8_bringup_hacks/sys/dev/e1000/em_txrx.c
  projects/power8_bringup_hacks/sys/dev/e1000/igb_txrx.c
  projects/power8_bringup_hacks/sys/dev/ixgbe/if_ix.c
  projects/power8_bringup_hacks/sys/dev/ixgbe/if_ixv.c
  projects/power8_bringup_hacks/sys/dev/ixgbe/ix_txrx.c
  projects/power8_bringup_hacks/sys/dev/ixl/i40e_osdep.c
  projects/power8_bringup_hacks/sys/dev/ixl/if_ixl.c
  projects/power8_bringup_hacks/sys/dev/ixl/ixl.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_debug.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_iov.c
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_iov.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_main.c
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_qmgr.c
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_pf_qmgr.h
  projects/power8_bringup_hacks/sys/dev/ixl/ixl_txrx.c
  projects/power8_bringup_hacks/sys/kern/kern_descrip.c
  projects/power8_bringup_hacks/sys/kern/kern_sendfile.c
  projects/power8_bringup_hacks/sys/kern/link_elf.c
  projects/power8_bringup_hacks/sys/kern/sys_capability.c
  projects/power8_bringup_hacks/sys/kern/syscalls.master
  projects/power8_bringup_hacks/sys/modules/Makefile
  projects/power8_bringup_hacks/sys/modules/ixl/Makefile
  projects/power8_bringup_hacks/sys/net/if_vlan.c
  projects/power8_bringup_hacks/sys/net/iflib.c
  projects/power8_bringup_hacks/sys/net/iflib.h
  projects/power8_bringup_hacks/sys/net/iflib_private.h
  projects/power8_bringup_hacks/sys/netinet/tcp_reass.c
  projects/power8_bringup_hacks/sys/netinet/udp_usrreq.c
  projects/power8_bringup_hacks/sys/netpfil/ipfw/ip_fw2.c
  projects/power8_bringup_hacks/sys/riscv/conf/GENERIC
  projects/power8_bringup_hacks/sys/riscv/include/cpufunc.h
  projects/power8_bringup_hacks/sys/riscv/include/kdb.h
  projects/power8_bringup_hacks/sys/riscv/include/sbi.h
  projects/power8_bringup_hacks/sys/riscv/riscv/cpufunc_asm.S
  projects/power8_bringup_hacks/sys/riscv/riscv/db_interface.c
  projects/power8_bringup_hacks/sys/riscv/riscv/mp_machdep.c
  projects/power8_bringup_hacks/sys/riscv/riscv/plic.c
  projects/power8_bringup_hacks/sys/riscv/riscv/pmap.c
  projects/power8_bringup_hacks/sys/sys/capsicum.h
  projects/power8_bringup_hacks/sys/sys/systm.h
  projects/power8_bringup_hacks/sys/x86/x86/ucode.c
  projects/power8_bringup_hacks/sys/x86/xen/pv.c
  projects/power8_bringup_hacks/usr.sbin/mfiutil/mfi_cmd.c
  projects/power8_bringup_hacks/usr.sbin/pw/pw.c
  projects/power8_bringup_hacks/usr.sbin/pw/pw.h
  projects/power8_bringup_hacks/usr.sbin/pw/pw_conf.c
  projects/power8_bringup_hacks/usr.sbin/pw/pw_utils.c
Directory Properties:
  projects/power8_bringup_hacks/   (props changed)
  projects/power8_bringup_hacks/contrib/elftoolchain/   (props changed)
  projects/power8_bringup_hacks/sys/cddl/contrib/opensolaris/   (props changed)
  projects/power8_bringup_hacks/sys/contrib/ck/   (props changed)

Modified: projects/power8_bringup_hacks/Makefile.inc1
==============================================================================
--- projects/power8_bringup_hacks/Makefile.inc1	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/Makefile.inc1	Tue Oct 16 16:45:21 2018	(r339383)
@@ -939,6 +939,15 @@ _cleanobj_fast_depend_hack: .PHONY
 		    ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
 	fi
 .endfor
+# 20181013  r339348  bcopy reimplemented as .c
+.for f in bcopy memcpy memmove
+	@if [ -e "${OBJTOP}/lib/libc/.depend.${f}.o" ] && \
+	    egrep -qw 'bcopy\.[sS]' ${OBJTOP}/lib/libc/.depend.${f}.o; then \
+		echo "Removing stale dependencies for bcopy"; \
+		rm -f ${OBJTOP}/lib/libc/.depend.${f}.* \
+		   ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/lib/libc/.depend.${f}.*}; \
+	fi
+.endfor
 # 20181009 track migration from ntp's embedded libevent to updated one
 	@if [ -e "${OBJTOP}/usr.sbin/ntp/libntpevent/.depend.bufferevent_openssl.o" ] && \
 	    egrep -q 'contrib/ntp/sntp/libevent/bufferevent_openssl.c' \
@@ -2534,8 +2543,8 @@ _prebuild_libs=	${_kerberos5_lib_libasn1} \
 		${_cddl_lib_libctf} \
 		lib/libufs \
 		lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
-		${_secure_lib_libcrypto} ${_lib_libldns} \
-		${_secure_lib_libssh} ${_secure_lib_libssl}
+		${_secure_lib_libcrypto} ${_secure_lib_libssl} \
+		${_lib_libldns} ${_secure_lib_libssh}
 
 .if ${MK_GNUCXX} != "no"
 _prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
@@ -2631,9 +2640,10 @@ lib/librtld_db__L: lib/libprocstat__L
 _secure_lib_libcrypto= secure/lib/libcrypto
 _secure_lib_libssl= secure/lib/libssl
 lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L
+secure/lib/libcrypto__L: lib/libthr__L
 .if ${MK_LDNS} != "no"
 _lib_libldns= lib/libldns
-lib/libldns__L: secure/lib/libcrypto__L
+lib/libldns__L: secure/lib/libssl__L
 .endif
 .if ${MK_OPENSSH} != "no"
 _secure_lib_libssh= secure/lib/libssh

Modified: projects/power8_bringup_hacks/ObsoleteFiles.inc
==============================================================================
--- projects/power8_bringup_hacks/ObsoleteFiles.inc	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/ObsoleteFiles.inc	Tue Oct 16 16:45:21 2018	(r339383)
@@ -38,6 +38,19 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20181015: Stale libcasper(3) files following 20181009: OpenSSL 1.1.1
+OLD_LIBS+=lib/casper/libcap_sysctl.so.0
+OLD_LIBS+=lib/casper/libcap_grp.so.0
+OLD_LIBS+=lib/casper/libcap_pwd.so.0
+OLD_LIBS+=lib/casper/libcap_random.so.0
+OLD_LIBS+=lib/casper/libcap_dns.so.0
+OLD_LIBS+=lib/casper/libcap_syslog.so.0
+OLD_LIBS+=usr/lib32/libcap_sysctl.so.0
+OLD_LIBS+=usr/lib32/libcap_grp.so.0
+OLD_LIBS+=usr/lib32/libcap_pwd.so.0
+OLD_LIBS+=usr/lib32/libcap_random.so.0
+OLD_LIBS+=usr/lib32/libcap_dns.so.0
+OLD_LIBS+=usr/lib32/libcap_syslog.so.0
 # 20181009: OpenSSL 1.1.1
 OLD_FILES+=usr/include/openssl/des_old.h
 OLD_FILES+=usr/include/openssl/dso.h

Modified: projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c
==============================================================================
--- projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/contrib/elftoolchain/elfcopy/sections.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -39,7 +39,6 @@ ELFTC_VCSID("$Id: sections.c 3443 2016-04-15 18:57:54Z
 static void	add_gnu_debuglink(struct elfcopy *ecp);
 static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
 static void	check_section_rename(struct elfcopy *ecp, struct section *s);
-static void	filter_reloc(struct elfcopy *ecp, struct section *s);
 static int	get_section_flags(struct elfcopy *ecp, const char *name);
 static void	insert_sections(struct elfcopy *ecp);
 static void	insert_to_strtab(struct section *t, const char *s);
@@ -574,14 +573,6 @@ copy_content(struct elfcopy *ecp)
 			continue;
 
 		/*
-		 * If strip action is STRIP_ALL, relocation info need
-		 * to be stripped. Skip filtering otherwisw.
-		 */
-		if (ecp->strip == STRIP_ALL &&
-		    (s->type == SHT_REL || s->type == SHT_RELA))
-			filter_reloc(ecp, s);
-
-		/*
 		 * The section indices in the SHT_GROUP section needs
 		 * to be updated since we might have stripped some
 		 * sections and changed section numbering.
@@ -670,125 +661,6 @@ update_section_group(struct elfcopy *ecp, struct secti
 			s->sz -= 4;
 	}
 
-	s->nocopy = 1;
-}
-
-/*
- * Filter relocation entries, only keep those entries whose
- * symbol is in the keep list.
- */
-static void
-filter_reloc(struct elfcopy *ecp, struct section *s)
-{
-	const char	*name;
-	GElf_Shdr	 ish;
-	GElf_Rel	 rel;
-	GElf_Rela	 rela;
-	Elf32_Rel	*rel32;
-	Elf64_Rel	*rel64;
-	Elf32_Rela	*rela32;
-	Elf64_Rela	*rela64;
-	Elf_Data	*id;
-	uint64_t	 cap, n, nrels;
-	int		 elferr, i;
-
-	if (gelf_getshdr(s->is, &ish) == NULL)
-		errx(EXIT_FAILURE, "gelf_getehdr() failed: %s",
-		    elf_errmsg(-1));
-
-	/* We don't want to touch relocation info for dynamic symbols. */
-	if ((ecp->flags & SYMTAB_EXIST) == 0) {
-		if (ish.sh_link == 0 || ecp->secndx[ish.sh_link] == 0) {
-			/*
-			 * This reloc section applies to the symbol table
-			 * that was stripped, so discard whole section.
-			 */
-			s->nocopy = 1;
-			s->sz = 0;
-		}
-		return;
-	} else {
-		/* Symbol table exist, check if index equals. */
-		if (ish.sh_link != elf_ndxscn(ecp->symtab->is))
-			return;
-	}
-
-#define	COPYREL(REL, SZ) do {					\
-	if (nrels == 0) {					\
-		if ((REL##SZ = malloc(cap *			\
-		    sizeof(*REL##SZ))) == NULL)			\
-			err(EXIT_FAILURE, "malloc failed");	\
-	}							\
-	if (nrels >= cap) {					\
-		cap *= 2;					\
-		if ((REL##SZ = realloc(REL##SZ, cap *		\
-		    sizeof(*REL##SZ))) == NULL)			\
-			err(EXIT_FAILURE, "realloc failed");	\
-	}							\
-	REL##SZ[nrels].r_offset = REL.r_offset;			\
-	REL##SZ[nrels].r_info	= REL.r_info;			\
-	if (s->type == SHT_RELA)				\
-		rela##SZ[nrels].r_addend = rela.r_addend;	\
-	nrels++;						\
-} while (0)
-
-	nrels = 0;
-	cap = 4;		/* keep list is usually small. */
-	rel32 = NULL;
-	rel64 = NULL;
-	rela32 = NULL;
-	rela64 = NULL;
-	if ((id = elf_getdata(s->is, NULL)) == NULL)
-		errx(EXIT_FAILURE, "elf_getdata() failed: %s",
-		    elf_errmsg(-1));
-	n = ish.sh_size / ish.sh_entsize;
-	for(i = 0; (uint64_t)i < n; i++) {
-		if (s->type == SHT_REL) {
-			if (gelf_getrel(id, i, &rel) != &rel)
-				errx(EXIT_FAILURE, "gelf_getrel failed: %s",
-				    elf_errmsg(-1));
-		} else {
-			if (gelf_getrela(id, i, &rela) != &rela)
-				errx(EXIT_FAILURE, "gelf_getrel failed: %s",
-				    elf_errmsg(-1));
-		}
-		name = elf_strptr(ecp->ein, elf_ndxscn(ecp->strtab->is),
-		    GELF_R_SYM(rel.r_info));
-		if (name == NULL)
-			errx(EXIT_FAILURE, "elf_strptr failed: %s",
-			    elf_errmsg(-1));
-		if (lookup_symop_list(ecp, name, SYMOP_KEEP) != NULL) {
-			if (ecp->oec == ELFCLASS32) {
-				if (s->type == SHT_REL)
-					COPYREL(rel, 32);
-				else
-					COPYREL(rela, 32);
-			} else {
-				if (s->type == SHT_REL)
-					COPYREL(rel, 64);
-				else
-					COPYREL(rela, 64);
-			}
-		}
-	}
-	elferr = elf_errno();
-	if (elferr != 0)
-		errx(EXIT_FAILURE, "elf_getdata() failed: %s",
-		    elf_errmsg(elferr));
-
-	if (ecp->oec == ELFCLASS32) {
-		if (s->type == SHT_REL)
-			s->buf = rel32;
-		else
-			s->buf = rela32;
-	} else {
-		if (s->type == SHT_REL)
-			s->buf = rel64;
-		else
-			s->buf = rela64;
-	}
-	s->sz = gelf_fsize(ecp->eout, (s->type == SHT_REL ? ELF_T_REL :
-	    ELF_T_RELA), nrels, EV_CURRENT);
 	s->nocopy = 1;
 }
 

Modified: projects/power8_bringup_hacks/lib/csu/aarch64/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/aarch64/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/aarch64/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/amd64/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/amd64/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/amd64/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -5,9 +5,9 @@
 SRCS=		crt1.c crti.S crtn.S
 OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
-CFLAGS+=	-I${.CURDIR:H}/common \
+CFLAGS+=	-I${.CURDIR} -I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
-CFLAGS+=	-fno-omit-frame-pointer
+CFLAGS+=	-fno-omit-frame-pointer -DCRT_IRELOC_RELA
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/amd64/crt1.c
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/amd64/crt1.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/amd64/crt1.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -59,10 +59,12 @@ _start(char **ap, void (*cleanup)(void))
 	env = ap + 2 + argc;
 	handle_argv(argc, argv, env);
 
-	if (&_DYNAMIC != NULL)
+	if (&_DYNAMIC != NULL) {
 		atexit(cleanup);
-	else
+	} else {
+		process_irelocs();
 		_init_tls();
+	}
 
 #ifdef GCRT
 	atexit(_mcleanup);

Copied: projects/power8_bringup_hacks/lib/csu/amd64/reloc.c (from r339382, head/lib/csu/amd64/reloc.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/power8_bringup_hacks/lib/csu/amd64/reloc.c	Tue Oct 16 16:45:21 2018	(r339383, copy of r339382, head/lib/csu/amd64/reloc.c)
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib at 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$");
+
+#include <machine/specialreg.h>
+#include <machine/cpufunc.h>
+
+static void
+crt1_handle_rela(const Elf_Rela *r)
+{
+	Elf_Addr *ptr, *where, target;
+	u_int p[4];
+	uint32_t cpu_feature, cpu_feature2;
+	uint32_t cpu_stdext_feature, cpu_stdext_feature2;
+
+	do_cpuid(1, p);
+	cpu_feature = p[3];
+	cpu_feature2 = p[2];
+	do_cpuid(0, p);
+	if (p[0] >= 7) {
+		cpuid_count(7, 0, p);
+		cpu_stdext_feature = p[1];
+		cpu_stdext_feature2 = p[2];
+	} else {
+		cpu_stdext_feature = 0;
+		cpu_stdext_feature2 = 0;
+	}
+
+	switch (ELF_R_TYPE(r->r_info)) {
+	case R_X86_64_IRELATIVE:
+		ptr = (Elf_Addr *)r->r_addend;
+		where = (Elf_Addr *)r->r_offset;
+		target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t,
+		    uint32_t))ptr)(cpu_feature, cpu_feature2,
+		    cpu_stdext_feature, cpu_stdext_feature2);
+		*where = target;
+		break;
+	}
+}

Modified: projects/power8_bringup_hacks/lib/csu/arm/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/arm/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/arm/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 STATIC_CFLAGS+=	-mlong-calls
 
 FILES=		${OBJS}

Modified: projects/power8_bringup_hacks/lib/csu/common/ignore_init.c
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/common/ignore_init.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/common/ignore_init.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -2,8 +2,11 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright 2012 Konstantin Belousov <kib at FreeBSD.org>
- * All rights reserved.
+ * Copyright (c) 2018 The FreeBSD Foundation
  *
+ * Parts of this software was developed by Konstantin Belousov
+ * <kib at 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:
@@ -29,7 +32,9 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/elf.h>
 #include <sys/elf_common.h>
+
 #include "notes.h"
 
 extern int main(int, char **, char **);
@@ -45,6 +50,39 @@ extern void _init(void) __hidden;
 
 extern int _DYNAMIC;
 #pragma weak _DYNAMIC
+
+#if defined(CRT_IRELOC_RELA)
+extern const Elf_Rela __rela_iplt_start[] __weak_symbol __hidden;
+extern const Elf_Rela __rela_iplt_end[] __weak_symbol __hidden;
+
+#include "reloc.c"
+
+static void
+process_irelocs(void)
+{
+	const Elf_Rela *r;
+
+	for (r = &__rela_iplt_start[0]; r < &__rela_iplt_end[0]; r++)
+		crt1_handle_rela(r);
+}
+#elif defined(CRT_IRELOC_REL)
+extern const Elf_Rel __rel_iplt_start[] __weak_symbol __hidden;
+extern const Elf_Rel __rel_iplt_end[] __weak_symbol __hidden;
+
+#include "reloc.c"
+
+static void
+process_irelocs(void)
+{
+	const Elf_Rel *r;
+
+	for (r = &__rel_iplt_start[0]; r < &__rel_iplt_end[0]; r++)
+		crt1_handle_rel(r);
+}
+#elif defined(CRT_IRELOC_SUPPRESS)
+#else
+#error "Define platform reloc type"
+#endif
 
 char **environ;
 const char *__progname = "";

Modified: projects/power8_bringup_hacks/lib/csu/i386/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/i386/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/i386/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -5,8 +5,9 @@
 SRCS=		crti.S crtn.S
 OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		gcrt1.o crt1.o Scrt1.o
-CFLAGS+=	-I${.CURDIR:H}/common \
+CFLAGS+=	-I${.CURDIR} -I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_REL
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/i386/crt1_c.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -56,10 +56,12 @@ _start1(fptr cleanup, int argc, char *argv[])
 
 	env = argv + argc + 1;
 	handle_argv(argc, argv, env);
-	if (&_DYNAMIC != NULL)
+	if (&_DYNAMIC != NULL) {
 		atexit(cleanup);
-	else
+	} else {
+		process_irelocs();
 		_init_tls();
+	}
 
 #ifdef GCRT
 	atexit(_mcleanup);

Copied: projects/power8_bringup_hacks/lib/csu/i386/reloc.c (from r339382, head/lib/csu/i386/reloc.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/power8_bringup_hacks/lib/csu/i386/reloc.c	Tue Oct 16 16:45:21 2018	(r339383, copy of r339382, head/lib/csu/i386/reloc.c)
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib at 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$");
+
+#include <machine/specialreg.h>
+#include <machine/cpufunc.h>
+
+static void
+crt1_handle_rel(const Elf_Rel *r)
+{
+	Elf_Addr *where, target;
+	u_int cpuid_supported, p[4];
+	uint32_t cpu_feature, cpu_feature2;
+	uint32_t cpu_stdext_feature, cpu_stdext_feature2;
+
+	__asm __volatile(
+	    "	pushfl\n"
+	    "	popl	%%eax\n"
+	    "	movl    %%eax,%%ecx\n"
+	    "	xorl    $0x200000,%%eax\n"
+	    "	pushl	%%eax\n"
+	    "	popfl\n"
+	    "	pushfl\n"
+	    "	popl    %%eax\n"
+	    "	xorl    %%eax,%%ecx\n"
+	    "	je	1f\n"
+	    "	movl	$1,%0\n"
+	    "	jmp	2f\n"
+	    "1:	movl	$0,%0\n"
+	    "2:\n"
+	    : "=r" (cpuid_supported) : : "eax", "ecx", "cc");
+	if (cpuid_supported) {
+		do_cpuid(1, p);
+		cpu_feature = p[3];
+		cpu_feature2 = p[2];
+		do_cpuid(0, p);
+		if (p[0] >= 7) {
+			cpuid_count(7, 0, p);
+			cpu_stdext_feature = p[1];
+			cpu_stdext_feature2 = p[2];
+		} else {
+			cpu_stdext_feature = 0;
+			cpu_stdext_feature2 = 0;
+		}
+	} else {
+		cpu_feature = 0;
+		cpu_feature2 = 0;
+		cpu_stdext_feature = 0;
+		cpu_stdext_feature2 = 0;
+	}
+
+	switch (ELF_R_TYPE(r->r_info)) {
+	case R_386_IRELATIVE:
+		where = (Elf_Addr *)r->r_offset;
+		target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t,
+		    uint32_t))*where)(cpu_feature, cpu_feature2,
+		    cpu_stdext_feature, cpu_stdext_feature2);
+		*where = target;
+		break;
+	}
+}

Modified: projects/power8_bringup_hacks/lib/csu/mips/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/mips/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/mips/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/powerpc/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/powerpc/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/powerpc/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/powerpc64/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,7 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include \
-		-mlongcall
+		-mlongcall -DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/riscv/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/riscv/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/riscv/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/csu/sparc64/Makefile
==============================================================================
--- projects/power8_bringup_hacks/lib/csu/sparc64/Makefile	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/csu/sparc64/Makefile	Tue Oct 16 16:45:21 2018	(r339383)
@@ -7,6 +7,7 @@ OBJS=		${SRCS:N*.h:R:S/$/.o/g}
 OBJS+=		Scrt1.o gcrt1.o
 CFLAGS+=	-I${.CURDIR:H}/common \
 		-I${SRCTOP}/lib/libc/include
+CFLAGS+=	-DCRT_IRELOC_SUPPRESS
 
 FILES=		${OBJS}
 FILESMODE=	${LIBMODE}

Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/amd64/string/Makefile.inc	Tue Oct 16 16:45:21 2018	(r339383)
@@ -2,7 +2,6 @@
 
 MDSRCS+= \
 	bcmp.S \
-	bcopy.S \
 	bzero.S \
 	memcmp.S \
 	memcpy.S \

Copied: projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c (from r339382, head/lib/libc/amd64/string/bcopy.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/power8_bringup_hacks/lib/libc/amd64/string/bcopy.c	Tue Oct 16 16:45:21 2018	(r339383, copy of r339382, head/lib/libc/amd64/string/bcopy.c)
@@ -0,0 +1,15 @@
+/*-
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <string.h>
+
+void
+bcopy(const void *src, void *dst, size_t len)
+{
+
+	memmove(dst, src, len);
+}

Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/amd64/string/memcpy.S	Tue Oct 16 16:45:21 2018	(r339383)
@@ -1,5 +1,5 @@
 /*	$NetBSD: memcpy.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $	*/
 /*	$FreeBSD$ */
 
-#define MEMCOPY
-#include "bcopy.S"
+#define MEMCPY
+#include "memmove.S"

Modified: projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/amd64/string/memmove.S	Tue Oct 16 16:45:21 2018	(r339383)
@@ -1,5 +1,270 @@
-/*	$NetBSD: memmove.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $	*/
-/*	$FreeBSD$ */
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Mateusz Guzik <mjg at 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.
+ */
 
-#define MEMMOVE
-#include "bcopy.S"
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#define	ALIGN_TEXT	.p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+/*
+ * memmove(dst, src, cnt)
+ *         rdi, rsi, rdx
+ * Contains parts of bcopy written by:
+ *  ws at tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+ */
+
+/*
+ * Register state at entry is supposed to be as follows:
+ * rdi - destination
+ * rsi - source
+ * rdx - count
+ *
+ * The macro possibly clobbers the above and: rcx, r8.
+ * It does not clobber rax, r10 nor r11.
+ */
+.macro MEMMOVE erms overlap begin end
+	\begin
+.if \overlap == 1
+	movq	%rdi,%r8
+	subq	%rsi,%r8
+	cmpq	%rcx,%r8	/* overlapping && src < dst? */
+	jb	2f
+.endif
+
+	cmpq	$32,%rcx
+	jb	1016f
+
+	cmpq	$256,%rcx
+	ja	1256f
+
+1032:
+	movq	(%rsi),%rdx
+	movq	%rdx,(%rdi)
+	movq	8(%rsi),%rdx
+	movq	%rdx,8(%rdi)
+	movq	16(%rsi),%rdx
+	movq	%rdx,16(%rdi)
+	movq	24(%rsi),%rdx
+	movq	%rdx,24(%rdi)
+	leaq	32(%rsi),%rsi
+	leaq	32(%rdi),%rdi
+	subq	$32,%rcx
+	cmpq	$32,%rcx
+	jae	1032b
+	cmpb	$0,%cl
+	jne	1016f
+	\end
+	ret
+	ALIGN_TEXT
+1016:
+	cmpb	$16,%cl
+	jl	1008f
+	movq	(%rsi),%rdx
+	movq	%rdx,(%rdi)
+	movq	8(%rsi),%rdx
+	movq	%rdx,8(%rdi)
+	subb	$16,%cl
+	jz	1000f
+	leaq	16(%rsi),%rsi
+	leaq	16(%rdi),%rdi
+1008:
+	cmpb	$8,%cl
+	jl	1004f
+	movq	(%rsi),%rdx
+	movq	%rdx,(%rdi)
+	subb	$8,%cl
+	jz	1000f
+	leaq	8(%rsi),%rsi
+	leaq	8(%rdi),%rdi
+1004:
+	cmpb	$4,%cl
+	jl	1002f
+	movl	(%rsi),%edx
+	movl	%edx,(%rdi)
+	subb	$4,%cl
+	jz	1000f
+	leaq	4(%rsi),%rsi
+	leaq	4(%rdi),%rdi
+1002:
+	cmpb	$2,%cl
+	jl	1001f
+	movw	(%rsi),%dx
+	movw	%dx,(%rdi)
+	subb	$2,%cl
+	jz	1000f
+	leaq	2(%rsi),%rsi
+	leaq	2(%rdi),%rdi
+1001:
+	cmpb	$1,%cl
+	jl	1000f
+	movb	(%rsi),%dl
+	movb	%dl,(%rdi)
+1000:
+	\end
+	ret
+
+	ALIGN_TEXT
+1256:
+.if \erms == 1
+	rep
+	movsb
+.else
+	shrq	$3,%rcx                         /* copy by 64-bit words */
+	rep
+	movsq
+	movq	%rdx,%rcx
+	andb	$7,%cl                         /* any bytes left? */
+	jne	1004b
+.endif
+	\end
+	ret
+
+.if \overlap == 1
+	/*
+	 * Copy backwards.
+	 */
+        ALIGN_TEXT
+2:
+	addq	%rcx,%rdi
+	addq	%rcx,%rsi
+
+	cmpq	$32,%rcx
+	jb	2016f
+
+	cmpq	$256,%rcx
+	ja	2256f
+
+2032:
+	movq	-8(%rsi),%rdx
+	movq	%rdx,-8(%rdi)
+	movq	-16(%rsi),%rdx
+	movq	%rdx,-16(%rdi)
+	movq	-24(%rsi),%rdx
+	movq	%rdx,-24(%rdi)
+	movq	-32(%rsi),%rdx
+	movq	%rdx,-32(%rdi)
+	leaq	-32(%rsi),%rsi
+	leaq	-32(%rdi),%rdi
+	subq	$32,%rcx
+	cmpq	$32,%rcx
+	jae	2032b
+	cmpb	$0,%cl
+	jne	2016f
+	\end
+	ret
+	ALIGN_TEXT
+2016:
+	cmpb	$16,%cl
+	jl	2008f
+	movq	-8(%rsi),%rdx
+	movq	%rdx,-8(%rdi)
+	movq	-16(%rsi),%rdx
+	movq	%rdx,-16(%rdi)
+	subb	$16,%cl
+	jz	2000f
+	leaq	-16(%rsi),%rsi
+	leaq	-16(%rdi),%rdi
+2008:
+	cmpb	$8,%cl
+	jl	2004f
+	movq	-8(%rsi),%rdx
+	movq	%rdx,-8(%rdi)
+	subb	$8,%cl
+	jz	2000f
+	leaq	-8(%rsi),%rsi
+	leaq	-8(%rdi),%rdi
+2004:
+	cmpb	$4,%cl
+	jl	2002f
+	movl	-4(%rsi),%edx
+	movl	%edx,-4(%rdi)
+	subb	$4,%cl
+	jz	2000f
+	leaq	-4(%rsi),%rsi
+	leaq	-4(%rdi),%rdi
+2002:
+	cmpb	$2,%cl
+	jl	2001f
+	movw	-2(%rsi),%dx
+	movw	%dx,-2(%rdi)
+	subb	$2,%cl
+	jz	2000f
+	leaq	-2(%rsi),%rsi
+	leaq	-2(%rdi),%rdi
+2001:
+	cmpb	$1,%cl
+	jl	2000f
+	movb	-1(%rsi),%dl
+	movb	%dl,-1(%rdi)
+2000:
+	\end
+	ret
+	ALIGN_TEXT
+2256:
+	decq	%rdi
+	decq	%rsi
+	std
+.if \erms == 1
+	rep
+	movsb
+.else
+	andq	$7,%rcx                         /* any fractional bytes? */
+	je	3f
+	rep
+	movsb
+3:
+	movq	%rdx,%rcx                       /* copy remainder by 32-bit words */
+	shrq	$3,%rcx
+	subq	$7,%rsi
+	subq	$7,%rdi
+	rep
+	movsq
+.endif
+	cld
+	\end
+	ret
+.endif
+.endm
+
+.macro MEMMOVE_BEGIN
+	movq	%rdi,%rax
+	movq	%rdx,%rcx
+.endm
+
+.macro MEMMOVE_END
+.endm
+
+#ifndef MEMCPY
+ENTRY(memmove)
+	MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
+END(memmove)
+#else
+ENTRY(memcpy)
+	MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
+END(memcpy)
+#endif

Modified: projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/net/nsdispatch.3	Tue Oct 16 16:45:21 2018	(r339383)
@@ -32,7 +32,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 4, 2010
+.Dd October 15, 2018
 .Dt NSDISPATCH 3
 .Os
 .Sh NAME
@@ -112,10 +112,7 @@ which case they are selected using the
 and
 .Fa method_name
 arguments along with the configured source.
-(The methods supplied via
-.Fa dtab
-take priority over those implemented in NSS modules in the event
-of a conflict.)
+Modules must use source names different from the built-in ones.
 .Pp
 .Va defaults
 contains a list of default sources to try if

Modified: projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/net/nsdispatch.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -486,9 +486,19 @@ nss_load_module(const char *source, nss_module_registe
 		 */
 		mod.handle = nss_builtin_handle;
 		fn = reg_fn;
-	} else if (!is_dynamic())
+	} else if (!is_dynamic()) {
 		goto fin;
-	else {
+	} else if (strcmp(source, NSSRC_CACHE) == 0 ||
+	    strcmp(source, NSSRC_COMPAT) == 0 ||
+	    strcmp(source, NSSRC_DB) == 0 ||
+	    strcmp(source, NSSRC_DNS) == 0 ||
+	    strcmp(source, NSSRC_FILES) == 0 ||
+	    strcmp(source, NSSRC_NIS) == 0) {
+		/*
+		 * Avoid calling dlopen(3) for built-in modules.
+		 */
+		goto fin;
+	} else {
 		if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name,
 		    NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf))
 			goto fin;

Modified: projects/power8_bringup_hacks/lib/libc/net/nslexer.l
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/net/nslexer.l	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/net/nslexer.l	Tue Oct 16 16:45:21 2018	(r339383)
@@ -50,6 +50,7 @@ static char *rcsid = 
 
 %}
 
+%option never-interactive
 %option noinput
 %option nounput
 %option yylineno

Modified: projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/stdtime/strptime.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -291,7 +291,7 @@ label:
 			if (c == 'H' || c == 'k') {
 				if (i > 23)
 					return (NULL);
-			} else if (i > 12)
+			} else if (i == 0 || i > 12)
 				return (NULL);
 
 			tm->tm_hour = i;

Modified: projects/power8_bringup_hacks/lib/libc/string/memmem.c
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/string/memmem.c	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/string/memmem.c	Tue Oct 16 16:45:21 2018	(r339383)
@@ -31,27 +31,27 @@ __FBSDID("$FreeBSD$");
 static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
 {
 	uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1];
-	for (h++, k--; k; k--, hw = hw<<8 | *++h)
-		if (hw == nw) return (char *)h-1;
-	return 0;
+	for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++)
+		if (hw == nw) return (char *)h-2;
+	return hw == nw ? (char *)h-2 : 0;
 }
 
 static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
 {
 	uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8;
 	uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8;
-	for (h+=2, k-=2; k; k--, hw = (hw|*++h)<<8)
-		if (hw == nw) return (char *)h-2;
-	return 0;
+	for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8)
+		if (hw == nw) return (char *)h-3;
+	return hw == nw ? (char *)h-3 : 0;
 }
 
 static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
 {
 	uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3];
 	uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3];
-	for (h+=3, k-=3; k; k--, hw = hw<<8 | *++h)
-		if (hw == nw) return (char *)h-3;
-	return 0;
+	for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++)
+		if (hw == nw) return (char *)h-4;
+	return hw == nw ? (char *)h-4 : 0;
 }
 
 #define MAX(a,b) ((a)>(b)?(a):(b))

Modified: projects/power8_bringup_hacks/lib/libc/sys/pdfork.2
==============================================================================
--- projects/power8_bringup_hacks/lib/libc/sys/pdfork.2	Tue Oct 16 16:36:02 2018	(r339382)
+++ projects/power8_bringup_hacks/lib/libc/sys/pdfork.2	Tue Oct 16 16:45:21 2018	(r339383)
@@ -32,7 +32,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 17, 2017

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list