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


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

[Question] patch-design for Solaris ld.so-startup


Hi,

the file sysdeps/sparc/sparc32/dl-machine.h contains 2 assumptions, 
which makes it impossible to launch ld.so under Solaris.

Assumption 1:
   dl-machine.h assumes that the stack, at the time of startup, 
   for all OS's contains the information
	- argc
	- argv
	- auxiliary table
	- environment.
   Solaris only places
	- argc
	- argv
	- environment
   onto the stack. Auxiliary table has to be taken from /proc/<pid> later.
   Stack-handling in the macro RTLD_START for Solaris has to be modified. 

Assumption 2:
   dl-machine.h assumes that register %l7, at the time of startup, 
   for all OS's contains the link-time address of _DYNAMIC.
   This is false Solaris.
   elf_machine_dynamic() has to be modified.


There are two design alternatives for a patch:

1. keep os-specific code away from dl-machine.h , 
   instead include something like
      sysdeps/unix/.../<os>/sparc/sparc32/dl-rtld_start.h ,
   which contains definitions for RTLD_START and elf_machine_dynamic().
      advantage: better readability, better separation of code in the 
      sense of the glibc-structure.

2. Modify RTLD_START inside of sysdeps/sparc/sparc32/dl-machine.h
      disadvantage: worse readability, machine- and os-pieces mixed 
      despite the overall-structure of glibc.


I've successfully built and tested glibc with the appended patch
(design alternative 2) on a Linux/Sparc32-system (Debian 2.2 potato) as 
well as on Solaris/Sparc32/64.

So before i post the final patch i kindly ask for the opinion of the
maintainers.

greetings
Gert


---------------------------------------------------------------------

2001-10-11 Gert Ohme <ohme@dialeasy.de>

	* sysdeps/sparc/sparc32/dl-machine.h: add startup code for Solaris2


============================================================
Index: sysdeps/sparc/sparc32/dl-machine.h
--- sysdeps/sparc/sparc32/dl-machine.h	2001/09/08 17:13:35	1.36
+++ sysdeps/sparc/sparc32/dl-machine.h	2001/10/11 16:08:41
@@ -17,6 +17,9 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#ifndef dl_machine_h
+#define dl_machine_h 1
+
 #define ELF_MACHINE_NAME "sparc"
 
 #include <string.h>
@@ -64,6 +67,14 @@
     return 0;
 }
 
+#ifdef SOLARIS2
+/* Return the offset address of _DYNAMIC for Solaris. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+  return (Elf32_Addr)_DYNAMIC;
+}
+#else  /*  SOLARIS2  */
 
 /* Return the link-time address of _DYNAMIC.  Conveniently, this is the
    first element of the GOT.  This must be inlined in a function which
@@ -74,6 +85,7 @@
   register Elf32_Addr *got asm ("%l7");
   return *got;
 }
+#endif /*  SOLARIS2  */
 
 /* Return the run-time load address of the shared object.  */
 static inline Elf32_Addr
@@ -198,7 +210,7 @@
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
 
-#define RTLD_START __asm__ ("\
+#define RTLD_START_1 __asm__ ("\
 	.text
 	.globl	_start
 	.type	_start, @function
@@ -260,7 +272,9 @@
 	tst	%i3
 	st	%i3, [%i1]
 	bne	22b
-	 add	%i1, 4, %i1
+	 add	%i1, 4, %i1 ");
+#ifndef SOLARIS2
+# define RTLD_START_2 __asm__ ("\
 	/* Copy down auxiliary table.  */
 23:	ld	[%i2], %i3
 	ld	[%i2+4], %i4
@@ -269,7 +283,21 @@
 	st	%i3, [%i1]
 	st	%i4, [%i1+4]
 	bne	23b
-	 add	%i1, 8, %i1
+	 add	%i1, 8, %i1 ");
+#else /* SOLARIS2 */
+# define RTLD_START_2 __asm__ ("\
+	sethi	%hi(_dl_loaded), %o0
+	add	%sp, 23*4, %o2
+	orcc	%o0, %lo(_dl_loaded), %o0
+	sll	%i5, 2, %o3
+	ld	[%l7+%o0], %o0
+	add	%o3, 4, %o3
+	mov	%i5, %o1
+	add	%o2, %o3, %o3
+	call	_sol2_newstart
+	 ld	[%o0], %o0 ");
+#endif  /* SOLARIS2 */
+#define RTLD_START_3 __asm__ ("\
   /* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp.  */
 3:	sethi	%hi(_dl_loaded), %o0
 	add	%sp, 23*4, %o2
@@ -290,6 +318,14 @@
 	 add	%sp, 6*4, %sp
 	.size   _dl_start_user, . - _dl_start_user
 	.previous");
+
+#define RTLD_START   \
+        RTLD_START_1 \
+        RTLD_START_2 \
+        RTLD_START_3 \
+
+
+#endif  /* dl_machine_h */
 
 static inline Elf32_Addr
 elf_machine_fixup_plt (struct link_map *map, lookup_t t,


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