Dynamic root: Move ld-elf.so.2 to /libexec
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 12 Apr 2014 06:41:54 +0000 (08:41 +0200)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sat, 12 Apr 2014 06:42:34 +0000 (08:42 +0200)
* 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.

Makefile.inc1
contrib/gcc-4.4/gcc/config/dragonfly.h
contrib/gcc-4.7/gcc/config/dragonfly.h
libexec/rtld-elf/Makefile
sys/cpu/i386/misc/elf_machdep.c
sys/cpu/x86_64/misc/elf_machdep.c

index 7877c65..e232351 100644 (file)
 # Put initial settings here.
 SUBDIR=
 
 # 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.
 # 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}/gnu)
 SUBDIR+= gnu
 .endif
-.if exists(${.CURDIR}/libexec)
-SUBDIR+= libexec
-.endif
 .if exists(${.CURDIR}/sbin)
 SUBDIR+= sbin
 .endif
 .if exists(${.CURDIR}/sbin)
 SUBDIR+= sbin
 .endif
index 0f20b10..509940b 100644 (file)
@@ -123,8 +123,7 @@ along with GCC; see the file COPYING3.  If not see
 #undef  LINK_SPEC
 #define LINK_SPEC DFBSD_LINK_SPEC
 
 #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"
 
 #if defined(HAVE_LD_EH_FRAME_HDR)
 #define LINK_EH_SPEC "--eh-frame-hdr"
index 8139adf..26b0dd9 100644 (file)
@@ -92,7 +92,7 @@ along with GCC; see the file COPYING3.  If not see
 #undef  LINK_SPEC
 #define LINK_SPEC DFBSD_LINK_SPEC
 
 #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.  */
 
 
 /* Use --as-needed -lgcc_s for eh support.  */
index 259eb5a..b06b039 100644 (file)
@@ -6,6 +6,8 @@ SRCS=           rtld_start.S \
                malloc.c xmalloc.c debug.c libmap.c
 MAN=           rtld.1
 CSTD?=         gnu99
                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
 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
 
 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 <bsd.symver.mk>
 .PATH: ${.CURDIR}/${MACHINE_ARCH}
 
 .include <bsd.symver.mk>
index 8cd2160..bb3311e 100644 (file)
@@ -62,7 +62,7 @@ static Elf32_Brandinfo dragonfly_brand_info = {
         .machine       = EM_386,
         .compat_3_brand        = "DragonFly",
         .emul_path     = NULL,
         .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,
         .sysvec                = &elf32_dragonfly_sysvec,
         .interp_newpath        = NULL,
         .flags         = BI_CAN_EXEC_DYN | BI_BRAND_NOTE,
index 2e8f780..ed93490 100644 (file)
@@ -62,7 +62,7 @@ static Elf64_Brandinfo dragonfly_brand_info = {
         .machine       = EM_X86_64,
         .compat_3_brand        = "DragonFly",
         .emul_path     = NULL,
         .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,
         .sysvec                = &elf64_dragonfly_sysvec,
         .interp_newpath        = NULL,
         .flags         = BI_CAN_EXEC_DYN | BI_BRAND_NOTE,