From 7e3300e505dc27f1a475c80a1acc68e17781ceeb Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 11 Jan 2020 09:18:58 +0000 Subject: [PATCH] rtld: clean up Makefile. Move all MD statements into $MACHINE_ARCH/Makefile.inc. Unconditionally apply version script to rtld, the interpreter is not functional without it for long time. Reviewed by: brooks, emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D23083 --- libexec/rtld-elf/Makefile | 33 +++---------------------- libexec/rtld-elf/amd64/Makefile.inc | 2 +- libexec/rtld-elf/arm/Makefile.inc | 6 +++++ libexec/rtld-elf/i386/Makefile.inc | 2 +- libexec/rtld-elf/mips/Makefile.inc | 3 +++ libexec/rtld-elf/powerpc64/Makefile.inc | 2 ++ libexec/rtld-elf/sparc64/Makefile.inc | 2 ++ 7 files changed, 18 insertions(+), 32 deletions(-) create mode 100644 libexec/rtld-elf/mips/Makefile.inc diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index d998a8694221..c1fedb42b8a5 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -37,11 +37,6 @@ RTLD_ARCH= ${MACHINE_ARCH} RTLD_ARCH= ${MACHINE_CPUARCH} .endif CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR} -.if ${MACHINE_ARCH} == "powerpc64" -LDFLAGS+= -nostdlib -e _rtld_start -.else -LDFLAGS+= -nostdlib -e .rtld_start -.endif NO_WCAST_ALIGN= yes WARNS?= 6 @@ -52,36 +47,14 @@ SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG} MLINKS?= rtld.1 ld-elf.so.1.1 \ rtld.1 ld.so.1 -.if ${MACHINE_CPUARCH} == "sparc64" -CFLAGS+= -fPIC -.else -CFLAGS+= -fpic -.endif -CFLAGS+= -DPIC $(DEBUG) -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -CFLAGS+= -fvisibility=hidden -.endif -.if ${MACHINE_CPUARCH} == "mips" -CFLAGS.reloc.c+=-fno-jump-tables -.endif -LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs +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 -.if ${MACHINE_CPUARCH} == "arm" -# Some of the required math functions (div & mod) are implemented in -# libcompiler_rt on ARM. The library also needs to be placed first to be -# correctly linked. As some of the functions are used before we have -# shared libraries. -LIBADD+= compiler_rt -.endif - - - -.if ${MK_SYMVER} == "yes" VERSION_DEF= ${LIBCSRCDIR}/Versions.def SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map VERSION_MAP= Version.map @@ -90,9 +63,9 @@ 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 -.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. diff --git a/libexec/rtld-elf/amd64/Makefile.inc b/libexec/rtld-elf/amd64/Makefile.inc index fe5164308b9b..9a4df6e7b648 100644 --- a/libexec/rtld-elf/amd64/Makefile.inc +++ b/libexec/rtld-elf/amd64/Makefile.inc @@ -1,3 +1,3 @@ # $FreeBSD$ -CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float +CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float -fvisibility=hidden diff --git a/libexec/rtld-elf/arm/Makefile.inc b/libexec/rtld-elf/arm/Makefile.inc index e8c0da7a1d7e..2ef884cfe1d0 100644 --- a/libexec/rtld-elf/arm/Makefile.inc +++ b/libexec/rtld-elf/arm/Makefile.inc @@ -1 +1,7 @@ # $FreeBSD$ + +# Some of the required math functions (div & mod) are implemented in +# libcompiler_rt on ARM. The library also needs to be placed first to be +# correctly linked. As some of the functions are used before we have +# shared libraries. +LIBADD+= compiler_rt diff --git a/libexec/rtld-elf/i386/Makefile.inc b/libexec/rtld-elf/i386/Makefile.inc index fe5164308b9b..9a4df6e7b648 100644 --- a/libexec/rtld-elf/i386/Makefile.inc +++ b/libexec/rtld-elf/i386/Makefile.inc @@ -1,3 +1,3 @@ # $FreeBSD$ -CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float +CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float -fvisibility=hidden diff --git a/libexec/rtld-elf/mips/Makefile.inc b/libexec/rtld-elf/mips/Makefile.inc new file mode 100644 index 000000000000..491f5b1bad62 --- /dev/null +++ b/libexec/rtld-elf/mips/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +CFLAGS.reloc.c+=-fno-jump-tables diff --git a/libexec/rtld-elf/powerpc64/Makefile.inc b/libexec/rtld-elf/powerpc64/Makefile.inc index e8c0da7a1d7e..a7bcb501e2b5 100644 --- a/libexec/rtld-elf/powerpc64/Makefile.inc +++ b/libexec/rtld-elf/powerpc64/Makefile.inc @@ -1 +1,3 @@ # $FreeBSD$ + +RTLD_ENTRY= _rtld_start diff --git a/libexec/rtld-elf/sparc64/Makefile.inc b/libexec/rtld-elf/sparc64/Makefile.inc index e8c0da7a1d7e..114c9ad80bdd 100644 --- a/libexec/rtld-elf/sparc64/Makefile.inc +++ b/libexec/rtld-elf/sparc64/Makefile.inc @@ -1 +1,3 @@ # $FreeBSD$ + +CFLAGS:=${CFLAGS:S/-fpic/-fPIC/}