Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Nov 2016 14:13:57 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r308925 - in head/libexec/rtld-elf: . aarch64 amd64 arm i386 mips powerpc powerpc64 riscv sparc64
Message-ID:  <201611211413.uALEDvPs088242@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Nov 21 14:13:57 2016
New Revision: 308925
URL: https://svnweb.freebsd.org/changeset/base/308925

Log:
  Adjust r308689 to make rtld compilable with either in-tree or
  (hopefully) stock gcc 4.2.1 on i386 and other arches.
  
  In particular:
  - Do not use %ebx in the asm constraints on i386, since rtld is
    compiled with -fPIC and gcc cannot handle GOT-base register reload
    (clang and newer gcc can).
  - Avoid direct use of [static N] construct in the function
    declaration/definion.  In-tree gcc was patched to support this, but
    stock 4.2.1 cannot handle the feature.
  
  Requested by:	bde
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/libexec/rtld-elf/aarch64/reloc.c
  head/libexec/rtld-elf/amd64/reloc.c
  head/libexec/rtld-elf/arm/reloc.c
  head/libexec/rtld-elf/i386/reloc.c
  head/libexec/rtld-elf/mips/reloc.c
  head/libexec/rtld-elf/powerpc/reloc.c
  head/libexec/rtld-elf/powerpc64/reloc.c
  head/libexec/rtld-elf/riscv/reloc.c
  head/libexec/rtld-elf/rtld.h
  head/libexec/rtld-elf/sparc64/reloc.c

Modified: head/libexec/rtld-elf/aarch64/reloc.c
==============================================================================
--- head/libexec/rtld-elf/aarch64/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/aarch64/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -300,7 +300,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr 
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/amd64/reloc.c
==============================================================================
--- head/libexec/rtld-elf/amd64/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/amd64/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -454,7 +454,7 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flag
 uint32_t cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2;
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 	u_int p[4], cpu_high;
 

Modified: head/libexec/rtld-elf/arm/reloc.c
==============================================================================
--- head/libexec/rtld-elf/arm/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/arm/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -480,7 +480,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr 
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/i386/reloc.c
==============================================================================
--- head/libexec/rtld-elf/i386/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/i386/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -33,7 +33,6 @@
 
 #include <sys/param.h>
 #include <sys/mman.h>
-#include <machine/cpufunc.h>
 #include <machine/segments.h>
 #include <machine/sysarch.h>
 
@@ -407,8 +406,21 @@ reloc_gnu_ifunc(Obj_Entry *obj, int flag
 
 uint32_t cpu_feature, cpu_feature2, cpu_stdext_feature, cpu_stdext_feature2;
 
+static void
+rtld_cpuid_count(int idx, int cnt, u_int *p)
+{
+
+	__asm __volatile(
+	    "	pushl	%%ebx\n"
+	    "	cpuid\n"
+	    "	movl	%%ebx,%1\n"
+	    "	popl	%%ebx\n"
+	    : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3])
+	    :  "0" (idx), "2" (cnt));
+}
+
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 	u_int p[4], cpu_high;
 	int cpuid_supported;
@@ -432,13 +444,13 @@ ifunc_init(Elf_Auxinfo aux_info[static A
 	if (!cpuid_supported)
 		return;
 
-	do_cpuid(1, p);
+	rtld_cpuid_count(1, 0, p);
 	cpu_feature = p[3];
 	cpu_feature2 = p[2];
-	do_cpuid(0, p);
+	rtld_cpuid_count(0, 0, p);
 	cpu_high = p[0];
 	if (cpu_high >= 7) {
-		cpuid_count(7, 0, p);
+		rtld_cpuid_count(7, 0, p);
 		cpu_stdext_feature = p[1];
 		cpu_stdext_feature2 = p[2];
 	}

Modified: head/libexec/rtld-elf/mips/reloc.c
==============================================================================
--- head/libexec/rtld-elf/mips/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/mips/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -618,7 +618,7 @@ reloc_jmpslot(Elf_Addr *where, Elf_Addr 
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==============================================================================
--- head/libexec/rtld-elf/powerpc/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/powerpc/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -620,7 +620,7 @@ init_pltgot(Obj_Entry *obj)
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/powerpc64/reloc.c
==============================================================================
--- head/libexec/rtld-elf/powerpc64/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/powerpc64/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -524,7 +524,7 @@ init_pltgot(Obj_Entry *obj)
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/riscv/reloc.c
==============================================================================
--- head/libexec/rtld-elf/riscv/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/riscv/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -367,7 +367,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 

Modified: head/libexec/rtld-elf/rtld.h
==============================================================================
--- head/libexec/rtld-elf/rtld.h	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/rtld.h	Mon Nov 21 14:13:57 2016	(r308925)
@@ -367,7 +367,7 @@ void dump_Elf_Rela(Obj_Entry *, const El
 unsigned long elf_hash(const char *);
 const Elf_Sym *find_symdef(unsigned long, const Obj_Entry *,
   const Obj_Entry **, int, SymCache *, struct Struct_RtldLockState *);
-void ifunc_init(Elf_Auxinfo[static AT_COUNT]);
+void ifunc_init(Elf_Auxinfo[__min_size(AT_COUNT)]);
 void init_pltgot(Obj_Entry *);
 void lockdflt_init(void);
 void digest_notes(Obj_Entry *, Elf_Addr, Elf_Addr);

Modified: head/libexec/rtld-elf/sparc64/reloc.c
==============================================================================
--- head/libexec/rtld-elf/sparc64/reloc.c	Mon Nov 21 13:07:57 2016	(r308924)
+++ head/libexec/rtld-elf/sparc64/reloc.c	Mon Nov 21 14:13:57 2016	(r308925)
@@ -787,7 +787,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr
 }
 
 void
-ifunc_init(Elf_Auxinfo aux_info[static AT_COUNT] __unused)
+ifunc_init(Elf_Auxinfo aux_info[__min_size(AT_COUNT)] __unused)
 {
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611211413.uALEDvPs088242>