Index: head/lib/csu/Makefile =================================================================== --- head/lib/csu/Makefile (revision 366038) +++ head/lib/csu/Makefile (revision 366039) @@ -1,14 +1,14 @@ # $FreeBSD$ .include -.if exists(${.CURDIR}/${MACHINE_ARCH}) -SUBDIR+= ${MACHINE_ARCH} +.if exists(${.CURDIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) +SUBDIR+= ${MACHINE_ARCH:S/powerpc64le/powerpc64/} .else SUBDIR+= ${MACHINE_CPUARCH} .endif HAS_TESTS= SUBDIR.${MK_TESTS}+= tests .include Index: head/lib/libc/Makefile =================================================================== --- head/lib/libc/Makefile (revision 366038) +++ head/lib/libc/Makefile (revision 366039) @@ -1,215 +1,215 @@ # @(#)Makefile 8.2 (Berkeley) 2/3/94 # $FreeBSD$ PACKAGE= clibs SHLIBDIR?= /lib .include # Force building of libc_pic.a MK_TOOLCHAIN= yes LIBC_SRCTOP?= ${.CURDIR} # Pick the current architecture directory for libc. In general, this is # named MACHINE_CPUARCH, but some ABIs are different enough to require # their own libc, so allow a directory named MACHINE_ARCH to override this. -.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH}) -LIBC_ARCH=${MACHINE_ARCH} +.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) +LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/} .else LIBC_ARCH=${MACHINE_CPUARCH} .endif # All library objects contain FreeBSD revision strings by default; they may be # excluded as a space-saving measure. To produce a library that does # not contain these strings, add -DSTRIP_FBSDID (see ) to CFLAGS # below. Note: there are no IDs for syscall stubs whose sources are generated. # To include legacy CSRG SCCS ID strings, remove -DNO__SCCSID from CFLAGS. # To include RCS ID strings from other BSD projects, remove -DNO__RCSID from CFLAGS. CFLAGS+=-DNO__SCCSID -DNO__RCSID LIB=c SHLIB_MAJOR= 7 .if ${MK_SSP} != "no" && \ (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "") SHLIB_LDSCRIPT=libc.ldscript .else SHLIB_LDSCRIPT=libc_nossp.ldscript .endif SHLIB_LDSCRIPT_LINKS=libxnet.so WARNS?= 2 CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH} .if ${MK_NLS} != "no" CFLAGS+=-DNLS .endif CLEANFILES+=tags INSTALL_PIC_ARCHIVE= BUILD_NOSSP_PIC_ARCHIVE= PRECIOUSLIB= .ifndef NO_THREAD_STACK_UNWIND CANCELPOINTS_CFLAGS=-fexceptions CFLAGS+=${CANCELPOINTS_CFLAGS} .endif # # Link with static libcompiler_rt.a. # LDFLAGS+= -nodefaultlibs LIBADD+= compiler_rt .if ${MK_SSP} != "no" && \ (${LIBC_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "") LIBADD+= ssp_nonshared .endif # Extras that live in either libc.a or libc_nonshared.a LIBC_NONSHARED_SRCS= # Define (empty) variables so that make doesn't give substitution # errors if the included makefiles don't change these: MDSRCS= MISRCS= MDASM= MIASM= NOASM= .include "${LIBC_SRCTOP}/${LIBC_ARCH}/Makefile.inc" .include "${LIBC_SRCTOP}/db/Makefile.inc" .include "${LIBC_SRCTOP}/compat-43/Makefile.inc" .include "${LIBC_SRCTOP}/gdtoa/Makefile.inc" .include "${LIBC_SRCTOP}/gen/Makefile.inc" .include "${LIBC_SRCTOP}/gmon/Makefile.inc" .if ${MK_ICONV} != "no" .include "${LIBC_SRCTOP}/iconv/Makefile.inc" .endif .include "${LIBC_SRCTOP}/inet/Makefile.inc" .include "${LIBC_SRCTOP}/isc/Makefile.inc" .include "${LIBC_SRCTOP}/locale/Makefile.inc" .include "${LIBC_SRCTOP}/md/Makefile.inc" .include "${LIBC_SRCTOP}/nameser/Makefile.inc" .include "${LIBC_SRCTOP}/net/Makefile.inc" .include "${LIBC_SRCTOP}/nls/Makefile.inc" .include "${LIBC_SRCTOP}/posix1e/Makefile.inc" .if ${LIBC_ARCH} != "aarch64" && \ ${LIBC_ARCH} != "amd64" && \ ${LIBC_ARCH} != "powerpc64" && \ ${LIBC_ARCH} != "riscv" && \ ${MACHINE_ARCH:Mmipsn32*} == "" && \ ${MACHINE_ARCH:Mmips64*} == "" .include "${LIBC_SRCTOP}/quad/Makefile.inc" .endif .include "${LIBC_SRCTOP}/regex/Makefile.inc" .include "${LIBC_SRCTOP}/resolv/Makefile.inc" .include "${LIBC_SRCTOP}/stdio/Makefile.inc" .include "${LIBC_SRCTOP}/stdlib/Makefile.inc" .include "${LIBC_SRCTOP}/stdlib/jemalloc/Makefile.inc" .include "${LIBC_SRCTOP}/stdtime/Makefile.inc" .include "${LIBC_SRCTOP}/string/Makefile.inc" .include "${LIBC_SRCTOP}/sys/Makefile.inc" .include "${LIBC_SRCTOP}/secure/Makefile.inc" .include "${LIBC_SRCTOP}/rpc/Makefile.inc" .include "${LIBC_SRCTOP}/uuid/Makefile.inc" .include "${LIBC_SRCTOP}/xdr/Makefile.inc" .if (${LIBC_ARCH} == "arm" && \ (${MACHINE_ARCH:Marmv[67]*} == "" || (defined(CPUTYPE) && ${CPUTYPE:M*soft*}))) || \ (${LIBC_ARCH} == "mips" && ${MACHINE_ARCH:Mmips*hf} == "") || \ (${LIBC_ARCH} == "riscv" && ${MACHINE_ARCH:Mriscv*sf} != "") .include "${LIBC_SRCTOP}/softfloat/Makefile.inc" .endif .if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64" .include "${LIBC_SRCTOP}/x86/sys/Makefile.inc" .include "${LIBC_SRCTOP}/x86/gen/Makefile.inc" .endif .if ${MK_NIS} != "no" CFLAGS+= -DYP .include "${LIBC_SRCTOP}/yp/Makefile.inc" .endif .include "${LIBC_SRCTOP}/capability/Makefile.inc" .if ${MK_HESIOD} != "no" CFLAGS+= -DHESIOD .endif .if ${MK_FP_LIBC} == "no" CFLAGS+= -DNO_FLOATING_POINT .endif .if ${MK_NS_CACHING} != "no" CFLAGS+= -DNS_CACHING .endif .if defined(_FREEFALL_CONFIG) CFLAGS+=-D_FREEFALL_CONFIG .endif STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/} VERSION_DEF=${LIBC_SRCTOP}/Versions.def SYMBOL_MAPS=${SYM_MAPS} CFLAGS+= -DSYMBOL_VERSIONING # If there are no machine dependent sources, append all the # machine-independent sources: .if empty(MDSRCS) SRCS+= ${MISRCS} .else # Append machine-dependent sources, then append machine-independent sources # for which there is no machine-dependent variant. SRCS+= ${MDSRCS} .for _src in ${MISRCS} .if ${MDSRCS:R:M${_src:R}} == "" SRCS+= ${_src} .endif .endfor .endif KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ strcmp.c strcpy.c strlen.c strncpy.c strrchr.c libkern: libkern.gen libkern.${LIBC_ARCH} libkern.gen: ${KQSRCS} ${KSRCS} ${CP} ${LIBC_SRCTOP}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern libkern.${LIBC_ARCH}:: ${KMSRCS} .if defined(KMSRCS) && !empty(KMSRCS) ${CP} ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH} .endif HAS_TESTS= SUBDIR.${MK_TESTS}+= tests .include .if (${LIBC_ARCH} == amd64 || ${LIBC_ARCH} == i386) && \ ${.TARGETS:Mall} == all && \ defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" .error ${LIBC_ARCH} libc requires linker ifunc support .endif .if !defined(_SKIP_BUILD) # We need libutil.h, get it directly to avoid # recording a build dependency CFLAGS+= -I${SRCTOP}/lib/libutil # Same issue with libm MSUN_ARCH_SUBDIR != ${MAKE} -B -C ${SRCTOP}/lib/msun -V ARCH_SUBDIR # unfortunately msun/src contains both private and public headers CFLAGS+= -I${SRCTOP}/lib/msun/${MSUN_ARCH_SUBDIR} .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -I${SRCTOP}/lib/msun/x86 .endif CFLAGS+= -I${SRCTOP}/lib/msun/src # and we do not want to record a dependency on msun .if ${.MAKE.LEVEL} > 0 GENDIRDEPS_FILTER+= N${RELDIR:H}/msun .endif .endif # Disable warnings in contributed sources. CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/} # Disable stack protection for SSP symbols. SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/} # Generate stack unwinding tables for cancellation points CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//} Index: head/lib/libc/powerpc64/string/Makefile.inc =================================================================== --- head/lib/libc/powerpc64/string/Makefile.inc (revision 366038) +++ head/lib/libc/powerpc64/string/Makefile.inc (revision 366039) @@ -1,18 +1,23 @@ # $FreeBSD$ MDSRCS+= \ bcopy.S \ bcopy_vsx.S \ bcopy_resolver.c \ memcpy.S \ memcpy_vsx.S \ memcpy_resolver.c \ memmove.S \ memmove_vsx.S \ memmove_resolver.c \ - strcpy_arch_2_05.S \ - strcpy.c \ - strcpy_resolver.c \ strncpy_arch_2_05.S \ strncpy.c \ strncpy_resolver.c + +# XXX Port strcpy to LE. +.if ${MACHINE_ARCH} == "powerpc64" +MDSRCS+= \ + strcpy_arch_2_05.S \ + strcpy.c \ + strcpy_resolver.c +.endif Index: head/libexec/rtld-elf/Makefile =================================================================== --- head/libexec/rtld-elf/Makefile (revision 366038) +++ head/libexec/rtld-elf/Makefile (revision 366039) @@ -1,94 +1,94 @@ # $FreeBSD$ # Use the following command to build local debug version of dynamic # linker: # make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all RTLD_ELF_DIR:= ${.PARSEDIR} .include PACKAGE= clibs MK_PIE= no # Always position independent using local rules MK_SSP= no CONFS= libmap.conf PROG?= ld-elf.so.1 .if (${PROG:M*ld-elf32*} != "") TAGS+= lib32 .endif SRCS= \ crtbrand.S \ rtld_start.S \ reloc.c \ rtld.c \ rtld_lock.c \ rtld_malloc.c \ rtld_printf.c \ map_object.c \ xmalloc.c \ debug.c \ libmap.c MAN?= rtld.1 ACFLAGS+= -DLOCORE CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding CFLAGS+= -I${SRCTOP}/lib/csu/common -.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH}) -RTLD_ARCH= ${MACHINE_ARCH} +.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) +RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/} .else RTLD_ARCH= ${MACHINE_CPUARCH} .endif CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR} NO_WCAST_ALIGN= yes WARNS?= 6 INSTALLFLAGS= -C -b PRECIOUSPROG= BINDIR= /libexec SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG} MLINKS?= rtld.1 ld-elf.so.1.1 \ rtld.1 ld.so.1 CFLAGS+= -fpic -DPIC $(DEBUG) LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY} # Pull in the dependencies that we use from libc .include "rtld-libc/Makefile.inc" .if ${MK_TOOLCHAIN} == "no" LDFLAGS+= -L${LIBCDIR} .endif VERSION_DEF= ${LIBCSRCDIR}/Versions.def SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map VERSION_MAP= Version.map LDFLAGS+= -Wl,--version-script=${VERSION_MAP} .if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map) SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map .endif .sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc" RTLD_ENTRY?= .rtld_start # Since moving rtld-elf to /libexec, we need to create a symlink. # Fixup the existing binary that's there so we can symlink over it. beforeinstall: .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no" -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG} .endif .PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common .if ${.CURDIR} == ${RTLD_ELF_DIR} HAS_TESTS= SUBDIR.${MK_TESTS}+= tests .endif .include ${PROG_FULL}: ${VERSION_MAP} .include .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 .endif Index: head/libexec/rtld-elf/rtld-libc/Makefile.inc =================================================================== --- head/libexec/rtld-elf/rtld-libc/Makefile.inc (revision 366038) +++ head/libexec/rtld-elf/rtld-libc/Makefile.inc (revision 366039) @@ -1,96 +1,96 @@ # $FreeBSD$ # This makefiles adds the necessary libc dependencies for RTLD without pulling # in all of the complex libc bits such as locales, etc. .include LIBC_SRCTOP=${SRCTOP}/lib/libc -.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH}) -LIBC_ARCH=${MACHINE_ARCH} +.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) +LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/} .else LIBC_ARCH=${MACHINE_CPUARCH} .endif CFLAGS+= -I${SRCTOP}/libexec/rtld-elf/rtld-libc # Build all the libc files that use interposed symbols or pthreads again for # RTLD. We compile with a different libc_private.h and namespace.h that # redirects all calls to interposed functions to use the non-interposed version # instead. .PATH: ${LIBC_SRCTOP}/gen SRCS+= opendir.c closedir.c readdir.c telldir.c # Avoid further dependencies by providing simple implementations of libc # functions such as __error(), etc. .PATH: ${SRCTOP}/libexec/rtld-elf/rtld-libc SRCS+= rtld_libc.c # Now build the remaining files from libc: .PATH: ${LIBC_SRCTOP}/stdlib SRCS+= reallocf.c realpath.c getenv.c merge.c reallocarray.c # TODO: fix merge.c to build with WARNS=6 .if ${COMPILER_TYPE} == "clang" CFLAGS.merge.c+=-Wno-error=null-pointer-arithmetic .endif .PATH: ${LIBC_SRCTOP}/gen SRCS+= errlst.c getcwd.c getprogname.c raise.c sigsetops.c sysctlnametomib.c \ __xuname.c # errlst.c needs the errlst.h header from libc: CFLAGS.errlst.c+=-I${LIBC_SRCTOP}/include # Use the string and memory .o files from libc instead of rebuilding them (they # might be using optimized assembly and duplicating that logic here is awkward). _libc_string_objects= bcmp bcopy bzero memset memchr memcmp memcpy memmove \ stpncpy strcat strchr strcmp stpcpy strcpy strcspn strdup strlcat strlcpy \ strlen strncmp strncpy strrchr strsep strspn strstr strtok # Also use all the syscall .o files from libc_nossp_pic: _libc_other_objects= sigsetjmp lstat stat fstat fstatat fstatfs syscall \ cerror geteuid getegid sigfastblock munmap mprotect \ sysarch __sysctl issetugid __getcwd utrace getpid \ thr_self thr_kill pread mmap lseek _exit _fstat _fstatat _fstatfs \ getdirentries _getdirentries _close _fcntl _open _openat _read \ _sigprocmask _write readlink __realpathat _setjmp setjmp setjmperr # Finally add additional architecture-dependent libc dependencies .if ${LIBC_ARCH} == "arm" # ARM needs aeabi_unwind_cpp for _setjmp _libc_other_objects+=aeabi_unwind_cpp .elif ${LIBC_ARCH} == "i386" # __udivdi3 is needed by kvprintf() in rtld_printf.c # i386 also needs i386_set_gsbase for allocate_initial_tls() _libc_other_objects+=umoddi3 udivdi3 qdivrem i386_set_gsbase .elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe" # ppc needs __syncicache for reloc.c and __umoddi3+__udivdi3 for rtld_printf.c _libc_other_objects+=syncicache umoddi3 udivdi3 qdivrem # for some reason there is also a reference to abs() _libc_other_objects+=abs .elif ${LIBC_ARCH} == "powerpc64" # ppc64 needs __syncicache for reloc.c _libc_other_objects+=syncicache .elif ${LIBC_ARCH} == "mips" # 32-bit MIPS needs __umoddi3+__udivdi3 for rtld_printf.c .if ${MACHINE_ARCH:Mmipsn32*} == "" && ${MACHINE_ARCH:Mmips64*} == "" _libc_other_objects+=umoddi3 udivdi3 qdivrem .endif .endif # Extract all the .o files from libc_nossp_pic.a. This ensures that # we don't accidentally pull in the interposing table or similar by linking # directly against libc_nossp_pic.a _rtld_libc_objs= .for _obj in ${_libc_other_objects} ${_libc_string_objects} _rtld_libc_objs+=${_obj}.nossppico CLEANFILES+=${_obj}.nossppico # LDFLAGS+= -Wl,--trace-symbol=${_obj} .endfor # LDFLAGS+= -Wl,--trace # We insert all the .o files from libc_nossp_pic.a into a new rtld_libc.a file # to ensure that only .o files that are actually used end up being included. rtld_libc.a: ${LIBC_NOSSP_PIC} ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc ${AR} x ${LIBC_NOSSP_PIC} ${_rtld_libc_objs} ${AR} cr ${.OBJDIR}/${.TARGET} ${_rtld_libc_objs} CLEANFILES+=rtld_libc.a LDADD+=${.OBJDIR}/rtld_libc.a beforelinking: rtld_libc.a