Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Pass local symbols relocations in both passes and pr...



details:   https://anonhg.NetBSD.org/src/rev/28453827b94a
branches:  trunk
changeset: 374495:28453827b94a
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Apr 28 07:33:55 2023 +0000

description:
Pass local symbols relocations in both passes and provide the kobj_reloc
implementation visibility of these relocations.

Currently all implementations resolve local symbol relocations in the first
pass and simply skip them in the second. The RISC-V implementation will
make use of this visiblity.

diffstat:

 sys/arch/aarch64/aarch64/kobj_machdep.c |  10 ++++++++--
 sys/arch/alpha/alpha/kobj_machdep.c     |  10 ++++++++--
 sys/arch/amd64/amd64/kobj_machdep.c     |  10 ++++++++--
 sys/arch/arm/arm32/kobj_machdep.c       |  10 ++++++++--
 sys/arch/hppa/hppa/kobj_machdep.c       |  10 ++++++++--
 sys/arch/i386/i386/kobj_machdep.c       |  10 ++++++++--
 sys/arch/m68k/m68k/kobj_machdep.c       |  10 ++++++++--
 sys/arch/mips/mips/kobj_machdep.c       |   8 +++++++-
 sys/arch/powerpc/powerpc/kobj_machdep.c |  10 ++++++++--
 sys/arch/sh3/sh3/kobj_machdep.c         |  10 ++++++++--
 sys/arch/sparc/sparc/kobj_machdep.c     |   8 +++++++-
 sys/arch/sparc64/sparc64/kobj_machdep.c |  10 ++++++++--
 sys/arch/vax/vax/kobj_machdep.c         |   8 +++++++-
 sys/kern/subr_kobj.c                    |  18 ++++++++++++++----
 sys/sys/kobj.h                          |   3 ++-
 15 files changed, 117 insertions(+), 28 deletions(-)

diffs (truncated from 446 to 300 lines):

diff -r 852942c3f561 -r 28453827b94a sys/arch/aarch64/aarch64/kobj_machdep.c
--- a/sys/arch/aarch64/aarch64/kobj_machdep.c   Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/aarch64/aarch64/kobj_machdep.c   Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.6 2020/12/11 18:03:33 skrll Exp $   */
+/*     $NetBSD: kobj_machdep.c,v 1.7 2023/04/28 07:33:55 skrll Exp $   */
 
 /*
  * Copyright (c) 2018 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.6 2020/12/11 18:03:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.7 2023/04/28 07:33:55 skrll Exp $");
 
 #define ELFSIZE                ARCH_ELFSIZE
 
@@ -168,6 +168,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                return 0;
        }
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        error = kobj_sym_lookup(ko, symidx, &saddr);
        if (error != 0) {
                printf("kobj_reloc: symidx %d lookup failure."
diff -r 852942c3f561 -r 28453827b94a sys/arch/alpha/alpha/kobj_machdep.c
--- a/sys/arch/alpha/alpha/kobj_machdep.c       Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/alpha/alpha/kobj_machdep.c       Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.3 2017/11/03 09:59:07 maxv Exp $    */
+/*     $NetBSD: kobj_machdep.c,v 1.4 2023/04/28 07:33:55 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.3 2017/11/03 09:59:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.4 2023/04/28 07:33:55 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -88,6 +88,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                symidx = ELF_R_SYM(rel->r_info);
        }
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_ALPHA_NONE:
                break;
diff -r 852942c3f561 -r 28453827b94a sys/arch/amd64/amd64/kobj_machdep.c
--- a/sys/arch/amd64/amd64/kobj_machdep.c       Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/amd64/amd64/kobj_machdep.c       Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $   */
+/*     $NetBSD: kobj_machdep.c,v 1.9 2023/04/28 07:33:55 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2019/05/28 03:52:08 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.9 2023/04/28 07:33:55 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -106,6 +106,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                }
        }
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_X86_64_NONE:     /* none */
                break;
diff -r 852942c3f561 -r 28453827b94a sys/arch/arm/arm32/kobj_machdep.c
--- a/sys/arch/arm/arm32/kobj_machdep.c Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/arm/arm32/kobj_machdep.c Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.15 2020/12/01 02:43:14 rin Exp $    */
+/*     $NetBSD: kobj_machdep.c,v 1.16 2023/04/28 07:33:56 skrll Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.15 2020/12/01 02:43:14 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.16 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -95,6 +95,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                symidx = ELF_R_SYM(rel->r_info);
        }
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_ARM_NONE:        /* none */
        case R_ARM_V4BX:        /* none */
