This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: unwind failures due to __pthread_initialize_minimal


>>>>> On Wed, 19 Nov 2003 15:54:49 -0800, Roland McGrath <roland@redhat.com> said:

  >> Just write your own pt-initfini file for ia64.  The requirement
  >> is that the code up to the __pthread_initialize_minimal functions
  >> depends on nothing but basic ld.so functionality.

  Roland> Remind me what happens wrong if the normal constructor
  Roland> mechanism is used in libpthread.

The problem is that the final function is constructed only at
link-time, so the assembler cannot emit the proper
function-length-information needed for the unwind-info.

>>>>> On Wed, 19 Nov 2003 15:30:44 -0800, Ulrich Drepper <drepper@redhat.com> said:

  Uli> Just write your own pt-initfini file for ia64.  The requirement
  Uli> is that the code up to the __pthread_initialize_minimal
  Uli> functions depends on nothing but basic ld.so functionality.

Ah, in fact there is already an ia64-specific version.  I missed it at
first.  Turns out the problem really was worse: not only was it using
.init, but the unwind directives for both _init and _fini were
missing!  With the proper unwind info for _init and _fini, the old
code was lucky enough to work fine, but I still think it's better to
switch to .init_array both for cleanliness and consistency reasons.
LinuxThreads had the same problem.  Patch to fix both is attached.
Please apply.

Thanks,

	--david

linuxthreads/ChangeLog

2003-11-19 David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/unix/sysv/linux/ia64/pt-initfini.c (INIT_NEW_WAY): New
	macro.
	(INIT_OLD_WAY): Likewise.  Define these macros depending on
	whether or not HAVE_INITFINI_ARRAY is defined.  If it is, use
	.init_array to invoke __pthread_initialize_minimal_internal.
	Also, add proper unwind-directives for _init and _fini.

nptl/ChangeLog

2003-11-19 David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/unix/sysv/linux/ia64/pt-initfini.c (INIT_NEW_WAY): New
	macro.
	(INIT_OLD_WAY): Likewise.  Define these macros depending on
	whether or not HAVE_INITFINI_ARRAY is defined.  If it is, use
	.init_array to invoke __pthread_initialize_minimal_internal.
	Also, add proper unwind-directives for _init and _fini.

Index: linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
===================================================================
RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c,v
retrieving revision 1.5
diff -u -r1.5 pt-initfini.c
--- linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c	14 Nov 2002 10:49:22 -0000	1.5
+++ linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c	20 Nov 2003 00:24:14 -0000
@@ -1,5 +1,5 @@
 /* Special .init and .fini section support for ia64. LinuxThreads version.
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it
@@ -36,34 +36,51 @@
    * crtn.s puts the corresponding function epilogues
    in the .init and .fini sections. */
 
