public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld lma assignment
@ 2006-07-26  5:09 Alan Modra
  2006-08-22 11:51 ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2006-07-26  5:09 UTC (permalink / raw)
  To: binutils

While playing with overlays recently, I noticed an annoying linker
script requirement.  An output section following an overlay must have
its lma specified (with AT or AT>).  As must any section following one
with an lma adjustment, because ld defaults to setting lma equal to
vma and this may cause lma overlap.  So I decided to teach ld how to
track lma assignments, to make following sections have reasonable
default lmas.  In the process I discovered a bug with LOADADDR
expressions, easily fixed, and found that code setting load_base for
orphans and overlays was no longer needed.

BTW, does anyone know why section lmas are set by lang_do_assignhments
rather than lang_size_sections?  If there is no good reason, I'll move
the code so that both vma and lma are set in lang_size_sections.

ld/
	* ldexp.c (fold_name <LOADADDR>): Use the lma.
	* ldlang.h (lang_memory_region_type): Delete old_length.  Add
	last_os.
	* ldlang.c (lang_memory_region_lookup): Init new field.
	(lang_reset_memory_regions): Reset new field.
	(lang_insert_orphan): Don't set load_base.
	(lang_leave_overlay): Likewise.
	(lang_size_sections_1): Delete unnecessary code setting lma_region
	to region.  Correct lma region check.
	(lang_do_assignments_1): Rename output_section_statement parm
	to current_os.  Set lma from previous section in region.
ld/testsuite/
	* ld-scripts/overlay-size-map.d: Update.

Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.60
diff -u -p -r1.60 ldexp.c
--- ld/ldexp.c	19 Jun 2006 13:17:44 -0000	1.60
+++ ld/ldexp.c	26 Jul 2006 01:08:19 -0000
@@ -577,7 +577,8 @@ fold_name (etree_type *tree)
 	  if (os != NULL && os->processed)
 	    {
 	      if (os->load_base == NULL)
-		new_rel (0, NULL, os->bfd_section);
+		new_rel (os->bfd_section->lma - os->bfd_section->vma,
+			 NULL, os->bfd_section);
 	      else
 		exp_fold_tree_1 (os->load_base);
 	    }
Index: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.63
diff -u -p -r1.63 ldlang.h
--- ld/ldlang.h	20 Jun 2006 16:37:29 -0000	1.63
+++ ld/ldlang.h	26 Jul 2006 01:08:23 -0000
@@ -54,7 +54,7 @@ typedef struct memory_region_struct
   bfd_vma origin;
   bfd_size_type length;
   bfd_vma current;
-  bfd_size_type old_length;
+  union lang_statement_union *last_os;
   flagword flags;
   flagword not_flags;
   bfd_boolean had_full_message;
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.229
diff -u -p -r1.229 ldlang.c
--- ld/ldlang.c	26 Jul 2006 00:42:33 -0000	1.229
+++ ld/ldlang.c	26 Jul 2006 01:08:22 -0000
@@ -1164,16 +1164,17 @@ lang_memory_region_lookup (const char *c
 
   new->name = xstrdup (name);
   new->next = NULL;
-
-  *lang_memory_region_list_tail = new;
-  lang_memory_region_list_tail = &new->next;
   new->origin = 0;
-  new->flags = 0;
-  new->not_flags = 0;
   new->length = ~(bfd_size_type) 0;
   new->current = 0;
+  new->last_os = NULL;
+  new->flags = 0;
+  new->not_flags = 0;
   new->had_full_message = FALSE;
 
+  *lang_memory_region_list_tail = new;
+  lang_memory_region_list_tail = &new->next;
+
   return new;
 }
 
