aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-10-28 19:28:57 +0000
committerPedro Alves <palves@redhat.com>2009-10-28 19:28:57 +0000
commit875cdfbb543a93950571891898569bb67e78de27 (patch)
treef62ec39e4d1ae3a1b9d1f7f52bebc1494a55d174 /gdb
parent1a587334a9924ac384c87dc3f1956cdb4d97ab8c (diff)
downloadgdb-875cdfbb543a93950571891898569bb67e78de27.zip
gdb-875cdfbb543a93950571891898569bb67e78de27.tar.gz
gdb-875cdfbb543a93950571891898569bb67e78de27.tar.bz2
* dwarf2-frame.c (dwarf2_build_frame_info): Discard --gc-section
leftover FDEs.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2-frame.c64
2 files changed, 54 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c080900..a58386d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2009-10-28 Pedro Alves <pedro@codesourcery.com>
+ * dwarf2-frame.c (dwarf2_build_frame_info): Discard --gc-section
+ leftover FDEs.
+
+2009-10-28 Pedro Alves <pedro@codesourcery.com>
+
* infrun.c (keep_going): Wrap with resume_cleanups.
2009-10-27 Paul Pluzhnikov <ppluzhnikov@google.com>
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 5e9be2c..a4d6dd5 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -2101,7 +2101,9 @@ dwarf2_build_frame_info (struct objfile *objfile)
if (fde_table.num_entries != 0)
{
struct dwarf2_fde_table *fde_table2;
- int i, j;
+ struct dwarf2_fde *fde_prev = NULL;
+ struct dwarf2_fde *first_non_zero_fde = NULL;
+ int i;
/* Prepare FDE table for lookups. */
qsort (fde_table.entries, fde_table.num_entries,
@@ -2110,22 +2112,54 @@ dwarf2_build_frame_info (struct objfile *objfile)
/* Copy fde_table to obstack: it is needed at runtime. */
fde_table2 = (struct dwarf2_fde_table *)
obstack_alloc (&objfile->objfile_obstack, sizeof (*fde_table2));
+ fde_table2->num_entries = 0;
+
+ /* Check for leftovers from --gc-sections. The GNU linker sets
+ the relevant symbols to zero, but doesn't zero the FDE *end*
+ ranges because there's no relocation there. It's (offset,
+ length), not (start, end). On targets where address zero is
+ just another valid address this can be a problem, since the
+ FDEs appear to be non-empty in the output --- we could pick
+ out the wrong FDE. To work around this, when overlaps are
+ detected, we prefer FDEs that do not start at zero.
+
+ Start by finding the first FDE with non-zero start. Below
+ we'll discard all FDEs that start at zero and overlap this
+ one. */
+ for (i = 0; i < fde_table.num_entries; i++)
+ {
+ struct dwarf2_fde *fde = fde_table.entries[i];
- /* Since we'll be doing bsearch, squeeze out identical (except for
- eh_frame_p) fde entries so bsearch result is predictable. */
- for (i = 0, j = 0; j < fde_table.num_entries; ++i)
- {
- const int k = j;
-
- obstack_grow (&objfile->objfile_obstack, &fde_table.entries[j],
- sizeof (fde_table.entries[0]));
- while (++j < fde_table.num_entries
- && (fde_table.entries[k]->initial_location
- == fde_table.entries[j]->initial_location))
- /* Skip. */;
- }
+ if (fde->initial_location != 0)
+ {
+ first_non_zero_fde = fde;
+ break;
+ }
+ }
+
+ /* Since we'll be doing bsearch, squeeze out identical (except
+ for eh_frame_p) fde entries so bsearch result is predictable.
+ Also discard leftovers from --gc-sections. */
+ for (i = 0; i < fde_table.num_entries; i++)
+ {
+ struct dwarf2_fde *fde = fde_table.entries[i];
+
+ if (fde->initial_location == 0
+ && first_non_zero_fde != NULL
+ && (first_non_zero_fde->initial_location
+ < fde->initial_location + fde->address_range))
+ continue;
+
+ if (fde_prev != NULL
+ && fde_prev->initial_location == fde->initial_location)
+ continue;
+
+ obstack_grow (&objfile->objfile_obstack, &fde_table.entries[i],
+ sizeof (fde_table.entries[0]));
+ ++fde_table2->num_entries;
+ fde_prev = fde;
+ }
fde_table2->entries = obstack_finish (&objfile->objfile_obstack);
- fde_table2->num_entries = i;
set_objfile_data (objfile, dwarf2_frame_objfile_data, fde_table2);
/* Discard the original fde_table. */