Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/libexec/ld.elf_so Catch up to -current, via patch, reques...



details:   https://anonhg.NetBSD.org/src/rev/45f0f9b118a2
branches:  netbsd-7
changeset: 799838:45f0f9b118a2
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 06 18:17:55 2016 +0000

description:
Catch up to -current, via patch, requested by christos in ticket #1126:

diffstat:

 libexec/ld.elf_so/arch/aarch64/mdreloc.c   |  12 ++++-
 libexec/ld.elf_so/arch/alpha/alpha_reloc.c |  12 ++++-
 libexec/ld.elf_so/arch/arm/mdreloc.c       |  12 ++++-
 libexec/ld.elf_so/arch/hppa/hppa_reloc.c   |  46 ++++++++++++++++++++--
 libexec/ld.elf_so/arch/i386/mdreloc.c      |  13 ++++-
 libexec/ld.elf_so/arch/m68k/mdreloc.c      |  16 +++++--
 libexec/ld.elf_so/arch/mips/mips_reloc.c   |  14 ++++-
 libexec/ld.elf_so/arch/powerpc/ppc_reloc.c |  12 ++++-
 libexec/ld.elf_so/arch/sh3/mdreloc.c       |  14 ++++-
 libexec/ld.elf_so/arch/sparc/mdreloc.c     |  12 ++++-
 libexec/ld.elf_so/arch/sparc64/mdreloc.c   |  12 ++++-
 libexec/ld.elf_so/arch/vax/mdreloc.c       |  16 +++++--
 libexec/ld.elf_so/arch/x86_64/mdreloc.c    |  15 +++++-
 libexec/ld.elf_so/headers.c                |  29 ++++++-------
 libexec/ld.elf_so/map_object.c             |   6 +-
 libexec/ld.elf_so/paths.c                  |   5 +-
 libexec/ld.elf_so/reloc.c                  |  17 +++++++-
 libexec/ld.elf_so/rtld.c                   |  61 ++++++++++++++++++-----------
 libexec/ld.elf_so/rtld.h                   |  31 +++++++++++---
 19 files changed, 253 insertions(+), 102 deletions(-)

diffs (truncated from 929 to 300 lines):

diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/aarch64/mdreloc.c
--- a/libexec/ld.elf_so/arch/aarch64/mdreloc.c  Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/aarch64/mdreloc.c  Sun Mar 06 18:17:55 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdreloc.c,v 1.1 2014/08/10 05:47:37 matt Exp $ */
+/* $NetBSD: mdreloc.c,v 1.1.2.1 2016/03/06 18:17:55 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.1 2014/08/10 05:47:37 matt Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.1.2.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -222,7 +222,13 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               new_value = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       }
        rdbg(("bind now/fixup in %s --> old=%p new=%p",
            defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
        if (*where != new_value)
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/alpha/alpha_reloc.c
--- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c        Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c        Sun Mar 06 18:17:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alpha_reloc.c,v 1.40 2011/03/31 15:30:31 skrll Exp $   */
+/*     $NetBSD: alpha_reloc.c,v 1.40.22.1 2016/03/06 18:17:55 martin Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -62,7 +62,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: alpha_reloc.c,v 1.40 2011/03/31 15:30:31 skrll Exp $");
+__RCSID("$NetBSD: alpha_reloc.c,v 1.40.22.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -376,7 +376,13 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               new_value = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       }
        rdbg(("bind now/fixup in %s --> old=%p new=%p",
            defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
 
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/arm/mdreloc.c
--- a/libexec/ld.elf_so/arch/arm/mdreloc.c      Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/arm/mdreloc.c      Sun Mar 06 18:17:55 2016 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: mdreloc.c,v 1.37 2011/11/18 16:10:03 joerg Exp $       */
+/*     $NetBSD: mdreloc.c,v 1.37.18.1 2016/03/06 18:17:55 martin Exp $ */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.37 2011/11/18 16:10:03 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.37.18.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -286,7 +286,13 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               new_value = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       }
        /* Set the Thumb bit, if needed.  */
        if (ELF_ST_TYPE(def->st_info) == STT_ARM_TFUNC)
                new_value |= 1;
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/hppa/hppa_reloc.c
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c  Sun Mar 06 18:17:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hppa_reloc.c,v 1.42 2012/01/06 10:38:57 skrll Exp $    */
+/*     $NetBSD: hppa_reloc.c,v 1.42.18.1 2016/03/06 18:17:55 martin Exp $      */
 
 /*-
  * Copyright (c) 2002, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: hppa_reloc.c,v 1.42 2012/01/06 10:38:57 skrll Exp $");
+__RCSID("$NetBSD: hppa_reloc.c,v 1.42.18.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <stdlib.h>
@@ -656,9 +656,19 @@
                if (__predict_false(def == &_rtld_sym_zero))
                        return 0;
 
-               func_pc = (Elf_Addr)(defobj->relocbase + def->st_value +
-                   rela->r_addend);
-               func_sl = (Elf_Addr)(defobj->pltgot);
+               if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+                       if (tp == NULL)
+                               return 0;
+                       Elf_Addr ptr = _rtld_resolve_ifunc(defobj, def);
+                       assert(RTLD_IS_PLABEL(ptr));
+                       hppa_plabel *label = RTLD_GET_PLABEL(ptr);
+                       func_pc = label->hppa_plabel_pc;
+                       func_sl = label->hppa_plabel_sl;
+               } else {
+                       func_pc = (Elf_Addr)(defobj->relocbase + def->st_value +
+                           rela->r_addend);
+                       func_sl = (Elf_Addr)(defobj->pltgot);
+               }
 
                rdbg(("bind now/fixup in %s --> old=(%p,%p) new=(%p,%p)",
                    defobj->strtab + def->st_name,
@@ -710,3 +720,29 @@
        }
        return 0;
 }
+
+void
+_rtld_call_function_void(const Obj_Entry *obj, Elf_Addr ptr)
+{
+       volatile hppa_plabel plabel;
+       void (*f)(void);
+
+       plabel.hppa_plabel_pc = (Elf_Addr)ptr;
+       plabel.hppa_plabel_sl = (Elf_Addr)(obj->pltgot);
+       f = (void (*)(void))RTLD_MAKE_PLABEL(&plabel);
+
+       f();
+}
+
+Elf_Addr
+_rtld_call_function_addr(const Obj_Entry *obj, Elf_Addr ptr)
+{
+       volatile hppa_plabel plabel;
+       Elf_Addr (*f)(void);
+
+       plabel.hppa_plabel_pc = (Elf_Addr)ptr;
+       plabel.hppa_plabel_sl = (Elf_Addr)(obj->pltgot);
+       f = (Elf_Addr (*)(void))RTLD_MAKE_PLABEL(&plabel);
+
+       return f();
+}
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/i386/mdreloc.c
--- a/libexec/ld.elf_so/arch/i386/mdreloc.c     Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/i386/mdreloc.c     Sun Mar 06 18:17:55 2016 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: mdreloc.c,v 1.35 2012/11/07 07:24:46 apb Exp $ */
+/*     $NetBSD: mdreloc.c,v 1.35.8.1 2016/03/06 18:17:55 martin Exp $  */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.35 2012/11/07 07:24:46 apb Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.35.8.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -230,7 +230,14 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       target = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               target = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               target = (Elf_Addr)(defobj->relocbase + def->st_value);
+       }
+
        rdbg(("bind now/fixup in %s --> old=%p new=%p",
            defobj->strtab + def->st_name, (void *)*where, 
            (void *)target));
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/m68k/mdreloc.c
--- a/libexec/ld.elf_so/arch/m68k/mdreloc.c     Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c     Sun Mar 06 18:17:55 2016 +0000
@@ -1,13 +1,13 @@
-/*     $NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $       */
+/*     $NetBSD: mdreloc.c,v 1.29.18.1 2016/03/06 18:17:55 martin Exp $ */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29.18.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.29 2011/11/22 15:25:28 joerg Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.29.18.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -223,8 +223,14 @@
                return 0;
 
        assert(rela->r_addend == 0);
