aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>2001-08-31 00:40:45 +0000
committerJim Blandy <jimb@codesourcery.com>2001-08-31 00:40:45 +0000
commit9ec8e6a0023bc8f4c2b31f42c590de8a68699747 (patch)
tree72f8d526611d143962b674c45464be996c992e07 /gdb/symfile.c
parent2889e661046068fe3d2ea7962a05ac05e5ba2123 (diff)
downloadgdb-9ec8e6a0023bc8f4c2b31f42c590de8a68699747.zip
gdb-9ec8e6a0023bc8f4c2b31f42c590de8a68699747.tar.gz
gdb-9ec8e6a0023bc8f4c2b31f42c590de8a68699747.tar.bz2
* symfile.c (sections_overlap): New function.
(map_overlay_command): Call sections_overlap, instead of using incorrect logic to recognize overlapping sections.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 1bda72e..7f3fdc6 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2490,6 +2490,7 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
section_is_overlay(sect): true if section's VMA != LMA
pc_in_mapped_range(pc,sec): true if pc belongs to section's VMA
pc_in_unmapped_range(...): true if pc belongs to section's LMA
+ sections_overlap(sec1, sec2): true if mapped sec1 and sec2 ranges overlap
overlay_mapped_address(...): map an address from section's LMA to VMA
overlay_unmapped_address(...): map an address from section's VMA to LMA
symbol_overlayed_address(...): Return a "current" address for symbol:
@@ -2629,6 +2630,20 @@ pc_in_mapped_range (CORE_ADDR pc, asection *section)
return 0;
}
+
+/* Return true if the mapped ranges of sections A and B overlap, false
+ otherwise. */
+int
+sections_overlap (asection *a, asection *b)
+{
+ CORE_ADDR a_start = a->vma;
+ CORE_ADDR a_end = a->vma + bfd_get_section_size_before_reloc (a);
+ CORE_ADDR b_start = b->vma;
+ CORE_ADDR b_end = b->vma + bfd_get_section_size_before_reloc (b);
+
+ return (a_start < b_end && b_start < a_end);
+}
+
/* Function: overlay_unmapped_address (PC, SECTION)
Returns the address corresponding to PC in the unmapped (load) range.
May be the same as PC. */
@@ -2807,11 +2822,11 @@ the 'overlay manual' command.");
/* Next, make a pass and unmap any sections that are
overlapped by this new section: */
ALL_OBJSECTIONS (objfile2, sec2)
- if (sec2->ovly_mapped &&
- sec != sec2 &&
- sec->the_bfd_section != sec2->the_bfd_section &&
- (pc_in_mapped_range (sec2->addr, sec->the_bfd_section) ||
- pc_in_mapped_range (sec2->endaddr, sec->the_bfd_section)))
+ if (sec2->ovly_mapped
+ && sec != sec2
+ && sec->the_bfd_section != sec2->the_bfd_section
+ && sections_overlap (sec->the_bfd_section,
+ sec2->the_bfd_section))
{
if (info_verbose)
printf_filtered ("Note: section %s unmapped by overlap\n",