aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2016-12-15 15:22:49 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2017-02-16 13:06:13 +0000
commit90ed9b8bc136c80116273d1aae5a31fbd415af27 (patch)
tree057578b7b94660075f4d1cccf9434047d15c7165 /ld
parent2bd7f877afeadd6da4c6b1dfc4d0489e9c0efb55 (diff)
downloadgdb-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 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-elf/dwarf.exp6
-rw-r--r--ld/testsuite/ld-elf/dwarf2.err4
-rw-r--r--ld/testsuite/ld-elf/dwarf2a.c8
-rw-r--r--ld/testsuite/ld-elf/dwarf2b.c10
-rw-r--r--ld/testsuite/ld-elf/dwarf3.c13
-rw-r--r--ld/testsuite/ld-elf/dwarf3.err4
7 files changed, 54 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 8d49373..696e08af 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,14 @@
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,
error, warning_output, and error_output actions. Remove separate
warnings parameter.
diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp
index 529ebcc..25b0c9d 100644
--- a/ld/testsuite/ld-elf/dwarf.exp
+++ b/ld/testsuite/ld-elf/dwarf.exp
@@ -49,6 +49,12 @@ set build_tests {
{"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 {
diff --git a/ld/testsuite/ld-elf/dwarf2.err b/ld/testsuite/ld-elf/dwarf2.err
new file mode 100644
index 0000000..872d282
--- /dev/null
+++ b/ld/testsuite/ld-elf/dwarf2.err
@@ -0,0 +1,4 @@
+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
diff --git a/ld/testsuite/ld-elf/dwarf2a.c b/ld/testsuite/ld-elf/dwarf2a.c
new file mode 100644
index 0000000..1de5794
--- /dev/null
+++ b/ld/testsuite/ld-elf/dwarf2a.c
@@ -0,0 +1,8 @@
+int global_var = 3;
+int other_var = 4;
+
+int
+function (void)
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/dwarf2b.c b/ld/testsuite/ld-elf/dwarf2b.c
new file mode 100644
index 0000000..c557978
--- /dev/null
+++ b/ld/testsuite/ld-elf/dwarf2b.c
@@ -0,0 +1,10 @@
+int global_var = 4;
+int other_var = 2;
+
+extern int function (void);
+
+int
+main ()
+{
+ return function ();
+}
diff --git a/ld/testsuite/ld-elf/dwarf3.c b/ld/testsuite/ld-elf/dwarf3.c
new file mode 100644
index 0000000..054eb9b
--- /dev/null
+++ b/ld/testsuite/ld-elf/dwarf3.c
@@ -0,0 +1,13 @@
+/* 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;
+}
diff --git a/ld/testsuite/ld-elf/dwarf3.err b/ld/testsuite/ld-elf/dwarf3.err
new file mode 100644
index 0000000..6027431
--- /dev/null
+++ b/ld/testsuite/ld-elf/dwarf3.err
@@ -0,0 +1,4 @@
+.*/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