This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: The current linker failed to generate working Linux kernel
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 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.
> Also, for orphan sections we've kept lma-vma the same as previous
> sections since 2002-12-05.
>
One of 2 testcases in my patch fails with the current linker. That is
a regression. None of the linker scripts in my testcases use overlay.
I think the new havior should be limited to overlay only.
Here is a patch with testcases only.
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/ : { *(.*) }
+}