forked from Imagelibrary/binutils-gdb
ld: add an error in case of address space overflow.
ld/ * ldlang.c (lang_check_section_addresses): Check for address space overflow. * testsuite/ld-checks/checks.exp (overflow_check): New procedure * testsuite/ld-checks/over.s: New test source. * testsuite/ld-checks/over.d: New test. * testsuite/ld-checks/over2.s: New test source. * testsuite/ld-checks/over2.d: New test.
This commit is contained in:
20
ld/ldlang.c
20
ld/ldlang.c
@@ -4768,6 +4768,7 @@ lang_check_section_addresses (void)
|
||||
asection *s, *p;
|
||||
struct check_sec *sections;
|
||||
size_t i, count;
|
||||
bfd_vma addr_mask;
|
||||
bfd_vma s_start;
|
||||
bfd_vma s_end;
|
||||
bfd_vma p_start = 0;
|
||||
@@ -4775,6 +4776,25 @@ lang_check_section_addresses (void)
|
||||
lang_memory_region_type *m;
|
||||
bfd_boolean overlays;
|
||||
|
||||
/* Detect address space overflow. */
|
||||
addr_mask = ((bfd_vma) 1 <<
|
||||
(bfd_arch_bits_per_address (link_info.output_bfd) - 1)) - 1;
|
||||
addr_mask = (addr_mask << 1) + 1;
|
||||
for (s = link_info.output_bfd->sections; s != NULL; s = s->next)
|
||||
{
|
||||
s_end = (s->vma + s->size) & addr_mask;
|
||||
if (s_end != 0 && s_end < s->vma)
|
||||
einfo (_("%X%P: section %s VMA wraps around address space\n"),
|
||||
s->name);
|
||||
else
|
||||
{
|
||||
s_end = (s->lma + s->size) & addr_mask;
|
||||
if (s_end != 0 && s_end < s->lma)
|
||||
einfo (_("%X%P: section %s LMA wraps around address space\n"),
|
||||
s->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (bfd_count_sections (link_info.output_bfd) <= 1)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user