This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: glibc 2.2.4pre2
On Sat, Aug 11, 2001 at 01:31:30PM -0700, Richard Henderson wrote:
> On Fri, Aug 10, 2001 at 10:05:24AM +0200, Andreas Jaeger wrote:
> > Please investigate yourself what's broken,
>
> The alpha patch looks incomplete -- it's missing the bits
> to call __cxa_finalize.
This could IMHO work:
2000-04-29 Richard Henderson <rth@cygnus.com>
* config/alpha/crtbegin.asm: Use C comments instead of #.
Mark __dso_handle hidden.
2000-02-16 Richard Henderson <rth@cygnus.com>
* configure.in (alpha-linux*, alpha-netbsd) [extra_parts]:
Add crtbeginS.o and crtendS.o.
* alpha/elf.h (STARTFILE_SPEC): Use crtbeginS.o.
(ENDFILE_SPEC): Use crtendS.o.
* alpha/t-crtbe (crtbeginS.o, crtendS.o): New targets.
* alpha/crtbegin.asm (__do_frame_takedown): Merge into ...
(__do_global_dtors_aux): ... here. Call __cxa_finalize if
shared and present.
(__dso_handle): New variable.
2000-04-04 Ulrich Drepper <drepper@cygnus.com>
* acconfig.h: Add HAVE_GAS_HIDDEN.
* config.in: Regenerated.
* configure.in: Add test for .hidden pseudo-op in gas.
* configure: Regenerated.
* crtstuff.c: Include auto-host.h.
Emit additional .hidden pseudo-op for __dso_handle if the
assembler knows about it.
--- gcc-2.95.x/gcc/config/alpha/crtbegin.asm.jj Wed Dec 16 22:00:53 1998
+++ gcc-2.95.x/gcc/config/alpha/crtbegin.asm Mon Aug 13 11:16:43 2001
@@ -1,42 +1,46 @@
- # Copyright (C) 1996, 1998 Free Software Foundation, Inc.
- # Contributed by Richard Henderson (rth@tamu.edu)
- #
- # This file is free software; you can redistribute it and/or modify it
- # under the terms of the GNU General Public License as published by the
- # Free Software Foundation; either version 2, or (at your option) any
- # later version.
- #
- # In addition to the permissions in the GNU General Public License, the
- # Free Software Foundation gives you unlimited permission to link the
- # compiled version of this file with other programs, and to distribute
- # those programs without any restriction coming from the use of this
- # file. (The General Public License restrictions do apply in other
- # respects; for example, they cover modification of the file, and
- # distribution when not linked into another program.)
- #
- # This file is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; see the file COPYING. If not, write to
- # the Free Software Foundation, 59 Temple Place - Suite 330,
- # Boston, MA 02111-1307, USA.
- #
- # As a special exception, if you link this library with files
- # compiled with GCC to produce an executable, this does not cause
- # the resulting executable to be covered by the GNU General Public License.
- # This exception does not however invalidate any other reasons why
- # the executable file might be covered by the GNU General Public License.
-
- #
- # Heads of the constructor/destructor lists.
- #
-
- # The __*TOR_LIST__ symbols are not global because when this file is used
- # in a shared library, we do not want the symbol to fall over to the
- # application's lists.
+/* Copyright (C) 1996, 1998 Free Software Foundation, Inc.
+ * Contributed by Richard Henderson (rth@tamu.edu)
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * In addition to the permissions in the GNU General Public License, the
+ * Free Software Foundation gives you unlimited permission to link the
+ * compiled version of this file with other programs, and to distribute
+ * those programs without any restriction coming from the use of this
+ * file. (The General Public License restrictions do apply in other
+ * respects; for example, they cover modification of the file, and
+ * distribution when not linked into another program.)
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * As a special exception, if you link this library with files
+ * compiled with GCC to produce an executable, this does not cause
+ * the resulting executable to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ */
+
+#include "auto-host.h"
+
+/*
+ * Heads of the constructor/destructor lists.
+ */
+
+/* The __*TOR_LIST__ symbols are not global because when this file is used
+ * in a shared library, we do not want the symbol to fall over to the
+ * application's lists.
+ */
.section .ctors,"aw"
@@ -53,34 +57,34 @@ __DTOR_LIST__:
.section .eh_frame,"aw"
__EH_FRAME_BEGIN__:
- #
- # Fragment of the ELF _fini routine that invokes our dtor cleanup.
- #
+/*
+ * Fragment of the ELF _fini routine that invokes our dtor cleanup.
+ */
.section .fini,"ax"
- # Since the bits of the _fini function are spread across many
- # object files, each potentially with its own GP, we must
- # assume we need to load ours. Further, our .fini section
- # can easily be more than 4MB away from our .text bits so we
- # can't use bsr.
+ /* Since the bits of the _fini function are spread across many
+ object files, each potentially with its own GP, we must
+ assume we need to load ours. Further, our .fini section
+ can easily be more than 4MB away from our .text bits so we
+ can't use bsr. */
br $29,1f
1: ldgp $29,0($29)
jsr $26,__do_global_dtors_aux
- # Ideally this call would go in crtend.o, except that we can't
- # get hold of __EH_FRAME_BEGIN__ there.
+ /* Ideally this call would go in crtend.o, except that we can't
+ get hold of __EH_FRAME_BEGIN__ there */
jsr $26,__do_frame_takedown
- # Must match the alignment we got from crti.o else we get
- # zero-filled holes in our _fini function and then SIGILL.
+ /* Must match the alignment we got from crti.o else we get
+ zero-filled holes in our _fini function and then SIGILL. */
.align 3
- #
- # Fragment of the ELF _init routine that sets up the frame info.
- #
+/*
+ * Fragment of the ELF _init routine that sets up the frame info.
+ */
.section .init,"ax"
br $29,1f
@@ -88,32 +92,68 @@ __EH_FRAME_BEGIN__:
jsr $26,__do_frame_setup
.align 3
- #
- # Invoke our destructors in order.
- #
+/*
+ * Invoke our destructors in order.
+ */
.data
- # Support recursive calls to exit.
+/* Support recursive calls to exit. */
$ptr: .quad __DTOR_LIST__
+/* A globally unique widget for c++ local destructors to hang off.
+
+ This has a unique value in every dso; in the main program its
+ value is zero. The object should be protected. This means the
+ instance in any dso or the main program is not used in any other
+ dso. The dynamic linker takes care of this. */
+
+ .global __dso_handle
+ .type __dso_handle,@object
+ .size __dso_handle,8
+#ifdef SHARED
+.section .data
+ .align 3
+__dso_handle:
+ .quad __dso_handle
+#else
+.section .bss
+ .align 3
+__dso_handle:
+ .zero 8
+#endif
+#ifdef HAVE_GAS_HIDDEN
+ .hidden __dso_handle
+#endif
+
.text
.align 3
.ent __do_global_dtors_aux
__do_global_dtors_aux:
+ ldgp $29,0($27)
lda $30,-16($30)
.frame $30,16,$26,0
stq $9,8($30)
stq $26,0($30)
.mask 0x4000200,-16
- .prologue 0
+ .prologue 1
+#ifdef SHARED
+ /* Do c++ local destructors. */
+ lda $1,__cxa_finalize
+ beq $1,2f
+ lda $16,__dso_handle
+ jsr $26,__cxa_finalize
+ ldgp $29,0($26)
+2:
+#endif
lda $9,$ptr
br 1f
0: stq $1,0($9)
jsr $26,($27)
+ ldgp $29,0($26)
1: ldq $1,0($9)
ldq $27,8($1)
addq $1,8,$1
@@ -126,11 +166,11 @@ __do_global_dtors_aux:
.end __do_global_dtors_aux
- #
- # Install our frame info.
- #
+/*
+ * Install our frame info.
+ */
- # ??? How can we rationally keep this size correct?
+/* ??? How can we rationally keep this size correct? */
.section .bss
.type $object,@object
@@ -163,9 +203,9 @@ __do_frame_setup:
.end __do_frame_setup
- #
- # Remove our frame info.
- #
+/*
+ * Remove our frame info.
+ */
.align 3
.ent __do_frame_takedown
@@ -190,3 +230,6 @@ __do_frame_takedown:
.weak __register_frame_info
.weak __deregister_frame_info
+#ifdef SHARED
+.weak __cxa_finalize
+#endif
--- gcc-2.95.x/gcc/config/alpha/t-crtbe.jj Wed Dec 16 22:01:05 1998
+++ gcc-2.95.x/gcc/config/alpha/t-crtbe Mon Aug 13 11:08:08 2001
@@ -3,7 +3,13 @@ T = disable
# Assemble startup files.
crtbegin.o: $(srcdir)/config/alpha/crtbegin.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) -c -o crtbegin.o -x assembler $(srcdir)/config/alpha/crtbegin.asm
+ $(GCC_FOR_TARGET) -c -o crtbegin.o -x assembler-with-cpp $(srcdir)/config/alpha/crtbegin.asm
crtend.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) -c -o crtend.o -x assembler $(srcdir)/config/alpha/crtend.asm
+ $(GCC_FOR_TARGET) -c -o crtend.o -x assembler $(srcdir)/config/alpha/crtend.asm
+
+crtbeginS.o: $(srcdir)/config/alpha/crtbegin.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET) -DSHARED -c -o crtbeginS.o -x assembler-with-cpp -I. $(srcdir)/config/alpha/crtbegin.asm
+
+crtendS.o: $(srcdir)/config/alpha/crtend.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET) -c -o crtendS.o -x assembler -I. $(srcdir)/config/alpha/crtend.asm
--- gcc-2.95.x/gcc/config/alpha/elf.h.jj Mon Jun 21 22:15:10 1999
+++ gcc-2.95.x/gcc/config/alpha/elf.h Mon Aug 13 11:09:13 2001
@@ -513,7 +513,7 @@ do { \
#define STARTFILE_SPEC \
"%{!shared: \
%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
- crti.o%s crtbegin.o%s"
+ crti.o%s %{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}"
/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the
magical crtend.o file which provides part of the support for
@@ -522,7 +522,7 @@ do { \
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
- "crtend.o%s crtn.o%s"
+ "%{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
/* We support #pragma. */
#define HANDLE_SYSV_PRAGMA
--- gcc-2.95.x/gcc/crtstuff.c 2001/04/03 10:34:32 1.18.4.1
+++ gcc-2.95.x/gcc/crtstuff.c 2001/08/09 06:56:33
@@ -55,6 +55,7 @@ Boston, MA 02111-1307, USA. */
#include "defaults.h"
#include <stddef.h>
#include "frame.h"
+#include "auto-host.h"
/* We do not want to add the weak attribute to the declarations of these
routines in frame.h because that will cause the definition of these
@@ -134,7 +135,29 @@ typedef void (*func_ptr) (void);
#ifdef INIT_SECTION_ASM_OP
#ifdef OBJECT_FORMAT_ELF
+/* Declare the __dso_handle variable. It should have a unique value
+ in every shared-object; in a main program its value is zero. The
+ object should in any case be protected. This means the instance
+ in one DSO or the main program is not used in another object. The
+ dynamic linker takes care of this. */
+
+/* XXX Ideally the following should be implemented using
+ __attribute__ ((__visibility__ ("hidden")))
+ but the __attribute__ support is not yet there. */
+#ifdef HAVE_GAS_HIDDEN
+asm (".hidden\t__dso_handle");
+#endif
+
+#ifdef CRTSTUFFS_O
+void *__dso_handle = &__dso_handle;
+#else
+void *__dso_handle = 0;
+#endif
+/* The __cxa_finalize function may not be available so we use only a
+ weak declaration. */
+extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
+
/* Run all the global destructors on exit from the program. */
/* Some systems place the number of pointers in the first word of the
@@ -164,6 +187,11 @@ __do_global_dtors_aux (void)
if (completed)
return;
+
+#ifdef CRTSTUFFS_O
+ if (__cxa_finalize)
+ __cxa_finalize (__dso_handle);
+#endif
while (*p)
{
--- gcc-2.95.x/gcc/configure.in.jj Wed Oct 13 09:58:02 1999
+++ gcc-2.95.x/gcc/configure.in Mon Aug 13 11:11:39 2001
@@ -608,7 +608,7 @@ changequote([,])dnl
tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h"
target_cpu_default="MASK_GAS"
tmake_file="t-linux t-linux-gnulibc1 alpha/t-linux alpha/t-crtbe alpha/t-ieee"
- extra_parts="crtbegin.o crtend.o"
+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
xmake_file=none
gas=yes gnu_ld=yes
if test x$enable_threads = xyes; then
@@ -619,7 +619,7 @@ changequote([,])dnl
tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h"
target_cpu_default="MASK_GAS"
tmake_file="t-linux alpha/t-linux alpha/t-crtbe alpha/t-ieee"
- extra_parts="crtbegin.o crtend.o"
+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
xmake_file=none
gas=yes gnu_ld=yes
if test x$enable_threads = xyes; then
@@ -630,7 +630,7 @@ changequote([,])dnl
tm_file="${tm_file} alpha/elf.h alpha/netbsd.h alpha/netbsd-elf.h"
target_cpu_default="MASK_GAS"
tmake_file="alpha/t-crtbe alpha/t-ieee"
- extra_parts="crtbegin.o crtend.o"
+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
xmake_file=none
gas=yes gnu_ld=yes
;;
@@ -4052,6 +4052,21 @@ EOF
rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
fi
AC_MSG_RESULT($gcc_cv_as_subsections)
+
+AC_MSG_CHECKING(assembler hidden support)
+gcc_cv_as_hidden=
+if test x$gcc_cv_as != x; then
+ # Check if we have .hidden
+ echo " .hidden foobar" > conftest.s
+ echo "foobar:" >> conftest.s
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+ AC_DEFINE(HAVE_GAS_HIDDEN, 1,
+ [Define if your assembler supports .hidden.])
+ gcc_cv_as_hidden="yes"
+ fi
+ rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
+fi
+AC_MSG_RESULT($gcc_cv_as_hidden)
AC_MSG_CHECKING(assembler instructions)
gcc_cv_as_instructions=
--- gcc-2.95.x/gcc/config.in.jj Mon Oct 25 10:02:08 1999
+++ gcc-2.95.x/gcc/config.in Wed Jun 13 12:45:56 2001
2 the beginning of your section */
#undef HAVE_GAS_SUBSECTION_ORDERING
+/* Define if your assembler supports .hidden. */
+#undef HAVE_GAS_HIDDEN
+
/* Define if your assembler uses the old HImode fild and fist notation. */
#undef HAVE_GAS_FILDS_FISTS
Jakub