Преглед изворни кода

Add a bunch of additional early debugg messages into the shared
lib loader to make it more obvious what is wrong when things puke
early on in the process.
-Erik

Eric Andersen пре 23 година
родитељ
комит
bcb41dd373
1 измењених фајлова са 29 додато и 9 уклоњено
  1. 29 9
      ldso/ldso/ldso.c

+ 29 - 9
ldso/ldso/ldso.c

@@ -387,6 +387,9 @@ LD_BOOT(unsigned long args)
 
 
 	/* OK, that was easy.  Next scan the DYNAMIC section of the image.
 	/* OK, that was easy.  Next scan the DYNAMIC section of the image.
 	   We are only doing ourself right now - we will have to do the rest later */
 	   We are only doing ourself right now - we will have to do the rest later */
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+	SEND_STDERR("scanning DYNAMIC section\n");
+#endif
 	while (dpnt->d_tag) {
 	while (dpnt->d_tag) {
 #if defined(__mips__)
 #if defined(__mips__)
 		if (dpnt->d_tag == DT_MIPS_GOTSYM)
 		if (dpnt->d_tag == DT_MIPS_GOTSYM)
@@ -430,12 +433,13 @@ LD_BOOT(unsigned long args)
 						continue;
 						continue;
 					}
 					}
 					app_tpnt->dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
 					app_tpnt->dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
-					if (dpnt->d_tag == DT_DEBUG)
+					if (dpnt->d_tag == DT_DEBUG) {
 #ifdef FORCE_SHAREABLE_TEXT_SEGMENTS
 #ifdef FORCE_SHAREABLE_TEXT_SEGMENTS
 						dpnt->d_un.d_val = (unsigned long) debug_addr;
 						dpnt->d_un.d_val = (unsigned long) debug_addr;
 #else
 #else
 						dpnt_debug = dpnt;
 						dpnt_debug = dpnt;
 #endif
 #endif
+					}
 					if (dpnt->d_tag == DT_TEXTREL)
 					if (dpnt->d_tag == DT_TEXTREL)
 						app_tpnt->dynamic_info[DT_TEXTREL] = 1;
 						app_tpnt->dynamic_info[DT_TEXTREL] = 1;
 					dpnt++;
 					dpnt++;
@@ -443,6 +447,10 @@ LD_BOOT(unsigned long args)
 			}
 			}
 	}
 	}
 
 
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+	SEND_STDERR("done scanning DYNAMIC section\n");
+#endif
+
 	/* Get some more of the information that we will need to dynamicly link
 	/* Get some more of the information that we will need to dynamicly link
 	   this module to itself */
 	   this module to itself */
 
 
@@ -452,6 +460,10 @@ LD_BOOT(unsigned long args)
 	tpnt->elf_buckets = hash_addr;
 	tpnt->elf_buckets = hash_addr;
 	hash_addr += tpnt->nbucket;
 	hash_addr += tpnt->nbucket;
 
 
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+	SEND_STDERR("done grabbing link information\n");
+#endif
+
 #ifndef FORCE_SHAREABLE_TEXT_SEGMENTS
 #ifndef FORCE_SHAREABLE_TEXT_SEGMENTS
 	/* Ugly, ugly.  We need to call mprotect to change the protection of
 	/* Ugly, ugly.  We need to call mprotect to change the protection of
 	   the text pages so that we can do the dynamic linking.  We can set the
 	   the text pages so that we can do the dynamic linking.  We can set the
@@ -461,6 +473,10 @@ LD_BOOT(unsigned long args)
 		elf_phdr *ppnt;
 		elf_phdr *ppnt;
 		int i;
 		int i;
 
 
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+		SEND_STDERR("calling mprotect on the shared library/dynamic linker\n");
+#endif
+
 		/* First cover the shared library/dynamic linker. */
 		/* First cover the shared library/dynamic linker. */
 		if (tpnt->dynamic_info[DT_TEXTREL]) {
 		if (tpnt->dynamic_info[DT_TEXTREL]) {
 			header = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr;
 			header = (elfhdr *) auxvt[AT_BASE].a_un.a_ptr;
@@ -475,6 +491,9 @@ LD_BOOT(unsigned long args)
 			}
 			}
 		}
 		}
 
 
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+		SEND_STDERR("calling mprotect on the application program\n");
+#endif
 		/* Now cover the application program. */
 		/* Now cover the application program. */
 		if (app_tpnt->dynamic_info[DT_TEXTREL]) {
 		if (app_tpnt->dynamic_info[DT_TEXTREL]) {
 			ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
 			ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
@@ -487,26 +506,27 @@ LD_BOOT(unsigned long args)
 			}
 			}
 		}
 		}
 	}
 	}
-
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+	SEND_STDERR("About to store the debug structure address\n");
+#endif
 	/* Now we can store the debug structure address */
 	/* Now we can store the debug structure address */
 	if (dpnt_debug != NULL) {
 	if (dpnt_debug != NULL) {
 		dpnt_debug->d_un.d_val = (unsigned long) debug_addr;
 		dpnt_debug->d_un.d_val = (unsigned long) debug_addr;
 	}
 	}
 #endif
 #endif
-
-
+	
 #if defined(__mips__)
 #if defined(__mips__)
-	/*
-	 * For MIPS we have to do stuff to the GOT before we do relocations.
-	 */
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+	SEND_STDERR("About to do MIPS specific GOT bootstrap\n");
+#endif
+	/* For MIPS we have to do stuff to the GOT before we do relocations.  */
 	PERFORM_BOOTSTRAP_GOT(got);
 	PERFORM_BOOTSTRAP_GOT(got);
 #endif
 #endif
 
 
-
 	/* OK, now do the relocations.  We do not do a lazy binding here, so
 	/* OK, now do the relocations.  We do not do a lazy binding here, so
 	   that once we are done, we have considerably more flexibility. */
 	   that once we are done, we have considerably more flexibility. */
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("About to do library loader relocations.\n");
+	SEND_STDERR("About to do library loader relocations\n");
 #endif
 #endif
 
 
 	goof = 0;
 	goof = 0;