From 382e0285e8f8b42a9e72c5267f726cf574b2d299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 9 Nov 2024 15:01:53 +0100 Subject: [PATCH] Trust DT_DEBUG in AUXV better than in ELF In cases of core dump, sometimes the ELF can be recreated and we should rather trust what is in the core dump than the ELF. --- gdb/solib-svr4.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 8378ecaff40..8f4450323a5 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -742,10 +742,11 @@ elf_locate_base (void) return extract_typed_address (pbuf, ptr_type); } - /* Find DT_DEBUG. */ - if (gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), - &dyn_ptr, NULL) - || scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL)) + /* Find DT_DEBUG. + Trust better the DT_DEBUG in AUXV */ + if (scan_dyntag_auxv (DT_DEBUG, &dyn_ptr, NULL) || + gdb_bfd_scan_elf_dyntag (DT_DEBUG, current_program_space->exec_bfd (), + &dyn_ptr, NULL)) return dyn_ptr; /* This may be a static executable. Look for the symbol -- 2.44.1