This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [ld]: Checks for address space overflow will reject any avr program.
- From: Tristan Gingold <gingold at adacore dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: binutils at sourceware dot org, Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- Date: Tue, 14 Mar 2017 12:52:27 +0100
- Subject: Re: [ld]: Checks for address space overflow will reject any avr program.
- Authentication-results: sourceware.org; auth=none
- References: <5f02d618-1171-c731-f16c-77c43f38a609@gjlay.de> <8245D628-D63D-42B8-9923-079DBCFCA8CA@adacore.com>
> On 14 Mar 2017, at 12:16, Tristan Gingold <gingold@adacore.com> wrote:
>
> [...]
>
>> I didn't actually check whether it's due to your change, but as
>> you are active there, you'll likely know the solution.
>>
>> avr is using virtual addresses in order to linearize the address
>> space.
>
> Yes, I suppose that section offset is larger than address space.
>
> I think I have an idea for this.
Does this work for you ?
Tristan.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index a0638ea..cf7aadc 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4782,16 +4782,23 @@ lang_check_section_addresses (void)
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
+ /* Only for allocated sections and if already in the address space.
+ This handles targets like avr which have I+D small spaces linearized
+ in the only one ELF address space. */
+ if ((s->flags & SEC_ALLOC) != 0
+ && (s->vma & addr_mask) == s->vma)
{
- 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_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);
+ }
}
}