Source-Changes-D archive

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

Re: CVS commit: src/sys



Thanks Paul for finding out the bug!

Then, compat_netbsd32 and compat_netbsd32_coredump modules are
successfully load for kernel without COMPAT_NETBSD32 option.

However, OABI binaries still do not work. I found this is due to
there remains ``#ifdef COMPAT_NETBSD32'' codes in sys/arch/arm.

By fixing them, OABI binaries work and dump valid core files!

I changed two files.

(1) arm_netbsd_elf32_probe() in arm/cpu_exec.c

Previously, determine whether emulation is native or netbsd32 by
testing ``epp->ep_esch->es_emul == &emul_netbsd32''. This requires
COMPAT_NETBSD32 option. However, we can use
``epp->ep_esch->es_emul != &emul_netbsd'' for this purpose.

(2) arm_netbsd_elf32_coredump_setup() in arm/core_machdep.c

This seems simply a mistake; kernel sets EABI flag to OABI core
files. We can remove entire COMPAT_NETBSD32 codes.

I will commit them soon if there's no objection.

Thanks,
rin

On 2020/11/08 6:53, Paul Goyette wrote:
Thanks for fixing ...

On Sat, 7 Nov 2020, Christos Zoulas wrote:

/usr/obj/evbarm-earmv7/tools/bin/nbmake-evbarm -V MACHINE_ARCH
earmv7


christos

On Nov 7, 2020, at 4:27 PM, Paul Goyette <paul%whooppee.com@localhost> wrote:

OK, I think I found the problem, but I don't know how to solve it...

All of the undefined symbols are supposed to be provided by

    .../sys/arch/arm/arm32/netbsd32_machdep.c

but there is no netbsd32_machdep.o included in the compat_netbsd32
module.  This file should be included by the following code in .../sys/modules/compat_netbsd32/Makefile

    .if ${MACHINE_ARCH} == "arm"
    .PATH:  ${S}/arch/arm/arm32
    SRCS+=  netbsd32_machdep.c
    .endif

but it seems not to work (or at least, it doesn't do what it was
intended to do).






On Thu, 5 Nov 2020, Rin Okuyama wrote:

On 2020/11/05 5:43, Paul Goyette wrote:
BTW, the patch you submitted with the initial message in this thread
looks good for avoiding the issue.  But I'm not sure it is a complete
solution.
In particular, you would need to build a 32-bit arm that contains ``no
options COMPAT_NETBSD32'' and then boot and load the compat_netbsd32
and compat_netbsd32_coredump modules

    modload compat_netbsd32
    modload compat_netbsd32_coredump
Then see if emulation of the old ABI still works, and check if core-
dump works for old-ADI programs; the test program I've been using for
core-dump checking is

    #include <stdlib.h>
    int main(int argc, void *argv) { abort(); }
I really have to leave and take care of some personal business, so I
would greatly appreciate if you can check this out.

Hmm, ``modload compat_netbsd32'' does not work on evbarmv6hf-el:

----
# uname -ap
NetBSD  9.99.75 NetBSD 9.99.75 (RPI0) #11: Thu Nov  5 20:26:39 JST 2020 rin@latipes:/sys/arch/evbarm/compile/RPI0 evbarm earmv6hf
# modload compat_netbsd32
[  29.6328410] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `netbsd32_vm_default_addr' not found
[  29.6460400] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `netbsd32_machdep_md_init' not found
[  29.6560750] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `netbsd32_sendsig' not found
[  29.6661200] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `cpu_mcontext32_validate' not found
[  29.6791570] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `cpu_setmcontext32' not found
[  29.6791570] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `netbsd32_machdep_md_fini' not found
[  29.6948370] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `startlwp32' not found
[  29.7048770] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `cpu_getmcontext32' not found
[  29.7168550] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `machine32' not found
[  29.7168550] kobj_checksyms, 994: [compat_netbsd32]: linker error: symbol `netbsd32_sysarch' not found
[  29.7318320] WARNING: module error: unable to affix module `compat_netbsd32', error 8
modload: compat_netbsd32: Exec format error
----

This should be because there are ``#ifdef COMPAT_NETBSD32'' codes in files
not included in compat_netbsd32 module. compat_netbsd32 module must not
work also for aarch64 and mips64 for the same reason, whereas amd64 and
sparc64 seem OK.

Thanks,
rin

!DSPAM:5fa3f309175521945872603!



+--------------------+--------------------------+-----------------------+
| Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
| (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost     |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost   |
+--------------------+--------------------------+-----------------------+



+--------------------+--------------------------+-----------------------+
| Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:     |
| (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost     |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost   |
+--------------------+--------------------------+-----------------------+
Index: sys/arch/arm/arm/cpu_exec.c
===================================================================
RCS file: /home/netbsd/src/sys/arch/arm/arm/cpu_exec.c,v
retrieving revision 1.10
diff -p -u -r1.10 cpu_exec.c
--- sys/arch/arm/arm/cpu_exec.c	27 Apr 2015 06:54:12 -0000	1.10
+++ sys/arch/arm/arm/cpu_exec.c	8 Nov 2020 00:26:08 -0000
@@ -33,7 +33,6 @@
 __KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v 1.10 2015/04/27 06:54:12 skrll Exp $");
 
 #include "opt_compat_netbsd.h"
-#include "opt_compat_netbsd32.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -45,10 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_exec.c,v
 #include <compat/common/compat_util.h>
 #include <sys/exec_elf.h>			/* mandatory */
 
-#ifdef COMPAT_NETBSD32
-#include <compat/netbsd32/netbsd32_exec.h>
-#endif
-
 #include <arm/locore.h>
 
 #if EXEC_ELF32
@@ -60,11 +55,7 @@ arm_netbsd_elf32_probe(struct lwp *l, st
 	const Elf_Ehdr * const eh = eh0;
 	const bool elf_aapcs_p =
 	    (eh->e_flags & EF_ARM_EABIMASK) >= EF_ARM_EABI_VER4;
-#ifdef COMPAT_NETBSD32
-	const bool netbsd32_p = (epp->ep_esch->es_emul == &emul_netbsd32);
-#else
-	const bool netbsd32_p = false;
-#endif
+	const bool netbsd32_p = (epp->ep_esch->es_emul != &emul_netbsd);
 #ifdef __ARM_EABI__
 	const bool aapcs_p = true;
 #else

Index: sys/arch/arm/arm/core_machdep.c
===================================================================
RCS file: /home/netbsd/src/sys/arch/arm/arm/core_machdep.c,v
retrieving revision 1.9
diff -p -u -r1.9 core_machdep.c
--- sys/arch/arm/arm/core_machdep.c	20 Nov 2019 19:37:51 -0000	1.9
+++ sys/arch/arm/arm/core_machdep.c	8 Nov 2020 00:25:07 -0000
@@ -41,7 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
-#include "opt_compat_netbsd32.h"
 #else
 #define EXEC_ELF32 1
 #endif
@@ -61,9 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep
 
 #ifdef EXEC_ELF32
 #include <sys/exec_elf.h>
-#ifdef COMPAT_NETBSD32
-#include <compat/netbsd32/netbsd32_exec.h>
-#endif
 #endif
 
 #include <machine/reg.h>
@@ -120,21 +116,16 @@ cpu_coredump(struct lwp *l, struct cored
 void
 arm_netbsd_elf32_coredump_setup(struct lwp *l, void *arg)
 {
-#if defined(__ARMEB__) || defined(__ARM_EABI__) || defined(COMPAT_NETBSD32)
+#if defined(__ARMEB__) || defined(__ARM_EABI__)
 	Elf_Ehdr * const eh = arg;
-#if defined(__ARM_EABI__) || defined(COMPAT_NETBSD32)
+#endif
+#ifdef __ARM_EABI__
 	struct proc * const p = l->l_proc;
 
-#ifdef __ARM_EABI__
 	if (p->p_emul == &emul_netbsd) {
 		eh->e_flags |= EF_ARM_EABI_VER5;
 	}
-#elif defined(COMPAT_NETBSD32)
-	if (p->p_emul == &emul_netbsd32) {
-		eh->e_flags |= EF_ARM_EABI_VER5;
-	}
 #endif
-#endif /* __ARM_EABI__ || COMPAT_NETBSD32 */
 #ifdef __ARMEB__
         if (CPU_IS_ARMV7_P()
 	    || (CPU_IS_ARMV6_P()
@@ -142,6 +133,5 @@ arm_netbsd_elf32_coredump_setup(struct l
 		eh->e_flags |= EF_ARM_BE8;
 	}
 #endif
-#endif
 }
 #endif


Home | Main Index | Thread Index | Old Index