From: François Tigeot Date: Sat, 12 Apr 2014 06:41:54 +0000 (+0200) Subject: Dynamic root: Move ld-elf.so.2 to /libexec X-Git-Tag: v3.9.0~161 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/16dbe6a928240d2203ae04fada72427e278b6f55 Dynamic root: Move ld-elf.so.2 to /libexec * Install it first to avoid breaking upgrades for systems previously having it located in /usr/libexec. install(1), beeing a dynamic binary, needs it at runtime. * Since ld-elf.so.2's path is embedded in ELF binaries, also create a symbolic link in the old location to support existing binaries. * Code to handle chflags attributes obtained from FreeBSD. --- diff --git a/Makefile.inc1 b/Makefile.inc1 index 7877c655d8..e232351050 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -26,6 +26,13 @@ # Put initial settings here. SUBDIR= +# /libexec/ld-elf.so.2 needs to be installed first +# Otherwise, install(1) beeing a dynamically linked binary will fail +# during the first upgrade from a static to a dynamic world +.if exists(${.CURDIR}/libexec) +SUBDIR+= libexec +.endif + # We must do share/info early so that installation of info `dir' # entries works correctly. Do it first since it is less likely to # grow dependencies on include and lib than vice versa. @@ -58,9 +65,6 @@ SUBDIR+= games .if exists(${.CURDIR}/gnu) SUBDIR+= gnu .endif -.if exists(${.CURDIR}/libexec) -SUBDIR+= libexec -.endif .if exists(${.CURDIR}/sbin) SUBDIR+= sbin .endif diff --git a/contrib/gcc-4.4/gcc/config/dragonfly.h b/contrib/gcc-4.4/gcc/config/dragonfly.h index 0f20b10ec7..509940b4be 100644 --- a/contrib/gcc-4.4/gcc/config/dragonfly.h +++ b/contrib/gcc-4.4/gcc/config/dragonfly.h @@ -123,8 +123,7 @@ along with GCC; see the file COPYING3. If not see #undef LINK_SPEC #define LINK_SPEC DFBSD_LINK_SPEC -#define DFBSD_DYNAMIC_LINKER \ - "/usr/libexec/ld-elf.so.2" +#define DFBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.2" #if defined(HAVE_LD_EH_FRAME_HDR) #define LINK_EH_SPEC "--eh-frame-hdr" diff --git a/contrib/gcc-4.7/gcc/config/dragonfly.h b/contrib/gcc-4.7/gcc/config/dragonfly.h index 8139adf5cc..26b0dd932d 100644 --- a/contrib/gcc-4.7/gcc/config/dragonfly.h +++ b/contrib/gcc-4.7/gcc/config/dragonfly.h @@ -92,7 +92,7 @@ along with GCC; see the file COPYING3. If not see #undef LINK_SPEC #define LINK_SPEC DFBSD_LINK_SPEC -#define DFBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.2" +#define DFBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.2" /* Use --as-needed -lgcc_s for eh support. */ diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index 259eb5a059..b06b039476 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -6,6 +6,8 @@ SRCS= rtld_start.S \ malloc.c xmalloc.c debug.c libmap.c MAN= rtld.1 CSTD?= gnu99 +BINDIR= /libexec +SYMLINKS= ${BINDIR}/${PROG} /usr/libexec/${PROG} WARNS?= 2 # To activate LD_DEBUG functionality, define ENABLE_DEBUG @@ -49,6 +51,13 @@ LDADD= -L${.OBJDIR}/../../lib/libc_rtld -lc_rtld_pic CFLAGS+= -DDEBUG .endif +# 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}) + chflags -h noschg ${DESTDIR}/usr/libexec/${PROG} +.endif + .PATH: ${.CURDIR}/${MACHINE_ARCH} .include diff --git a/sys/cpu/i386/misc/elf_machdep.c b/sys/cpu/i386/misc/elf_machdep.c index 8cd21606c0..bb3311e327 100644 --- a/sys/cpu/i386/misc/elf_machdep.c +++ b/sys/cpu/i386/misc/elf_machdep.c @@ -62,7 +62,7 @@ static Elf32_Brandinfo dragonfly_brand_info = { .machine = EM_386, .compat_3_brand = "DragonFly", .emul_path = NULL, - .interp_path = "/usr/libexec/ld-elf.so.2", + .interp_path = "/libexec/ld-elf.so.2", .sysvec = &elf32_dragonfly_sysvec, .interp_newpath = NULL, .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE, diff --git a/sys/cpu/x86_64/misc/elf_machdep.c b/sys/cpu/x86_64/misc/elf_machdep.c index 2e8f78020e..ed934902e9 100644 --- a/sys/cpu/x86_64/misc/elf_machdep.c +++ b/sys/cpu/x86_64/misc/elf_machdep.c @@ -62,7 +62,7 @@ static Elf64_Brandinfo dragonfly_brand_info = { .machine = EM_X86_64, .compat_3_brand = "DragonFly", .emul_path = NULL, - .interp_path = "/usr/libexec/ld-elf.so.2", + .interp_path = "/libexec/ld-elf.so.2", .sysvec = &elf64_dragonfly_sysvec, .interp_newpath = NULL, .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE,