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]

PATCH: 2 ld testcases for lma/vma


On Thu, Aug 17, 2006 at 10:50:39AM +0930, Alan Modra wrote:
> On Wed, Aug 16, 2006 at 11:26:35AM -0700, H. J. Lu wrote:
> > 	PR ld/3052
> > 	* ldlang.c (lang_size_sections_1): Don't change lma unless the
> > 	current vma overlaps the previous section.
> 
> Not OK.  The main reason I added this code was to make using overlays
> simpler.  See http://sourceware.org/ml/binutils/2006-07/msg00314.html
> Your patch means that all loaded sections after an overlay would again
> need to have their lma specified, which is a pain.

I don't see why all loaded sections after an overlay have to have the
same lma and vma relationship as the overlay. Do you have an example
for this? Some testcases to showe befor and after your change will be
nice. 

> 
> I think the new default of keeping the lma to vma relationship the same
> as previous sections is a much better default than setting lma equal to
> vma.  (Of course, scripts that never specify lma will be unaffected
> since the "previous section" will have lma equal to vma.)  The new
> default should allow many ld scripts that specify lmas to be simplified.

I believe it is wrong, especially when overlay isn't used. According
to the linker manual:

   The linker will normally set the LMA equal to the VMA.  You can
   change that by using the `AT' keyword.  The expression LMA that
   follows the `AT' keyword specifies the load address of the section.

The current linker makes the above untrue. I will check in 2 testases
enclosed here  if there are no objections.

BTW, about moving dot backwards, this example from the linker manual

       .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
       __load_start_text0 = LOADADDR (.text0);
       __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
       .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
       __load_start_text1 = LOADADDR (.text1);
       __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
       . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));

seems to move dot backwards implicitly when 2 sections are placed at
the same address.


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

	PR ld/3052
	* ld-elf/loadaddr.s: New file.
	* ld-elf/loadaddr1.d: Likewise.
	* ld-elf/loadaddr1.t: Likewise.
	* ld-elf/loadaddr2.d: Likewise.
	* ld-elf/loadaddr2.t: Likewise.

--- ld/testsuite/ld-elf/loadaddr.s.loadaddr	2006-08-16 09:52:59.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr.s	2006-08-16 09:18:31.000000000 -0700
@@ -0,0 +1,16 @@
+	.text
+	.globl main
+	.globl start
+	.globl _start
+	.globl __start
+main:
+start:
+_start:
+__start:
+	.byte 0
+	.section .bar,"ax","progbits"
+	.byte 0
+	.section .foo,"aw","progbits"
+	.byte 0
+	.data
+	.byte 0
--- ld/testsuite/ld-elf/loadaddr1.d.loadaddr	2006-08-16 09:52:59.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr1.d	2006-08-16 09:42:20.000000000 -0700
@@ -0,0 +1,10 @@
+#source: loadaddr.s
+#ld: -T loadaddr1.t -z max-page-size=0x200000
+#readelf: -l --wide
+#target: *-*-linux*
+
+#...
+  LOAD +0x000000 0xf*80000000 0xf*80000000 0x100041 0x100041 RWE 0x200000
+  LOAD +0x200000 0xf*ff600000 0xf*80101000 0x0*1 0x0*1 R E 0x200000
+  LOAD +0x302000 0xf*80102000 0xf*80102000 0x0*1 0x0*1 RW  0x200000
+#pass
--- ld/testsuite/ld-elf/loadaddr1.t.loadaddr	2006-08-16 09:52:59.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr1.t	2006-08-16 09:12:08.000000000 -0700
@@ -0,0 +1,13 @@
+SECTIONS
+{
+  . = -0x7ff00000;
+  .text : {*(.text .text.*)}
+  . = ALIGN(64);
+  .foo : { *(.foo) }
+  .bar -0xa00000 : AT ((LOADADDR(.foo) + SIZEOF(.foo) + 4095) & ~(4095))
+    { *(.bar) }
+  . = LOADADDR(.bar) + 4096;
+  . = ALIGN(8192);
+  .data : { *(.data) }
+  /DISCARD/ : { *(.*) }
+}
--- ld/testsuite/ld-elf/loadaddr2.d.loadaddr	2006-08-16 09:52:59.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr2.d	2006-08-16 09:51:43.000000000 -0700
@@ -0,0 +1,10 @@
+#source: loadaddr.s
+#ld: -T loadaddr2.t -z max-page-size=0x200000
+#readelf: -l --wide
+#target: *-*-linux*
+
+#...
+  LOAD +0x000000 0xf*80000000 0xf*80000000 0x100041 0x100041 RWE 0x200000
+  LOAD +0x110000 0xf*80110000 0xf*80101000 0x0*1 0x0*1 R E 0x200000
+  LOAD +0x302000 0xf*80302000 0xf*80302000 0x0*1 0x0*1 RW  0x200000
+#pass
--- ld/testsuite/ld-elf/loadaddr2.t.loadaddr	2006-08-16 09:52:59.000000000 -0700
+++ ld/testsuite/ld-elf/loadaddr2.t	2006-08-16 09:50:05.000000000 -0700
@@ -0,0 +1,13 @@
+SECTIONS
+{
+  . = -0x7ff00000;
+  .text : {*(.text .text.*)}
+  . = ALIGN(64);
+  .foo : { *(.foo) }
+  .bar -0x7fef0000 : AT ((LOADADDR(.foo) + SIZEOF(.foo) + 4095) & ~(4095))
+    { *(.bar) }
+  . = LOADADDR(.bar) + 0x200000;
+  . = ALIGN(8192);
+  .data : { *(.data) }
+  /DISCARD/ : { *(.*) }
+}


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