diff -r 852942c3f561 -r 28453827b94a sys/arch/hppa/hppa/kobj_machdep.c
--- a/sys/arch/hppa/hppa/kobj_machdep.c Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/hppa/hppa/kobj_machdep.c Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.15 2017/11/03 09:59:08 maxv Exp $   */
+/*     $NetBSD: kobj_machdep.c,v 1.16 2023/04/28 07:33:56 skrll Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.15 2017/11/03 09:59:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.16 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -149,6 +149,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
        rtype = ELF_R_TYPE(rela->r_info);
        symidx = ELF_R_SYM(rela->r_info);
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_TYPE(NONE):
                break;
diff -r 852942c3f561 -r 28453827b94a sys/arch/i386/i386/kobj_machdep.c
--- a/sys/arch/i386/i386/kobj_machdep.c Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/i386/i386/kobj_machdep.c Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.8 2017/11/03 09:59:08 maxv Exp $    */
+/*     $NetBSD: kobj_machdep.c,v 1.9 2023/04/28 07:33:56 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2017/11/03 09:59:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.9 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -95,6 +95,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
                symidx = ELF_R_SYM(rel->r_info);
        }
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_386_NONE:        /* none */
                return 0;
diff -r 852942c3f561 -r 28453827b94a sys/arch/m68k/m68k/kobj_machdep.c
--- a/sys/arch/m68k/m68k/kobj_machdep.c Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/m68k/m68k/kobj_machdep.c Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.4 2017/11/03 09:59:08 maxv Exp $    */
+/*     $NetBSD: kobj_machdep.c,v 1.5 2023/04/28 07:33:56 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.4 2017/11/03 09:59:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.5 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -57,6 +57,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
        symnum = ELF_R_SYM(rela->r_info);
        rtype = ELF_R_TYPE(rela->r_info);
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_TYPE(NONE):
                break;
diff -r 852942c3f561 -r 28453827b94a sys/arch/mips/mips/kobj_machdep.c
--- a/sys/arch/mips/mips/kobj_machdep.c Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/mips/mips/kobj_machdep.c Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.1 2021/03/23 13:22:40 simonb Exp $  */
+/*     $NetBSD: kobj_machdep.c,v 1.2 2023/04/28 07:33:56 skrll Exp $   */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -84,6 +84,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
        rtype = ELF_R_TYPE(rela->r_info);
        symidx = ELF_R_SYM(rela->r_info);
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        /* pointer to 32bit value and instruction */
        insn = (void *)where;
 
diff -r 852942c3f561 -r 28453827b94a sys/arch/powerpc/powerpc/kobj_machdep.c
--- a/sys/arch/powerpc/powerpc/kobj_machdep.c   Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/powerpc/powerpc/kobj_machdep.c   Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.7 2017/11/03 09:59:08 maxv Exp $    */
+/*     $NetBSD: kobj_machdep.c,v 1.8 2023/04/28 07:33:56 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.7 2017/11/03 09:59:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -91,6 +91,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
        rtype = ELF_R_TYPE(rela->r_info);
        symidx = ELF_R_SYM(rela->r_info);
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_PPC_NONE:
                break;
diff -r 852942c3f561 -r 28453827b94a sys/arch/sh3/sh3/kobj_machdep.c
--- a/sys/arch/sh3/sh3/kobj_machdep.c   Fri Apr 28 07:12:39 2023 +0000
+++ b/sys/arch/sh3/sh3/kobj_machdep.c   Fri Apr 28 07:33:55 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kobj_machdep.c,v 1.7 2019/04/09 00:36:55 uwe Exp $     */
+/*     $NetBSD: kobj_machdep.c,v 1.8 2023/04/28 07:33:56 skrll Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.7 2019/04/09 00:36:55 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.8 2023/04/28 07:33:56 skrll Exp $");
 
 #define        ELFSIZE         ARCH_ELFSIZE
 
@@ -59,6 +59,12 @@ kobj_reloc(kobj_t ko, uintptr_t relocbas
        symidx = ELF_R_SYM(rela->r_info);
        rtype = ELF_R_TYPE(rela->r_info);
 
+       const Elf_Sym *sym = kobj_symbol(ko, symidx);
+
+       if (!local && ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
+               return 0;
+       }
+
        switch (rtype) {
        case R_TYPE(NONE):



Home | Main Index | Thread Index | Old Index