Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2002 05:49:11 -0700 (PDT)
From:      Doug Rabson <dfr@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 10678 for review
Message-ID:  <200205021249.g42CnBm82603@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=10678

Change 10678 by dfr@dfr_home on 2002/05/02 05:48:25

	Allow both elf32 and elf64 in the same kernel.

Affected files ...

... //depot/projects/ia64/sys/compat/pecoff/imgact_pecoff.c#5 edit
... //depot/projects/ia64/sys/compat/svr4/imgact_svr4.c#3 edit
... //depot/projects/ia64/sys/compat/svr4/svr4_sysvec.c#4 edit
... //depot/projects/ia64/sys/conf/files#19 edit
... //depot/projects/ia64/sys/i386/ibcs2/imgact_coff.c#5 edit
... //depot/projects/ia64/sys/i386/include/elf.h#2 edit
... //depot/projects/ia64/sys/i386/linux/imgact_linux.c#3 edit
... //depot/projects/ia64/sys/i386/linux/linux_sysvec.c#8 edit
... //depot/projects/ia64/sys/ia64/include/elf.h#3 edit
... //depot/projects/ia64/sys/kern/imgact_aout.c#5 edit
... //depot/projects/ia64/sys/kern/imgact_elf.c#4 edit
... //depot/projects/ia64/sys/kern/imgact_elf32.c#1 add
... //depot/projects/ia64/sys/kern/imgact_elf64.c#1 add
... //depot/projects/ia64/sys/kern/imgact_elfN.c#1 add
... //depot/projects/ia64/sys/kern/imgact_gzip.c#4 edit
... //depot/projects/ia64/sys/kern/init_main.c#7 edit
... //depot/projects/ia64/sys/kern/kern_exec.c#13 edit
... //depot/projects/ia64/sys/kern/link_elf.c#5 edit
... //depot/projects/ia64/sys/powerpc/include/elf.h#2 edit
... //depot/projects/ia64/sys/sparc64/include/elf.h#2 edit
... //depot/projects/ia64/sys/sys/elf_generic.h#2 edit
... //depot/projects/ia64/sys/sys/imgact.h#4 edit
... //depot/projects/ia64/sys/sys/imgact_elf.h#3 edit
... //depot/projects/ia64/sys/sys/sysent.h#6 edit
... //depot/projects/ia64/sys/sys/user.h#5 edit
... //depot/projects/ia64/sys/vm/vm_extern.h#7 edit
... //depot/projects/ia64/sys/vm/vm_map.c#12 edit

Differences ...

==== //depot/projects/ia64/sys/compat/pecoff/imgact_pecoff.c#5 (text+ko) ====

@@ -465,7 +465,7 @@
 	    peofs + PECOFF_HDR_SIZE, (caddr_t) sh, scnsiz);
 	if ((error = exec_extract_strings(imgp)) != 0)
 		goto fail;
