public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] [Patch] Fix in process.c
@ 2003-01-18  1:43 Siddha, Suresh B
  2003-01-18  1:53 ` David Mosberger
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Siddha, Suresh B @ 2003-01-18  1:43 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

Attached/appended fix for another problem(getting the address of a function), which depends on the compiler behaviour.

thanks,
suresh

diff -Nru linux-2.5.52/arch/ia64/kernel/process.c~ linux-2.5.52/arch/ia64/kernel/process.c
--- linux-2.5.52/arch/ia64/kernel/process.c~	Fri Jan 17 14:53:52 2003
+++ linux-2.5.52/arch/ia64/kernel/process.c	Fri Jan 17 15:27:46 2003
@@ -281,7 +281,10 @@
 {
 	unsigned long rbs, child_rbs, rbs_size, stack_offset, stack_top, stack_used;
 	struct switch_stack *child_stack, *stack;
-	extern char ia64_ret_from_clone, ia32_ret_from_clone;
+	extern void  ia64_ret_from_clone(void);
+#ifdef CONFIG_IA32_SUPPORT
+	extern void ia32_ret_from_clone(void);
+#endif
 	struct pt_regs *child_ptregs;
 	int retval = 0;
 
@@ -332,10 +335,13 @@
 		child_ptregs->r12 = (unsigned long) (child_ptregs + 1); /* kernel sp */
 		child_ptregs->r13 = (unsigned long) p;		/* set `current' pointer */
 	}
+#ifdef CONFIG_IA32_SUPPORT
 	if (IS_IA32_PROCESS(regs))
-		child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
+		child_stack->b0 = ((unsigned long *) &ia32_ret_from_clone)[0];
 	else
-		child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
+#else
+		child_stack->b0 = ((unsigned long *) &ia64_ret_from_clone)[0];
+#endif
 	child_stack->ar_bspstore = child_rbs + rbs_size;
 
 	/* copy parts of thread_struct: */

[-- Attachment #2: process.c.diff --]
[-- Type: application/octet-stream, Size: 1226 bytes --]

diff -Nru linux-2.5.52/arch/ia64/kernel/process.c~ linux-2.5.52/arch/ia64/kernel/process.c
--- linux-2.5.52/arch/ia64/kernel/process.c~	Fri Jan 17 14:53:52 2003
+++ linux-2.5.52/arch/ia64/kernel/process.c	Fri Jan 17 15:27:46 2003
@@ -281,7 +281,10 @@
 {
 	unsigned long rbs, child_rbs, rbs_size, stack_offset, stack_top, stack_used;
 	struct switch_stack *child_stack, *stack;
-	extern char ia64_ret_from_clone, ia32_ret_from_clone;
+	extern void  ia64_ret_from_clone(void);
+#ifdef CONFIG_IA32_SUPPORT
+	extern void ia32_ret_from_clone(void);
+#endif
 	struct pt_regs *child_ptregs;
 	int retval = 0;
 
@@ -332,10 +335,13 @@
 		child_ptregs->r12 = (unsigned long) (child_ptregs + 1); /* kernel sp */
 		child_ptregs->r13 = (unsigned long) p;		/* set `current' pointer */
 	}
+#ifdef CONFIG_IA32_SUPPORT
 	if (IS_IA32_PROCESS(regs))
-		child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
+		child_stack->b0 = ((unsigned long *) &ia32_ret_from_clone)[0];
 	else
-		child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
+#else
+		child_stack->b0 = ((unsigned long *) &ia64_ret_from_clone)[0];
+#endif
 	child_stack->ar_bspstore = child_rbs + rbs_size;
 
 	/* copy parts of thread_struct: */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Linux-ia64] [Patch] Fix in process.c
  2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
@ 2003-01-18  1:53 ` David Mosberger
  2003-01-18  3:04 ` Siddha, Suresh B
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: David Mosberger @ 2003-01-18  1:53 UTC (permalink / raw)
  To: linux-ia64

This one I REALLY don't like:

>>>>> On Fri, 17 Jan 2003 17:43:44 -0800, "Siddha, Suresh B" <suresh.b.siddha@intel.com> said:

  Suresh> - extern char ia64_ret_from_clone;
  Suresh> + extern void  ia64_ret_from_clone(void);

  Suresh> - child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
  Suresh> + child_stack->b0 = ((unsigned long *) &ia64_ret_from_clone)[0];

