+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
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;
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);