Kaynağa Gözat

create some DEBUG macros for the ld debug early

Mike Frysinger 21 yıl önce
ebeveyn
işleme
ea3903eb7b
2 değiştirilmiş dosya ile 22 ekleme ve 33 silme
  1. 9 1
      ldso/include/dl-string.h
  2. 13 32
      ldso/ldso/dl-startup.c

+ 9 - 1
ldso/include/dl-string.h

@@ -282,7 +282,7 @@ static inline char *_dl_simple_ltoahex(char * local, unsigned long i)
 	const char *tmp1 = (X); \
 	const char *tmp1 = (X); \
 	CONSTANT_STRING_GOT_FIXUP(tmp1); \
 	CONSTANT_STRING_GOT_FIXUP(tmp1); \
 	_dl_write(2, tmp1, _dl_strlen(tmp1)); \
 	_dl_write(2, tmp1, _dl_strlen(tmp1)); \
-};
+}
 
 
 #define SEND_ADDRESS_STDERR(ADR, add_a_newline) \
 #define SEND_ADDRESS_STDERR(ADR, add_a_newline) \
 { \
 { \
@@ -321,4 +321,12 @@ static inline char *_dl_simple_ltoahex(char * local, unsigned long i)
 }
 }
 #endif
 #endif
 
 
+#ifdef __SUPPORT_LD_DEBUG_EARLY__
+# define SEND_STDERR_DEBUG(X) SEND_STDERR(X)
+# define SEND_ADDRESS_STDERR_DEBUG(X, add_a_newline) SEND_ADDRESS_STDERR(X, add_a_newline)
+#else
+# define SEND_STDERR_DEBUG(X)
+# define SEND_ADDRESS_STDERR_DEBUG(X, add_a_newline)
+#endif
+
 #endif
 #endif

+ 13 - 32
ldso/ldso/dl-startup.c

@@ -177,10 +177,8 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 		SEND_STDERR("Invalid ELF header\n");
 		SEND_STDERR("Invalid ELF header\n");
 		_dl_exit(0);
 		_dl_exit(0);
 	}
 	}
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("ELF header=");
-	SEND_ADDRESS_STDERR(load_addr, 1);
-#endif
+	SEND_STDERR_DEBUG("ELF header=");
+	SEND_ADDRESS_STDERR_DEBUG(load_addr, 1);
 
 
 
 
 	/* Locate the global offset table.  Since this code must be PIC
 	/* Locate the global offset table.  Since this code must be PIC
@@ -189,17 +187,13 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 	 * we can always read stuff out of the ELF file to find it... */
 	 * we can always read stuff out of the ELF file to find it... */
 	got = elf_machine_dynamic();
 	got = elf_machine_dynamic();
 	dpnt = (Elf32_Dyn *) (got + load_addr);
 	dpnt = (Elf32_Dyn *) (got + load_addr);
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("First Dynamic section entry=");
-	SEND_ADDRESS_STDERR(dpnt, 1);
-#endif
+	SEND_STDERR_DEBUG("First Dynamic section entry=");
+	SEND_ADDRESS_STDERR_DEBUG(dpnt, 1);
 	_dl_memset(tpnt, 0, sizeof(struct elf_resolve));
 	_dl_memset(tpnt, 0, sizeof(struct elf_resolve));
 	tpnt->loadaddr = load_addr;
 	tpnt->loadaddr = load_addr;
 	/* 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
+	SEND_STDERR_DEBUG("scanning DYNAMIC section\n");
 	tpnt->dynamic_addr = dpnt;
 	tpnt->dynamic_addr = dpnt;
 #if defined(__mips__) || defined(__cris__)
 #if defined(__mips__) || defined(__cris__)
 	/* Some architectures cannot call functions here, must inline */
 	/* Some architectures cannot call functions here, must inline */
@@ -208,15 +202,11 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 	_dl_parse_dynamic_info(dpnt, tpnt->dynamic_info, NULL, load_addr);
 	_dl_parse_dynamic_info(dpnt, tpnt->dynamic_info, NULL, load_addr);
 #endif
 #endif
 
 
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("done scanning DYNAMIC section\n");
-#endif
+	SEND_STDERR_DEBUG("done scanning DYNAMIC section\n");
 
 
 #if defined(__mips__)
 #if defined(__mips__)
 
 
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("About to do specific GOT bootstrap\n");
-#endif
+	SEND_STDERR_DEBUG("About to do specific GOT bootstrap\n");
 	/* For MIPS we have to do stuff to the GOT before we do relocations.  */
 	/* For MIPS we have to do stuff to the GOT before we do relocations.  */
 	PERFORM_BOOTSTRAP_GOT(tpnt);
 	PERFORM_BOOTSTRAP_GOT(tpnt);
 
 
@@ -224,9 +214,7 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 
 
 	/* 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__
-	SEND_STDERR("About to do library loader relocations\n");
-#endif
+	SEND_STDERR_DEBUG("About to do library loader relocations\n");
 
 
 	{
 	{
 		int goof, indx;
 		int goof, indx;
@@ -279,11 +267,9 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 					sym = &symtab[symtab_index];
 					sym = &symtab[symtab_index];
 					symbol_addr = load_addr + sym->st_value;
 					symbol_addr = load_addr + sym->st_value;
 
 
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-					SEND_STDERR("relocating symbol: ");
-					SEND_STDERR(strtab + sym->st_name);
-					SEND_STDERR("\n");
-#endif
+					SEND_STDERR_DEBUG("relocating symbol: ");
+					SEND_STDERR_DEBUG(strtab + sym->st_name);
+					SEND_STDERR_DEBUG("\n");
 				}
 				}
 				/* Use this machine-specific macro to perform the actual relocation.  */
 				/* Use this machine-specific macro to perform the actual relocation.  */
 				PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
 				PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
@@ -296,11 +282,9 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 	}
 	}
 #endif
 #endif
 
 
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
 	/* Wahoo!!! */
 	/* Wahoo!!! */
-	SEND_STDERR("Done relocating library loader, so we can now\n"
+	SEND_STDERR_DEBUG("Done relocating library loader, so we can now\n"
 			"\tuse globals and make function calls!\n");
 			"\tuse globals and make function calls!\n");
-#endif
 
 
 	/* Now we have done the mandatory linking of some things.  We are now
 	/* Now we have done the mandatory linking of some things.  We are now
 	   free to start using global variables, since these things have all been
 	   free to start using global variables, since these things have all been
@@ -310,10 +294,7 @@ static void * __attribute_used__ _dl_start(unsigned long args)
 
 
 
 
 	/* Transfer control to the application.  */
 	/* Transfer control to the application.  */
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
-	SEND_STDERR("transfering control to application\n");
-#endif
+	SEND_STDERR_DEBUG("transfering control to application\n");
 	_dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_fcn;
 	_dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_fcn;
 	START();
 	START();
 }
 }
-