This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] ld: check overflow only for allocated sections
- From: gingold <gingold at adacore dot com>
- To: binutils at sourceware dot org
- Date: Fri, 17 Mar 2017 11:28:58 +0100
- Subject: [PATCH] ld: check overflow only for allocated sections
- Authentication-results: sourceware.org; auth=none
As hinted by Johann, some targets (like avr) have a small address space.
According to the latest tests they are handled correctly, but I think it
is better not to check overflow for non-allocated sections (like debug
or comment sections).
No regression on i686-linux.
Ok for master ?
Tristan.
commit 7e14f390b77d05ffb6c33cf74820f30312e34e25
Author: Tristan Gingold <gingold@adacore.com>
Date: Fri Mar 17 11:12:05 2017 +0100
ld: check overflow only for allocated sections.
* ldlang.c (lang_check_section_addresses): Check only for
allocated sections.
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 1f1fafd..43f00e5 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-17 gingold <gingold@gingold-Precision-7510>
+
+ * ldlang.c (lang_check_section_addresses): Check only for
+ allocated sections.
+
2017-03-15 Tristan Gingold <gingold@adacore.com>
* testsuite/ld-checks/checks.exp (overflow_check): Disable for
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 8c1d829..5a42659 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4776,24 +4776,25 @@ lang_check_section_addresses (void)
lang_memory_region_type *m;
bfd_boolean overlays;
- /* Detect address space overflow. */
+ /* Detect address space overflow on allocated sections. */
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 & addr_mask))
- 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 & addr_mask))
- einfo (_("%X%P: section %s LMA wraps around address space\n"),
- s->name);
- }
- }
+ if ((s->flags & SEC_ALLOC) != 0)
+ {
+ s_end = (s->vma + s->size) & addr_mask;
+ if (s_end != 0 && s_end < (s->vma & addr_mask))
+ 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 & addr_mask))
+ einfo (_("%X%P: section %s LMA wraps around address space\n"),
+ s->name);
+ }
+ }
if (bfd_count_sections (link_info.output_bfd) <= 1)
return;