@@ -1462,7 +1463,6 @@ lang_insert_orphan (asection *s,
   lang_statement_list_type *old;
   lang_statement_list_type add;
   const char *ps;
-  etree_type *load_base;
   lang_output_section_statement_type *os;
   lang_output_section_statement_type **os_tail;
 
@@ -1506,20 +1506,10 @@ lang_insert_orphan (asection *s,
   if (link_info.relocatable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0)
     address = exp_intop (0);
 
-  load_base = NULL;
-  if (after != NULL && after->load_base != NULL)
-    {
-      etree_type *lma_from_vma;
-      lma_from_vma = exp_binop ('-', after->load_base,
-				exp_nameop (ADDR, after->name));
-      load_base = exp_binop ('+', lma_from_vma,
-			     exp_nameop (ADDR, secname));
-    }
-
   os_tail = ((lang_output_section_statement_type **)
 	     lang_output_section_statement.tail);
   os = lang_enter_output_section_statement (secname, address, 0, NULL, NULL,
-					    load_base, 0);
+					    NULL, 0);
 
   if (add_child == NULL)
     add_child = &os->children;
@@ -4417,20 +4407,16 @@ lang_size_sections_1
 		  os_region_check (os, os->region, os->addr_tree,
 				   os->bfd_section->vma);
 
-		/* If there's no load address specified, use the run
-		   region as the load region.  */
-		if (os->lma_region == NULL && os->load_base == NULL)
-		  os->lma_region = os->region;
-
 		if (os->lma_region != NULL && os->lma_region != os->region)
 		  {
 		    /* Set load_base, which will be handled later.  */
 		    os->load_base = exp_intop (os->lma_region->current);
 		    os->lma_region->current +=
 		      TO_ADDR (os->bfd_section->size);
+
 		    if (check_regions)
 		      os_region_check (os, os->lma_region, NULL,
-				       os->bfd_section->lma);
+				       os->lma_region->current);
 		  }
 	      }
 	  }
