Skip to content

Commit

Permalink
Merge remote-tracking branch 'freebsd/main' into hardened/current/master
Browse files Browse the repository at this point in the history
Conflicts:
	libexec/rtld-elf/rtld.c (unresolved)
  • Loading branch information
lattera committed Jul 10, 2023
2 parents 77c3758 + 8ab2da6 commit 957a0c9
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 152 deletions.
6 changes: 3 additions & 3 deletions Makefile.libcompat
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ LIB${_LIBCOMPAT}WMAKEENV+= \
# Don't rebuild build-tools targets during normal build.
LIB${_LIBCOMPAT}WMAKEENV+= BUILD_TOOLS_META=.NOMETA
.endif
LIB${_LIBCOMPAT}WMAKEFLAGS+= CC="${XCC} ${LIB${_LIBCOMPAT}CFLAGS}" \
CXX="${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS} ${LIB${_LIBCOMPAT}CFLAGS}" \
CPP="${XCPP} ${LIB${_LIBCOMPAT}CFLAGS}" \
LIB${_LIBCOMPAT}WMAKEFLAGS+= CC="${XCC} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
CXX="${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS:@v@${v:Q}@} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
CPP="${XCPP} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
DESTDIR=${WORLDTMP} \
-DNO_CPU_CFLAGS \
MK_BOOT=no \
Expand Down
2 changes: 2 additions & 0 deletions ObsoleteFiles.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8427,6 +8427,8 @@ OLD_DIRS+=usr/include/c++/4.2/debug
OLD_DIRS+=usr/include/c++/4.2/bits
OLD_DIRS+=usr/include/c++/4.2/backward
OLD_DIRS+=usr/include/c++/4.2
OLD_DIRS+=usr/include/gcc/4.2
OLD_DIRS+=usr/include/gcc

