diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2016-12-15 15:22:49 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2017-02-16 13:06:13 +0000 |
commit | 90ed9b8bc136c80116273d1aae5a31fbd415af27 (patch) | |
tree | 057578b7b94660075f4d1cccf9434047d15c7165 /bfd/dwarf2.c | |
parent | 2bd7f877afeadd6da4c6b1dfc4d0489e9c0efb55 (diff) | |
download | gdb-90ed9b8bc136c80116273d1aae5a31fbd415af27.zip gdb-90ed9b8bc136c80116273d1aae5a31fbd415af27.tar.gz gdb-90ed9b8bc136c80116273d1aae5a31fbd415af27.tar.bz2 |
bfd/dwarf: Improve use of previously loaded dwarf information
When parsing DWARF data in order to report file/line type error messages
we perform section placement to make section addresses unique within
relocatable object files.
Currently, if we reuse previously loaded (and cached) dwarf data then we
neglect to perform section placement, the result is that the section
addresses will not be unique, and we might, incorrectly associate an
address with the wrong debug information, and so report an incorrect
file and line number.
Further we neglect to check that that bfd for which we are looking up
debug information is actually the bfd for which the previous debug
information was loaded, it is possible that we will reuse previously
loaded debug information for a different bfd.
And finally, due to following of gnu_debuglink links in one bfd to
another, the process of checking that the cached debug information is
valid requires us to track the original bfd in the cached debug
information. The original debug information here is either the bfd that
we're interested in, not the bfd we finally load the debug information
from.
bfd/ChangeLog:
* dwarf2.c (struct dwarf2_debug): Add orig_bfd member.
(_bfd_dwarf2_slurp_debug_info): If stashed debug information does
not match current bfd, then reload debug information. Record bfd
we're loading debug info for in the stash. If we have debug
informatin in the cache then perform section placement before
returning.
ld/ChangeLog:
* testsuite/ld-elf/dwarf.exp (build_tests): Add new tests.
* testsuite/ld-elf/dwarf2.err: New file.
* testsuite/ld-elf/dwarf2a.c: New file.
* testsuite/ld-elf/dwarf2b.c: New file.
* testsuite/ld-elf/dwarf3.c: New file.
* testsuite/ld-elf/dwarf3.err: New file.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r-- | bfd/dwarf2.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 6b111d3..03447a9 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -100,6 +100,12 @@ struct dwarf2_debug /* Pointer to the end of the .debug_info section memory buffer. */ bfd_byte *info_ptr_end; + /* 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; + /* Pointer to the bfd, section and address of the beginning of the section. The bfd might be different than expected because of gnu_debuglink sections. */ @@ -3897,8 +3903,20 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, if (stash != NULL) { - if (section_vma_same (abfd, stash)) - return TRUE; + if (stash->orig_bfd == abfd + && section_vma_same (abfd, stash)) + { + /* Check that we did previously find some debug information + before attempting to make use of it. */ + if (stash->bfd_ptr != NULL) + { + if (do_place && !place_sections (abfd, stash)) + return FALSE; + return TRUE; + } + + return FALSE; + } _bfd_dwarf2_cleanup_debug_info (abfd, pinfo); memset (stash, 0, amt); } @@ -3908,6 +3926,7 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, if (! stash) return FALSE; } + stash->orig_bfd = abfd; stash->debug_sections = debug_sections; stash->syms = symbols; if (!save_section_vma (abfd, stash)) |