-	exec_new_vmspace(imgp);
+	exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
 	vmspace = imgp->proc->p_vmspace;
 	for (i = 0; i < fp->f_nscns; i++) {
 		prot = VM_PROT_WRITE;	/* XXX for relocation? */

==== //depot/projects/ia64/sys/compat/svr4/imgact_svr4.c#3 (text+ko) ====

@@ -119,7 +119,7 @@
     /*
      * Destroy old process VM and create a new one (with a new stack)
      */
-    exec_new_vmspace(imgp);
+    exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
     vmspace = imgp->proc->p_vmspace;
 
     /*

==== //depot/projects/ia64/sys/compat/svr4/svr4_sysvec.c#4 (text+ko) ====

@@ -179,7 +179,7 @@
   &svr4_szsigcode,
   NULL,
   "SVR4",
-  elf_coredump,
+  elf32_coredump,
   NULL,
   SVR4_MINSIGSTKSZ
 };
@@ -376,7 +376,7 @@
 
 	switch(type) {
 	case MOD_LOAD:
-		if (elf_insert_brand_entry(&svr4_brand) < 0)
+		if (elf32_insert_brand_entry(&svr4_brand) < 0)
 			error = EINVAL;
 		if (error)
 			printf("cannot insert svr4 elf brand handler\n");
@@ -385,9 +385,9 @@
 		break;
 	case MOD_UNLOAD:
 		/* Only allow the emulator to be removed if it isn't in use. */
-		if (elf_brand_inuse(&svr4_brand) != 0) {
+		if (elf32_brand_inuse(&svr4_brand) != 0) {
 			error = EBUSY;
-		} else if (elf_remove_brand_entry(&svr4_brand) < 0) {
+		} else if (elf32_remove_brand_entry(&svr4_brand) < 0) {
 			error = EINVAL;
 		}
 

==== //depot/projects/ia64/sys/conf/files#19 (text+ko) ====

@@ -810,7 +810,9 @@
 isofs/cd9660/cd9660_util.c	optional cd9660
 isofs/cd9660/cd9660_vfsops.c	optional cd9660
 isofs/cd9660/cd9660_vnops.c	optional cd9660
-kern/imgact_elf.c	standard
+kern/imgact_elf32.c	standard
+kern/imgact_elf64.c	standard
+kern/imgact_elfN.c	standard
 kern/imgact_shell.c	standard
 kern/inflate.c		optional gzip
 kern/init_main.c	standard

==== //depot/projects/ia64/sys/i386/ibcs2/imgact_coff.c#5 (text+ko) ====

@@ -333,7 +333,7 @@
 		return error;
 	}
 
-	exec_new_vmspace(imgp);
+	exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
 	vmspace = imgp->proc->p_vmspace;
 
 	for (i = 0; i < nscns; i++) {

==== //depot/projects/ia64/sys/i386/include/elf.h#2 (text+ko) ====

@@ -69,8 +69,6 @@
 
 typedef Elf32_Off Elf32_Hashelt;
 
-__ElfType(Hashelt);
-
 /* Values for a_type. */
 #define	AT_NULL		0	/* Terminates the vector. */
 #define	AT_IGNORE	1	/* Ignored entry. */

==== //depot/projects/ia64/sys/i386/linux/imgact_linux.c#3 (text+ko) ====

@@ -118,7 +118,7 @@
     /*
      * Destroy old process VM and create a new one (with a new stack)
      */
-    exec_new_vmspace(imgp);
+    exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
     vmspace = imgp->proc->p_vmspace;
 
     /*

==== //depot/projects/ia64/sys/i386/linux/linux_sysvec.c#8 (text+ko) ====

@@ -792,7 +792,7 @@
 	&linux_szsigcode,
 	linux_prepsyscall,
 	"Linux ELF",
-	elf_coredump,
+	elf32_coredump,
 	exec_linux_imgact_try,
 	LINUX_MINSIGSTKSZ
 };
@@ -832,7 +832,7 @@
 	case MOD_LOAD:
 		for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
 		     ++brandinfo)
-			if (elf_insert_brand_entry(*brandinfo) < 0)
+			if (elf32_insert_brand_entry(*brandinfo) < 0)
 				error = EINVAL;
 		if (error == 0) {
 			SET_FOREACH(lihp, linux_ioctl_handler_set)
@@ -845,12 +845,12 @@
 	case MOD_UNLOAD:
 		for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
 		     ++brandinfo)
-			if (elf_brand_inuse(*brandinfo))
+			if (elf32_brand_inuse(*brandinfo))
 				error = EBUSY;
 		if (error == 0) {
 			for (brandinfo = &linux_brandlist[0];
 			     *brandinfo != NULL; ++brandinfo)
-				if (elf_remove_brand_entry(*brandinfo) < 0)
+				if (elf32_remove_brand_entry(*brandinfo) < 0)
 					error = EINVAL;
 		}
 		if (error == 0) {

==== //depot/projects/ia64/sys/ia64/include/elf.h#3 (text+ko) ====

@@ -33,9 +33,13 @@
  * ELF definitions for the IA-64 architecture.
  */
 
+#ifndef __ELF_WORD_SIZE
+#define __ELF_WORD_SIZE 64
+#endif
+
 #include <sys/elf64.h>	/* Definitions common to all 64 bit architectures. */
+#include <sys/elf32.h>	/* Definitions common to all 32 bit architectures. */
 
-#define	__ELF_WORD_SIZE	64	/* Used by <sys/elf_generic.h> */
 #include <sys/elf_generic.h>
 
 #define	ELF_ARCH	EM_IA_64
@@ -52,14 +56,19 @@
 typedef struct {	/* Auxiliary vector entry on initial stack */
 	int	a_type;			/* Entry type. */
 	union {
+		int	a_val;		/* Integer value. */
+	} a_un;
+} Elf32_Auxinfo;
+
+typedef struct {	/* Auxiliary vector entry on initial stack */
+	int	a_type;			/* Entry type. */
+	union {
 		long	a_val;		/* Integer value. */
 		void	*a_ptr;		/* Address. */
 		void	(*a_fcn)(void);	/* Function pointer (not used). */
 	} a_un;
 } Elf64_Auxinfo;
 
-__ElfType(Auxinfo);
-
 /*
  * Types of dynamic symbol hash table bucket and chain elements.
  *
@@ -67,10 +76,9 @@
  * typedef is required.
  */
 
-typedef Elf64_Half Elf64_Hashelt;
+typedef Elf32_Off	Elf32_Hashelt;
+typedef Elf64_Half	Elf64_Hashelt;
 
-__ElfType(Hashelt);
-
 /* Values for a_type. */
 #define	AT_NULL		0	/* Terminates the vector. */
 #define	AT_IGNORE	1	/* Ignored entry. */
@@ -205,7 +213,11 @@
 #define	R_IA64_LDXMOV		0x87	/* immediate22	special */
 
 /* Define "machine" characteristics */
+#if __ELF_WORD_SIZE == 32
+#define	ELF_TARG_CLASS	ELFCLASS32
+#else
 #define	ELF_TARG_CLASS	ELFCLASS64
+#endif
 #define	ELF_TARG_DATA	ELFDATA2LSB
 #define	ELF_TARG_MACH	EM_IA_64
 #define	ELF_TARG_VER	1

==== //depot/projects/ia64/sys/kern/imgact_aout.c#5 (text+ko) ====

@@ -178,7 +178,7 @@
 	/*
 	 * Destroy old process VM and create a new one (with a new stack)
 	 */
-	exec_new_vmspace(imgp);
+	exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
 
 	/*
 	 * The vm space can be changed by exec_new_vmspace

==== //depot/projects/ia64/sys/kern/imgact_elf.c#4 (text+ko) ====

@@ -70,21 +70,21 @@
 __ElfType(Brandinfo);
 __ElfType(Auxargs);
 
-static int elf_check_header(const Elf_Ehdr *hdr);
-static int elf_freebsd_fixup(register_t **stack_base,
+static int __elfN(check_header)(const Elf_Ehdr *hdr);
+static int __elfN(freebsd_fixup)(register_t **stack_base,
     struct image_params *imgp);
-static int elf_load_file(struct proc *p, const char *file, u_long *addr,
+static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
     u_long *entry);
-static int elf_load_section(struct proc *p,
+static int __elfN(load_section)(struct proc *p,
     struct vmspace *vmspace, struct vnode *vp,
     vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
     vm_prot_t prot);
-static int exec_elf_imgact(struct image_params *imgp);
+static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
 
 static int elf_trace = 0;
 SYSCTL_INT(_debug, OID_AUTO, elf_trace, CTLFLAG_RW, &elf_trace, 0, "");
 
-struct sysentvec elf_freebsd_sysvec = {
+struct sysentvec __elfN(freebsd_sysvec) = {
         SYS_MAXSYSCALL,
         sysent,
         0,
@@ -93,13 +93,13 @@
         0,
         0,
         0,
-        elf_freebsd_fixup,
+        __elfN(freebsd_fixup),
         sendsig,
         sigcode,
         &szsigcode,
         0,
 	"FreeBSD ELF",
-	elf_coredump,
+	__elfN(coredump),
 	NULL,
 	MINSIGSTKSZ
 };
@@ -109,7 +109,7 @@
 						"FreeBSD",
 						"",
 						"/usr/libexec/ld-elf.so.1",
-						&elf_freebsd_sysvec
+						&__elfN(freebsd_sysvec)
 					  };
 static Elf_Brandinfo *elf_brand_list[MAX_BRANDS] = {
 							&freebsd_brand_info,
@@ -118,7 +118,7 @@
 						    };
 
 int
-elf_insert_brand_entry(Elf_Brandinfo *entry)
+__elfN(insert_brand_entry)(Elf_Brandinfo *entry)
 {
 	int i;
 
@@ -134,7 +134,7 @@
 }
 
 int
-elf_remove_brand_entry(Elf_Brandinfo *entry)
+__elfN(remove_brand_entry)(Elf_Brandinfo *entry)
 {
 	int i;
 
@@ -150,7 +150,7 @@
 }
 
 int
-elf_brand_inuse(Elf_Brandinfo *entry)
+__elfN(brand_inuse)(Elf_Brandinfo *entry)
 {
 	struct proc *p;
 	int rval = FALSE;
@@ -168,7 +168,7 @@
 }
 
 static int
-elf_check_header(const Elf_Ehdr *hdr)
+__elfN(check_header)(const Elf_Ehdr *hdr)
 {
 	if (!IS_ELF(*hdr) ||
 	    hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS ||
@@ -186,7 +186,7 @@
 }
 
 static int
-elf_load_section(struct proc *p, struct vmspace *vmspace, struct vnode *vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot)
+__elfN(load_section)(struct proc *p, struct vmspace *vmspace, struct vnode *vp, vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz, vm_prot_t prot)
 {
 	size_t map_len;
 	vm_offset_t map_addr;
@@ -322,7 +322,7 @@
  * the entry point for the loaded file.
  */
 static int
-elf_load_file(struct proc *p, const char *file, u_long *addr, u_long *entry)
+__elfN(load_file)(struct proc *p, const char *file, u_long *addr, u_long *entry)
 {
 	struct {
 		struct nameidata nd;
@@ -394,7 +394,7 @@
                 goto fail;
 
 	hdr = (const Elf_Ehdr *)imgp->image_header;
-	if ((error = elf_check_header(hdr)) != 0)
+	if ((error = __elfN(check_header)(hdr)) != 0)
 		goto fail;
 	if (hdr->e_type == ET_DYN)
 		rbase = *addr;
@@ -424,12 +424,13 @@
 			if (phdr[i].p_flags & PF_R)
   				prot |= VM_PROT_READ;
 
-			if ((error = elf_load_section(p, vmspace, nd->ni_vp,
-  						     phdr[i].p_offset,
-  						     (caddr_t)phdr[i].p_vaddr +
-							rbase,
-  						     phdr[i].p_memsz,
-  						     phdr[i].p_filesz, prot)) != 0)
+			if ((error = __elfN(load_section)
+			     (p, vmspace, nd->ni_vp,
+			      phdr[i].p_offset,
+			      (caddr_t)(uintptr_t)phdr[i].p_vaddr +
+			      rbase,
+			      phdr[i].p_memsz,
+			      phdr[i].p_filesz, prot)) != 0)
 				goto fail;
 			/*
 			 * Establish the base address if this is the
@@ -457,20 +458,10 @@
 	return error;
 }
 
-/*
- * non static, as it can be overridden by start_init()
- */
-#ifdef __ia64__
-int fallback_elf_brand = ELFOSABI_FREEBSD;
-#else
-int fallback_elf_brand = -1;
-#endif
-SYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW,
-		&fallback_elf_brand, -1,
-		"ELF brand of last resort");
+extern int fallback_elf_brand;
 
 static int
-exec_elf_imgact(struct image_params *imgp)
+__CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
 {
 	const Elf_Ehdr *hdr = (const Elf_Ehdr *) imgp->image_header;
 	const Elf_Phdr *phdr;
@@ -490,7 +481,7 @@
 	/*
 	 * Do we have a valid ELF header ?
 	 */
-	if (elf_check_header(hdr) != 0 || hdr->e_type != ET_EXEC)
+	if (__elfN(check_header)(hdr) != 0 || hdr->e_type != ET_EXEC)
 		return -1;
 
 	/*
@@ -522,7 +513,8 @@
 	if ((error = exec_extract_strings(imgp)) != 0)
 		goto fail;
 
-	exec_new_vmspace(imgp);
+	exec_new_vmspace(imgp, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS,
+			 USRSTACK);
 
 	vmspace = imgp->proc->p_vmspace;
 
@@ -538,12 +530,13 @@
 			if (phdr[i].p_flags & PF_R)
   				prot |= VM_PROT_READ;
 
-			if ((error = elf_load_section(imgp->proc,
-						     vmspace, imgp->vp,
-  						     phdr[i].p_offset,
-  						     (caddr_t)phdr[i].p_vaddr,
-  						     phdr[i].p_memsz,
-  						     phdr[i].p_filesz, prot)) != 0)
+			if ((error = __elfN(load_section)
+			     (imgp->proc,
+			      vmspace, imgp->vp,
+			      phdr[i].p_offset,
+			      (caddr_t)(uintptr_t)phdr[i].p_vaddr,
+			      phdr[i].p_memsz,
+			      phdr[i].p_filesz, prot)) != 0)
   				goto fail;
 
 			/*
@@ -652,10 +645,11 @@
 		path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
 	        snprintf(path, MAXPATHLEN, "%s%s",
 			 brand_info->emul_path, interp);
-		if ((error = elf_load_file(imgp->proc, path, &addr,
-					   &imgp->entry_addr)) != 0) {
-		        if ((error = elf_load_file(imgp->proc, interp, &addr,
-						   &imgp->entry_addr)) != 0) {
+		if ((error = __elfN(load_file)(imgp->proc, path, &addr,
+					       &imgp->entry_addr)) != 0) {
+		        if ((error = __elfN(load_file)
+			     (imgp->proc, interp, &addr,
+			      &imgp->entry_addr)) != 0) {
 			        uprintf("ELF interpreter %s not found\n", path);
 				free(path, M_TEMP);
 				goto fail;
@@ -686,7 +680,7 @@
 }
 
 static int
-elf_freebsd_fixup(register_t **stack_base, struct image_params *imgp)
+__elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp)
 {
 	Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs;
 	register_t *pos;
@@ -737,17 +731,17 @@
 static void cb_put_phdr(vm_map_entry_t, void *);
 static void cb_size_segment(vm_map_entry_t, void *);
 static void each_writable_segment(struct proc *, segment_callback, void *);
-static int elf_corehdr(struct thread *, struct vnode *, struct ucred *,
+static int __elfN(corehdr)(struct thread *, struct vnode *, struct ucred *,
     int, void *, size_t);
-static void elf_puthdr(struct proc *, void *, size_t *,
+static void __elfN(puthdr)(struct proc *, void *, size_t *,
     const prstatus_t *, const prfpregset_t *, const prpsinfo_t *, int);
-static void elf_putnote(void *, size_t *, const char *, int,
+static void __elfN(putnote)(void *, size_t *, const char *, int,
     const void *, size_t);
 
 extern int osreldate;
 
 int
-elf_coredump(td, vp, limit)
+__elfN(coredump)(td, vp, limit)
 	struct thread *td;
 	register struct vnode *vp;
 	off_t limit;
@@ -770,7 +764,7 @@
 	 * size is calculated.
 	 */
 	hdrsize = 0;
-	elf_puthdr((struct proc *)NULL, (void *)NULL, &hdrsize,
+	__elfN(puthdr)((struct proc *)NULL, (void *)NULL, &hdrsize,
 	    (const prstatus_t *)NULL, (const prfpregset_t *)NULL,
 	    (const prpsinfo_t *)NULL, seginfo.count);
 
@@ -785,7 +779,7 @@
 	if (hdr == NULL) {
 		return EINVAL;
 	}
-	error = elf_corehdr(td, vp, cred, seginfo.count, hdr, hdrsize);
+	error = __elfN(corehdr)(td, vp, cred, seginfo.count, hdr, hdrsize);
 
 	/* Write the contents of all of the writable segments. */
 	if (error == 0) {
@@ -797,7 +791,7 @@
 		offset = hdrsize;
 		for (i = 0;  i < seginfo.count;  i++) {
 			error = vn_rdwr_inchunks(UIO_WRITE, vp, 
-			    (caddr_t)php->p_vaddr,
+			    (caddr_t)(uintptr_t)php->p_vaddr,
 			    php->p_filesz, offset, UIO_USERSPACE,
 			    IO_UNIT | IO_DIRECT, cred, (int *)NULL, curthread); /* XXXKSE */
 			if (error != 0)
@@ -911,7 +905,7 @@
  * the page boundary.
  */
 static int
-elf_corehdr(td, vp, cred, numsegs, hdr, hdrsize)
+__elfN(corehdr)(td, vp, cred, numsegs, hdr, hdrsize)
 	struct thread *td;
 	struct vnode *vp;
 	struct ucred *cred;
@@ -957,7 +951,7 @@
 	/* Fill in the header. */
 	bzero(hdr, hdrsize);
 	off = 0;
-	elf_puthdr(p, hdr, &off, status, fpregset, psinfo, numsegs);
+	__elfN(puthdr)(p, hdr, &off, status, fpregset, psinfo, numsegs);
 
 	free(tempdata, M_TEMP);
 
@@ -967,7 +961,7 @@
 }
 
 static void
-elf_puthdr(struct proc *p, void *dst, size_t *off, const prstatus_t *status,
+__elfN(puthdr)(struct proc *p, void *dst, size_t *off, const prstatus_t *status,
     const prfpregset_t *fpregset, const prpsinfo_t *psinfo, int numsegs)
 {
 	size_t ehoff;
@@ -982,11 +976,11 @@
 	*off += (numsegs + 1) * sizeof(Elf_Phdr);
 
 	noteoff = *off;
-	elf_putnote(dst, off, "FreeBSD", NT_PRSTATUS, status,
+	__elfN(putnote)(dst, off, "FreeBSD", NT_PRSTATUS, status,
 	    sizeof *status);
-	elf_putnote(dst, off, "FreeBSD", NT_FPREGSET, fpregset,
+	__elfN(putnote)(dst, off, "FreeBSD", NT_FPREGSET, fpregset,
 	    sizeof *fpregset);
-	elf_putnote(dst, off, "FreeBSD", NT_PRPSINFO, psinfo,
+	__elfN(putnote)(dst, off, "FreeBSD", NT_PRPSINFO, psinfo,
 	    sizeof *psinfo);
 	notesz = *off - noteoff;
 
@@ -1049,7 +1043,7 @@
 }
 
 static void
-elf_putnote(void *dst, size_t *off, const char *name, int type,
+__elfN(putnote)(void *dst, size_t *off, const char *name, int type,
     const void *desc, size_t descsz)
 {
 	Elf_Note note;
@@ -1071,5 +1065,10 @@
 /*
  * Tell kern_execve.c about it, with a little help from the linker.
  */
-static struct execsw elf_execsw = {exec_elf_imgact, "ELF"};
-EXEC_SET(elf, elf_execsw);
+#if __ELF_WORD_SIZE == 32
+static struct execsw elf_execsw = {exec_elf32_imgact, "ELF32"};
+EXEC_SET(elf32, elf_execsw);
+#else
+static struct execsw elf_execsw = {exec_elf64_imgact, "ELF64"};
+EXEC_SET(elf64, elf_execsw);
+#endif

==== //depot/projects/ia64/sys/kern/imgact_gzip.c#4 (text+ko) ====

@@ -229,7 +229,7 @@
 	/*
 	 * Destroy old process VM and create a new one (with a new stack)
 	 */
-	exec_new_vmspace(gz->ip);
+	exec_new_vmspace(gz->ip, VM_MIN_ADDRESS, VM_MAXUSER_ADDRESS, USRSTACK);
 
 	vmspace = gz->ip->proc->p_vmspace;
 

==== //depot/projects/ia64/sys/kern/init_main.c#7 (text+ko) ====

@@ -252,6 +252,9 @@
 }
 SYSINIT(boot_verbose, SI_SUB_TUNABLES, SI_ORDER_ANY, set_boot_verbose, NULL)
 
+static struct sysentvec null_sysvec;
+
+
 /*
  ***************************************************************************
  ****
@@ -316,11 +319,7 @@
 	session0.s_count = 1;
 	session0.s_leader = p;
 
-#ifdef __ELF__
-	p->p_sysent = &elf_freebsd_sysvec;
-#else
-	p->p_sysent = &aout_sysvec;
-#endif
+	p->p_sysent = &null_sysvec;
 
 	ke = &proc0.p_kse;	/* XXXKSE */
 	kg = &proc0.p_ksegrp;	/* XXXKSE */

==== //depot/projects/ia64/sys/kern/kern_exec.c#13 (text+ko) ====

@@ -266,7 +266,10 @@
 	/*
 	 * Copy out strings (args and env) and initialize stack base
 	 */
-	stack_base = exec_copyout_strings(imgp);
+	if (p->p_sysent->sv_copyout_strings)
+		stack_base = (*p->p_sysent->sv_copyout_strings)(imgp);
+	else
+		stack_base = exec_copyout_strings(imgp);
 	p->p_vmspace->vm_minsaddr = (char *)stack_base;
 
 	/*
@@ -454,8 +457,12 @@
 	pargs_drop(pa);
 
 	/* Set values passed into the program in registers. */
-	setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base,
-	    imgp->ps_strings);
+	if (p->p_sysent->sv_setregs)
+		(*p->p_sysent->sv_setregs)(td, imgp->entry_addr,
+		    (u_long)(uintptr_t)stack_base, imgp->ps_strings);
+	else
+		setregs(td, imgp->entry_addr, (u_long)(uintptr_t)stack_base,
+		    imgp->ps_strings);
 
 	/* Cache arguments if they fit inside our allowance */
 	i = imgp->endargs - imgp->stringbase;
@@ -582,17 +589,19 @@
  *	automatically in trap.c.
  */
 int
-exec_new_vmspace(imgp)
+exec_new_vmspace(imgp, minuser, maxuser, stack_addr)
 	struct image_params *imgp;
+	vm_offset_t minuser, maxuser, stack_addr;
 {
 	int error;
 	struct execlist *ep;
 	struct proc *p = imgp->proc;
 	struct vmspace *vmspace = p->p_vmspace;
-	vm_offset_t stack_addr = USRSTACK - maxssiz;
 
 	GIANT_REQUIRED;
 
+	stack_addr = stack_addr - maxssiz;
+
 	imgp->vmspace_destroyed = 1;
 
 	/*
@@ -606,13 +615,15 @@
 	 * otherwise, create a new VM space so that other threads are
 	 * not disrupted
 	 */
-	if (vmspace->vm_refcnt == 1) {
+	if (vmspace->vm_refcnt == 1
+	    && vm_map_min(&vmspace->vm_map) == minuser
+	    && vm_map_max(&vmspace->vm_map) == maxuser) {
 		if (vmspace->vm_shm)
 			shmexit(p);
-		pmap_remove_pages(vmspace_pmap(vmspace), 0, VM_MAXUSER_ADDRESS);
-		vm_map_remove(&vmspace->vm_map, 0, VM_MAXUSER_ADDRESS);
+		pmap_remove_pages(vmspace_pmap(vmspace), minuser, maxuser);
+		vm_map_remove(&vmspace->vm_map, minuser, maxuser);
 	} else {
-		vmspace_exec(p);
+		vmspace_exec(p, minuser, maxuser);
 		vmspace = p->p_vmspace;
 	}
 

==== //depot/projects/ia64/sys/kern/link_elf.c#5 (text+ko) ====

@@ -62,6 +62,8 @@
 
 #include "linker_if.h"
 
+__ElfType(Hashelt);
+
 typedef struct elf_file {
     struct linker_file	lf;		/* Common fields */
     int			preloaded;	/* Was file pre-loaded */

==== //depot/projects/ia64/sys/powerpc/include/elf.h#2 (text+ko) ====

@@ -72,8 +72,6 @@
 
 typedef Elf32_Off Elf32_Hashelt;
 
-__ElfType(Hashelt);
-
 /* Values for a_type. */
 #define	AT_NULL		0	/* Terminates the vector. */
 #define	AT_IGNORE	1	/* Ignored entry. */

==== //depot/projects/ia64/sys/sparc64/include/elf.h#2 (text+ko) ====

@@ -66,8 +66,6 @@
 
 typedef Elf64_Half Elf64_Hashelt;
 
-__ElfType(Hashelt);
-
 /* Values for a_type. */
 #define	AT_NULL		0	/* Terminates the vector. */
 #define	AT_IGNORE	1	/* Ignored entry. */

==== //depot/projects/ia64/sys/sys/elf_generic.h#2 (text+ko) ====

@@ -50,6 +50,7 @@
 #error "Unknown byte order"
 #endif
 
+#define __elfN(x)	__CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x)
 #define __ElfN(x)	__CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x)
 #define __ELFN(x)	__CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x)
 #define __ElfType(x)	typedef __ElfN(x) __CONCAT(Elf_,x)

==== //depot/projects/ia64/sys/sys/imgact.h#4 (text+ko) ====

@@ -64,7 +64,8 @@
 #ifdef _KERNEL
 int	exec_check_permissions(struct image_params *);
 int	exec_extract_strings(struct image_params *);
-int	exec_new_vmspace(struct image_params *);
+int	exec_new_vmspace(struct image_params *, vm_offset_t, vm_offset_t,
+    vm_offset_t);
 int	exec_shell_imgact(struct image_params *);
 #endif
 

==== //depot/projects/ia64/sys/sys/imgact_elf.h#3 (text+ko) ====

@@ -37,6 +37,8 @@
 
 #define AUXARGS_ENTRY(pos, id, val) {suword(pos++, id); suword(pos++, val);}
 
+struct thread;
+
 #if ELF_TARG_CLASS == ELFCLASS32
 
 /*
@@ -65,9 +67,10 @@
 
 #define MAX_BRANDS      8
 
-int	elf_brand_inuse(Elf32_Brandinfo *entry);
-int	elf_insert_brand_entry(Elf32_Brandinfo *entry);
-int	elf_remove_brand_entry(Elf32_Brandinfo *entry);
+int	elf32_brand_inuse(Elf32_Brandinfo *entry);
+int	elf32_insert_brand_entry(Elf32_Brandinfo *entry);
+int	elf32_remove_brand_entry(Elf32_Brandinfo *entry);
+int	elf32_coredump(struct thread *, struct vnode *, off_t);
 
 #else /* !(ELF_TARG_CLASS == ELFCLASS32) */
 
@@ -97,16 +100,13 @@
 
 #define MAX_BRANDS      8
 
-int	elf_brand_inuse(Elf64_Brandinfo *entry);
-int	elf_insert_brand_entry(Elf64_Brandinfo *entry);
-int	elf_remove_brand_entry(Elf64_Brandinfo *entry);
+int	elf64_brand_inuse(Elf64_Brandinfo *entry);
+int	elf64_insert_brand_entry(Elf64_Brandinfo *entry);
+int	elf64_remove_brand_entry(Elf64_Brandinfo *entry);
+int	elf64_coredump(struct thread *, struct vnode *, off_t);
 
 #endif /* ELF_TARG_CLASS == ELFCLASS32 */
 
-struct thread;
-
-int	elf_coredump(struct thread *, struct vnode *, off_t);
-
 #endif /* _KERNEL */
 
 #endif /* !_SYS_IMGACT_ELF_H_ */

==== //depot/projects/ia64/sys/sys/sysent.h#6 (text+ko) ====

@@ -79,6 +79,8 @@
 					/* function to dump core, or NULL */
 	int		(*sv_imgact_try)(struct image_params *);
 	int		sv_minsigstksz;	/* minimum signal stack size */
+	register_t	*(*sv_copyout_strings)(struct image_params *);
+	void		(*sv_setregs)(struct thread *, u_long, u_long, u_long);
 };
 
 #ifdef _KERNEL

==== //depot/projects/ia64/sys/sys/user.h#5 (text+ko) ====

@@ -74,12 +74,9 @@
  * to initialize it in two places: kern/kern_proc.c in the function
  * fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist.
  */
-#if defined(__alpha__) || defined(__sparc64__)
+#if defined(__alpha__) || defined(__sparc64__) || defined(__ia64__)
 #define	KINFO_PROC_SIZE	912		/* the correct size for kinfo_proc */
 #endif
-#ifdef	__ia64__
-#define KINFO_PROC_SIZE 888
-#endif
 #ifdef	__i386__
 #define	KINFO_PROC_SIZE	648		/* the correct size for kinfo_proc */
 #endif

==== //depot/projects/ia64/sys/vm/vm_extern.h#7 (text+ko) ====

@@ -85,7 +85,7 @@
 void vm_set_page_size(void);
 struct vmspace *vmspace_alloc(vm_offset_t, vm_offset_t);
 struct vmspace *vmspace_fork(struct vmspace *);
-void vmspace_exec(struct proc *);
+void vmspace_exec(struct proc *, vm_offset_t, vm_offset_t);
 void vmspace_unshare(struct proc *);
 void vmspace_free(struct vmspace *);
 void vmspace_exitfree(struct proc *);

==== //depot/projects/ia64/sys/vm/vm_map.c#12 (text+ko) ====

@@ -2686,14 +2686,13 @@
  * mapped to it, then create a new one.  The new vmspace is null.
  */
 void
-vmspace_exec(struct proc *p) 
+vmspace_exec(struct proc *p, vm_offset_t minuser, vm_offset_t maxuser) 
 {
 	struct vmspace *oldvmspace = p->p_vmspace;
 	struct vmspace *newvmspace;
-	vm_map_t map = &p->p_vmspace->vm_map;
 
 	GIANT_REQUIRED;
-	newvmspace = vmspace_alloc(map->min_offset, map->max_offset);
+	newvmspace = vmspace_alloc(minuser, maxuser);
 	bcopy(&oldvmspace->vm_startcopy, &newvmspace->vm_startcopy,
 	    (caddr_t) (newvmspace + 1) - (caddr_t) &newvmspace->vm_startcopy);
 	/*

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205021249.g42CnBm82603>