NetBSD-Bugs archive

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

kern/58983: INSTALL_FLOPPY on i386 broken



>Number:         58983
>Category:       kern
>Synopsis:       INSTALL_FLOPPY on i386 broken
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 11 14:55:01 +0000 2025
>Originator:     Harold Gutch
>Release:        current, 10.0
>Organization:
The No-options-ptrace Foundation
>Environment:
NetBSD netbsd 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
As pointed out by Eirik Øverby, since October 2020 it is impossible to build INSTALL_FLOPPY, this started with this commit:

https://mail-index.netbsd.org/source-changes/2020/10/20/msg123166.html

Since then we have the following in sys/kern/sys_process_lwpstatus.c :
int
process_doregs(struct lwp *curl /*tracer*/,
[...]
#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
[...]
                r = (ptrace_regrfunc_t)process_read_fpregs;
                w = (ptrace_regwfunc_t)process_write_fpregs;
[...]
#endif
}

(and likewise in process_dofpregs() and process_dodbregs() ) and both PT_GETFPREGS and PT_SETFPREGS are unconditionally set due to the inclusion of <sys/ptrace.h>.

Should something here be protected by an #ifdef PTRACE or so?

From a quick grep, INSTALL on zaurus and MODULAR on amd64 (and any local kernel configuration without "options ptrace") should also be broken - but at least INSTALL on zaurus gets built (not sure why).
>How-To-Repeat:
$ ./build.sh -u -U -O ../obj -m i386 tools kernel=INSTALL_FLOPPY

and observe 

.../i486--netbsdelf-ld -Map netbsd.map --cref -T netbsd.ldscript -Ttext c0100000 -e start -z noseparate-code -X -o netbsd ${SYSTEM_OBJ:[@]:Nswapnetbsd.o} ${EXTRA_OBJ} vers.o swapnetbsd.o
.../i486--netbsdelf-ld: sys_process_lwpstatus.o: in function `process_doregs':
sys_process_lwpstatus.c:(.text+0x22d): undefined reference to `process_write_regs'
.../i486--netbsdelf-ld: sys_process_lwpstatus.o: in function `process_dofpregs':
sys_process_lwpstatus.c:(.text+0x24f): undefined reference to `process_write_fpregs'
.../i486--netbsdelf-ld: sys_process_lwpstatus.o: in function `process_dodbregs':
sys_process_lwpstatus.c:(.text+0x271): undefined reference to `process_write_dbregs'


>Fix:
1) Declare ptrace as mandatory and remove "no-options ptrace" from i386's INSTALL_FLOPPY
or
2) Only compile-tested, I don't know of the functional implications of this:

--- sys/kern/sys_process_lwpstatus.c.orig
+++ sys/kern/sys_process_lwpstatus.c
@@ -141,7 +141,7 @@ process_validdbregs(struct lwp *l)
 #endif
 }

-#ifdef PT_REGISTERS
+#if defined(PTRACE) && defined(PT_REGISTERS)
 static int
 proc_regio(struct lwp *l, struct uio *uio, size_t ks, ptrace_regrfunc_t r,
     ptrace_regwfunc_t w)
@@ -183,7 +183,7 @@ process_doregs(struct lwp *curl /*tracer*/,
     struct lwp *l /*traced*/,
     struct uio *uio)
 {
-#if defined(PT_GETREGS) || defined(PT_SETREGS)
+#if defined(PTRACE) && (defined(PT_GETREGS) || defined(PT_SETREGS))
	size_t s;
	ptrace_regrfunc_t r;
	ptrace_regwfunc_t w;
@@ -217,7 +217,7 @@ process_dofpregs(struct lwp *curl /*tracer*/,
     struct lwp *l /*traced*/,
     struct uio *uio)
 {
-#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS)
+#if defined(PTRACE) && (defined(PT_GETREGS) || defined(PT_SETREGS))
	size_t s;
	ptrace_regrfunc_t r;
	ptrace_regwfunc_t w;
@@ -252,7 +252,7 @@ process_dodbregs(struct lwp *curl /*tracer*/,
     struct lwp *l /*traced*/,
     struct uio *uio)
 {
-#if defined(PT_GETDBREGS) || defined(PT_SETDBREGS)
+#if defined(PTRACE) && (defined(PT_GETDBREGS) || defined(PT_SETDBREGS))
	size_t s;
	ptrace_regrfunc_t r;
	ptrace_regwfunc_t w;



Home | Main Index | Thread Index | Old Index