This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
An important patch for glibc 2.0
- To: drepper@cygnus.com
- Subject: An important patch for glibc 2.0
- From: hjl@lucon.org (H.J. Lu)
- Date: Fri, 11 Dec 1998 10:42:48 -0800 (PST)
- Cc: libc-hacker@cygnus.com (GNU C Library)
>
> hjl@lucon.org (H.J. Lu) writes:
>
> > Ok, it is not needed if we can copy elf/so*.c from glibc 2.1
> > to glibc 2.0. Ulrich, can we do that?
>
> We could do this but I don't want to release any 2.0.* version anymore.
>
Here is a patch. You don't have to make a new release. In fact, we
haven't had one since glibc 2.0.6. Just put it into CVS so that
RedHat/Debian/SuSE can get it if they want. I have a patch for egcs,
which depends on it.
I believe we have to maintain glibc 2.0 at least for a while since
there are so many users now. I don't think they can/will switch to
glibc 2.1 anytime soon.
Thanks.
H.J.
---
Fri Dec 11 07:39:39 1998 H.J. Lu (hjl@gnu.org)
* elf/soinit.c: Copied from glibc 2.1.
* elf/sofini.c: Likewise.
* config.h.in (HAVE_DWARF2_UNWIND_INFO): New.
(HAVE_DWARF2_UNWIND_INFO_STATIC): New.
* configure.in (HAVE_DWARF2_UNWIND_INFO): Check for it.
(HAVE_DWARF2_UNWIND_INFO_STATIC): Check for it.
* configure: Regenerated.
Index: elf/soinit.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc-2.0/elf/soinit.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 soinit.c
--- elf/soinit.c 1997/09/19 18:10:34 1.1.1.1
+++ elf/soinit.c 1998/12/11 15:34:32
@@ -17,6 +17,28 @@
(**list) ();
}
+#ifdef HAVE_DWARF2_UNWIND_INFO
+static char __EH_FRAME_BEGIN__[]
+ __attribute__ ((section (".eh_frame")))
+ = { };
+# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
+/* This must match what's in frame.h in gcc. How can one do that? */
+struct object
+{
+ void *pc_begin;
+ void *pc_end;
+ void *fde_begin;
+ void *fde_array;
+ __SIZE_TYPE__ count;
+ struct object *next;
+};
+extern void __register_frame_info (const void *, struct object *);
+extern void __deregister_frame_info (const void *);
+# else
+extern void __register_frame (const void *);
+extern void __deregister_frame (const void *);
+# endif
+#endif
/* This function will be called from _init in init-first.c. */
void
@@ -24,6 +46,16 @@
{
/* Call constructor functions. */
run_hooks (__CTOR_LIST__);
+#ifdef HAVE_DWARF2_UNWIND_INFO
+# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
+ {
+ static struct object ob;
+ __register_frame_info (__EH_FRAME_BEGIN__, &ob);
+ }
+# else
+ __register_frame (__EH_FRAME_BEGIN__);
+# endif
+#endif
}
@@ -35,4 +67,11 @@
{
/* Call destructor functions. */
run_hooks (__DTOR_LIST__);
+#ifdef HAVE_DWARF2_UNWIND_INFO
+# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
+ __deregister_frame_info (__EH_FRAME_BEGIN__);
+# else
+ __deregister_frame (__EH_FRAME_BEGIN__);
+# endif
+#endif
}
Index: elf/sofini.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc-2.0/elf/sofini.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sofini.c
--- elf/sofini.c 1997/09/19 18:10:34 1.1.1.1
+++ elf/sofini.c 1998/12/11 15:34:32
@@ -7,3 +7,13 @@
static void (*const __DTOR_END__[1]) (void)
__attribute__ ((unused, section (".dtors")))
= { 0 };
+
+#ifdef HAVE_DWARF2_UNWIND_INFO
+/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
+ this would be the 'length' field in a real FDE. */
+
+typedef unsigned int ui32 __attribute__ ((mode (SI)));
+static ui32 __FRAME_END__[1]
+ __attribute__ ((unused, section (".eh_frame")))
+ = { 0 };
+#endif
Index: config.h.in
===================================================================
RCS file: /home/work/cvs/gnu/glibc-2.0/config.h.in,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 config.h.in
--- config.h.in 1997/12/12 20:44:09 1.1.1.2
+++ config.h.in 1998/12/11 15:33:46
@@ -46,6 +46,13 @@
/* Define to the prefix Alpha/ELF GCC emits before ..ng symbols. */
#undef ASM_ALPHA_NG_SYMBOL_PREFIX
+/* Define if gcc uses DWARF2 unwind information for exception support. */
+#undef HAVE_DWARF2_UNWIND_INFO
+
+/* Define if gcc uses DWARF2 unwind information for exception support
+ with static variable. */
+#undef HAVE_DWARF2_UNWIND_INFO_STATIC
+
/*
*/
Index: configure.in
===================================================================
RCS file: /home/work/cvs/gnu/glibc-2.0/configure.in,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 configure.in
--- configure.in 1998/05/20 21:50:24 1.1.1.7
+++ configure.in 1998/12/11 15:30:27
@@ -759,6 +759,61 @@
rm -f conftest*])
AC_SUBST(libc_cv_ld_no_whole_archive)dnl
+AC_CACHE_CHECK(for DWARF2 unwind info support, libc_cv_gcc_dwarf2_unwind_info,
+[cat > conftest.c <<EOF
+#line __oline__ "configure"
+static char __EH_FRAME_BEGIN__[];
+_start ()
+{
+#ifdef CHECK__register_frame
+ __register_frame (__EH_FRAME_BEGIN__);
+ __deregister_frame (__EH_FRAME_BEGIN__);
+#endif
+#ifdef CHECK__register_frame_info
+ __register_frame_info (__EH_FRAME_BEGIN__);
+ __deregister_frame_info (__EH_FRAME_BEGIN__);
+#endif
+}
+int __eh_pc;
+__throw () {}
+/* FIXME: this is fragile. */
+malloc () {}
+strcmp () {}
+strlen () {}
+memcpy () {}
+memset () {}
+free () {}
+abort () {}
+__bzero () {}
+EOF
+dnl No \ in command here because it ends up inside ''.
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS -DCHECK__register_frame_info
+ -nostdlib -nostartfiles
+ -o conftest conftest.c -lgcc >&AC_FD_CC]); then
+ libc_cv_gcc_dwarf2_unwind_info=static
+else
+ libc_cv_gcc_dwarf2_unwind_info=no
+fi
+if test $libc_cv_gcc_dwarf2_unwind_info = no; then
+ if AC_TRY_COMMAND([${CC-cc} $CFLAGS -DCHECK__register_frame
+ -nostdlib -nostartfiles
+ -o conftest conftest.c -lgcc >&AC_FD_CC]); then
+ libc_cv_gcc_dwarf2_unwind_info=yes
+ else
+ libc_cv_gcc_dwarf2_unwind_info=no
+ fi
+fi
+rm -f conftest*])
+case $libc_cv_gcc_dwarf2_unwind_info in
+yes)
+ AC_DEFINE(HAVE_DWARF2_UNWIND_INFO)
+ ;;
+static)
+ AC_DEFINE(HAVE_DWARF2_UNWIND_INFO)
+ AC_DEFINE(HAVE_DWARF2_UNWIND_INFO_STATIC)
+ ;;
+esac
+
AC_CACHE_CHECK(for gcc -fno-exceptions, libc_cv_gcc_no_exceptions, [dnl
cat > conftest.c <<\EOF
_start () {}