diff options
author | Alan Modra <amodra@gmail.com> | 2024-12-11 13:01:23 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-12-12 16:04:51 +1030 |
commit | 338c58cac6ea08a8ec90a06496054fcf9e45d094 (patch) | |
tree | a3f481b55aa0f04a6e3b03d80c26f8fae2e356f0 /bfd | |
parent | 4d72d1027143d8a63f5e61d36516cb6846d7c71b (diff) | |
download | binutils-338c58cac6ea08a8ec90a06496054fcf9e45d094.zip binutils-338c58cac6ea08a8ec90a06496054fcf9e45d094.tar.gz binutils-338c58cac6ea08a8ec90a06496054fcf9e45d094.tar.bz2 |
Use bfd id to validate dwarf2 cache
Using a bfd pointer to validate the cache isn't very robust. If a bfd
is closed somehow without clearing the cache, then it's possible that
another bfd is opened using the same memory and thus orig_bfd compares
equal to the new bfd.
* dwarf2.c (struct dwarf2_debug): Add orig_bfd_id. Delete
orig_bfd.
(_bfd_dwarf2_slurp_debug_info): Validate stash with orig_bfd_id.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/dwarf2.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 151ed02..e93a331 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -292,12 +292,6 @@ struct dwarf2_debug /* Per-file stuff. */ struct dwarf2_debug_file f, alt; - /* Pointer to the original bfd for which debug was loaded. This is what - we use to compare and so check that the cached debug data is still - valid - it saves having to possibly dereference the gnu_debuglink each - time. */ - bfd *orig_bfd; - /* If the most recent call to bfd_find_nearest_line was given an address in an inlined function, preserve a pointer into the calling chain for subsequent calls to bfd_find_inliner_info to @@ -315,6 +309,9 @@ struct dwarf2_debug /* Array of sections with adjusted VMA. */ struct adjusted_section *adjusted_sections; + /* Used to validate the cached debug data. */ + unsigned int orig_bfd_id; + /* Number of times find_line is called. This is used in the heuristic for enabling the info hash tables. */ int info_hash_count; @@ -5401,7 +5398,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, if (stash != NULL) { - if (stash->orig_bfd == abfd + if (stash->orig_bfd_id == abfd->id && section_vma_same (abfd, stash)) { /* Check that we did previously find some debug information @@ -5425,7 +5422,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, return false; *pinfo = stash; } - stash->orig_bfd = abfd; + stash->orig_bfd_id = abfd->id; stash->debug_sections = debug_sections; stash->f.syms = symbols; if (!save_section_vma (abfd, stash)) |