public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] NetBSD note segment
@ 2002-11-03  3:20 Momchil Velikov
  2002-11-03  8:10 ` Jason R Thorpe
  2002-11-03  9:14 ` Momchil Velikov
  0 siblings, 2 replies; 9+ messages in thread
From: Momchil Velikov @ 2002-11-03  3:20 UTC (permalink / raw)
  To: gcc-patches

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

This is the first shot for generating NetBSD .note* section and the
corresponding PT_NOTE segment.  Without this segment NetBSD refuses to
execute the file.

The attached patch is specific for powerpc-netbsd. It adds a new
"startup" file note.o to STARTUP_NETBSD_SPEC, which file contains only
the .note* section.  

If this feature is considered sufficiently general I'd suggest just
adding
#ifdef NOTE_OS_IDENT
NOTE_OS_IDENT
#endif
to crtstuff.c and be done with it.

Tested by building cross-compiling native and cross compilers[1] for
C/C++ for powerpc-unknown-netbsd and compiling and running a hello-world
with each language. Running dynamically linked binaries seems broken[2],
statically linked seem to work.

~velco

[1] --build=i383-netbsd {--host=i386-netbsd|--host=powerpc-netbsd}
    --target=powerpc-netbsd

[2] Probably binutils problem, will check later with NetBSD's own as/ld.


[-- Attachment #2: netbsd-note.diff --]
[-- Type: text/x-patch, Size: 2719 bytes --]

Index: gcc/config/netbsd-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/netbsd-elf.h,v
retrieving revision 1.1
diff -u -d -p -r1.1 netbsd-elf.h
--- gcc/config/netbsd-elf.h	22 Jan 2002 04:23:02 -0000	1.1
+++ gcc/config/netbsd-elf.h	3 Nov 2002 10:47:46 -0000
@@ -74,3 +74,13 @@ Boston, MA 02111-1307, USA.  */
        %{rdynamic:-export-dynamic}					\
        %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}	\
      %{static:-static}}"
