[parisc-linux-cvs] linux amodra

Alan Modra alan@linuxcare.com.au
Fri, 23 Feb 2001 18:15:29 +1100 (EST)


On Fri, 23 Feb 2001, Alan Modra wrote:

> constify ret_from_kernel_thread et al. so that gcc knows they are
> in the text segment (Kills linker warning about DPREL relocs)

Index: arch/parisc/kernel/process.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/process.c,v
retrieving revision 1.33
diff -u -p -r1.33 process.c
--- process.c	2001/02/23 04:43:28	1.33
+++ process.c	2001/02/23 06:52:28
@@ -220,10 +220,11 @@ copy_thread(int nr, unsigned long clone_
 	struct pt_regs * cregs = &(p->thread.regs);
 	
 	/* We have to use void * instead of a function pointer, because
-	 * function pointers aren't a pointer to the function on 64-bit */
-	extern void *ret_from_kernel_thread;
-	extern void *child_return;
-	extern void *hpux_child_return;
+	 * function pointers aren't a pointer to the function on 64-bit.
+	 * Make them const so the compiler knows they live in .text */
+	extern void * const ret_from_kernel_thread;
+	extern void * const child_return;
+	extern void * const hpux_child_return;
 
 	*cregs = *pregs;
 
@@ -232,11 +233,6 @@ copy_thread(int nr, unsigned long clone_
            here for consistency in case of signals. */
 	cregs->gr[28] = 0; /* child */
 
-	/* Must exit via ret_from_kernel_thread in order to call
-	 * schedule_tail()
-	 */
-	cregs->kpc = (unsigned long) &ret_from_kernel_thread;
-
 	/*
 	 * We need to differentiate between a user fork and a
 	 * kernel fork. We can't use user_mode, because the
@@ -247,6 +243,10 @@ copy_thread(int nr, unsigned long clone_
 	if (usp == 0) {
 		/* kernel thread */
 		cregs->ksp = (((unsigned long)(p)) + TASK_SZ_ALGN);
+		/* Must exit via ret_from_kernel_thread in order
+		 * to call schedule_tail()
+		 */
+		cregs->kpc = (unsigned long) &ret_from_kernel_thread;
 		/*
 		 * Copy function and argument to be called from
 		 * ret_from_kernel_thread.
@@ -265,9 +265,9 @@ copy_thread(int nr, unsigned long clone_
 			+ (pregs->gr[21] & (INIT_TASK_SIZE - 1));
 		cregs->gr[30] = usp;
 		if (p->personality == PER_HPUX) {
-			cregs->kpc = &hpux_child_return;
+			cregs->kpc = (unsigned long) &hpux_child_return;
 		} else {
-			cregs->kpc = &child_return;
+			cregs->kpc = (unsigned long) &child_return;
 		}
 	}