瀏覽代碼

Make some nice SEND_ADDRESS_STDERR and SEND_NUMBER_STDERR macros that
operate inline, to help when debugging ldso (i.e. before we can do
things like function calls).
-Erik

Eric Andersen 24 年之前
父節點
當前提交
f5d08871d3
共有 7 個文件被更改,包括 49 次插入26 次删除
  1. 3 6
      ldso/ldso/boot1.c
  2. 18 0
      ldso/ldso/hash.h
  3. 3 6
      ldso/ldso/ld-uClibc.c
  4. 18 0
      ldso/ldso/ld_hash.h
  5. 2 4
      ldso/ldso/ld_string.h
  6. 3 6
      ldso/ldso/ldso.c
  7. 2 4
      ldso/ldso/string.h

+ 3 - 6
ldso/ldso/boot1.c

@@ -219,11 +219,9 @@ void _dl_boot(unsigned int args)
 	}
 #ifdef DL_DEBUG
 	SEND_STDERR("ELF header =");
-	SEND_STDERR(_dl_simple_ltoahex(load_addr));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(load_addr, 1);
 #endif	
 
-
 	/* Locate the global offset table.  Since this code must be PIC  
 	 * we can take advantage of the magic offset register, if we
 	 * happen to know what that is for this architecture.  If not,
@@ -288,8 +286,7 @@ found_got:
 	dpnt = (Elf32_Dyn *) (*got + load_addr);
 #ifdef DL_DEBUG
 	SEND_STDERR("First Dynamic section entry=");
-	SEND_STDERR(_dl_simple_ltoahex((unsigned long)dpnt));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(dpnt, 1);
 #endif	
 
 	
@@ -1012,7 +1009,7 @@ void *_dl_malloc(int size)
 
 #ifdef DL_DEBUG
 	SEND_STDERR("malloc: request for ");
-	SEND_STDERR(_dl_simple_itoa(size));
+	SEND_NUMBER_STDERR(size, 0);
 	SEND_STDERR(" bytes\n");
 #endif	
 

+ 18 - 0
ldso/ldso/hash.h

@@ -82,6 +82,24 @@ extern int _dl_linux_dynamic_link(void);
 #else
 #define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
 #endif
+
+#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
+    char tmp[13]; \
+    _dl_write(2, _dl_simple_ltoahex_inline( tmp, (unsigned long)(X)), 12); \
+    if (add_a_newline) { \
+	tmp[0]='\n'; \
+	_dl_write(2, tmp, 1); \
+    } \
+};    
+
+#define SEND_NUMBER_STDERR(X, add_a_newline) { \
+    char tmp[13]; \
+    _dl_write(2, (void *)_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)), 12); \
+    if (add_a_newline) { \
+	tmp[0]='\n'; \
+	_dl_write(2, tmp, 1); \
+    } \
+};    
 extern int _dl_fdprintf(int, const char *, ...);
 extern char * _dl_library_path;
 extern char * _dl_not_lazy;

+ 3 - 6
ldso/ldso/ld-uClibc.c

@@ -219,11 +219,9 @@ void _dl_boot(unsigned int args)
 	}
 #ifdef DL_DEBUG
 	SEND_STDERR("ELF header =");
-	SEND_STDERR(_dl_simple_ltoahex(load_addr));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(load_addr, 1);
 #endif	
 
-
 	/* Locate the global offset table.  Since this code must be PIC  
 	 * we can take advantage of the magic offset register, if we
 	 * happen to know what that is for this architecture.  If not,
@@ -288,8 +286,7 @@ found_got:
 	dpnt = (Elf32_Dyn *) (*got + load_addr);
 #ifdef DL_DEBUG
 	SEND_STDERR("First Dynamic section entry=");
-	SEND_STDERR(_dl_simple_ltoahex((unsigned long)dpnt));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(dpnt, 1);
 #endif	
 
 	
@@ -1012,7 +1009,7 @@ void *_dl_malloc(int size)
 
 #ifdef DL_DEBUG
 	SEND_STDERR("malloc: request for ");
-	SEND_STDERR(_dl_simple_itoa(size));
+	SEND_NUMBER_STDERR(size, 0);
 	SEND_STDERR(" bytes\n");
 #endif	
 

+ 18 - 0
ldso/ldso/ld_hash.h

@@ -82,6 +82,24 @@ extern int _dl_linux_dynamic_link(void);
 #else
 #define SEND_STDERR(X) _dl_write(2, X, _dl_strlen_inline(X));
 #endif
+
+#define SEND_ADDRESS_STDERR(X, add_a_newline) { \
+    char tmp[13]; \
+    _dl_write(2, _dl_simple_ltoahex_inline( tmp, (unsigned long)(X)), 12); \
+    if (add_a_newline) { \
+	tmp[0]='\n'; \
+	_dl_write(2, tmp, 1); \
+    } \
+};    
+
+#define SEND_NUMBER_STDERR(X, add_a_newline) { \
+    char tmp[13]; \
+    _dl_write(2, (void *)_dl_simple_ltoahex_inline( tmp, (unsigned long)(X)), 12); \
+    if (add_a_newline) { \
+	tmp[0]='\n'; \
+	_dl_write(2, tmp, 1); \
+    } \
+};    
 extern int _dl_fdprintf(int, const char *, ...);
 extern char * _dl_library_path;
 extern char * _dl_not_lazy;

+ 2 - 4
ldso/ldso/ld_string.h

@@ -170,10 +170,9 @@ static inline char *_dl_get_last_path_component_inline(char *path)
 
 /* Early on, we can't call printf, so use this to print out
  * numbers using the SEND_STDERR() macro */
-static inline char *_dl_simple_ltoa_inline(unsigned long i)
+static inline char *_dl_simple_ltoa_inline(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	static char local[22];
 	char *p = &local[21];
 	*p-- = '\0';
 	do {
@@ -183,10 +182,9 @@ static inline char *_dl_simple_ltoa_inline(unsigned long i)
 	return p + 1;
 }
 
-static inline char *_dl_simple_ltoahex(unsigned long i)
+static inline char *_dl_simple_ltoahex_inline(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	static char local[22];
 	char *p = &local[21];
 	*p-- = '\0';
 	do {

+ 3 - 6
ldso/ldso/ldso.c

@@ -219,11 +219,9 @@ void _dl_boot(unsigned int args)
 	}
 #ifdef DL_DEBUG
 	SEND_STDERR("ELF header =");
-	SEND_STDERR(_dl_simple_ltoahex(load_addr));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(load_addr, 1);
 #endif	
 
-
 	/* Locate the global offset table.  Since this code must be PIC  
 	 * we can take advantage of the magic offset register, if we
 	 * happen to know what that is for this architecture.  If not,
@@ -288,8 +286,7 @@ found_got:
 	dpnt = (Elf32_Dyn *) (*got + load_addr);
 #ifdef DL_DEBUG
 	SEND_STDERR("First Dynamic section entry=");
-	SEND_STDERR(_dl_simple_ltoahex((unsigned long)dpnt));
-	SEND_STDERR("\n");
+	SEND_ADDRESS_STDERR(dpnt, 1);
 #endif	
 
 	
@@ -1012,7 +1009,7 @@ void *_dl_malloc(int size)
 
 #ifdef DL_DEBUG
 	SEND_STDERR("malloc: request for ");
-	SEND_STDERR(_dl_simple_itoa(size));
+	SEND_NUMBER_STDERR(size, 0);
 	SEND_STDERR(" bytes\n");
 #endif	
 

+ 2 - 4
ldso/ldso/string.h

@@ -170,10 +170,9 @@ static inline char *_dl_get_last_path_component_inline(char *path)
 
 /* Early on, we can't call printf, so use this to print out
  * numbers using the SEND_STDERR() macro */
-static inline char *_dl_simple_ltoa_inline(unsigned long i)
+static inline char *_dl_simple_ltoa_inline(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	static char local[22];
 	char *p = &local[21];
 	*p-- = '\0';
 	do {
@@ -183,10 +182,9 @@ static inline char *_dl_simple_ltoa_inline(unsigned long i)
 	return p + 1;
 }
 
-static inline char *_dl_simple_ltoahex(unsigned long i)
+static inline char *_dl_simple_ltoahex_inline(char * local, unsigned long i)
 {
 	/* 21 digits plus null terminator, good for 64-bit or smaller ints */
-	static char local[22];
 	char *p = &local[21];
 	*p-- = '\0';
 	do {