On Wed, Jul 12, 2006 at 12:21:42PM +0300, Hayim Shaul wrote: > I copied the defines: > > #if defined __USE_MISC || defined _ASM > # define JB_BX 0 > # define JB_SI 1 > # define JB_DI 2 > # define JB_BP 3 > # define JB_SP 4 > # define JB_PC 5 > # define JB_SIZE 24 > #endif
Instead of the patch mentioned earlier, you might also try the one below - it depends on klibc, so you need to apply it to a recent -mm UML. I'm thinking about sending this to Andrew, despite it's nastinesses. It applies on top of (and backs out) the other jmpbuf patch. Jeff This patch should not go to mainline before klibc, since it depends on klibc. It does add an in-tree user, so if that's a consideration for klibc going to mainline, it should be duly considered. In order for UML to dump kernel stacks properly, it needs access to the kernel registers, which are stored in jmpbufs. Recent glibc removes the JB_* macros which formerly provided access to jmpbuf contents. Ulrich's advice was to provide my own setjmp/longjmp implementation. Rather than do that, this patch uses the klibc setjmp/longjmp implementations. In doing so, there are various nasty things needed in order to pull in the correct headers when needed. There's a new symlink added in order for #include "klibc/..." to work - arch/um/include/klibc -> usr/include/klibc In addition, usr/include/arch/{i386,x86_64}/klibc is pulled in by adding -I to the userspace compilations. -I isn't usable for usr/include/klibc because that would have to be -Iusr/include, which would confuse gcc into using klibc headers when glibc headers are wanted. Mixing libcs is walking on thin ice - the -I that is used is safe because there are (currently) no name conflicts between usr/include/arch/{i386,x86_64}/klibc and /usr/include. setjmp and longjmp themselves are pulled in with a symlink from arch/um/os-Linux/setjmp.o to usr/klibc/arch/{i386,x86_64}/setjmp.o To fix - the symlink should really be under arch/um/os/, since it's really an OS-specific thing there should probably be a dependency on klibc having already been built Index: linux-2.6.17/arch/um/os-Linux/sys-i386/registers.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/sys-i386/registers.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/sys-i386/registers.c 2006-07-12 11:51:17.000000000 -0400 @@ -5,12 +5,12 @@ #include <errno.h> #include <string.h> -#include <setjmp.h> #include "sysdep/ptrace_user.h" #include "sysdep/ptrace.h" #include "uml-config.h" #include "skas_ptregs.h" #include "registers.h" +#include "longjmp.h" #include "user.h" /* These are set once at boot time and not changed thereafter */ @@ -130,17 +130,11 @@ void get_safe_registers(unsigned long *r HOST_FP_SIZE * sizeof(unsigned long)); } -#ifndef JB_PC -#define JB_PC 5 -#define JB_SP 4 -#define JB_BP 3 -#endif - void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) { - struct __jmp_buf_tag *jmpbuf = buffer; + struct __jmp_buf *jmpbuf = buffer; - UPT_SET(uml_regs, EIP, jmpbuf->__jmpbuf[JB_PC]); - UPT_SET(uml_regs, UESP, jmpbuf->__jmpbuf[JB_SP]); - UPT_SET(uml_regs, EBP, jmpbuf->__jmpbuf[JB_BP]); + UPT_SET(uml_regs, EIP, jmpbuf->__eip); + UPT_SET(uml_regs, UESP, jmpbuf->__esp); + UPT_SET(uml_regs, EBP, jmpbuf->__ebp); } Index: linux-2.6.17/arch/um/os-Linux/sys-x86_64/registers.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/sys-x86_64/registers.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/sys-x86_64/registers.c 2006-07-12 11:51:17.000000000 -0400 @@ -5,11 +5,11 @@ #include <errno.h> #include <string.h> -#include <setjmp.h> #include "ptrace_user.h" #include "uml-config.h" #include "skas_ptregs.h" #include "registers.h" +#include "longjmp.h" #include "user.h" /* These are set once at boot time and not changed thereafter */ @@ -78,17 +78,11 @@ void get_safe_registers(unsigned long *r HOST_FP_SIZE * sizeof(unsigned long)); } -#ifndef JB_PC -#define JB_PC 7 -#define JB_RSP 6 -#define JB_RBP 1 -#endif - void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) { - struct __jmp_buf_tag *jmpbuf = buffer; + struct __jmp_buf *jmpbuf = buffer; - UPT_SET(uml_regs, RIP, jmpbuf->__jmpbuf[JB_PC]); - UPT_SET(uml_regs, RSP, jmpbuf->__jmpbuf[JB_RSP]); - UPT_SET(uml_regs, RBP, jmpbuf->__jmpbuf[JB_RBP]); + UPT_SET(uml_regs, RIP, jmpbuf->__rip); + UPT_SET(uml_regs, RSP, jmpbuf->__rsp); + UPT_SET(uml_regs, RBP, jmpbuf->__rbp); } Index: linux-2.6.17/arch/um/Makefile =================================================================== --- linux-2.6.17.orig/arch/um/Makefile 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/Makefile 2006-07-12 11:51:17.000000000 -0400 @@ -29,7 +29,8 @@ SYMLINK_HEADERS := $(foreach header,$(SY # These are cleaned up during mrproper. Please DO NOT fix it again, this is # the Correct Thing(tm) to do! ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ - $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h + $(ARCH_DIR)/include/klibc $(SYMLINK_HEADERS) \ + $(ARCH_DIR)/include/uml-config.h um-modes-$(CONFIG_MODE_TT) += tt um-modes-$(CONFIG_MODE_SKAS) += skas @@ -52,6 +53,12 @@ SYS_DIR := $(ARCH_DIR)/include/sysdep-$ KLIBCARCH := $(SUBARCH) +ifneq ($(KBUILD_SRC),) +KLIBC_ARCH_INCLUDE := -I$(srctree)/usr/include/arch/$(SUBARCH) +else +KLIBC_ARCH_INCLUDE := -Iusr/include/arch/$(SUBARCH) +endif + # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so # named - it's a common symbol in libpcap, so we get a binary which crashes. # @@ -68,7 +75,7 @@ AFLAGS += $(ARCH_INCLUDE) USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ - $(MODE_INCLUDE) -D_FILE_OFFSET_BITS=64 + $(MODE_INCLUDE) $(KLIBC_ARCH_INCLUDE) -D_FILE_OFFSET_BITS=64 # -Derrno=kernel_errno - This turns all kernel references to errno into # kernel_errno to separate them from the libc errno. This allows -fno-common @@ -202,6 +209,14 @@ else $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os endif +$(ARCH_DIR)/include/klibc: + @echo ' SYMLINK $@' +ifneq ($(KBUILD_SRC),) + $(Q)ln -fsn $(srctree)/usr/include/klibc $(ARCH_DIR)/include/klibc +else + $(Q)ln -sf usr/include/klibc $(ARCH_DIR)/include/klibc +endif + # Generated files define filechk_umlconfig sed 's/ CONFIG/ UML_CONFIG/' Index: linux-2.6.17/arch/um/include/longjmp.h =================================================================== --- linux-2.6.17.orig/arch/um/include/longjmp.h 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/include/longjmp.h 2006-07-12 11:51:17.000000000 -0400 @@ -1,7 +1,7 @@ #ifndef __UML_LONGJMP_H #define __UML_LONGJMP_H -#include <setjmp.h> +#include "../../../usr/include/setjmp.h" #include "os.h" #define UML_LONGJMP(buf, val) do { \ Index: linux-2.6.17/arch/um/os-Linux/trap.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/trap.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/trap.c 2006-07-12 11:51:17.000000000 -0400 @@ -5,7 +5,6 @@ #include <stdlib.h> #include <signal.h> -#include <setjmp.h> #include "kern_util.h" #include "user_util.h" #include "os.h" Index: linux-2.6.17/arch/um/os-Linux/uaccess.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/uaccess.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/uaccess.c 2006-07-12 11:51:17.000000000 -0400 @@ -4,8 +4,7 @@ * Licensed under the GPL */ -#include <setjmp.h> -#include <string.h> +#include <stddef.h> #include "longjmp.h" unsigned long __do_user_copy(void *to, const void *from, int n, Index: linux-2.6.17/arch/um/os-Linux/util.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/util.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/util.c 2006-07-12 12:04:38.000000000 -0400 @@ -7,7 +7,6 @@ #include <stdlib.h> #include <unistd.h> #include <limits.h> -#include <setjmp.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/utsname.h> @@ -107,11 +106,11 @@ int setjmp_wrapper(void (*proc)(void *, jmp_buf buf; int n; - n = sigsetjmp(buf, 1); + n = UML_SETJMP(&buf); if(n == 0){ va_start(args, proc); (*proc)(&buf, &args); } va_end(args); - return(n); + return n; } Index: linux-2.6.17/arch/um/os-Linux/process.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/process.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/process.c 2006-07-12 12:04:41.000000000 -0400 @@ -7,7 +7,6 @@ #include <stdio.h> #include <errno.h> #include <signal.h> -#include <setjmp.h> #include <linux/unistd.h> #include <sys/mman.h> #include <sys/wait.h> Index: linux-2.6.17/arch/um/os-Linux/skas/process.c =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/skas/process.c 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/skas/process.c 2006-07-12 12:04:41.000000000 -0400 @@ -8,7 +8,6 @@ #include <unistd.h> #include <errno.h> #include <signal.h> -#include <setjmp.h> #include <sched.h> #include "ptrace_user.h" #include <sys/wait.h> @@ -470,7 +469,7 @@ void thread_wait(void *sw, void *fb) *switch_buf = &buf; fork_buf = fb; if(UML_SETJMP(&buf) == 0) - siglongjmp(*fork_buf, INIT_JMP_REMOVE_SIGSTACK); + UML_LONGJMP(fork_buf, INIT_JMP_REMOVE_SIGSTACK); } void switch_threads(void *me, void *next) Index: linux-2.6.17/arch/um/os-Linux/Makefile =================================================================== --- linux-2.6.17.orig/arch/um/os-Linux/Makefile 2006-07-12 11:51:15.000000000 -0400 +++ linux-2.6.17/arch/um/os-Linux/Makefile 2006-07-12 11:51:17.000000000 -0400 @@ -5,7 +5,8 @@ obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o \ signal.o start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o tls.o \ - user_syms.o util.o drivers/ sys-$(SUBARCH)/ + user_syms.o util.o setjmp.o \ + drivers/ sys-$(SUBARCH)/ obj-$(CONFIG_MODE_SKAS) += skas/ obj-$(CONFIG_TTY_LOG) += tty_log.o @@ -22,3 +23,6 @@ HAVE_AIO_ABI := $(shell [ -r /usr/includ CFLAGS_aio.o += $(HAVE_AIO_ABI) include arch/um/scripts/Makefile.rules + +arch/um/os-Linux/setjmp.o : + ln -sf $(objtree)/usr/klibc/arch/$(SUBARCH)/setjmp.o $@ ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ User-mode-linux-user mailing list User-mode-linux-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user