-       new_value = (Elf_Addr)(defobj->relocbase + def->st_value +
-           rela->r_addend);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               new_value = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               new_value = (Elf_Addr)(defobj->relocbase + def->st_value +
+                   rela->r_addend);
+       }
        rdbg(("bind now/fixup in %s --> old=%p new=%p",
            defobj->strtab + def->st_name, (void *)*where, (void *)new_value));
        if (*where != new_value)
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/mips/mips_reloc.c
--- a/libexec/ld.elf_so/arch/mips/mips_reloc.c  Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c  Sun Mar 06 18:17:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_reloc.c,v 1.62 2011/03/25 18:07:05 joerg Exp $    */
+/*     $NetBSD: mips_reloc.c,v 1.62.22.1 2016/03/06 18:17:55 martin Exp $      */
 
 /*
  * Copyright 1997 Michael L. Hitch <mhitch%montana.edu@localhost>
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mips_reloc.c,v 1.62 2011/03/25 18:07:05 joerg Exp $");
+__RCSID("$NetBSD: mips_reloc.c,v 1.62.22.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -445,7 +445,7 @@
 
                        rdbg(("TPREL %s in %s --> %p in %s",
                            obj->strtab + obj->symtab[r_symndx].st_name,
-                           obj->path, (void *)*where, defobj->path));
+                           obj->path, where, defobj->path));
                        break;
                }
 
@@ -487,7 +487,13 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)
+                       return 0;
+               new_value = _rtld_resolve_ifunc(defobj, def);
+       } else {
+               new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       }
        rdbg(("bind now/fixup in %s --> new=%p",
            defobj->strtab + def->st_name, (void *)new_value));
        got[obj->local_gotno + sym - obj->gotsym] = new_value;
diff -r 7dce0704a659 -r 45f0f9b118a2 libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
--- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c        Sun Mar 06 18:08:04 2016 +0000
+++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c        Sun Mar 06 18:17:55 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ppc_reloc.c,v 1.52 2014/07/28 17:28:13 matt Exp $      */
+/*     $NetBSD: ppc_reloc.c,v 1.52.2.1 2016/03/06 18:17:55 martin Exp $        */
 
 /*-
  * Copyright (C) 1998  Tsubai Masanari
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ppc_reloc.c,v 1.52 2014/07/28 17:28:13 matt Exp $");
+__RCSID("$NetBSD: ppc_reloc.c,v 1.52.2.1 2016/03/06 18:17:55 martin Exp $");
 #endif /* not lint */
 
 #include <stdarg.h>
@@ -366,7 +366,13 @@
        if (__predict_false(def == &_rtld_sym_zero))
                return 0;
 
-       value = (Elf_Addr)(defobj->relocbase + def->st_value);
+       if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+               if (tp == NULL)



Home | Main Index | Thread Index | Old Index