All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] to make grub2 compile on NetBSD
@ 2008-02-03 21:33 walt
  2008-02-04 15:56 ` Marco Gerards
  0 siblings, 1 reply; 12+ messages in thread
From: walt @ 2008-02-03 21:33 UTC (permalink / raw)
  To: grub-devel

NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
but this is useless for a free-standing executable like grub.  Define
a dummy function in lieu of libgcc to supply __enable_execute_stack.



Index: include/grub/mm.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/mm.h,v
retrieving revision 1.8
diff -u -r1.8 mm.h
--- include/grub/mm.h   21 Jul 2007 23:32:22 -0000      1.8
+++ include/grub/mm.h   3 Feb 2008 21:24:18 -0000
@@ -33,6 +33,7 @@
 void EXPORT_FUNC(grub_free) (void *ptr);
 void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
 void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
+void EXPORT_FUNC(__enable_execute_stack) (void);   /* For NetBSD gcc */
 
 /* For debugging.  */
 #if defined(MM_DEBUG) && !defined(GRUB_UTIL)
Index: kern/mm.c
===================================================================
RCS file: /sources/grub/grub2/kern/mm.c,v
retrieving revision 1.19
diff -u -r1.19 mm.c
--- kern/mm.c   23 Jan 2008 14:57:40 -0000      1.19
+++ kern/mm.c   3 Feb 2008 21:24:19 -0000
@@ -66,6 +66,12 @@
 #include <grub/disk.h>
 #include <grub/dl.h>
 
+/* Dummy symbol to make NetBSD gcc happy */
+void
+__enable_execute_stack(void)
+{
+}
+
 #ifdef MM_DEBUG
 # undef grub_malloc
 # undef grub_realloc






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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-03 21:33 [PATCH] to make grub2 compile on NetBSD walt
@ 2008-02-04 15:56 ` Marco Gerards
  2008-02-04 20:21   ` walt
  2008-02-11 22:44   ` walt
  0 siblings, 2 replies; 12+ messages in thread
From: Marco Gerards @ 2008-02-04 15:56 UTC (permalink / raw)
  To: The development of GRUB 2

walt <wa1ter@myrealbox.com> writes:

> NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> but this is useless for a free-standing executable like grub.  Define
> a dummy function in lieu of libgcc to supply __enable_execute_stack.


Great, thanks!

Can you send in a changelog entry?

> Index: include/grub/mm.h
> ===================================================================
> RCS file: /sources/grub/grub2/include/grub/mm.h,v
> retrieving revision 1.8
> diff -u -r1.8 mm.h
> --- include/grub/mm.h   21 Jul 2007 23:32:22 -0000      1.8
> +++ include/grub/mm.h   3 Feb 2008 21:24:18 -0000
> @@ -33,6 +33,7 @@
>  void EXPORT_FUNC(grub_free) (void *ptr);
>  void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
>  void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
> +void EXPORT_FUNC(__enable_execute_stack) (void);   /* For NetBSD gcc */

Please use our style of commenting.  So a `.' followed by two spaces.
Better put this on a separate line.  If this is for NetBSD only,
shouldn't you add a #ifdef instead of a comment?
  
>  /* For debugging.  */
>  #if defined(MM_DEBUG) && !defined(GRUB_UTIL)
> Index: kern/mm.c
> ===================================================================
> RCS file: /sources/grub/grub2/kern/mm.c,v
> retrieving revision 1.19
> diff -u -r1.19 mm.c
> --- kern/mm.c   23 Jan 2008 14:57:40 -0000      1.19
> +++ kern/mm.c   3 Feb 2008 21:24:19 -0000
> @@ -66,6 +66,12 @@
>  #include <grub/disk.h>
>  #include <grub/dl.h>
>  
> +/* Dummy symbol to make NetBSD gcc happy */
> +void
> +__enable_execute_stack(void)
> +{
> +}
> +
>  #ifdef MM_DEBUG
>  # undef grub_malloc
>  # undef grub_realloc
>
>
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel




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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 15:56 ` Marco Gerards
@ 2008-02-04 20:21   ` walt
  2008-02-04 20:55     ` Marco Gerards
  2008-02-04 22:27     ` Robert Millan
  2008-02-11 22:44   ` walt
  1 sibling, 2 replies; 12+ messages in thread