@@ -4709,11 +4695,10 @@ lang_size_sections (bfd_boolean *relax, 
 /* Worker function for lang_do_assignments.  Recursiveness goes here.  */
 
 static bfd_vma
-lang_do_assignments_1
-  (lang_statement_union_type *s,
-   lang_output_section_statement_type *output_section_statement,
-   fill_type *fill,
-   bfd_vma dot)
+lang_do_assignments_1 (lang_statement_union_type *s,
+		       lang_output_section_statement_type *current_os,
+		       fill_type *fill,
+		       bfd_vma dot)
 {
   for (; s != NULL; s = s->header.next)
     {
@@ -4721,9 +4706,7 @@ lang_do_assignments_1
 	{
 	case lang_constructors_statement_enum:
 	  dot = lang_do_assignments_1 (constructor_list.head,
-				       output_section_statement,
-				       fill,
-				       dot);
+				       current_os, fill, dot);
 	  break;
 
 	case lang_output_section_statement_enum:
@@ -4733,22 +4716,61 @@ lang_do_assignments_1
 	    os = &(s->output_section_statement);
 	    if (os->bfd_section != NULL && !os->ignored)
 	      {
+		lang_memory_region_type *r;
+
 		dot = os->bfd_section->vma;
-		lang_do_assignments_1 (os->children.head, os, os->fill, dot);
+		r = os->region;
+		if (r == NULL)
+		  r = lang_memory_region_lookup (DEFAULT_MEMORY_REGION, FALSE);
+
+		if (os->load_base)
+		  os->bfd_section->lma
+		    = exp_get_abs_int (os->load_base, 0, "load base");
+		else if (r->last_os != NULL)
+		  {
+		    asection *last;
+		    bfd_vma lma;
+
+		    last = r->last_os->output_section_statement.bfd_section;
+
+		    /* If the current vma overlaps the previous section,
+		       then set the current lma to that at the end of
+		       the previous section.  The previous section was
+		       probably an overlay.  */
+		    if ((dot >= last->vma
+			 && dot < last->vma + last->size)
+			|| (last->vma >= dot
+			    && last->vma < dot + os->bfd_section->size))
+		      lma = last->lma + last->size;
+
+		    /* Otherwise, keep the same lma to vma relationship
+		       as the previous section.  */
+		    else
+		      lma = dot + last->lma - last->vma;
+
+		    if (os->section_alignment != -1)
+		      lma = align_power (lma, os->section_alignment);
+		    os->bfd_section->lma = lma;
+		  }
+
+		lang_do_assignments_1 (os->children.head,
+				       os, os->fill, dot);
+
 		/* .tbss sections effectively have zero size.  */
 		if ((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0
 		    || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0
 		    || link_info.relocatable)
-		  dot += TO_ADDR (os->bfd_section->size);
-	      }
-	    if (os->load_base)
-	      {
-		/* If nothing has been placed into the output section then
-		   it won't have a bfd_section.  */
-		if (os->bfd_section && !os->ignored)
 		  {
-		    os->bfd_section->lma
-		      = exp_get_abs_int (os->load_base, 0, "load base");
+		    dot += TO_ADDR (os->bfd_section->size);
+
+		    /* Keep track of normal sections using the default
+		       lma region.  We use this to set the lma for
+		       following sections.  Overlays or other linker
+		       script assignment to lma might mean that the
+		       default lma == vma is incorrect.  */
+		    if (!link_info.relocatable
+			&& os->lma_region == NULL)
+		      r->last_os = s;
 		  }
 	      }
 	  }
@@ -4757,8 +4779,7 @@ lang_do_assignments_1
 	case lang_wild_statement_enum:
 
 	  dot = lang_do_assignments_1 (s->wild_statement.children.head,
-				       output_section_statement,
-				       fill, dot);
+				       current_os, fill, dot);
 	  break;
 
 	case lang_object_symbols_statement_enum:
@@ -4827,7 +4848,7 @@ lang_do_assignments_1
 
 	case lang_assignment_statement_enum:
 	  exp_fold_tree (s->assignment_statement.exp,
-			 output_section_statement->bfd_section,
+			 current_os->bfd_section,
 			 &dot);
 	  break;
 
@@ -4837,8 +4858,7 @@ lang_do_assignments_1
 
 	case lang_group_statement_enum:
 	  dot = lang_do_assignments_1 (s->group_statement.children.head,
-				       output_section_statement,
-				       fill, dot);
+				       current_os, fill, dot);
 	  break;
 
 	default:
@@ -5423,8 +5443,8 @@ lang_reset_memory_regions (void)
 
   for (p = lang_memory_region_list; p != NULL; p = p->next)
     {
-      p->old_length = (bfd_size_type) (p->current - p->origin);
       p->current = p->origin;
+      p->last_os = NULL;
     }
 
   for (os = &lang_output_section_statement.head->output_section_statement;
@@ -6350,10 +6370,6 @@ lang_leave_overlay (etree_type *lma_expr
 	 an LMA region was specified.  */
       if (l->next == 0)
 	l->os->load_base = lma_expr;
-      else if (lma_region == 0)
-	l->os->load_base = exp_binop ('+',
-				      exp_nameop (LOADADDR, l->next->os->name),
-				      exp_nameop (SIZEOF, l->next->os->name));
 
       if (phdrs != NULL && l->os->phdrs == NULL)
 	l->os->phdrs = phdrs;
Index: ld/testsuite/ld-scripts/overlay-size-map.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/overlay-size-map.d,v
retrieving revision 1.1
diff -u -p -r1.1 overlay-size-map.d
--- ld/testsuite/ld-scripts/overlay-size-map.d	7 May 2002 11:08:57 -0000	1.1
+++ ld/testsuite/ld-scripts/overlay-size-map.d	26 Jul 2006 01:08:25 -0000
@@ -1,9 +1,9 @@
 #...
 \.bss1 *0x0*20000 *0x10
 #...
-\.bss2 *0x0*20000 *0x30 load address 0x0*20010
+\.bss2 *0x0*20000 *0x30
 #...
-\.bss3 *0x0*20000 *0x20 load address 0x0*20040
+\.bss3 *0x0*20000 *0x20
 #...
 \.mtext *0x0*10000 *0x20 load address 0x0*30000
 #...

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-07-26  5:09 ld lma assignment Alan Modra
@ 2006-08-22 11:51 ` Alan Modra
  2006-08-22 18:46   ` H. J. Lu
  2006-08-23  1:34   ` H. J. Lu
  0 siblings, 2 replies; 10+ messages in thread
From: Alan Modra @ 2006-08-22 11:51 UTC (permalink / raw)
  To: binutils

On Wed, Jul 26, 2006 at 02:39:14PM +0930, Alan Modra wrote:
> While playing with overlays recently, I noticed an annoying linker
> script requirement.  An output section following an overlay must have
> its lma specified (with AT or AT>).  As must any section following one
> with an lma adjustment, because ld defaults to setting lma equal to
> vma and this may cause lma overlap.

Fixes doco for this change, and warns on backward movement of VMA
unless accompanied with an explicit LMA assignment.  I guess I should
have added the news item when I committed the first patch to raise
awareness of the change in default lma.  Apologies for that, I wasn't
trying to slip a change in under the radar!  I still feel it's a good
change for 2.18, one that shouldn't affect too many scripts, and those
that it does are easily fixed.

	* NEWS: Mention LMA default change.
	* ld.texinfo (Output Section LMA): Update default description.
	(Location Counter): Clarify backward movement.
	* ldlang.c (lang_size_sections_1): Leave non-alloc sections with
	default lma equal to vma.  Warn on backward movement of dot.

Index: ld/NEWS
===================================================================
RCS file: /cvs/src/src/ld/NEWS,v
retrieving revision 1.66
diff -u -p -r1.66 NEWS
--- ld/NEWS	4 Aug 2006 14:53:26 -0000	1.66
+++ ld/NEWS	22 Aug 2006 04:39:19 -0000
@@ -1,4 +1,10 @@
 -*- text -*-
+* The default output section LMA has changed for allocatable sections from
+  being equal to VMA, to keeping the difference between LMA and VMA the same as
+  the previous output section in the same region.  This is a more useful
+  default when using overlays and other cases where you specify an LMA
+  differing from the VMA for some sections.
+
 * New switch: --print-gc-sections to list any sections removed by garabge
   collection.
 
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.171
diff -u -p -r1.171 ld.texinfo
--- ld/ld.texinfo	4 Aug 2006 14:53:26 -0000	1.171
+++ ld/ld.texinfo	22 Aug 2006 04:39:24 -0000
@@ -3764,15 +3764,20 @@ Every section has a virtual address (VMA
 an output section description sets the VMA (@pxref{Output Section
 Address}).
 
-The linker will normally set the LMA equal to the VMA.  You can change
-that by using the @code{AT} keyword.  The expression @var{lma} that
-follows the @code{AT} keyword specifies the load address of the
-section.
+The expression @var{lma} that follows the @code{AT} keyword specifies
+the load address of the section.
 
 Alternatively, with @samp{AT>@var{lma_region}} expression, you may
 specify a memory region for the section's load address. @xref{MEMORY}.
 Note that if the section has not had a VMA assigned to it then the
 linker will use the @var{lma_region} as the VMA region as well.
+
+If neither @code{AT} nor @code{AT>} is specified for an allocatable
+section, the linker will set the LMA such that the difference between
+VMA and LMA for the section is the same as the preceding output
+section in the same region.  If there is no preceding output section
+or the section is not allocatable, the linker will set the LMA equal
+to the VMA.
 @xref{Output Section Region}.
 
 @cindex ROM initialized data
@@ -4586,7 +4591,9 @@ anywhere that an ordinary symbol is allo
 @cindex holes
 Assigning a value to @code{.} will cause the location counter to be
 moved.  This may be used to create holes in the output section.  The
-location counter may never be moved backwards.
+location counter may not be moved backwards inside an output section,
+and may not be moved backwards outside of an output section if so
+doing creates areas with overlapping LMAs.
 
 @smallexample
 SECTIONS
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.234
diff -u -p -r1.234 ldlang.c
--- ld/ldlang.c	16 Aug 2006 08:31:45 -0000	1.234
+++ ld/ldlang.c	22 Aug 2006 04:39:28 -0000
@@ -4400,16 +4400,30 @@ lang_size_sections_1
 		  lma = align_power (lma, os->section_alignment);
 		os->bfd_section->lma = lma;
 	      }
-	    else if (r->last_os != NULL)
+	    else if (r->last_os != NULL
+		     && (os->bfd_section->flags & SEC_ALLOC) != 0)
 	      {
 		bfd_vma lma;
 		asection *last;
 
 		last = r->last_os->output_section_statement.bfd_section;
-		/* If dot moved backwards (which is invalid according
-		   to ld docs) then leave lma equal to vma.  This
-		   keeps users of buggy ld scripts happy.  */
-		if (dot >= last->vma)
+
+		/* A backwards move of dot should be accompanied by
+		   an explicit assignment to the section LMA (ie.
+		   os->load_base set) because backwards moves normally
+		   create overlapping LMAs.  */
+		if (dot < last->vma)
+		  {
+		    einfo (_("%P: warning: dot moved backwards before `%s'\n"),
+			   os->name);
+
+		    /* If dot moved backwards then leave lma equal to
+		       vma.  This is the old default lma, which might
+		       just happen to work when the backwards move is
+		       sufficiently large.  Nag anyway, so people fix
+		       their linker scripts.  */
+		  }
+		else
 		  {
 		    /* If the current vma overlaps the previous section,
 		       then set the current lma to that at the end of
@@ -4440,9 +4454,16 @@ lang_size_sections_1
 	       lma region.  We use this to set the lma for
 	       following sections.  Overlays or other linker
 	       script assignment to lma might mean that the
-	       default lma == vma is incorrect.  */
+	       default lma == vma is incorrect.
+	       To avoid warnings about dot moving backwards when using
+	       -Ttext, don't start tracking sections until we find one
+	       of non-zero size or with lma set differently to vma.  */
 	    if (((os->bfd_section->flags & SEC_HAS_CONTENTS) != 0
 		 || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0)
+		&& (os->bfd_section->flags & SEC_ALLOC) != 0
+		&& (os->bfd_section->size != 0
+		    || os->bfd_section->vma != os->bfd_section->lma
+		    || r->last_os != NULL)
 		&& os->lma_region == NULL
 		&& !link_info.relocatable)
 	      r->last_os = s;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-22 11:51 ` Alan Modra
@ 2006-08-22 18:46   ` H. J. Lu
  2006-08-23  1:55     ` Alan Modra
  2006-08-23  1:34   ` H. J. Lu
  1 sibling, 1 reply; 10+ messages in thread
From: H. J. Lu @ 2006-08-22 18:46 UTC (permalink / raw)
  To: binutils

On Tue, Aug 22, 2006 at 05:03:44PM +0930, Alan Modra wrote:
>  	      {
>  		bfd_vma lma;
>  		asection *last;
>  
>  		last = r->last_os->output_section_statement.bfd_section;
> -		/* If dot moved backwards (which is invalid according
> -		   to ld docs) then leave lma equal to vma.  This
> -		   keeps users of buggy ld scripts happy.  */
> -		if (dot >= last->vma)
> +
> +		/* A backwards move of dot should be accompanied by
> +		   an explicit assignment to the section LMA (ie.
> +		   os->load_base set) because backwards moves normally
> +		   create overlapping LMAs.  */
> +		if (dot < last->vma)
> +		  {
> +		    einfo (_("%P: warning: dot moved backwards before `%s'\n"),
> +			   os->name);
> +
> +		    /* If dot moved backwards then leave lma equal to
> +		       vma.  This is the old default lma, which might
> +		       just happen to work when the backwards move is
> +		       sufficiently large.  Nag anyway, so people fix
> +		       their linker scripts.  */
> +		  }
> +		else
>  		  {


There are 2 issues:

1. It doesn't check if there are overlapping LMAs when warning moving
dot backwards.
2. I don't think we should change lma just because dot is moved
backwards. We can change the affected linker scripts if they can be
made backward compatible.


H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-22 11:51 ` Alan Modra
  2006-08-22 18:46   ` H. J. Lu
@ 2006-08-23  1:34   ` H. J. Lu
  2006-08-23  2:58     ` Alan Modra
  1 sibling, 1 reply; 10+ messages in thread
From: H. J. Lu @ 2006-08-23  1:34 UTC (permalink / raw)
  To: binutils

On Tue, Aug 22, 2006 at 05:03:44PM +0930, Alan Modra wrote:
> On Wed, Jul 26, 2006 at 02:39:14PM +0930, Alan Modra wrote:
> > While playing with overlays recently, I noticed an annoying linker
> > script requirement.  An output section following an overlay must have
> > its lma specified (with AT or AT>).  As must any section following one
> > with an lma adjustment, because ld defaults to setting lma equal to
> > vma and this may cause lma overlap.
> 
> Fixes doco for this change, and warns on backward movement of VMA
> unless accompanied with an explicit LMA assignment.  I guess I should
> have added the news item when I committed the first patch to raise
> awareness of the change in default lma.  Apologies for that, I wasn't
> trying to slip a change in under the radar!  I still feel it's a good
> change for 2.18, one that shouldn't affect too many scripts, and those
> that it does are easily fixed.
> 

I tried AT (.). It seems to generate different outputs comparing with
the old linker.


H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-22 18:46   ` H. J. Lu
@ 2006-08-23  1:55     ` Alan Modra
  2006-08-23  3:47       ` H. J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2006-08-23  1:55 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Aug 22, 2006 at 11:04:15AM -0700, H. J. Lu wrote:
> 1. It doesn't check if there are overlapping LMAs when warning moving
> dot backwards.

That's why it is a warning rather than an error.  I think anyone setting
a section VMA to a value before previous sections ought to also set
section LMA.

> 2. I don't think we should change lma just because dot is moved
> backwards. We can change the affected linker scripts if they can be
> made backward compatible.

Well, yes, I don't really like the exception to the rule.  Are there
released linux kernels that need the old default LMA for their linker
scripts to work?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-23  1:34   ` H. J. Lu
@ 2006-08-23  2:58     ` Alan Modra
  2006-08-23  3:36       ` H. J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2006-08-23  2:58 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Aug 22, 2006 at 11:46:48AM -0700, H. J. Lu wrote:
> On Tue, Aug 22, 2006 at 05:03:44PM +0930, Alan Modra wrote:
> > Fixes doco for this change, and warns on backward movement of VMA
> > unless accompanied with an explicit LMA assignment.  I guess I should
> > have added the news item when I committed the first patch to raise
> > awareness of the change in default lma.  Apologies for that, I wasn't
> > trying to slip a change in under the radar!  I still feel it's a good
> > change for 2.18, one that shouldn't affect too many scripts, and those
> > that it does are easily fixed.
> 
> I tried AT (.). It seems to generate different outputs comparing with
> the old linker.

AT(ADDR(section_name)) is probably better.  AT(.) ignores section
alignment requirements.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-23  2:58     ` Alan Modra
@ 2006-08-23  3:36       ` H. J. Lu
  2006-08-23  5:08         ` PATCH: ld lma assignment test failure H. J. Lu
  0 siblings, 1 reply; 10+ messages in thread
From: H. J. Lu @ 2006-08-23  3:36 UTC (permalink / raw)
  To: binutils

On Wed, Aug 23, 2006 at 11:25:24AM +0930, Alan Modra wrote:
> On Tue, Aug 22, 2006 at 11:46:48AM -0700, H. J. Lu wrote:
> > On Tue, Aug 22, 2006 at 05:03:44PM +0930, Alan Modra wrote:
> > > Fixes doco for this change, and warns on backward movement of VMA
> > > unless accompanied with an explicit LMA assignment.  I guess I should
> > > have added the news item when I committed the first patch to raise
> > > awareness of the change in default lma.  Apologies for that, I wasn't
> > > trying to slip a change in under the radar!  I still feel it's a good
> > > change for 2.18, one that shouldn't affect too many scripts, and those
> > > that it does are easily fixed.
> > 
> > I tried AT (.). It seems to generate different outputs comparing with
> > the old linker.
> 
> AT(ADDR(section_name)) is probably better.  AT(.) ignores section
> alignment requirements.

It seems to work for the testcase. I think we should document it in
case that people want the old behavior.


H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ld lma assignment
  2006-08-23  1:55     ` Alan Modra
@ 2006-08-23  3:47       ` H. J. Lu
  0 siblings, 0 replies; 10+ messages in thread
From: H. J. Lu @ 2006-08-23  3:47 UTC (permalink / raw)
  To: binutils

On Wed, Aug 23, 2006 at 11:22:57AM +0930, Alan Modra wrote:
> On Tue, Aug 22, 2006 at 11:04:15AM -0700, H. J. Lu wrote:
> > 1. It doesn't check if there are overlapping LMAs when warning moving
> > dot backwards.
> 
> That's why it is a warning rather than an error.  I think anyone setting
> a section VMA to a value before previous sections ought to also set
> section LMA.

If that is the case, I'd rather to see an error especially if we decide
not to make an exception for this to switch back the old default LMA.

> 
> > 2. I don't think we should change lma just because dot is moved
> > backwards. We can change the affected linker scripts if they can be
> > made backward compatible.
> 
> Well, yes, I don't really like the exception to the rule.  Are there
> released linux kernels that need the old default LMA for their linker
> scripts to work?

I think at least 2.6.9 kernel uses vsyscall, which expects the old
default LMA.


H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* PATCH: ld lma assignment test failure
  2006-08-23  3:36       ` H. J. Lu
@ 2006-08-23  5:08         ` H. J. Lu
  2006-08-23 10:25           ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: H. J. Lu @ 2006-08-23  5:08 UTC (permalink / raw)
  To: binutils

On Tue, Aug 22, 2006 at 07:45:38PM -0700, H. J. Lu wrote:
> On Wed, Aug 23, 2006 at 11:25:24AM +0930, Alan Modra wrote:
> > On Tue, Aug 22, 2006 at 11:46:48AM -0700, H. J. Lu wrote:
> > > On Tue, Aug 22, 2006 at 05:03:44PM +0930, Alan Modra wrote:
> > > > Fixes doco for this change, and warns on backward movement of VMA
> > > > unless accompanied with an explicit LMA assignment.  I guess I should
> > > > have added the news item when I committed the first patch to raise
> > > > awareness of the change in default lma.  Apologies for that, I wasn't
> > > > trying to slip a change in under the radar!  I still feel it's a good
> > > > change for 2.18, one that shouldn't affect too many scripts, and those
> > > > that it does are easily fixed.
> > > 
> > > I tried AT (.). It seems to generate different outputs comparing with
> > > the old linker.
> > 
> > AT(ADDR(section_name)) is probably better.  AT(.) ignores section
> > alignment requirements.
> 
> It seems to work for the testcase. I think we should document it in
> case that people want the old behavior.
> 
> 

Here is the patch for the 2 failed testcases.


H.J.
---
2006-08-22  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/3052
	* ld-elf/loadaddr1.t: Add "AT (ADDR(.data))".
	* ld-elf/loadaddr2.t: Likewise.

--- ld/testsuite/ld-elf/loadaddr1.t.load	2006-08-18 07:38:00.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr1.t	2006-08-22 20:30:14.000000000 -0700
@@ -8,6 +8,6 @@ SECTIONS
     { *(.bar) }
   . = LOADADDR(.bar) + 4096;
   . = ALIGN(8192);
-  .data : { *(.data) }
+  .data : AT (ADDR(.data)) { *(.data) }
   /DISCARD/ : { *(.*) }
 }
--- ld/testsuite/ld-elf/loadaddr2.t.load	2006-08-18 07:38:00.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr2.t	2006-08-22 20:30:04.000000000 -0700
@@ -8,6 +8,6 @@ SECTIONS
     { *(.bar) }
   . = LOADADDR(.bar) + 0x200000;
   . = ALIGN(8192);
-  .data : { *(.data) }
+  .data : AT (ADDR(.data)) { *(.data) }
   /DISCARD/ : { *(.*) }
 }

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: PATCH: ld lma assignment test failure
  2006-08-23  5:08         ` PATCH: ld lma assignment test failure H. J. Lu
@ 2006-08-23 10:25           ` Alan Modra
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Modra @ 2006-08-23 10:25 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

On Tue, Aug 22, 2006 at 08:36:08PM -0700, H. J. Lu wrote:
> 	PR ld/3052
> 	* ld-elf/loadaddr1.t: Add "AT (ADDR(.data))".
> 	* ld-elf/loadaddr2.t: Likewise.

Thanks, please commit.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-08-23  5:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-26  5:09 ld lma assignment Alan Modra
2006-08-22 11:51 ` Alan Modra
2006-08-22 18:46   ` H. J. Lu
2006-08-23  1:55     ` Alan Modra
2006-08-23  3:47       ` H. J. Lu
2006-08-23  1:34   ` H. J. Lu
2006-08-23  2:58     ` Alan Modra
2006-08-23  3:36       ` H. J. Lu
2006-08-23  5:08         ` PATCH: ld lma assignment test failure H. J. Lu
2006-08-23 10:25           ` Alan Modra

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).