aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2010-07-17 03:12:02 +0000
committerAlan Modra <amodra@gmail.com>2010-07-17 03:12:02 +0000
commitf4427a75c8c7166f2c9e08ec75115743344c5519 (patch)
tree12c6d227f4d7a9a9874d9328a7d92a0aa58ab320 /ld
parentb559959291b5423bbdc51a8d3b84f322f82a1e2b (diff)
downloadgdb-f4427a75c8c7166f2c9e08ec75115743344c5519.zip
gdb-f4427a75c8c7166f2c9e08ec75115743344c5519.tar.gz
gdb-f4427a75c8c7166f2c9e08ec75115743344c5519.tar.bz2
* ldlang.c (lang_check_section_addresses): Catch overlap for
sections that wrap around the address space.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/ldlang.c27
2 files changed, 21 insertions, 11 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 864901d..80bcd25 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-17 Alan Modra <amodra@gmail.com>
+
+ * ldlang.c (lang_check_section_addresses): Catch overlap for
+ sections that wrap around the address space.
+
2010-06-29 Nick Clifton <nickc@redhat.com>
* scripttempl/xstormy16.sc (.gcc_except_table): Include sections
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 5ba4360..9c4e17b 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4561,13 +4561,13 @@ sort_sections_by_lma (const void *arg1, const void *arg2)
static void
lang_check_section_addresses (void)
{
- asection *s, *os;
+ asection *s, *p;
asection **sections, **spp;
unsigned int count;
bfd_vma s_start;
bfd_vma s_end;
- bfd_vma os_start;
- bfd_vma os_end;
+ bfd_vma p_start;
+ bfd_vma p_end;
bfd_size_type amt;
lang_memory_region_type *m;
@@ -4600,24 +4600,29 @@ lang_check_section_addresses (void)
spp = sections;
s = *spp++;
- s_start = bfd_section_lma (link_info.output_bfd, s);
+ s_start = s->lma;
s_end = s_start + TO_ADDR (s->size) - 1;
for (count--; count; count--)
{
/* We must check the sections' LMA addresses not their VMA
addresses because overlay sections can have overlapping VMAs
but they must have distinct LMAs. */
- os = s;
- os_start = s_start;
- os_end = s_end;
+ p = s;
+ p_start = s_start;
+ p_end = s_end;
s = *spp++;
- s_start = bfd_section_lma (link_info.output_bfd, s);
+ s_start = s->lma;
s_end = s_start + TO_ADDR (s->size) - 1;
- /* Look for an overlap. */
- if (s_end >= os_start && s_start <= os_end)
+ /* Look for an overlap. We have sorted sections by lma, so we
+ know that s_start >= p_start. Besides the obvious case of
+ overlap when the current section starts before the previous
+ one ends, we also must have overlap if the previous section
+ wraps around the address space. */
+ if (s_start <= p_end
+ || p_end < p_start)
einfo (_("%X%P: section %s loaded at [%V,%V] overlaps section %s loaded at [%V,%V]\n"),
- s->name, s_start, s_end, os->name, os_start, os_end);
+ s->name, s_start, s_end, p->name, p_start, p_end);
}
free (sections);