[uClibc-cvs] uClibc/ldso/ldso/mips dl-startup.h, 1.8, 1.9 dl-sysdep.h, 1.8, 1.9

Erik Andersen andersen at uclibc.org
Tue Feb 17 10:55:58 UTC 2004


Update of /var/cvs/uClibc/ldso/ldso/mips
In directory nail:/tmp/cvs-serv25724/mips

Modified Files:
	dl-startup.h dl-sysdep.h 
Log Message:
Seperate out the startup stuff from the non-startup stuff.
Begin converting some big ugly macros to inline functions
instead


Index: dl-sysdep.h
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/mips/dl-sysdep.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dl-sysdep.h	14 Feb 2004 11:30:33 -0000	1.8
+++ dl-sysdep.h	17 Feb 2004 10:55:55 -0000	1.9
@@ -1,120 +1,35 @@
-/* vi: set sw=4 ts=4: */
+/* vi: set sw=8 ts=8: */
 
 /*
  * Various assmbly language/system dependent hacks that are required
  * so that we can minimize the amount of platform specific code.
  */
 
-/* 
- * Define this if the system uses RELOCA.
- */
+/* Define this if the system uses RELOCA.  */
 #undef ELF_USES_RELOCA
 
 
-/*
- * Get a pointer to the argv array.  On many platforms this can be just
- * the address if the first argument, on other platforms we need to
- * do something a little more subtle here.
- */
-#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
-
-
-/*
- * Initialization sequence for the application/library GOT.
- */
-#define INIT_GOT(GOT_BASE,MODULE)										\
-do {																	\
-	unsigned long i;													\
-																		\
-	/* Check if this is the dynamic linker itself */					\
-	if (MODULE->libtype == program_interpreter)							\
-		continue;														\
-																		\
-	/* Fill in first two GOT entries according to the ABI */			\
-	GOT_BASE[0] = (unsigned long) _dl_linux_resolve;					\
-	GOT_BASE[1] = (unsigned long) MODULE;								\
-																		\
-	/* Add load address displacement to all local GOT entries */		\
-	i = 2;																\
-	while (i < MODULE->mips_local_gotno)								\
-		GOT_BASE[i++] += (unsigned long) MODULE->loadaddr;				\
-																		\
-} while (0)
-
-
-/*
- * Here is a macro to perform the GOT relocation. This is only
- * used when bootstrapping the dynamic loader.
- */
-#define PERFORM_BOOTSTRAP_GOT(got)										\
-do {																	\
-	Elf32_Sym *sym;														\
-	unsigned long i;													\
-																		\
+/* Initialization sequence for the application/library GOT.  */
+#define INIT_GOT(GOT_BASE,MODULE)						\
+do {										\
+	unsigned long i;							\
+										\
+	/* Check if this is the dynamic linker itself */			\
+	if (MODULE->libtype == program_interpreter)				\
+		continue;							\
+										\
+	/* Fill in first two GOT entries according to the ABI */		\
+	GOT_BASE[0] = (unsigned long) _dl_linux_resolve;			\
+	GOT_BASE[1] = (unsigned long) MODULE;					\
+										\
 	/* Add load address displacement to all local GOT entries */		\
-	i = 2;																\
-	while (i < tpnt->mips_local_gotno)									\
-		got[i++] += load_addr;											\
-																		\
-	/* Handle global GOT entries */										\
-	got += tpnt->mips_local_gotno;										\
-	sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +				\
-		 load_addr) + tpnt->mips_gotsym;								\
-	i = tpnt->mips_symtabno - tpnt->mips_gotsym;						\
-																		\
-	while (i--) {														\
-		if (sym->st_shndx == SHN_UNDEF ||								\
-			sym->st_shndx == SHN_COMMON)								\
-			*got = load_addr + sym->st_value;							\
-		else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&				\
-			*got != sym->st_value)										\
-			*got += load_addr;											\
-		else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {			\
-			if (sym->st_other == 0)										\
-				*got += load_addr;										\
-		}																\
-		else															\
-			*got = load_addr + sym->st_value;							\
-																		\
-		got++;															\
-		sym++;															\
-	}																	\
+	i = 2;									\
+	while (i < MODULE->mips_local_gotno)					\
+		GOT_BASE[i++] += (unsigned long) MODULE->loadaddr;		\
+										\
 } while (0)
 
 
