Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jan 2010 23:59:40 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r203262 - in projects/ppc64/sys: amd64/amd64 amd64/ia32 amd64/linux32 arm/arm compat/ia32 i386/i386 i386/linux ia64/ia32 ia64/ia64 kern mips/mips pc98/pc98 powerpc/include powerpc/power...
Message-ID:  <201001302359.o0UNxfgv046795@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sat Jan 30 23:59:40 2010
New Revision: 203262
URL: http://svn.freebsd.org/changeset/base/203262

Log:
  Pass the image_params struct as a new parameter to exec_setregs(), and add
  a new field with the ELF base address to the struct. This is required to
  relocate the subfields of PPC64 function descriptors for dynamic
  executables, and with this change, RTLD is able to start (although not
  work).
  
  Suggested by:	kib

Modified:
  projects/ppc64/sys/amd64/amd64/machdep.c
  projects/ppc64/sys/amd64/ia32/ia32_signal.c
  projects/ppc64/sys/amd64/linux32/linux32_sysvec.c
  projects/ppc64/sys/arm/arm/machdep.c
  projects/ppc64/sys/compat/ia32/ia32_signal.h
  projects/ppc64/sys/i386/i386/machdep.c
  projects/ppc64/sys/i386/linux/linux_sysvec.c
  projects/ppc64/sys/ia64/ia32/ia32_signal.c
  projects/ppc64/sys/ia64/ia64/machdep.c
  projects/ppc64/sys/kern/imgact_elf.c
  projects/ppc64/sys/kern/kern_exec.c
  projects/ppc64/sys/mips/mips/pm_machdep.c
  projects/ppc64/sys/pc98/pc98/machdep.c
  projects/ppc64/sys/powerpc/include/reg.h
  projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
  projects/ppc64/sys/sparc64/sparc64/machdep.c
  projects/ppc64/sys/sun4v/sun4v/machdep.c
  projects/ppc64/sys/sys/imgact.h
  projects/ppc64/sys/sys/sysent.h

Modified: projects/ppc64/sys/amd64/amd64/machdep.c
==============================================================================
--- projects/ppc64/sys/amd64/amd64/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/amd64/amd64/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -841,11 +841,12 @@ SYSCTL_PROC(_machdep, OID_AUTO, idle, CT
  * Reset registers to default values on exec.
  */
 void
-exec_setregs(td, entry, stack, ps_strings)
+exec_setregs(td, entry, stack, ps_strings, imgp)
 	struct thread *td;
 	u_long entry;
 	u_long stack;
 	u_long ps_strings;
+	struct image_params *imgp;
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;

Modified: projects/ppc64/sys/amd64/ia32/ia32_signal.c
==============================================================================
--- projects/ppc64/sys/amd64/ia32/ia32_signal.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/amd64/ia32/ia32_signal.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -701,11 +701,12 @@ freebsd32_sigreturn(td, uap)
  * Clear registers on exec
  */
 void
-ia32_setregs(td, entry, stack, ps_strings)
+ia32_setregs(td, entry, stack, ps_strings, imgp)
 	struct thread *td;
 	u_long entry;
 	u_long stack;
 	u_long ps_strings;
+	struct image_params *imgp;
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;

Modified: projects/ppc64/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- projects/ppc64/sys/amd64/linux32/linux32_sysvec.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/amd64/linux32/linux32_sysvec.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -828,11 +828,12 @@ exec_linux_imgact_try(struct image_param
  * XXX copied from ia32_signal.c.
  */
 static void
-exec_linux_setregs(td, entry, stack, ps_strings)
+exec_linux_setregs(td, entry, stack, ps_strings, imgp)
 	struct thread *td;
 	u_long entry;
 	u_long stack;
 	u_long ps_strings;
+	struct image_params *imgp;
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;

Modified: projects/ppc64/sys/arm/arm/machdep.c
==============================================================================
--- projects/ppc64/sys/arm/arm/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/arm/arm/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -516,7 +516,8 @@ spinlock_exit(void)
  * Clear registers on exec
  */
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe *tf = td->td_frame;
 

Modified: projects/ppc64/sys/compat/ia32/ia32_signal.h
==============================================================================
--- projects/ppc64/sys/compat/ia32/ia32_signal.h	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/compat/ia32/ia32_signal.h	Sat Jan 30 23:59:40 2010	(r203262)
@@ -186,4 +186,4 @@ extern int sz_ia32_sigcode;
 extern int sz_freebsd4_ia32_sigcode;
 extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *);
 extern void ia32_setregs(struct thread *td, u_long entry, u_long stack,
-    u_long ps_strings);
+    u_long ps_strings, struct image_params *imgp);

