[7/7] Fix address comparison in lookup_minimal_symbol_by_pc_section

Message ID 20240217-dwarf-race-relocate-v1-7-d3d2d908c1e8@tromey.com
State New
Headers
Series Fix race in DWARF reader |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Testing failed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Testing failed

Commit Message

Tom Tromey Feb. 18, 2024, 1:10 a.m. UTC
  I noticed that lookup_minimal_symbol_by_pc_section is comparing
unrelocated addresses across objfiles when trying to find the best
symbol.  However, this seems incorrect to me, as the unrelocated
addresses aren't of interest here.  This patch changes this code to
compare the true addresses instead.

This does make me wonder whether this code is necessary at all.
---
 gdb/minsyms.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Patch

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 64f085a0314..06a87865c13 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1035,8 +1035,7 @@  lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
 	 table.  See if it is the best one overall.  */
       if (minsym != nullptr
 	  && (best.minsym == nullptr
-	      || (best.minsym->unrelocated_address ()
-		  < minsym->unrelocated_address ())))
+	      || best.value_address () < minsym->value_address (objfile)))
 	best = { minsym, objfile };
     }