This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ld]: Checks for address space overflow will reject any avr program.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]