public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Georg-Johann Lay <avr@gjlay.de>
To: Tristan Gingold <gingold@adacore.com>
Cc: binutils@sourceware.org,
	Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Subject: Re: [ld]: Checks for address space overflow will reject any avr program.
Date: Wed, 15 Mar 2017 10:24:00 -0000	[thread overview]
Message-ID: <cfe1f903-0f14-39e6-5cdd-4f657d88e242@gjlay.de> (raw)
In-Reply-To: <9FC68732-6FC9-4D09-B30A-577F3F73AF1A@adacore.com>

On 14.03.2017 12:52, Tristan Gingold wrote:
>
>> 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);
> +	    }
>  	}
>      }
>

I tried this patch with some simple programs and it worked for them.

Thanks for the fast fix.

Johann


      reply	other threads:[~2017-03-15 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14 11:01 Georg-Johann Lay
2017-03-14 11:16 ` Tristan Gingold
2017-03-14 11:52   ` Tristan Gingold
2017-03-15 10:24     ` Georg-Johann Lay [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cfe1f903-0f14-39e6-5cdd-4f657d88e242@gjlay.de \
    --to=avr@gjlay.de \
    --cc=binutils@sourceware.org \
    --cc=gingold@adacore.com \
    --cc=senthil_kumar.selvaraj@atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).