This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use PT_GNU_EH_FRAME registry on alpha*-linux* too


Hi!

I skipped Alpha initially, since it is more complicated (as crtbegin.asm
is in assembly, the check for dl_iterate_phdr function in target glibc
cannot be done (link.h cannot be included in assembly).
The following should work (preprocessing a C file, seeing if target glibc
headers guarantee dl_iterate_phdr, if yes, adding a define to crtbegin.asm).

Also, if -Dinhibit_libc, we definitely shouldn't try to include glibc
headers (might solve Bo's issues).

Ok to commit (bootstrap pending)?

2001-12-30  Jakub Jelinek  <jakub@redhat.com>

	* config.gcc (alpha*-*-linux*): Use alpha/t-linux instead of
	alpha/t-crtbe.
	* config/alpha/t-linux: New file.
	* config/alpha/linux-elf.h (STARTFILE_SPEC, LINK_EH_SPEC): Define.
	* config/alpha/crtbegin.asm: If USE_PT_GNU_EH_FRAME is defined,
	don't call __register_frame_info nor __deregister_frame_info.
	* config/alpha/crtbegin.c: New file.

	* unwind-dw2-fde-glibc.c: If inhibit_libc, use __register_frame*
	registry only.
	* crtstuff.c: Likewise.

--- gcc/config.gcc.jj	Thu Dec 27 13:49:24 2001
+++ gcc/config.gcc	Sun Dec 30 23:29:27 2001
@@ -452,7 +452,7 @@ alpha*-*-linux*libc1*)
 alpha*-*-linux*)
 	tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h"
 	target_cpu_default="MASK_GAS"
-	tmake_file="t-slibgcc-elf-ver t-linux alpha/t-crtbe alpha/t-crtfm alpha/t-alpha alpha/t-ieee"
+	tmake_file="t-slibgcc-elf-ver t-linux alpha/t-linux alpha/t-crtfm alpha/t-alpha alpha/t-ieee"
 	gas=yes gnu_ld=yes
 	if test x$enable_threads = xyes; then
 		thread_file='posix'
--- gcc/config/alpha/t-linux.jj	Sun Dec 30 23:22:46 2001
+++ gcc/config/alpha/t-linux	Mon Dec 31 00:03:51 2001
@@ -0,0 +1,20 @@
+# Effectively disable the crtbegin/end rules using crtstuff.c
+T = disable
+
+EXTRA_PARTS += crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o
+
+# Assemble startup files.
+crtbegin.o: $(srcdir)/config/alpha/crtbegin.asm $(srcdir)/config/alpha/crtbegin.c $(GCC_PASSES)
+	$(GCC_FOR_TARGET) -c -o crtbegin.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm \
+	`$(GCC_FOR_TARGET) -E $(srcdir)/config/alpha/crtbegin.c 2>/dev/null \
+	 | sed -n 's/^.*crtbegin_cflags="\(.*\)";/\1/p'`
+crtend.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES)
+	$(GCC_FOR_TARGET) -c -o crtend.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtend.asm
+crtbeginS.o: $(srcdir)/config/alpha/crtbegin.asm $(srcdir)/config/alpha/crtbegin.c $(GCC_PASSES)
+	$(GCC_FOR_TARGET) -DSHARED -c -o crtbeginS.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm \
+	`$(GCC_FOR_TARGET) -E $(srcdir)/config/alpha/crtbegin.c 2>/dev/null \
+	 | sed -n 's/^.*crtbegin_cflags="\(.*\)";/\1/p'`
+crtendS.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES)
+	$(GCC_FOR_TARGET) -DSHARED -c -o crtendS.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtend.asm
+crtbeginT.o: $(srcdir)/config/alpha/crtbegin.asm $(GCC_PASSES)
+	$(GCC_FOR_TARGET) -c -o crtbegin.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm
--- gcc/config/alpha/linux-elf.h.jj	Sun Jul 22 21:34:21 2001
+++ gcc/config/alpha/linux-elf.h	Sun Dec 30 23:29:12 2001
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler
    for Alpha Linux-based GNU systems using ELF.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
    Contributed by Richard Henderson.
 
 This file is part of GNU CC.
@@ -40,4 +40,16 @@ Boston, MA 02111-1307, USA.  */
 #undef LIB_SPEC
 #define LIB_SPEC \
 "%{shared:-lc}%{!shared:%{pthread:-lpthread }%{profile:-lc_p}%{!profile:-lc}} "
+
+#undef	STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "%{!shared: \
+     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
+   crti.o%s %{static:crtbeginT.o%s}\
+   %{!static:%{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}}"
+
+#ifdef HAVE_LD_EH_FRAME_HDR
+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
 #endif
+
+#endif /* !USE_GNULIBC_1 */
--- gcc/config/alpha/crtbegin.asm.jj	Sat Aug 18 22:10:36 2001
+++ gcc/config/alpha/crtbegin.asm	Sun Dec 30 23:33:43 2001
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996, 1998, 2000 Free Software Foundation, Inc.
+ * Copyright (C) 1996, 1998, 2000, 2001 Free Software Foundation, Inc.
  *  Contributed by Richard Henderson (rth@tamu.edu)
  *
  * This file is free software; you can redistribute it and/or modify it
@@ -162,11 +162,13 @@ __do_global_dtors_aux:
 	bne     $27,1b
 
 	/* Remove our frame info.  */
+#ifndef USE_PT_GNU_EH_FRAME
 	lda	$1,__deregister_frame_info
 	beq	$1,3f
 	lda	$16,__EH_FRAME_BEGIN__
 	jsr	$26,__deregister_frame_info
 	ldgp	$29,0($26)
+#endif
 
 3:	ldq     $26,0($30)
 	ldq	$9,8($30)
@@ -199,12 +201,14 @@ __do_frame_setup:
 	.mask   0x4000000,-16
 	.prologue 1
 
+#ifndef USE_PT_GNU_EH_FRAME
 	lda	$1,__register_frame_info
 	beq	$1,0f
 	lda	$16,__EH_FRAME_BEGIN__
 	lda	$17,frame_object
 	jsr	$26,__register_frame_info
 	ldgp	$29,0($26)
+#endif
 
 0:	lda	$1,_Jv_RegisterClasses
 	lda	$16,__JCR_LIST__
@@ -220,8 +224,10 @@ __do_frame_setup:
 
 	.end __do_frame_setup
 
+#ifndef USE_PT_GNU_EH_FRAME
 .weak __register_frame_info
 .weak __deregister_frame_info
+#endif
 #ifdef SHARED
 .weak __cxa_finalize
 #endif
--- gcc/config/alpha/crtbegin.c.jj	Sun Dec 30 23:57:43 2001
+++ gcc/config/alpha/crtbegin.c	Sun Dec 30 23:57:37 2001
@@ -0,0 +1,16 @@
+/* This is a test whether PT_GNU_EH_FRAME eh should be used.
+   This cannot be checked in configure, since target library headers
+   need to be checked, but as crtbegin is written in assembly on
+   Alpha, link.h cannot be included in crtbegin.asm.
+   Thus, this file is preprocessed and crtbegin_cflags it defines
+   (if any) are added to crtbegin.asm's CFLAGS.  */
+
+#include "auto-host.h"
+#ifndef inhibit_libc
+#include <link.h>
+#if defined(HAVE_LD_EH_FRAME_HDR) \
+    && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
+	|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
+const char *crtbegin_cflags="-DUSE_PT_GNU_EH_FRAME";
+#endif
+#endif
--- gcc/unwind-dw2-fde-glibc.c.jj	Tue Dec 18 01:28:15 2001
+++ gcc/unwind-dw2-fde-glibc.c	Sun Dec 30 23:13:42 2001
@@ -31,9 +31,11 @@
 
 #include "auto-host.h" /* For HAVE_LD_EH_FRAME_HDR.  */
 #include "tconfig.h"
+#ifndef inhibit_libc
 #include <stddef.h>
 #include <stdlib.h>
 #include <link.h>
+#endif
 #include "tsystem.h"
 #include "dwarf2.h"
 #include "unwind.h"
@@ -42,7 +44,7 @@
 #include "unwind-dw2-fde.h"
 #include "gthr.h"
 
-#if defined(HAVE_LD_EH_FRAME_HDR) \
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
     && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
 	|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
 
--- gcc/crtstuff.c.jj	Sat Dec 15 14:00:20 2001
+++ gcc/crtstuff.c	Mon Dec 31 00:08:39 2001
@@ -67,7 +67,7 @@ Software Foundation, 59 Temple Place - S
 #endif
 
 #if defined(OBJECT_FORMAT_ELF) && defined(HAVE_LD_EH_FRAME_HDR) \
-    && !defined(CRTSTUFFT_O) \
+    && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
     && defined(__GLIBC__) && __GLIBC__ >= 2
 #include <link.h>
 # if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]