[RFC] elf: fine-grained output LD_DEBUG log when symbol lookup error

Lv Ying lvying.system.thoughts@gmail.com
Sun Aug 7 12:00:03 GMT 2022


When LD_DEBUG environment variable is set except "unused" value, symbol lookup error
in _dl_lookup_symbol_x will output unrelated debugging information which mess up the
"files" "libs" "reloc" log.

"undefined symbol" debugging information should only output when LD_DEBUG="symbols|all".
---
 elf/dl-lookup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 4c86dc694e..6085c6c90c 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -781,7 +781,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
   if (__glibc_unlikely (current_value.s == NULL))
     {
       if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
-	  && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED))
+	  && (GLRO(dl_debug_mask) & DL_DEBUG_SYMBOLS))
 	{
 	  /* We could find no value for a strong reference.  */
 	  const char *reference_name = undef_map ? undef_map->l_name : "";
-- 
2.27.0



More information about the Libc-alpha mailing list