Why materialize a function pointer for ABSOLUTELY no reason?
Furthermore, &FUNC can be used as a static initializer, whereas
((long*)&FUNC)[0] cannot.

	--david


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Linux-ia64] [Patch] Fix in process.c
  2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
  2003-01-18  1:53 ` David Mosberger
@ 2003-01-18  3:04 ` Siddha, Suresh B
  2003-01-18  3:11 ` David Mosberger
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Siddha, Suresh B @ 2003-01-18  3:04 UTC (permalink / raw)
  To: linux-ia64

hi David,

Type of "ia64_ret_from_clone" is declared differently here(char as against function) and we end up linking object files with different types for the symbol(which the linker will not like).

Current C-code is assuming gcc specific behaviour(gcc does not fix the type for extern variables, leaves it to the linker). 

thanks,
suresh

> -----Original Message-----
> From: David Mosberger [mailto:davidm@napali.hpl.hp.com]
> Sent: Friday, January 17, 2003 5:53 PM
> To: Siddha, Suresh B
> Cc: linux-ia64@linuxia64.org
> Subject: Re: [Linux-ia64] [Patch] Fix in process.c
> 
> 
> This one I REALLY don't like:
> 
> >>>>> On Fri, 17 Jan 2003 17:43:44 -0800, "Siddha, Suresh B" 
> <suresh.b.siddha@intel.com> said:
> 
>   Suresh> - extern char ia64_ret_from_clone;
>   Suresh> + extern void  ia64_ret_from_clone(void);
> 
>   Suresh> - child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
>   Suresh> + child_stack->b0 = ((unsigned long *) 
> &ia64_ret_from_clone)[0];
> 
> Why materialize a function pointer for ABSOLUTELY no reason?
> Furthermore, &FUNC can be used as a static initializer, whereas
> ((long*)&FUNC)[0] cannot.
> 
> 	--david
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Linux-ia64] [Patch] Fix in process.c
  2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
  2003-01-18  1:53 ` David Mosberger
  2003-01-18  3:04 ` Siddha, Suresh B
@ 2003-01-18  3:11 ` David Mosberger
  2003-01-18  3:39 ` Siddha, Suresh B
  2003-01-21  2:41 ` Siddha, Suresh B
  4 siblings, 0 replies; 6+ messages in thread
From: David Mosberger @ 2003-01-18  3:11 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Fri, 17 Jan 2003 19:04:55 -0800, "Siddha, Suresh B" <suresh.b.siddha@intel.com> said:

  Suresh> hi David, Type of "ia64_ret_from_clone" is declared
  Suresh> differently here(char as against function) and we end up
  Suresh> linking object files with different types for the
  Suresh> symbol(which the linker will not like).

  Suresh> Current C-code is assuming gcc specific behaviour(gcc does
  Suresh> not fix the type for extern variables, leaves it to the
  Suresh> linker).

I understand that.  What I'm saying is that GCC does the sane thing.
There's got to be a way to get the address of a label without having
to materialize a function pointer.

	--david


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Linux-ia64] [Patch] Fix in process.c
  2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
                   ` (2 preceding siblings ...)
  2003-01-18  3:11 ` David Mosberger
@ 2003-01-18  3:39 ` Siddha, Suresh B
  2003-01-21  2:41 ` Siddha, Suresh B
  4 siblings, 0 replies; 6+ messages in thread
From: Siddha, Suresh B @ 2003-01-18  3:39 UTC (permalink / raw)
  To: linux-ia64

> 
> >>>>> On Fri, 17 Jan 2003 19:04:55 -0800, "Siddha, Suresh B" 
> <suresh.b.siddha@intel.com> said:
> 
>   Suresh> hi David, Type of "ia64_ret_from_clone" is declared
>   Suresh> differently here(char as against function) and we end up
>   Suresh> linking object files with different types for the
>   Suresh> symbol(which the linker will not like).
> 
>   Suresh> Current C-code is assuming gcc specific behaviour(gcc does
>   Suresh> not fix the type for extern variables, leaves it to the
>   Suresh> linker).
> 
> I understand that.  What I'm saying is that GCC does the sane thing.
> There's got to be a way to get the address of a label without having
> to materialize a function pointer.
> 
> 	--david
> 

We can do that through the linker script vmlinux.lds.S.

thanks,
suresh


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [Linux-ia64] [Patch] Fix in process.c
  2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
                   ` (3 preceding siblings ...)
  2003-01-18  3:39 ` Siddha, Suresh B
@ 2003-01-21  2:41 ` Siddha, Suresh B
  4 siblings, 0 replies; 6+ messages in thread
From: Siddha, Suresh B @ 2003-01-21  2:41 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]

> > 
> > I understand that.  What I'm saying is that GCC does the sane thing.
> > There's got to be a way to get the address of a label without having
> > to materialize a function pointer.
> > 
> > 	--david
> > 
> 
> We can do that through the linker script vmlinux.lds.S.
> 

hi David,

Here is the patch which does this. Please apply.

thanks,
suresh

diff -Nru linux-2.5.52/arch/ia64/kernel/process.c linux/arch/ia64/kernel/process.c
--- linux-2.5.52/arch/ia64/kernel/process.c	Mon Jan 20 13:12:08 2003
+++ linux/arch/ia64/kernel/process.c	Mon Jan 20 09:45:21 2003
@@ -281,7 +281,10 @@
 {
 	unsigned long rbs, child_rbs, rbs_size, stack_offset, stack_top, stack_used;
 	struct switch_stack *child_stack, *stack;
-	extern char ia64_ret_from_clone, ia32_ret_from_clone;
+	extern int  __ia64_ret_from_clone;
+#ifdef CONFIG_IA32_SUPPORT
+	extern int __ia32_ret_from_clone;
+#endif
 	struct pt_regs *child_ptregs;
 	int retval = 0;
 
@@ -332,10 +335,12 @@
 		child_ptregs->r12 = (unsigned long) (child_ptregs + 1); /* kernel sp */
 		child_ptregs->r13 = (unsigned long) p;		/* set `current' pointer */
 	}