+
+#define NOTE_NETBSD_IDENT						 \
+	.section	".note.netbsd.ident", "a";			 \
+	.p2align	2;						 \
+	.long		7;						 \
+	.long		4;						 \
+	.long		1;						 \
+	.ascii		"NetBSD\0\0";					 \
+	.long		199905;						 \
+	.p2align	2;
Index: gcc/config/rs6000/sysv4.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/sysv4.h,v
retrieving revision 1.84.2.3.4.3
diff -u -d -p -r1.84.2.3.4.3 sysv4.h
--- gcc/config/rs6000/sysv4.h	13 Sep 2002 06:53:05 -0000	1.84.2.3.4.3
+++ gcc/config/rs6000/sysv4.h	3 Nov 2002 10:48:23 -0000
@@ -1300,7 +1300,7 @@ do {						\
 %{profile:-lgmon -lc_p} %{!profile:-lc}"
 
 #define	STARTFILE_NETBSD_SPEC "\
-ncrti.o%s crt0.o%s \
+ncrti.o%s crt0.o%s note.o%s \
 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
 
 #define ENDFILE_NETBSD_SPEC "\
Index: gcc/config/rs6000/t-ppccomm
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/t-ppccomm,v
retrieving revision 1.15
diff -u -d -p -r1.15 t-ppccomm
--- gcc/config/rs6000/t-ppccomm	19 Feb 2002 19:40:41 -0000	1.15
+++ gcc/config/rs6000/t-ppccomm	3 Nov 2002 10:48:24 -0000
@@ -37,7 +37,7 @@ MULTILIB_MATCHES_SYSV	= mcall-sysv=mcall
 
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
-EXTRA_MULTILIB_PARTS = crtbegin$(objext) crtend$(objext) \
+EXTRA_MULTILIB_PARTS = note$(objext) crtbegin$(objext) crtend$(objext) \
   crtbeginS$(objext) crtendS$(objext) crtbeginT$(objext) \
   ecrti$(objext) ecrtn$(objext) \
   ncrti$(objext) ncrtn$(objext) \
@@ -47,6 +47,9 @@ EXTRA_MULTILIB_PARTS = crtbegin$(objext)
 # end labels to all of the special sections used when we link using gcc.
 
 # Assemble startup files.
+note.S: $(srcdir)/config/rs6000/note.asm
+	cat $(srcdir)/config/rs6000/note.asm > note.S
+
 ecrti.S: $(srcdir)/config/rs6000/eabi-ci.asm
 	cat $(srcdir)/config/rs6000/eabi-ci.asm >ecrti.S
 
@@ -63,3 +66,6 @@ crtsavres.S: $(srcdir)/config/rs6000/crt
 	cat $(srcdir)/config/rs6000/crtsavres.asm >crtsavres.S
 
 # Build multiple copies of ?crt{i,n}.o, one for each target switch.
+$(T)note$(objext): note.S
+	$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -c note.S -o $(T)note$(objext)
+


[-- Attachment #3: gcc-config-rs6000-note.asm --]
[-- Type: text/plain, Size: 43 bytes --]

#include "netbsd-elf.h"
NOTE_NETBSD_IDENT


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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  3:20 [PATCH] [RFC] NetBSD note segment Momchil Velikov
@ 2002-11-03  8:10 ` Jason R Thorpe
  2002-11-03  9:22   ` Momchil Velikov
  2002-11-03  9:14 ` Momchil Velikov
  1 sibling, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2002-11-03  8:10 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc-patches

On Sun, Nov 03, 2002 at 01:15:55PM +0200, Momchil Velikov wrote:

 > This is the first shot for generating NetBSD .note* section and the
 > corresponding PT_NOTE segment.  Without this segment NetBSD refuses to
 > execute the file.

This patch is not really correct.  The .note section in question should
be supplied by system files, not by a file shipped with the compiler.

I am working on a comprehensive fix for this problem, but in the mean time,
you can run noteless binaries by enabling the EXEC_ELF_NOTELESS option in
your kernel.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  3:20 [PATCH] [RFC] NetBSD note segment Momchil Velikov
  2002-11-03  8:10 ` Jason R Thorpe
@ 2002-11-03  9:14 ` Momchil Velikov
  1 sibling, 0 replies; 9+ messages in thread
From: Momchil Velikov @ 2002-11-03  9:14 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc-patches

On Sun, 3 Nov 2002 13:15:55 +0200
Momchil Velikov <velco@fadata.bg> wrote:

> C/C++ for powerpc-unknown-netbsd and compiling and running a
> hello-world with each language. Running dynamically linked binaries
> seems broken[2], statically linked seem to work.
> 
> [2] Probably binutils problem, will check later with NetBSD's own
> as/ld.

It didn't work with them also, the message is from the dynamic linker
(/usr/libexec/ld.elf_so), apparently GCC/as generate a relocation which
the linker does not support.
 
/usr/local/lib/libstdc++.so.5: Unsupported relocation type 10 in non-PLT
relocations

The relocation type 10 is R_PPC_REL24.  Similar relocations are marked
as "should not occur" throughout ld.elf_so sources.

~velco

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  8:10 ` Jason R Thorpe
@ 2002-11-03  9:22   ` Momchil Velikov
  2002-11-03  9:25     ` Jason R Thorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Momchil Velikov @ 2002-11-03  9:22 UTC (permalink / raw)
  To: Jason R Thorpe; +Cc: gcc-patches

On Sun, 3 Nov 2002 08:10:29 -0800
Jason R Thorpe <thorpej@wasabisystems.com> wrote:

> On Sun, Nov 03, 2002 at 01:15:55PM +0200, Momchil Velikov wrote:
> 
>  > This is the first shot for generating NetBSD .note* section and the
>  > corresponding PT_NOTE segment.  Without this segment NetBSD refuses
>  > to execute the file.
> 
> This patch is not really correct.  

You mean the content of the section may change with new OS releases ?
Like new version numbers, etc ?

> The .note section in question
> should be supplied by system files, not by a file shipped with the
> compiler.

Then it should be in crt0.o, not in files overriden by third party
compilers. As far as I can understand crtbegin*.o is compiler's turf, no?

> I am working on a comprehensive fix for this problem, but in the mean
> time, you can run noteless binaries by enabling the EXEC_ELF_NOTELESS
> option in your kernel.

Thanks.

~velco

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  9:22   ` Momchil Velikov
@ 2002-11-03  9:25     ` Jason R Thorpe
  2002-11-03  9:50       ` Momchil Velikov
  0 siblings, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2002-11-03  9:25 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc-patches

On Sun, Nov 03, 2002 at 07:17:59PM +0200, Momchil Velikov wrote:

 > You mean the content of the section may change with new OS releases ?
 > Like new version numbers, etc ?

Yes.

 > Then it should be in crt0.o, not in files overriden by third party
 > compilers. As far as I can understand crtbegin*.o is compiler's turf, no?

No, because the notes need to be present in shlibs, too.

The comprehensive solution I referred to involves splitting the NetBSD-
specific bits out of NetBSD's crtbegin/crtend into crti and crtn files,
like other OSs do.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  9:25     ` Jason R Thorpe
@ 2002-11-03  9:50       ` Momchil Velikov
  2002-11-03  9:57         ` Jason R Thorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Momchil Velikov @ 2002-11-03  9:50 UTC (permalink / raw)
  To: Jason R Thorpe; +Cc: gcc-patches

On Sun, 3 Nov 2002 09:25:14 -0800
Jason R Thorpe <thorpej@wasabisystems.com> wrote:

> On Sun, Nov 03, 2002 at 07:17:59PM +0200, Momchil Velikov wrote:
>  > Then it should be in crt0.o, not in files overriden by third party
>  > compilers. As far as I can understand crtbegin*.o is compiler's
>  > turf, no?
> 
> No, because the notes need to be present in shlibs, too.
> 
> The comprehensive solution I referred to involves splitting the
> NetBSD- specific bits out of NetBSD's crtbegin/crtend into crti and
> crtn files, like other OSs do.

How about putting them in the compiler's crtbegin/crtend files? That
would require changing only gcc/config/netbsd.h and gcc/crtstuff.c
instead of changing crt{i|n} of all the NetBSD CPUs (which seem quite a
large number :)

~velco

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  9:50       ` Momchil Velikov
@ 2002-11-03  9:57         ` Jason R Thorpe
  2002-11-03 10:13           ` Momchil Velikov
  0 siblings, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2002-11-03  9:57 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc-patches

On Sun, Nov 03, 2002 at 07:45:55PM +0200, Momchil Velikov wrote:

 > How about putting them in the compiler's crtbegin/crtend files? That
 > would require changing only gcc/config/netbsd.h and gcc/crtstuff.c
 > instead of changing crt{i|n} of all the NetBSD CPUs (which seem quite a
 > large number :)

Err, I already said that the compiler-supplied files should not supply
the notes.

(Besides, I have already written the crti.S/crtn.S files for all of
NetBSD's supported platforms :-)

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03  9:57         ` Jason R Thorpe
@ 2002-11-03 10:13           ` Momchil Velikov
  2002-11-03 10:20             ` Jason R Thorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Momchil Velikov @ 2002-11-03 10:13 UTC (permalink / raw)
  To: Jason R Thorpe; +Cc: gcc-patches

On Sun, 3 Nov 2002 09:57:24 -0800
Jason R Thorpe <thorpej@wasabisystems.com> wrote:

> On Sun, Nov 03, 2002 at 07:45:55PM +0200, Momchil Velikov wrote:
> 
>  > How about putting them in the compiler's crtbegin/crtend files?
>  > That would require changing only gcc/config/netbsd.h and
>  > gcc/crtstuff.c instead of changing crt{i|n} of all the NetBSD CPUs
>  > (which seem quite a large number :)
> 
> Err, I already said that the compiler-supplied files should not supply
> the notes.

But crti/crtn are compiler supplied, too ?

~velco

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

* Re: [PATCH] [RFC] NetBSD note segment
  2002-11-03 10:13           ` Momchil Velikov
@ 2002-11-03 10:20             ` Jason R Thorpe
  0 siblings, 0 replies; 9+ messages in thread
From: Jason R Thorpe @ 2002-11-03 10:20 UTC (permalink / raw)
  To: Momchil Velikov; +Cc: gcc-patches

On Sun, Nov 03, 2002 at 08:09:16PM +0200, Momchil Velikov wrote:

 > > Err, I already said that the compiler-supplied files should not supply
 > > the notes.
 > 
 > But crti/crtn are compiler supplied, too ?

No [*].

[*] The powerpc target currently supplies them, but once I get the
infrastructure changes finished up, I will be changing the powerpc-netbsd
configuration to use the OS-supplied versions.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

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

end of thread, other threads:[~2002-11-03 18:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03  3:20 [PATCH] [RFC] NetBSD note segment Momchil Velikov
2002-11-03  8:10 ` Jason R Thorpe
2002-11-03  9:22   ` Momchil Velikov
2002-11-03  9:25     ` Jason R Thorpe
2002-11-03  9:50       ` Momchil Velikov
2002-11-03  9:57         ` Jason R Thorpe
2002-11-03 10:13           ` Momchil Velikov
2002-11-03 10:20             ` Jason R Thorpe
2002-11-03  9:14 ` Momchil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).