From: walt @ 2008-02-04 20:21 UTC (permalink / raw)
  To: grub-devel


On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
> walt <wa1ter@myrealbox.com> writes:
> 
> > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> > but this is useless for a free-standing executable like grub.  Define
> > a dummy function in lieu of libgcc to supply __enable_execute_stack.

> ...  If this is for NetBSD only,
> shouldn't you add a #ifdef instead of a comment?

Second try:

	Make NetBSD's gcc happy.

	* kern/mm.c: New dummy symbol __enable_execute_stack.
	(include/grub/mm.h): Likewise.


Index: include/grub/mm.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/mm.h,v
retrieving revision 1.8
diff -u -r1.8 mm.h
--- include/grub/mm.h   21 Jul 2007 23:32:22 -0000      1.8
+++ include/grub/mm.h   4 Feb 2008 20:05:36 -0000
@@ -34,6 +34,11 @@
 void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
 void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
 
+#ifdef __NetBSD__
+/* Dummy symbol to make gcc happy. */
+void EXPORT_FUNC(__enable_execute_stack) (void);
+#endif
+
 /* For debugging.  */
 #if defined(MM_DEBUG) && !defined(GRUB_UTIL)
 /* Set this variable to 1 when you want to trace all memory function
calls.  */
Index: kern/mm.c
===================================================================
RCS file: /sources/grub/grub2/kern/mm.c,v
retrieving revision 1.19
diff -u -r1.19 mm.c
--- kern/mm.c   23 Jan 2008 14:57:40 -0000      1.19
+++ kern/mm.c   4 Feb 2008 20:05:36 -0000
@@ -66,6 +66,14 @@
 #include <grub/disk.h>
 #include <grub/dl.h>
 
+#ifdef __NetBSD__
+/* Dummy symbol to make gcc happy. */
+void
+__enable_execute_stack(void)
+{
+}
+#endif
+
 #ifdef MM_DEBUG
 # undef grub_malloc
 # undef grub_realloc






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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 20:21   ` walt
@ 2008-02-04 20:55     ` Marco Gerards
  2008-02-04 22:27     ` Robert Millan
  1 sibling, 0 replies; 12+ messages in thread
From: Marco Gerards @ 2008-02-04 20:55 UTC (permalink / raw)
  To: The development of GRUB 2

walt <wa1ter@myrealbox.com> writes:

> On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
>> walt <wa1ter@myrealbox.com> writes:
>> 
>> > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
>> > but this is useless for a free-standing executable like grub.  Define
>> > a dummy function in lieu of libgcc to supply __enable_execute_stack.
>
>> ...  If this is for NetBSD only,
>> shouldn't you add a #ifdef instead of a comment?
>
> Second try:
>
> 	Make NetBSD's gcc happy.
>
> 	* kern/mm.c: New dummy symbol __enable_execute_stack.
> 	(include/grub/mm.h): Likewise.

The patch looks fine to me.  Can you please supply the header for the
changelog entry?  It's not complete this way.

--
Marco




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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 20:21   ` walt
  2008-02-04 20:55     ` Marco Gerards
@ 2008-02-04 22:27     ` Robert Millan
  2008-02-04 22:55       ` walt
  1 sibling, 1 reply; 12+ messages in thread
From: Robert Millan @ 2008-02-04 22:27 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Feb 04, 2008 at 12:21:11PM -0800, walt wrote:
> 
> On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
> > walt <wa1ter@myrealbox.com> writes:
> > 
> > > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> > > but this is useless for a free-standing executable like grub.  Define
> > > a dummy function in lieu of libgcc to supply __enable_execute_stack.
> 
> > ...  If this is for NetBSD only,
> > shouldn't you add a #ifdef instead of a comment?
> 
> Second try:
> 
> 	Make NetBSD's gcc happy.
> 
> 	* kern/mm.c: New dummy symbol __enable_execute_stack.
> 	(include/grub/mm.h): Likewise.

This ChangeLog entry seems wrong.  I'll write it up for you, as it's easier to
explain with an example:

	Make NetBSD's gcc happy.

	* include/grub/mm.h
	[__NetBSD__] (__enable_execute_stack): New function prototype.
	* kern/mm.c
	[__NetBSD__] (__enable_execute_stack): New function.

> +#ifdef __NetBSD__
> +/* Dummy symbol to make gcc happy. */
> +void
> +__enable_execute_stack(void)

Missing space here       ^

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 22:27     ` Robert Millan
@ 2008-02-04 22:55       ` walt
  2008-02-04 23:30         ` Robert Millan
  2008-02-05  6:37         ` Marco Gerards
  0 siblings, 2 replies; 12+ messages in thread
From: walt @ 2008-02-04 22:55 UTC (permalink / raw)
  To: grub-devel

Robert Millan wrote:
>>> walt<wa1ter@myrealbox.com>  writes:
>>>
>>>> NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
>>>> but this is useless for a free-standing executable like grub.  Define
>>>> a dummy function in lieu of libgcc to supply __enable_execute_stack.

>> Second try:
>>
>> 	Make NetBSD's gcc happy.
>>
>> 	* kern/mm.c: New dummy symbol __enable_execute_stack.
>> 	(include/grub/mm.h): Likewise.
>
> This ChangeLog entry seems wrong.  I'll write it up for you, as it's easier to
> explain with an example:
>
> 	Make NetBSD's gcc happy.
>
> 	* include/grub/mm.h
> 	[__NetBSD__] (__enable_execute_stack): New function prototype.
> 	* kern/mm.c
> 	[__NetBSD__] (__enable_execute_stack): New function.

Okay, thanks.  Does the [__NetBSD__] token denote an #ifdef?  How
would I indicate a patch for, say, Net/Free/Dragonfly BSD's at the
same time?

Oh, and should you mention that the new function does nothing?

Marco:  I didn't add the header for the changelog because I don't
know who (if anyone) is going to commit it.




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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 22:55       ` walt
@ 2008-02-04 23:30         ` Robert Millan
  2008-02-05  6:37         ` Marco Gerards
  1 sibling, 0 replies; 12+ messages in thread
From: Robert Millan @ 2008-02-04 23:30 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Feb 04, 2008 at 02:55:34PM -0800, walt wrote:
> 
> Okay, thanks.  Does the [__NetBSD__] token denote an #ifdef?  How
> would I indicate a patch for, say, Net/Free/Dragonfly BSD's at the
> same time?

No idea, you just caught me on this ;-)

Anyway, if we come to this, maybe it is better to just add an autoconf
check.

> Oh, and should you mention that the new function does nothing?

That's optional.

> Marco:  I didn't add the header for the changelog because I don't
> know who (if anyone) is going to commit it.

Just put your name in it.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 22:55       ` walt
  2008-02-04 23:30         ` Robert Millan
@ 2008-02-05  6:37         ` Marco Gerards
  1 sibling, 0 replies; 12+ messages in thread
From: Marco Gerards @ 2008-02-05  6:37 UTC (permalink / raw)
  To: The development of GRUB 2

walt <wa1ter@myrealbox.com> writes:

> Robert Millan wrote:
>>>> walt<wa1ter@myrealbox.com>  writes:
>>>>
>>>>> NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
>>>>> but this is useless for a free-standing executable like grub.  Define
>>>>> a dummy function in lieu of libgcc to supply __enable_execute_stack.
>
>>> Second try:
>>>
>>> 	Make NetBSD's gcc happy.
>>>
>>> 	* kern/mm.c: New dummy symbol __enable_execute_stack.
>>> 	(include/grub/mm.h): Likewise.
>>
>> This ChangeLog entry seems wrong.  I'll write it up for you, as it's easier to
>> explain with an example:
>>
>> 	Make NetBSD's gcc happy.
>>
>> 	* include/grub/mm.h
>> 	[__NetBSD__] (__enable_execute_stack): New function prototype.
>> 	* kern/mm.c
>> 	[__NetBSD__] (__enable_execute_stack): New function.
>
> Okay, thanks.  Does the [__NetBSD__] token denote an #ifdef?  How
> would I indicate a patch for, say, Net/Free/Dragonfly BSD's at the
> same time?
>
> Oh, and should you mention that the new function does nothing?
>
> Marco:  I didn't add the header for the changelog because I don't
> know who (if anyone) is going to commit it.

Your name and email address should be used when committing, at least
that's preferred.  The date will be updated to the commit date when
committing.

--
Marco




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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-04 15:56 ` Marco Gerards
  2008-02-04 20:21   ` walt
@ 2008-02-11 22:44   ` walt
  2008-02-12  7:22     ` Yoshinori K. Okuji
  1 sibling, 1 reply; 12+ messages in thread
From: walt @ 2008-02-11 22:44 UTC (permalink / raw)
  To: grub-devel


On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
> walt <wa1ter@myrealbox.com> writes:
>
> > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> > but this is useless for a free-standing executable like grub.  Define
> > a dummy function in lieu of libgcc to supply __enable_execute_stack.

> ...  If this is for NetBSD only,
> shouldn't you add a #ifdef instead of a comment?

Third try:

2008-??-??  walt <wa1ter@myrealbox.com>

	Make NetBSD's gcc happy.  Based on pkgsrc/wip/grub2 patches.

	* include/grub/mm.h
	[__NetBSD__] (__enable_execute_stack): New function prototype.
	* kern/mm.c
	[__NetBSD__] (__enable_execute_stack): New function.



Index: include/grub/mm.h
===================================================================
RCS file: /sources/grub/grub2/include/grub/mm.h,v
retrieving revision 1.8
diff -u -r1.8 mm.h
--- include/grub/mm.h   21 Jul 2007 23:32:22 -0000      1.8
+++ include/grub/mm.h   4 Feb 2008 20:05:36 -0000
@@ -34,6 +34,11 @@
  void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
  void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
  +#ifdef __NetBSD__
+/* Dummy symbol to make gcc happy. */
+void EXPORT_FUNC(__enable_execute_stack) (void);
+#endif
+
  /* For debugging.  */
  #if defined(MM_DEBUG) && !defined(GRUB_UTIL)
  /* Set this variable to 1 when you want to trace all memory function
calls.  */
Index: kern/mm.c
===================================================================
RCS file: /sources/grub/grub2/kern/mm.c,v
retrieving revision 1.19
diff -u -r1.19 mm.c
--- kern/mm.c   23 Jan 2008 14:57:40 -0000      1.19
+++ kern/mm.c   4 Feb 2008 20:05:36 -0000
@@ -66,6 +66,14 @@
  #include <grub/disk.h>
  #include <grub/dl.h>
  +#ifdef __NetBSD__
+/* Dummy symbol to make gcc happy. */
+void
+__enable_execute_stack (void)
+{
+}
+#endif
+
  #ifdef MM_DEBUG
  # undef grub_malloc
  # undef grub_realloc




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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-11 22:44   ` walt
@ 2008-02-12  7:22     ` Yoshinori K. Okuji
  2008-02-12 23:56       ` walt
  0 siblings, 1 reply; 12+ messages in thread
From: Yoshinori K. Okuji @ 2008-02-12  7:22 UTC (permalink / raw)
  To: The development of GRUB 2

On Monday 11 February 2008 23:44, walt wrote:
> On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
> > walt <wa1ter@myrealbox.com> writes:
> > > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> > > but this is useless for a free-standing executable like grub.  Define
> > > a dummy function in lieu of libgcc to supply __enable_execute_stack.
> >
> > ...  If this is for NetBSD only,
> > shouldn't you add a #ifdef instead of a comment?
>
> Third try:
>
> 2008-??-??  walt <wa1ter@myrealbox.com>
>
> 	Make NetBSD's gcc happy.  Based on pkgsrc/wip/grub2 patches.
>
> 	* include/grub/mm.h
> 	[__NetBSD__] (__enable_execute_stack): New function prototype.
> 	* kern/mm.c
> 	[__NetBSD__] (__enable_execute_stack): New function.

I don't strongly object to this way, but I feel that it would be better to 
probe if __enable_execute_stack must be defined, and define a variable in 
configure, instead of hardcoding __NetBSD__.

Okuji



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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-12  7:22     ` Yoshinori K. Okuji
@ 2008-02-12 23:56       ` walt
  2008-02-13  3:55         ` Yoshinori K. Okuji
  0 siblings, 1 reply; 12+ messages in thread
From: walt @ 2008-02-12 23:56 UTC (permalink / raw)
  To: grub-devel


On Tue, 2008-02-12 at 08:22 +0100, Yoshinori K. Okuji wrote:
> On Monday 11 February 2008 23:44, walt wrote:
> > On Mon, 2008-02-04 at 16:56 +0100, Marco Gerards wrote:
> > > walt <wa1ter@myrealbox.com> writes:
> > > > NetBSD's gcc wants libgcc and libc to define __enable_execute_stack,
> > > > but this is useless for a free-standing executable like grub.  Define
> > > > a dummy function in lieu of libgcc to supply __enable_execute_stack.
> > >
> > > ...  If this is for NetBSD only,
> > > shouldn't you add a #ifdef instead of a comment?
> >
> > Third try:
> >
> > 2008-??-??  walt <wa1ter@myrealbox.com>
> >
> > 	Make NetBSD's gcc happy.  Based on pkgsrc/wip/grub2 patches.
> >
> > 	* include/grub/mm.h
> > 	[__NetBSD__] (__enable_execute_stack): New function prototype.
> > 	* kern/mm.c
> > 	[__NetBSD__] (__enable_execute_stack): New function.
> 
> I don't strongly object to this way, but I feel that it would be better to 
> probe if __enable_execute_stack must be defined, and define a variable in 
> configure, instead of hardcoding __NetBSD__.

That sounds excellent -- I hate adding ifdefs for specific operating 
systems because it just disguises the real problem instead of solving 
it.

This is a link-time error, and I have no clue how to detect it at
configure time.  Please show me how you would do it.

Thanks!






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

* Re: [PATCH] to make grub2 compile on NetBSD
  2008-02-12 23:56       ` walt
@ 2008-02-13  3:55         ` Yoshinori K. Okuji
  0 siblings, 0 replies; 12+ messages in thread
From: Yoshinori K. Okuji @ 2008-02-13  3:55 UTC (permalink / raw)
  To: The development of GRUB 2

On Wednesday 13 February 2008 00:56, walt wrote:
> This is a link-time error, and I have no clue how to detect it at
> configure time.  Please show me how you would do it.

I think the following would be sufficient:

1. Find small code which produces a reference to __enable_execute_stack even 
with -fno-stack-protector. Probably using a nested function should be enough.

2. Compile it to an object file, and run "nm -u object_file | grep 
__enable_execute_stack".

3. Write a test in aclocal.m4 using the above, and call it from configure.ac.

You can see many examples in aclocal.m4. If you have no clue on writing an 
autoconf test, I can write it for you, if you show me such code.

Okuji



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

end of thread, other threads:[~2008-02-13  3:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-03 21:33 [PATCH] to make grub2 compile on NetBSD walt
2008-02-04 15:56 ` Marco Gerards
2008-02-04 20:21   ` walt
2008-02-04 20:55     ` Marco Gerards
2008-02-04 22:27     ` Robert Millan
2008-02-04 22:55       ` walt
2008-02-04 23:30         ` Robert Millan
2008-02-05  6:37         ` Marco Gerards
2008-02-11 22:44   ` walt
2008-02-12  7:22     ` Yoshinori K. Okuji
2008-02-12 23:56       ` walt
2008-02-13  3:55         ` Yoshinori K. Okuji

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.