+#ifdef CONFIG_IA32_SUPPORT
 	if (IS_IA32_PROCESS(regs))
-		child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
+		child_stack->b0 = (unsigned long) &__ia32_ret_from_clone;
 	else
-		child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
+#endif
+		child_stack->b0 = (unsigned long) &__ia64_ret_from_clone;
 	child_stack->ar_bspstore = child_rbs + rbs_size;
 
 	/* copy parts of thread_struct: */
diff -Nru linux-2.5.52/arch/ia64/vmlinux.lds.S linux/arch/ia64/vmlinux.lds.S
--- linux-2.5.52/arch/ia64/vmlinux.lds.S	Mon Jan 20 13:12:09 2003
+++ linux/arch/ia64/vmlinux.lds.S	Mon Jan 20 18:31:14 2003
@@ -39,6 +39,14 @@
 #endif
   _etext = .;
 
+   /* We want to get the address of a label without having
+      to materialize a function pointer. "+0" is for changing
+      the symbol type */
+   __ia64_ret_from_clone = ia64_ret_from_clone + 0;
+#ifdef CONFIG_IA32_SUPPORT
+   __ia32_ret_from_clone = ia32_ret_from_clone + 0;
+#endif
+
   /* Read-only data */
 
   /* Global data */


[-- Attachment #2: process.diff --]
[-- Type: application/octet-stream, Size: 1786 bytes --]

diff -Nru linux-2.5.52/arch/ia64/kernel/process.c linux/arch/ia64/kernel/process.c
--- linux-2.5.52/arch/ia64/kernel/process.c	Mon Jan 20 13:12:08 2003
+++ linux/arch/ia64/kernel/process.c	Mon Jan 20 09:45:21 2003
@@ -281,7 +281,10 @@
 {
 	unsigned long rbs, child_rbs, rbs_size, stack_offset, stack_top, stack_used;
 	struct switch_stack *child_stack, *stack;
-	extern char ia64_ret_from_clone, ia32_ret_from_clone;
+	extern int  __ia64_ret_from_clone;
+#ifdef CONFIG_IA32_SUPPORT
+	extern int __ia32_ret_from_clone;
+#endif
 	struct pt_regs *child_ptregs;
 	int retval = 0;
 
@@ -332,10 +335,12 @@
 		child_ptregs->r12 = (unsigned long) (child_ptregs + 1); /* kernel sp */
 		child_ptregs->r13 = (unsigned long) p;		/* set `current' pointer */
 	}
+#ifdef CONFIG_IA32_SUPPORT
 	if (IS_IA32_PROCESS(regs))
-		child_stack->b0 = (unsigned long) &ia32_ret_from_clone;
+		child_stack->b0 = (unsigned long) &__ia32_ret_from_clone;
 	else
-		child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
+#endif
+		child_stack->b0 = (unsigned long) &__ia64_ret_from_clone;
 	child_stack->ar_bspstore = child_rbs + rbs_size;
 
 	/* copy parts of thread_struct: */
diff -Nru linux-2.5.52/arch/ia64/vmlinux.lds.S linux/arch/ia64/vmlinux.lds.S
--- linux-2.5.52/arch/ia64/vmlinux.lds.S	Mon Jan 20 13:12:09 2003
+++ linux/arch/ia64/vmlinux.lds.S	Mon Jan 20 18:31:14 2003
@@ -39,6 +39,14 @@
 #endif
   _etext = .;
 
+   /* We want to get the address of a label without having
+      to materialize a function pointer. "+0" is for changing
+      the symbol type */
+   __ia64_ret_from_clone = ia64_ret_from_clone + 0;
+#ifdef CONFIG_IA32_SUPPORT
+   __ia32_ret_from_clone = ia32_ret_from_clone + 0;
+#endif
+
   /* Read-only data */
 
   /* Global data */

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-01-21  2:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-18  1:43 [Linux-ia64] [Patch] Fix in process.c Siddha, Suresh B
2003-01-18  1:53 ` David Mosberger
2003-01-18  3:04 ` Siddha, Suresh B
2003-01-18  3:11 ` David Mosberger
2003-01-18  3:39 ` Siddha, Suresh B
2003-01-21  2:41 ` Siddha, Suresh B

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox