Explorar o código

use _dl_debug_file instead of hardcode 2

Mike Frysinger %!s(int64=20) %!d(string=hai) anos
pai
achega
af519ad1c0
Modificáronse 1 ficheiros con 24 adicións e 29 borrados
  1. 24 29
      ldso/ldso/ldso.c

+ 24 - 29
ldso/ldso/ldso.c

@@ -97,12 +97,7 @@ static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
 			void (*dl_elf_func) (void);
 
 			dl_elf_func = (void (*)(void)) (intptr_t) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
-#if defined (__SUPPORT_LD_DEBUG__)
-			if(_dl_debug)
-				_dl_dprintf(_dl_debug_file,
-					    "\ncalling FINI: %s\n\n",
-					    tpnt->libname);
-#endif
+			_dl_if_debug_dprint("\ncalling FINI: %s\n\n", tpnt->libname);
 			(*dl_elf_func) ();
 		}
 	}
@@ -144,7 +139,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
 	/* Wahoo!!! */
-	_dl_dprintf(2, "\nCool, ldso survived making function calls.\n");
+	_dl_dprintf(_dl_debug_file, "\nCool, ldso survived making function calls.\n");
 #endif
 
 	/* Now we have done the mandatory linking of some things.  We are now
@@ -157,7 +152,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 	}
 
 	if (_start == (void *) auxvt[AT_ENTRY].a_un.a_fcn) {
-		_dl_dprintf(2, "Standalone execution is not supported yet\n");
+		_dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n");
 		_dl_exit(1);
 	}
 
@@ -223,7 +218,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
 		if (app_tpnt->loadaddr) {
-			_dl_dprintf(2, "Position Independent Executable: "
+			_dl_dprintf(_dl_debug_file, "Position Independent Executable: "
 					"app_tpnt->loadaddr=%x\n", app_tpnt->loadaddr);
 		}
 #endif
@@ -252,7 +247,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 			 * again once we are done.
 			 */
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-			_dl_dprintf(2, "calling mprotect on the application program\n");
+			_dl_dprintf(_dl_debug_file, "calling mprotect on the application program\n");
 #endif
 			/* Now cover the application program. */
 			if (app_tpnt->dynamic_info[DT_TEXTREL]) {
@@ -306,7 +301,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 				*ptmp = '\0';
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-			_dl_dprintf(2, "Lib Loader:\t(%x) %s\n",
+			_dl_dprintf(_dl_debug_file, "Lib Loader:\t(%x) %s\n",
 				    tpnt->loadaddr, tpnt->libname);
 #endif
 		}
@@ -355,7 +350,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 				_dl_debug_file= _dl_open(filename, O_WRONLY|O_CREAT, 0644);
 				if (_dl_debug_file < 0) {
 					_dl_debug_file = 2;
-					_dl_dprintf (2, "can't open file: '%s'\n",filename);
+					_dl_dprintf(_dl_debug_file, "can't open file: '%s'\n",filename);
 				}
 			}
 		}
@@ -426,14 +421,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 					else
 #endif
 					{
-						_dl_dprintf(2, "%s: can't load " "library '%s'\n", _dl_progname, str);
+						_dl_dprintf(_dl_debug_file, "%s: can't load " "library '%s'\n", _dl_progname, str);
 						_dl_exit(15);
 					}
 				} else {
 					tpnt1->rtld_flags = unlazy | RTLD_GLOBAL;
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-					_dl_dprintf(2,
+					_dl_dprintf(_dl_debug_file,
 						    "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
 #endif
 
@@ -472,7 +467,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 		}
 
 		if ((fd = _dl_open(LDSO_PRELOAD, O_RDONLY, 0)) < 0) {
-			_dl_dprintf(2, "%s: can't open file '%s'\n",
+			_dl_dprintf(_dl_debug_file, "%s: can't open file '%s'\n",
 				    _dl_progname, LDSO_PRELOAD);
 			break;
 		}
@@ -481,7 +476,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 					     PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 		_dl_close(fd);
 		if (preload == (caddr_t) -1) {
-			_dl_dprintf(2, "%s: can't map file '%s'\n",
+			_dl_dprintf(_dl_debug_file, "%s: can't map file '%s'\n",
 				    _dl_progname, LDSO_PRELOAD);
 			break;
 		}
@@ -524,14 +519,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 				else
 #endif
 				{
-					_dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, cp2);
+					_dl_dprintf(_dl_debug_file, "%s: can't load library '%s'\n", _dl_progname, cp2);
 					_dl_exit(15);
 				}
 			} else {
 				tpnt1->rtld_flags = unlazy | RTLD_GLOBAL;
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-				_dl_dprintf(2, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
+				_dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
 #endif
 
 #ifdef __LDSO_LDD_SUPPORT__
@@ -582,7 +577,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 					} else
 #endif
 					{
-						_dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, lpntstr);
+						_dl_dprintf(_dl_debug_file, "%s: can't load library '%s'\n", _dl_progname, lpntstr);
 						_dl_exit(16);
 					}
 				}
@@ -595,7 +590,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 				tpnt1->rtld_flags = unlazy | RTLD_GLOBAL;
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-				_dl_dprintf(2, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
+				_dl_dprintf(_dl_debug_file, "Loading:\t(%x) %s\n", tpnt1->loadaddr, tpnt1->libname);
 #endif
 
 #ifdef __LDSO_LDD_SUPPORT__
@@ -632,7 +627,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 					struct elf_resolve *here = init_fini_list[k];
 #ifdef __SUPPORT_LD_DEBUG__
 					if(_dl_debug)
-						_dl_dprintf(2, "Move %s from pos %d to %d in INIT/FINI list.\n", here->libname, k, j);
+						_dl_dprintf(_dl_debug_file, "Move %s from pos %d to %d in INIT/FINI list.\n", here->libname, k, j);
 #endif
 					for (i = (k - j); i; --i)
 						init_fini_list[i+j] = init_fini_list[i+j-1];
@@ -645,16 +640,16 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 	}
 #ifdef __SUPPORT_LD_DEBUG__
 	if(_dl_debug) {
-		_dl_dprintf(2, "\nINIT/FINI order and dependencies:\n");
+		_dl_dprintf(_dl_debug_file, "\nINIT/FINI order and dependencies:\n");
 		for (i = 0; i < nlist; i++) {
 			struct init_fini_list *tmp;
 
-			_dl_dprintf(2, "lib: %s has deps:\n",
+			_dl_dprintf(_dl_debug_file, "lib: %s has deps:\n",
 				    init_fini_list[i]->libname);
 			tmp = init_fini_list[i]->init_fini;
 			for (; tmp; tmp = tmp->next)
-				_dl_dprintf(2, " %s ", tmp->tpnt->libname);
-			_dl_dprintf(2, "\n");
+				_dl_dprintf(_dl_debug_file, " %s ", tmp->tpnt->libname);
+			_dl_dprintf(_dl_debug_file, "\n");
 		}
 	}
 #endif
@@ -723,7 +718,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr,
 #endif
 
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-	_dl_dprintf(2, "Beginning relocation fixups\n");
+	_dl_dprintf(_dl_debug_file, "Beginning relocation fixups\n");
 #endif
 
 #ifdef __mips__
@@ -881,7 +876,7 @@ void *_dl_malloc(int size)
 
 #if 0
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-	_dl_dprintf(2, "malloc: request for %d bytes\n", size);
+	_dl_dprintf(_dl_debug_file, "malloc: request for %d bytes\n", size);
 #endif
 #endif
 
@@ -890,12 +885,12 @@ void *_dl_malloc(int size)
 
 	if (_dl_malloc_addr - _dl_mmap_zero + (unsigned)size > _dl_pagesize) {
 #ifdef __SUPPORT_LD_DEBUG_EARLY__
-		_dl_dprintf(2, "malloc: mmapping more memory\n");
+		_dl_dprintf(_dl_debug_file, "malloc: mmapping more memory\n");
 #endif
 		_dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, size,
 				PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 		if (_dl_mmap_check_error(_dl_mmap_zero)) {
-			_dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+			_dl_dprintf(_dl_debug_file, "%s: mmap of a spare page failed!\n", _dl_progname);
 			_dl_exit(20);
 		}
 	}