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]

Resetting LMA for new VMAs


This patch addresses a problem I found with the attached linker script. The current behaviour places '.reset's LMA so as to maintain the same delta from the previous section as the VMA delta:

  0 .text         00000004  00001000  00001000  00001000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000004  00000010  00001004  00001010  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .reset        00000004  0000fffc  00010ff0  00001ffc  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE


but that's a surprise (especially if .reset is really at the top of the address space, in which case its LMA is set somewhere in the middle of the address space). With this patch we get:


  0 .text         00000004  00001000  00001000  00001000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000004  00000010  00001004  00001010  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .reset        00000004  0000fffc  0000fffc  00001ffc  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE

I'm not sure if this will have a deleterious effect on linker scripts that I'm unaware of though. Perhaps some scripts that have displaced LMAs explicitly set the VMA to be just after the previous section, and expect the current behaviour.
Testing on i686-linux shows no problems.


Thoughts? (if approved I'll wrap up the script as a test case, of course)

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery

2008-04-04  Nathan Sidwell  <nathan@codesourcery.com>

	* ldlang.c (lang_size_sections_1): If a section has a new VMA
	reset the LMA unless it's specified explicitly.

Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.283
diff -c -3 -p -r1.283 ldlang.c
*** ldlang.c	22 Feb 2008 14:19:43 -0000	1.283
--- ldlang.c	4 Apr 2008 11:11:19 -0000
*************** lang_size_sections_1
*** 4635,4640 ****
--- 4635,4644 ----
  		    if (os->sectype == overlay_section)
  		      lma = last->lma + last->size;
  
+ 		    /* If there was a new VMA, set the LMA.  */
+ 		    else if (os->addr_tree)
+ 		      lma = dot;
+ 
  		    /* Otherwise, keep the same lma to vma relationship
  		       as the previous section.  */
  		    else
SECTIONS {
	 .text 0x1000 : { *(.text) }
	 .data 0x0010 : AT (ADDR(.text)+SIZEOF(.text)) { *(.data) }
	 .reset 0xfffc : { *(.reset) }
}
	.text
	.long 0
	.data
	.long 0
	.section ".reset","ax"
	.long 0
	

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