+2017-02-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2017-02-16 Alan Modra <amodra@gmail.com>
PR 21000
/* 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. */
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);
}
if (! stash)
return FALSE;
}
+ stash->orig_bfd = abfd;
stash->debug_sections = debug_sections;
stash->syms = symbols;
if (!save_section_vma (abfd, stash))
+2017-02-16 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2017-02-16 Andrew Burgess <andrew.burgess@embecosm.com>
* testsuite/lib/ld-lib.exp (run_cc_link_tests): Add warning,
{"Build libdwarf1.so"
"-s -shared" "-fPIC -g -feliminate-dwarf2-dups"
{dwarf1.c} {} "libdwarf1.so"}
+ {"DWARF parse during linker error"
+ "" "-fno-toplevel-reorder"
+ {dwarf2a.c dwarf2b.c} {{error_output "dwarf2.err"}} "dwarf2.x"}
+ {"Handle no DWARF information"
+ "" "-g0"
+ {dwarf3.c} {{error_output "dwarf3.err"}} "dwarf3.x"}
}
set run_tests {
--- /dev/null
+tmpdir/dwarf2b\.o:\(\.data\+0x0\): multiple definition of `global_var'
+tmpdir/dwarf2a\.o:\(\.data\+0x0\): first defined here
+tmpdir/dwarf2b\.o:\(\.data\+0x4\): multiple definition of `other_var'
+tmpdir/dwarf2a\.o:\(\.data\+0x4\): first defined here
--- /dev/null
+int global_var = 3;
+int other_var = 4;
+
+int
+function (void)
+{
+ return 0;
+}
--- /dev/null
+int global_var = 4;
+int other_var = 2;
+
+extern int function (void);
+
+int
+main ()
+{
+ return function ();
+}
--- /dev/null
+/* This test is actually used to test for a segfault that came from the bfd
+ dwarf parsing code in the case when there is _no_ dwarf info. */
+
+extern void bar (int a);
+
+int
+main ()
+{
+ bar (1);
+ bar (2);
+
+ return 0;
+}
--- /dev/null
+.*/dwarf3\.o: In function `main':
+.*dwarf3.c:\(\.text.*\+0x[0-9a-f]+\): undefined reference to `bar'
+.*dwarf3.c:\(\.text.*\+0x[0-9a-f]+\): undefined reference to `bar'
+#...
\ No newline at end of file