-/*
- * Here is a macro to perform a relocation.  This is only used when
- * bootstrapping the dynamic loader.
- */
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)			\
-	switch(ELF32_R_TYPE((RELP)->r_info)) {								\
-	case R_MIPS_REL32:													\
-		if (symtab_index) {												\
-			if (symtab_index < tpnt->mips_gotsym)						\
-				*REL += SYMBOL;											\
-		}																\
-		else {															\
-			*REL += LOAD;												\
-		}																\
-		break;															\
-	case R_MIPS_NONE:													\
-		break;															\
-	default:															\
-		SEND_STDERR("Aiieeee!");										\
-		_dl_exit(1);													\
-	}
-
-
-/*
- * Transfer control to the user's application, once the dynamic loader
- * is done.  This routine has to exit the current function, then 
- * call the _dl_elf_main function. For MIPS, we do it in assembly
- * because the stack doesn't get properly restored otherwise. Got look
- * at boot1_arch.h
- */
-#define START()
-
-
 /* Here we define the magic numbers that this dynamic loader should accept */
 #define MAGIC1 EM_MIPS
 #define MAGIC2 EM_MIPS_RS3_LE

Index: dl-startup.h
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/mips/dl-startup.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dl-startup.h	7 Feb 2004 12:26:22 -0000	1.8
+++ dl-startup.h	17 Feb 2004 10:55:55 -0000	1.9
@@ -35,3 +35,86 @@
 );
 
 #define DL_BOOT(X)   static void __attribute__ ((unused)) _dl_boot2 (X)
+
+/*
+ * Get a pointer to the argv array.  On many platforms this can be just
+ * the address if the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *) ARGS)
+
+
+/*
+ * Here is a macro to perform the GOT relocation. This is only
+ * used when bootstrapping the dynamic loader.
+ */
+#define PERFORM_BOOTSTRAP_GOT(got)						\
+do {										\
+	Elf32_Sym *sym;								\
+	unsigned long i;							\
+										\
+	/* Add load address displacement to all local GOT entries */		\
+	i = 2;									\
+	while (i < tpnt->mips_local_gotno)					\
+		got[i++] += load_addr;						\
+										\
+	/* Handle global GOT entries */						\
+	got += tpnt->mips_local_gotno;						\
+	sym = (Elf32_Sym *) (tpnt->dynamic_info[DT_SYMTAB] +			\
+		 load_addr) + tpnt->mips_gotsym;				\
+	i = tpnt->mips_symtabno - tpnt->mips_gotsym;				\
+										\
+	while (i--) {								\
+		if (sym->st_shndx == SHN_UNDEF ||				\
+			sym->st_shndx == SHN_COMMON)				\
+			*got = load_addr + sym->st_value;			\
+		else if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC &&		\
+			*got != sym->st_value)					\
+			*got += load_addr;					\
+		else if (ELF32_ST_TYPE(sym->st_info) == STT_SECTION) {		\
+			if (sym->st_other == 0)					\
+				*got += load_addr;				\
+		}								\
+		else								\
+			*got = load_addr + sym->st_value;			\
+										\
+		got++;								\
+		sym++;								\
+	}									\
+} while (0)
+
+
+/*
+ * Here is a macro to perform a relocation.  This is only used when
+ * bootstrapping the dynamic loader.
+ */
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)			\
+	switch(ELF32_R_TYPE((RELP)->r_info)) {					\
+	case R_MIPS_REL32:							\
+		if (symtab_index) {						\
+			if (symtab_index < tpnt->mips_gotsym)			\
+				*REL += SYMBOL;					\
+		}								\
+		else {								\
+			*REL += LOAD;						\
+		}								\
+		break;								\
+	case R_MIPS_NONE:							\
+		break;								\
+	default:								\
+		SEND_STDERR("Aiieeee!");					\
+		_dl_exit(1);							\
+	}
+
+
+/*
+ * Transfer control to the user's application, once the dynamic loader
+ * is done.  This routine has to exit the current function, then
+ * call the _dl_elf_main function. For MIPS, we do it in assembly
+ * because the stack doesn't get properly restored otherwise. Got look
+ * at boot1_arch.h
+ */
+#define START()
+
+
+




More information about the uClibc-cvs mailing list