# 20200220: Upgrade of ncurses, shlib bumped to version 9
OLD_LIBS+=lib/libncurses.so.8
Expand Down
6 changes: 3 additions & 3 deletions contrib/openpam/lib/libpam/openpam_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ const char *openpam_policy_path[] = {
const char *openpam_module_path[] = {
#ifdef OPENPAM_MODULES_DIRECTORY
OPENPAM_MODULES_DIRECTORY,
#elif COMPAT_32BIT
"/usr/lib32",
"/usr/local/lib32",
#elif defined(COMPAT_libcompat)
"/usr/lib" COMPAT_libcompat,
"/usr/local/lib" COMPAT_libcompat,
#else
"/usr/lib",
"/usr/local/lib",
Expand Down
4 changes: 0 additions & 4 deletions etc/mtree/BSD.include.dist
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@
unionfs
..
..
gcc
4.2
..
..
geom
cache
..
Expand Down
2 changes: 2 additions & 0 deletions include/elf-hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct elfhints_hdr {

#define ELFHINTS_MAGIC 0x746e6845

#ifndef _PATH_ELF_HINTS
#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
#endif

#endif /* !_ELF_HINTS_H_ */
4 changes: 2 additions & 2 deletions include/paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
#define _PATH_GBDE "/sbin/gbde"
#define _PATH_GELI "/sbin/geli"
#define _PATH_HALT "/sbin/halt"
#ifdef COMPAT_32BIT
#define _PATH_I18NMODULE "/usr/lib32/i18n"
#ifdef COMPAT_libcompat
#define _PATH_I18NMODULE "/usr/lib" COMPAT_libcompat "/i18n"
#else
#define _PATH_I18NMODULE "/usr/lib/i18n"
#endif
Expand Down
2 changes: 1 addition & 1 deletion kerberos5/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR:H:H}/include
WARNS?= 1
CWARNFLAGS.clang+= -Wno-absolute-value

.if ${MK_OPENLDAP} != "no" && !defined(COMPAT_32BIT)
.if ${MK_OPENLDAP} != "no" && !defined(COMPAT_LIBCOMPAT)
OPENLDAPBASE?= /usr/local
LDAPLDADD= -lldap -llber
LDAPDPADD= ${LDAPLDADD:C;^-l(.*)$;${OPENLDAPBASE}/lib/lib\1.a;}
Expand Down
6 changes: 3 additions & 3 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ SUBDIR_DEPEND_libpcap= ofed
.endif
SUBDIR_DEPEND_nss_tacplus= libtacplus

.if !defined(COMPAT_32BIT)
.if !defined(COMPAT_LIBCOMPAT)
SUBDIR+= flua
SUBDIR_DEPEND_flua= libjail
.endif
Expand All @@ -161,7 +161,7 @@ SUBDIR.${MK_BLACKLIST}+=libblacklist
SUBDIR.${MK_BLUETOOTH}+=libbluetooth libsdp
SUBDIR.${MK_BSNMP}+= libbsnmp

.if !defined(COMPAT_32BIT) && !defined(COMPAT_SOFTFP)
.if !defined(COMPAT_LIBCOMPAT)
.if ${MK_CLANG} != "no" || ${MK_LLD} != "no" || \
${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS} != "no"
SUBDIR+= clang
Expand Down Expand Up @@ -208,7 +208,7 @@ SUBDIR.${MK_BHYVE}+= libvmmapi
.if ${MACHINE_ARCH} != "powerpc"
SUBDIR.${MK_OPENMP}+= libomp
.endif
.if !defined(COMPAT_32BIT) && ${MK_USB} != "no"
.if ${MK_USB} != "no"
SUBDIR.${MK_OPENSSH}+= libcbor libfido2
.endif
SUBDIR.${MK_OPENSSL}+= libmp
Expand Down
4 changes: 2 additions & 2 deletions lib/geom/Makefile.classes
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# $FreeBSD$

.if !defined(COMPAT_32BIT)
.if !defined(COMPAT_libcompat)
GEOM_CLASS_DIR?=/lib/geom
.else
GEOM_CLASS_DIR?=/usr/lib32/geom
GEOM_CLASS_DIR?=/usr/lib${COMPAT_libcompat}/geom
.endif

GEOM_CLASSES= cache
Expand Down
6 changes: 2 additions & 4 deletions lib/libc/i386/sys/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
# $FreeBSD$

.if !defined(COMPAT_32BIT)
SRCS+= i386_clr_watch.c i386_set_watch.c i386_vm86.c
.endif
SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \
i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c
i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \
i386_clr_watch.c i386_set_watch.c i386_vm86.c

MDASM= Ovfork.S cerror.S getcontext.S syscall.S

Expand Down
6 changes: 1 addition & 5 deletions lib/libiconv_modules/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ CFLAGS+= -I${SRCTOP}/lib/libc/iconv

CFLAGS+= -Dbool=_Bool

.if !defined(COMPAT_32BIT)
SHLIBDIR= /usr/lib/i18n
.else
SHLIBDIR= /usr/lib32/i18n
.endif
SHLIBDIR= /usr/lib${COMPAT_libcompat:U}/i18n
LIBDIR= ${SHLIBDIR}
MK_PROFILE= no
3 changes: 2 additions & 1 deletion lib/libsysdecode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \

CLEANFILES= ioctl.c ioctl.c.tmp tables.h tables_linux.h

.if defined(COMPAT_32BIT)
# XXX: The flags should come from bsd.compat.mk / Makefile.libcompat
.if ${COMPAT_LIBCOMPAT:U} == "32"
CPP+= -m32
.endif

Expand Down
4 changes: 0 additions & 4 deletions lib/libsysdecode/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ __FBSDID("$FreeBSD$");
#elif __i386__
#include <i386/linux/linux.h>
#elif __amd64__
#ifdef COMPAT_32BIT
#include <amd64/linux32/linux.h>
#else
#include <amd64/linux/linux.h>
#endif
#else
#error "Unsupported Linux arch"
#endif
Expand Down
13 changes: 4 additions & 9 deletions libexec/rtld-elf/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <sys/cdefs.h>

#include <string.h>
#include "rtld_paths.h"
#include "rtld_printf.h"

void debug_printf(const char *, ...) __printflike(1, 2);
Expand All @@ -48,17 +49,11 @@ extern int debug;
#define dbg(...) ((void) 0)
#endif

#ifndef COMPAT_32BIT
#define _MYNAME "ld-elf.so.1"
#else
#define _MYNAME "ld-elf32.so.1"
#endif

#define assert(cond) ((cond) ? (void) 0 : \
(msg(_MYNAME ": assert failed: " __FILE__ ":" \
#define assert(cond) ((cond) ? (void) 0 : \
(msg(_BASENAME_RTLD ": assert failed: " __FILE__ ":" \
__XSTRING(__LINE__) "\n"), abort()))
#define msg(s) rtld_putstr(s)
#define trace() msg(_MYNAME ": " __XSTRING(__LINE__) "\n")
#define trace() msg(_BASENAME_RTLD ": " __XSTRING(__LINE__) "\n")


#endif /* DEBUG_H */
8 changes: 8 additions & 0 deletions libexec/rtld-elf/rtld.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,15 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
dbg("obj_main path %s", obj_main->path);
obj_main->mainprog = true;

<<<<<<< HEAD
#ifndef COMPAT_32BIT
=======
if (aux_info[AT_STACKPROT] != NULL &&
aux_info[AT_STACKPROT]->a_un.a_val != 0)
stack_prot = aux_info[AT_STACKPROT]->a_un.a_val;

#ifndef COMPAT_libcompat
>>>>>>> freebsd/main
/*
* Get the actual dynamic linker pathname from the executable if
* possible. (It should always be possible.) That ensures that
Expand Down
49 changes: 28 additions & 21 deletions libexec/rtld-elf/rtld_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,60 @@

#undef _PATH_ELF_HINTS

#ifndef _COMPAT32_BASENAME_RTLD
#define _COMPAT32_BASENAME_RTLD "ld-elf32.so.1"
#ifndef _RTLD_COMPAT_LIB_SUFFIX
#ifdef COMPAT_libcompat
#define _RTLD_COMPAT_LIB_SUFFIX COMPAT_libcompat
#else
#define _RTLD_COMPAT_LIB_SUFFIX ""
#endif
#endif

#ifndef _PATH_ELF32_HINTS
#define _PATH_ELF32_HINTS "/var/run/ld-elf32.so.hints"
#ifndef _RTLD_COMPAT_ENV_SUFFIX
#ifdef COMPAT_LIBCOMPAT
#define _RTLD_COMPAT_ENV_SUFFIX COMPAT_LIBCOMPAT "_"
#else
#define _RTLD_COMPAT_ENV_SUFFIX ""
#endif
#endif

#ifdef COMPAT_32BIT
#define _PATH_ELF_HINTS _PATH_ELF32_HINTS
#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
#define _BASENAME_RTLD _COMPAT32_BASENAME_RTLD
#define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
#define LD_ "LD_32_"
#define TOKEN_LIB "lib32"
#ifndef __PATH_ELF_HINTS
#define __PATH_ELF_HINTS(_lc) "/var/run/ld-elf" _lc ".so.hints"
#endif

#ifndef _PATH_ELF_HINTS
#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
#define _PATH_ELF_HINTS __PATH_ELF_HINTS(_RTLD_COMPAT_LIB_SUFFIX)
#endif

#ifndef _PATH_LIBMAP_CONF
#define _PATH_LIBMAP_CONF "/etc/libmap.conf"
#define _PATH_LIBMAP_CONF "/etc/libmap" _RTLD_COMPAT_LIB_SUFFIX ".conf"
#endif

#ifndef __BASENAME_RTLD
#define __BASENAME_RTLD(_lc) "ld-elf" _lc ".so.1"
#endif

#ifndef _BASENAME_RTLD
#define _BASENAME_RTLD "ld-elf.so.1"
#define _BASENAME_RTLD __BASENAME_RTLD(_RTLD_COMPAT_LIB_SUFFIX)
#endif

#ifndef _PATH_RTLD
#define _PATH_RTLD "/libexec/" _BASENAME_RTLD
#ifndef __PATH_RTLD
#define __PATH_RTLD(_lc) "/libexec/" __BASENAME_RTLD(_lc)
#endif

#ifndef _COMPAT32_PATH_RTLD
#define _COMPAT32_PATH_RTLD "/libexec/" _COMPAT32_BASENAME_RTLD
#ifndef _PATH_RTLD
#define _PATH_RTLD __PATH_RTLD(_RTLD_COMPAT_LIB_SUFFIX)
#endif

#ifndef STANDARD_LIBRARY_PATH
#define STANDARD_LIBRARY_PATH "/lib:/usr/lib"
#define STANDARD_LIBRARY_PATH "/lib" _RTLD_COMPAT_LIB_SUFFIX ":/usr/lib" _RTLD_COMPAT_LIB_SUFFIX
#endif

#ifndef LD_
#define LD_ "LD_"
#define LD_ "LD_" _RTLD_COMPAT_ENV_SUFFIX
#endif

#ifndef TOKEN_LIB
#define TOKEN_LIB "lib"
#define TOKEN_LIB "lib" _RTLD_COMPAT_LIB_SUFFIX
#endif

#ifdef IN_RTLD
Expand Down
2 changes: 1 addition & 1 deletion sbin/ldconfig/ldconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ main(int argc, char **argv)
}

if (is_32)
hints_file = _PATH_ELF32_HINTS;
hints_file = __PATH_ELF_HINTS("32");
else
hints_file = _PATH_ELF_HINTS;
while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
Expand Down
Loading

0 comments on commit 957a0c9

Please sign in to comment.