svn commit: r309411 - in head/libexec/rtld-elf: . aarch64 riscv sparc64

Ed Maste emaste at FreeBSD.org
Fri Dec 2 14:23:28 UTC 2016


Author: emaste
Date: Fri Dec  2 14:23:26 2016
New Revision: 309411
URL: https://svnweb.freebsd.org/changeset/base/309411

Log:
  Retire long-broken/unused static rtld support
  
  rtld-elf has some vestigial support for building as a static executable.
  r45501 introduced a partial implementation with a prescient note that it
  "might never be enabled." r153515 introduced ELF symbol versioning
  support, and removed part of the unused build infrastructure for static
  rtld.
  
  GNU ld populates rela relocation addends and GOT entries with the same
  values, and rtld's run-time dynamic executable check relied on this.
  Alternate toolchains may not populate the GOT entries, which caused
  RTLD_IS_DYNAMIC to return false. Simplify rtld by just removing the
  unused check.
  
  If we want to restore static rtld support later on we ought to introduce
  a build-time #ifdef flag.
  
  PR:		214972
  Reviewed by:	kan
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D8687

Modified:
  head/libexec/rtld-elf/aarch64/rtld_machdep.h
  head/libexec/rtld-elf/riscv/rtld_machdep.h
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/sparc64/rtld_machdep.h

Modified: head/libexec/rtld-elf/aarch64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/aarch64/rtld_machdep.h	Fri Dec  2 11:32:11 2016	(r309410)
+++ head/libexec/rtld-elf/aarch64/rtld_machdep.h	Fri Dec  2 14:23:26 2016	(r309411)
@@ -45,7 +45,6 @@ struct Struct_Obj_Entry;
 	asm volatile("adr	%0, _DYNAMIC" : "=&r"(_dynamic_addr));	\
 	(const Elf_Dyn *)_dynamic_addr;					\
 })
-#define	RTLD_IS_DYNAMIC() (1)
 
 Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
 		       const struct Struct_Obj_Entry *defobj,

Modified: head/libexec/rtld-elf/riscv/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/riscv/rtld_machdep.h	Fri Dec  2 11:32:11 2016	(r309410)
+++ head/libexec/rtld-elf/riscv/rtld_machdep.h	Fri Dec  2 14:23:26 2016	(r309411)
@@ -52,7 +52,6 @@ uint64_t set_gp(struct Struct_Obj_Entry 
 	__asm __volatile("lla       %0, _DYNAMIC" : "=r"(_dynamic_addr));   \
 	(const Elf_Dyn *)_dynamic_addr;                                 \
 })
-#define RTLD_IS_DYNAMIC() (1)
 
 Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
 		       const struct Struct_Obj_Entry *defobj,

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Fri Dec  2 11:32:11 2016	(r309410)
+++ head/libexec/rtld-elf/rtld.c	Fri Dec  2 14:23:26 2016	(r309411)
@@ -200,9 +200,6 @@ Elf_Sym sym_zero;		/* For resolving unde
 
 extern Elf_Dyn _DYNAMIC;
 #pragma weak _DYNAMIC
-#ifndef RTLD_IS_DYNAMIC
-#define	RTLD_IS_DYNAMIC()	(&_DYNAMIC != NULL)
-#endif
 
 int dlclose(void *) __exported;
 char *dlerror(void) __exported;
@@ -1920,22 +1917,20 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo *
 #ifdef PIC
     objtmp.relocbase = mapbase;
 #endif
-    if (RTLD_IS_DYNAMIC()) {
-	objtmp.dynamic = rtld_dynamic(&objtmp);
-	digest_dynamic1(&objtmp, 1, &dyn_rpath, &dyn_soname, &dyn_runpath);
-	assert(objtmp.needed == NULL);
+
+    objtmp.dynamic = rtld_dynamic(&objtmp);
+    digest_dynamic1(&objtmp, 1, &dyn_rpath, &dyn_soname, &dyn_runpath);
+    assert(objtmp.needed == NULL);
 #if !defined(__mips__)
-	/* MIPS has a bogus DT_TEXTREL. */
-	assert(!objtmp.textrel);
+    /* MIPS has a bogus DT_TEXTREL. */
+    assert(!objtmp.textrel);
 #endif
+    /*
+     * Temporarily put the dynamic linker entry into the object list, so
+     * that symbols can be found.
+     */
+    relocate_objects(&objtmp, true, &objtmp, 0, NULL);
 
-	/*
-	 * Temporarily put the dynamic linker entry into the object list, so
-	 * that symbols can be found.
-	 */
-
-	relocate_objects(&objtmp, true, &objtmp, 0, NULL);
-    }
     ehdr = (Elf_Ehdr *)mapbase;
     objtmp.phdr = (Elf_Phdr *)((char *)mapbase + ehdr->e_phoff);
     objtmp.phsize = ehdr->e_phnum * sizeof(objtmp.phdr[0]);

Modified: head/libexec/rtld-elf/sparc64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/sparc64/rtld_machdep.h	Fri Dec  2 11:32:11 2016	(r309410)
+++ head/libexec/rtld-elf/sparc64/rtld_machdep.h	Fri Dec  2 14:23:26 2016	(r309411)
@@ -37,7 +37,6 @@ struct Struct_Obj_Entry;
 /* Return the address of the .dynamic section in the dynamic linker. */
 Elf_Dyn *rtld_dynamic_addr(void);
 #define	rtld_dynamic(obj)	rtld_dynamic_addr()
-#define	RTLD_IS_DYNAMIC()	(rtld_dynamic_addr() != NULL)
 
 Elf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr,
 		       const struct Struct_Obj_Entry *,


More information about the svn-src-head mailing list