Modified: projects/ppc64/sys/i386/i386/machdep.c
==============================================================================
--- projects/ppc64/sys/i386/i386/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/i386/i386/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -1461,11 +1461,12 @@ SYSCTL_PROC(_machdep, OID_AUTO, idle, CT
  * Reset registers to default values on exec.
  */
 void
-exec_setregs(td, entry, stack, ps_strings)
+exec_setregs(td, entry, stack, ps_strings, imgp)
 	struct thread *td;
 	u_long entry;
 	u_long stack;
 	u_long ps_strings;
+	struct image_params *imgp;
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;

Modified: projects/ppc64/sys/i386/linux/linux_sysvec.c
==============================================================================
--- projects/ppc64/sys/i386/linux/linux_sysvec.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/i386/linux/linux_sysvec.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -106,7 +106,7 @@ static void	linux_prepsyscall(struct tra
 		    caddr_t *params);
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void	exec_linux_setregs(struct thread *td, u_long entry,
-				   u_long stack, u_long ps_strings);
+		    u_long stack, u_long ps_strings, struct image_params *imgp);
 static register_t *linux_copyout_strings(struct image_params *imgp);
 static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
 
@@ -928,7 +928,7 @@ exec_linux_imgact_try(struct image_param
  */
 static void
 exec_linux_setregs(struct thread *td, u_long entry,
-		   u_long stack, u_long ps_strings)
+		   u_long stack, u_long ps_strings, struct image_params *imgp)
 {
 	struct pcb *pcb = td->td_pcb;
 

Modified: projects/ppc64/sys/ia64/ia32/ia32_signal.c
==============================================================================
--- projects/ppc64/sys/ia64/ia32/ia32_signal.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/ia64/ia32/ia32_signal.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -120,7 +120,8 @@ freebsd32_sigreturn(struct thread *td, s
 
 
 void
-ia32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+ia32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe *tf = td->td_frame;
 	vm_offset_t gdt, ldt;
@@ -129,7 +130,7 @@ ia32_setregs(struct thread *td, u_long e
 	struct segment_descriptor desc;
 	struct vmspace *vmspace = td->td_proc->p_vmspace;
 
-	exec_setregs(td, entry, stack, ps_strings);
+	exec_setregs(td, entry, stack, ps_strings, imgp);
 
 	/* Non-syscall frames are cleared by exec_setregs() */
 	if (tf->tf_flags & FRAME_SYSCALL) {

Modified: projects/ppc64/sys/ia64/ia64/machdep.c
==============================================================================
--- projects/ppc64/sys/ia64/ia64/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/ia64/ia64/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -1320,7 +1320,8 @@ set_mcontext(struct thread *td, const mc
  * Clear registers on exec.
  */
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe *tf;
 	uint64_t *ksttop, *kst;

Modified: projects/ppc64/sys/kern/imgact_elf.c
==============================================================================
--- projects/ppc64/sys/kern/imgact_elf.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/kern/imgact_elf.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -942,6 +942,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 
 	imgp->auxargs = elf_auxargs;
 	imgp->interpreted = 0;
+	imgp->reloc_base = addr;
 	imgp->proc->p_osrel = osrel;
 
 	return (error);

Modified: projects/ppc64/sys/kern/kern_exec.c
==============================================================================
--- projects/ppc64/sys/kern/kern_exec.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/kern/kern_exec.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -372,6 +372,7 @@ do_execve(td, args, mac_p)
 	imgp->execlabel = NULL;
 	imgp->attr = &attr;
 	imgp->entry_addr = 0;
+	imgp->reloc_base = 0;
 	imgp->vmspace_destroyed = 0;
 	imgp->interpreted = 0;
 	imgp->opened = 0;
@@ -800,10 +801,10 @@ interpret:
 	/* Set values passed into the program in registers. */
 	if (p->p_sysent->sv_setregs)
 		(*p->p_sysent->sv_setregs)(td, imgp->entry_addr,
-		    (u_long)(uintptr_t)stack_base, imgp->ps_strings);
+		    (u_long)(uintptr_t)stack_base, imgp->ps_strings, imgp);
 	else
 		exec_setregs(td, imgp->entry_addr,
-		    (u_long)(uintptr_t)stack_base, imgp->ps_strings);
+		    (u_long)(uintptr_t)stack_base, imgp->ps_strings, imgp);
 
 	vfs_mark_atime(imgp->vp, td->td_ucred);
 

Modified: projects/ppc64/sys/mips/mips/pm_machdep.c
==============================================================================
--- projects/ppc64/sys/mips/mips/pm_machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/mips/mips/pm_machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -472,7 +472,8 @@ set_fpregs(struct thread *td, struct fpr
  * code by the MIPS elf abi).
  */
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 
 	bzero((caddr_t)td->td_frame, sizeof(struct trapframe));

Modified: projects/ppc64/sys/pc98/pc98/machdep.c
==============================================================================
--- projects/ppc64/sys/pc98/pc98/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/pc98/pc98/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -1172,11 +1172,12 @@ void (*cpu_idle_hook)(void) = cpu_idle_d
  * Reset registers to default values on exec.
  */
 void
-exec_setregs(td, entry, stack, ps_strings)
+exec_setregs(td, entry, stack, ps_strings, imgp)
 	struct thread *td;
 	u_long entry;
 	u_long stack;
 	u_long ps_strings;
+	struct image_params *imgp;
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;

Modified: projects/ppc64/sys/powerpc/include/reg.h
==============================================================================
--- projects/ppc64/sys/powerpc/include/reg.h	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/powerpc/include/reg.h	Sat Jan 30 23:59:40 2010	(r203262)
@@ -60,9 +60,12 @@ int	fill_dbregs(struct thread *, struct 
 int	set_dbregs(struct thread *, struct dbreg *);
 
 #ifdef COMPAT_PPC32
+struct image_params;
+
 int	fill_regs32(struct thread *, struct reg32 *);
 int	set_regs32(struct thread *, struct reg32 *);
-void	ppc32_setregs(struct thread *, u_long, u_long, u_long);
+void	ppc32_setregs(struct thread *, u_long, u_long, u_long,
+	    struct image_params *);
 
 #define	fill_fpregs32(td, reg)	fill_fpregs(td,(struct fpreg *)reg)
 #define	set_fpregs32(td, reg)	set_fpregs(td,(struct fpreg *)reg)

Modified: projects/ppc64/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/exec_machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/powerpc/powerpc/exec_machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -486,7 +486,8 @@ set_mcontext(struct thread *td, const mc
  * Set set up registers on exec.
  */
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe	*tf;
 	struct ps_strings	arginfo;
@@ -543,9 +544,9 @@ exec_setregs(struct thread *td, u_long e
 	 */
 
 	(void)copyin((void *)entry, entry_desc, sizeof(entry_desc));
-	tf->srr0 = entry_desc[0];
-	tf->fixreg[2] = entry_desc[1];
-	tf->fixreg[11] = entry_desc[2];
+	tf->srr0 = entry_desc[0] + imgp->reloc_base;
+	tf->fixreg[2] = entry_desc[1] + imgp->reloc_base;
+	tf->fixreg[11] = entry_desc[2] + imgp->reloc_base;
 	tf->srr1 = PSL_SF | PSL_MBO | PSL_USERSET | PSL_FE_DFLT;
 	#else
 	tf->srr0 = entry;
@@ -556,7 +557,8 @@ exec_setregs(struct thread *td, u_long e
 
 #ifdef COMPAT_PPC32
 void
-ppc32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+ppc32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe		*tf;
 	struct freebsd32_ps_strings	arginfo;

Modified: projects/ppc64/sys/sparc64/sparc64/machdep.c
==============================================================================
--- projects/ppc64/sys/sparc64/sparc64/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/sparc64/sparc64/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -899,7 +899,8 @@ ptrace_clear_single_step(struct thread *
 }
 
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe *tf;
 	struct pcb *pcb;

Modified: projects/ppc64/sys/sun4v/sun4v/machdep.c
==============================================================================
--- projects/ppc64/sys/sun4v/sun4v/machdep.c	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/sun4v/sun4v/machdep.c	Sat Jan 30 23:59:40 2010	(r203262)
@@ -869,7 +869,8 @@ ptrace_clear_single_step(struct thread *
 }
 
 void
-exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
+exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings,
+    struct image_params *imgp)
 {
 	struct trapframe *tf;
 	struct pcb *pcb;

Modified: projects/ppc64/sys/sys/imgact.h
==============================================================================
--- projects/ppc64/sys/sys/imgact.h	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/sys/imgact.h	Sat Jan 30 23:59:40 2010	(r203262)
@@ -56,6 +56,7 @@ struct image_params {
 	struct vattr *attr;	/* attributes of file */
 	const char *image_header; /* head of file to exec */
 	unsigned long entry_addr; /* entry address of target executable */
+	unsigned long reloc_base; /* load address of image */
 	char vmspace_destroyed;	/* flag - we've blown away original vm space */
 	char interpreted;	/* flag - this executable is interpreted */
 	char opened;		/* flag - we have opened executable vnode */
@@ -78,7 +79,8 @@ struct thread;
 int	exec_check_permissions(struct image_params *);
 register_t *exec_copyout_strings(struct image_params *);
 int	exec_new_vmspace(struct image_params *, struct sysentvec *);
-void	exec_setregs(struct thread *, u_long, u_long, u_long);
+void	exec_setregs(struct thread *, u_long, u_long, u_long,
+	    struct image_params *);
 int	exec_shell_imgact(struct image_params *);
 int	exec_copyin_args(struct image_args *, char *, enum uio_seg,
 	char **, char **);

Modified: projects/ppc64/sys/sys/sysent.h
==============================================================================
--- projects/ppc64/sys/sys/sysent.h	Sat Jan 30 23:13:19 2010	(r203261)
+++ projects/ppc64/sys/sys/sysent.h	Sat Jan 30 23:59:40 2010	(r203262)
@@ -98,7 +98,8 @@ struct sysentvec {
 	vm_offset_t	sv_psstrings;	/* PS_STRINGS */
 	int		sv_stackprot;	/* vm protection for stack */
 	register_t	*(*sv_copyout_strings)(struct image_params *);
-	void		(*sv_setregs)(struct thread *, u_long, u_long, u_long);
+	void		(*sv_setregs)(struct thread *, u_long, u_long, u_long,
+			    struct image_params *);
 	void		(*sv_fixlimit)(struct rlimit *, int);
 	u_long		*sv_maxssiz;
 	u_int		sv_flags;



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