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

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).