+#include <stddef.h>
+
+#ifdef HAVE_INITFINI_ARRAY
+
+# define INIT_NEW_WAY \
+    ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal_internal)\n"
+# define INIT_OLD_WAY ""
+#else
+# define INIT_NEW_WAY ""
+# define INIT_OLD_WAY \
+	"\n\
+	st8 [r12] = gp, -16\n\
+	br.call.sptk.many b0 = __pthread_initialize_minimal_internal# ;;\n\
+	;;\n\
+	adds r12 = 16, r12\n\
+	;;\n\
+	ld8 gp = [r12]\n\
+	;;\n"
+#endif
+
 __asm__ ("\n\
 \n\
 #include \"defs.h\"\n\
 \n\
 /*@HEADER_ENDS*/\n\
 \n\
-/*@_init_PROLOG_BEGINS*/\n\
-	.section .init\n\
+/*@_init_PROLOG_BEGINS*/\n"
+	INIT_NEW_WAY
+	".section .init\n\
 	.align 16\n\
 	.global _init#\n\
 	.proc _init#\n\
 _init:\n\
+	.prologue\n\
+	.save ar.pfs, r34\n\
 	alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+	.vframe r32\n\
 	mov r32 = r12\n\
+	.save rp, r33\n\
 	mov r33 = b0\n\
+	.body\n\
 	adds r12 = -16, r12\n\
-	;;\n\
-/* we could use r35 to save gp, but we use the stack since that's what\n\
- * all the other init routines will do --davidm 00/04/05 */\n\
-	st8 [r12] = gp, -16\n\
-	br.call.sptk.many b0 = __pthread_initialize_minimal# ;;\n\
-	;;\n\
-	adds r12 = 16, r12\n\
-	;;\n\
-	ld8 gp = [r12]\n\
-	;;\n\
-	.align 16\n\
-	.endp _init#\n\
+	;;\n"
+	INIT_OLD_WAY
+	".endp _init#\n\
 \n\
 /*@_init_PROLOG_ENDS*/\n\
 \n\
@@ -83,12 +100,16 @@
 	.global _fini#\n\
 	.proc _fini#\n\
 _fini:\n\
+	.prologue\n\
+	.save ar.pfs, r34\n\
 	alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+	.vframe r32\n\
 	mov r32 = r12\n\
+	.save rp, r33\n\
 	mov r33 = b0\n\
+	.body\n\
 	adds r12 = -16, r12\n\
 	;;\n\
-	.align 16\n\
 	.endp _fini#\n\
 \n\
 /*@_fini_PROLOG_ENDS*/\n\
Index: nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
===================================================================
RCS file: /cvs/glibc/libc/nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c,v
retrieving revision 1.1
diff -u -r1.1 pt-initfini.c
--- nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c	11 Mar 2003 09:20:41 -0000	1.1
+++ nptl/sysdeps/unix/sysv/linux/ia64/pt-initfini.c	20 Nov 2003 00:24:15 -0000
@@ -36,34 +36,51 @@
    * crtn.s puts the corresponding function epilogues
    in the .init and .fini sections. */
 
+#include <stddef.h>
+
+#ifdef HAVE_INITFINI_ARRAY
+
+# define INIT_NEW_WAY \
+    ".xdata8 \".init_array\", @fptr(__pthread_initialize_minimal_internal)\n"
+# define INIT_OLD_WAY ""
+#else
+# define INIT_NEW_WAY ""
+# define INIT_OLD_WAY \
+	"\n\
+	st8 [r12] = gp, -16\n\
+	br.call.sptk.many b0 = __pthread_initialize_minimal_internal# ;;\n\
+	;;\n\
+	adds r12 = 16, r12\n\
+	;;\n\
+	ld8 gp = [r12]\n\
+	;;\n"
+#endif
+
 __asm__ ("\n\
 \n\
 #include \"defs.h\"\n\
 \n\
 /*@HEADER_ENDS*/\n\
 \n\
-/*@_init_PROLOG_BEGINS*/\n\
-	.section .init\n\
+/*@_init_PROLOG_BEGINS*/\n"
+	INIT_NEW_WAY
+	".section .init\n\
 	.align 16\n\
 	.global _init#\n\
 	.proc _init#\n\
 _init:\n\
+	.prologue\n\
+	.save ar.pfs, r34\n\
 	alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+	.vframe r32\n\
 	mov r32 = r12\n\
+	.save rp, r33\n\
 	mov r33 = b0\n\
+	.body\n\
 	adds r12 = -16, r12\n\
-	;;\n\
-/* we could use r35 to save gp, but we use the stack since that's what\n\
- * all the other init routines will do --davidm 00/04/05 */\n\
-	st8 [r12] = gp, -16\n\
-	br.call.sptk.many b0 = __pthread_initialize_minimal_internal# ;;\n\
-	;;\n\
-	adds r12 = 16, r12\n\
-	;;\n\
-	ld8 gp = [r12]\n\
-	;;\n\
-	.align 16\n\
-	.endp _init#\n\
+	;;\n"
+	INIT_OLD_WAY
+	".endp _init#\n\
 \n\
 /*@_init_PROLOG_ENDS*/\n\
 \n\
@@ -83,12 +100,16 @@
 	.global _fini#\n\
 	.proc _fini#\n\
 _fini:\n\
+	.prologue\n\
+	.save ar.pfs, r34\n\
 	alloc r34 = ar.pfs, 0, 3, 0, 0\n\
+	.vframe r32\n\
 	mov r32 = r12\n\
+	.save rp, r33\n\
 	mov r33 = b0\n\
+	.body\n\
 	adds r12 = -16, r12\n\
 	;;\n\
-	.align 16\n\
 	.endp _fini#\n\
 \n\
 /*@_fini_PROLOG_ENDS*/\n\


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