* lib/ld-lib.exp (run_dump_test): Add -L$srcdir/$subdir.
authorRichard Sandiford <rdsandiford@googlemail.com>
Tue, 7 May 2002 11:08:57 +0000 (11:08 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Tue, 7 May 2002 11:08:57 +0000 (11:08 +0000)
(is_elf_format): New, extracted from...
* ld-scripts/weak.exp: ...here.
* ld-scripts/overlay-size.exp: New test.
* ld-scripts/overlay-size.[tsd],
* ld-scripts/overlay-size-map.d: New files for it.

ld/testsuite/ChangeLog
ld/testsuite/ld-scripts/overlay-size-map.d [new file with mode: 0644]
ld/testsuite/ld-scripts/overlay-size.d [new file with mode: 0644]
ld/testsuite/ld-scripts/overlay-size.exp [new file with mode: 0644]
ld/testsuite/ld-scripts/overlay-size.s [new file with mode: 0644]
ld/testsuite/ld-scripts/overlay-size.t [new file with mode: 0644]
ld/testsuite/ld-scripts/weak.exp
ld/testsuite/lib/ld-lib.exp

index b65e4f718f038d8aed0b130737977f68a5b8f365..0bdf71f65d76462204f09ab7e6e0e5092de8d3d7 100644 (file)
@@ -1,3 +1,12 @@
+2002-05-07  Richard Sandiford  <rsandifo@redhat.com>
+
+       * lib/ld-lib.exp (run_dump_test): Add -L$srcdir/$subdir.
+       (is_elf_format): New, extracted from...
+       * ld-scripts/weak.exp: ...here.
+       * ld-scripts/overlay-size.exp: New test.
+       * ld-scripts/overlay-size.[tsd],
+       * ld-scripts/overlay-size-map.d: New files for it.
+
 2002-05-02  Richard Sandiford  <rsandifo@redhat.com>
 
        * ld-scripts/map-address.exp: Quote conditions.
diff --git a/ld/testsuite/ld-scripts/overlay-size-map.d b/ld/testsuite/ld-scripts/overlay-size-map.d
new file mode 100644 (file)
index 0000000..3607169
--- /dev/null
@@ -0,0 +1,23 @@
+#...
+\.bss1 *0x0*20000 *0x10
+#...
+\.bss2 *0x0*20000 *0x30 load address 0x0*20010
+#...
+\.bss3 *0x0*20000 *0x20 load address 0x0*20040
+#...
+\.mtext *0x0*10000 *0x20 load address 0x0*30000
+#...
+\.mbss *0x0*20030 *0x230 load address 0x0*20060
+#...
+\.text1 *0x0*10020 *0x80 load address 0x0*30020
+#...
+\.text2 *0x0*10020 *0x40 load address 0x0*300a0
+#...
+\.text3 *0x0*10020 *0x20 load address 0x0*300e0
+#...
+\.data1 *0x0*20260 *0x30 load address 0x0*30100
+#...
+\.data2 *0x0*20260 *0x40 load address 0x0*30130
+#...
+\.data3 *0x0*20260 *0x50 load address 0x0*30170
+#pass
diff --git a/ld/testsuite/ld-scripts/overlay-size.d b/ld/testsuite/ld-scripts/overlay-size.d
new file mode 100644 (file)
index 0000000..cf1f5e8
--- /dev/null
@@ -0,0 +1,29 @@
+# ld: -T overlay-size.t -Map tmpdir/overlay-size.map
+# name: overlay size
+# objdump: --headers
+#
+# The .bss[123] LMAs are deliberately blanked out.  We can't
+# reliably map overlaid sections to segments.
+#...
+  0 \.bss1 +0+010 +0+20000 .*
+#...
+  1 \.bss2 +0+030 +0+20000 .*
+#...
+  2 \.bss3 +0+020 +0+20000 .*
+#...
+  3 \.mtext +0+020 +0+10000 +0+30000 .*
+#...
+  4 \.mbss +0+230 +0+20030 +0+20060 .*
+#...
+  5 \.text1 +0+080 +0+10020 +0+30020 .*
+#...
+  6 \.text2 +0+040 +0+10020 +0+300a0 .*
+#...
+  7 \.text3 +0+020 +0+10020 +0+300e0 .*
+#...
+  8 \.data1 +0+030 +0+20260 +0+30100 .*
+#...
+  9 \.data2 +0+040 +0+20260 +0+30130 .*
+#...
+ 10 \.data3 +0+050 +0+20260 +0+30170 .*
+#pass
diff --git a/ld/testsuite/ld-scripts/overlay-size.exp b/ld/testsuite/ld-scripts/overlay-size.exp
new file mode 100644 (file)
index 0000000..e44466a
--- /dev/null
@@ -0,0 +1,31 @@
+# Test the OVERLAY statement.
+# Copyright 2002 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if ![is_elf_format] {
+    return
+}
+
+run_dump_test overlay-size
+
+set testname "overlay size (map check)"
+
+if [regexp_diff "tmpdir/overlay-size.map" \
+               "$srcdir/$subdir/overlay-size-map.d"] {
+    fail $testname
+} else {
+    pass $testname
+}
diff --git a/ld/testsuite/ld-scripts/overlay-size.s b/ld/testsuite/ld-scripts/overlay-size.s
new file mode 100644 (file)
index 0000000..5428c97
--- /dev/null
@@ -0,0 +1,25 @@
+       .section .bss1, "aw", "nobits"
+       .space 0x10
+       .section .bss2, "aw", "nobits"
+       .space 0x30
+       .section .bss3, "aw", "nobits"
+       .space 0x20
+
+       .section .text1, "ax", "progbits"
+       .space 0x80
+       .section .text2, "ax", "progbits"
+       .space 0x40
+       .section .text3, "ax", "progbits"
+       .space 0x20
+
+       .section .data1, "aw", "progbits"
+       .space 0x30
+       .section .data2, "aw", "progbits"
+       .space 0x40
+       .section .data3, "aw", "progbits"
+       .space 0x50
+
+       .section .mtext, "ax", "progbits"
+       .space 0x20
+       .section .mbss, "aw", "nobits"
+       .space 0x30
diff --git a/ld/testsuite/ld-scripts/overlay-size.t b/ld/testsuite/ld-scripts/overlay-size.t
new file mode 100644 (file)
index 0000000..f7ffbbb
--- /dev/null
@@ -0,0 +1,57 @@
+MEMORY
+{
+  TEXTMEM (ARX) : ORIGIN = 0x10000, LENGTH = 32K
+  DATAMEM (AW)  : ORIGIN = 0x20000, LENGTH = 32K
+  LOADMEM (AW)  : ORIGIN = 0x30000, LENGTH = 32K
+}
+
+/* Map should be:
+
+           SIZE    VMA    LMA
+   .bss1     10  20000  20000
+   .bss2     30  20000  20010
+   .bss3     20  20000  20040
+   .mbss    230  20030  20060
+
+   .mtext    20  10000  30000
+   .text1    80  10020  30020
+   .text2    40  10020  300a0
+   .text3    20  10020  300e0
+
+   .data1    30  20260  30100
+   .data2    40  20260  30130
+   .data3    50  20260  30170  */
+
+SECTIONS
+{
+  OVERLAY : 
+    {
+      .bss1 { *(.bss1) }
+      .bss2 { *(.bss2) }
+      .bss3 { *(.bss3) }
+    } > DATAMEM
+
+  .mtext : { *(.mtext) } > TEXTMEM AT > LOADMEM
+
+  .mbss : AT (__load_stop_bss3)
+    {
+      *(.mbss)
+      . += 0x200;
+    } > DATAMEM
+
+  OVERLAY :
+    {
+      .text1 { *(.text1) }
+      .text2 { *(.text2) }
+      .text3 { *(.text3) }
+    } > TEXTMEM AT > LOADMEM
+
+  OVERLAY :
+    {
+      .data1 { *(.data1) }
+      .data2 { *(.data2) }
+      .data3 { *(.data3) }
+    } > DATAMEM AT > LOADMEM
+
+  . = 0x8000;
+}
index f5d6e20572037650c6e4e3c28404c057c2e9f5de..3167ea45fedfe13d50a0d756467f739f6cc46ff9 100644 (file)
@@ -21,22 +21,10 @@ set testname "weak symbols"
 
 # This test only works for ELF targets.  It ought to work for some
 # a.out targets, but it doesn't.
-
-if { ![istarget *-*-sysv4*] \
-     && ![istarget *-*-unixware*] \
-     && ![istarget *-*-elf*] \
-     && ![istarget *-*-eabi*] \
-     && ![istarget *-*-linux*] \
-     && ![istarget *-*-irix5*] \
-     && ![istarget *-*-irix6*] \
-     && ![istarget *-*-solaris2*] } then {
+if ![is_elf_format] {
     return
 }
 
-if { [istarget *-*-linux*aout*] \
-     || [istarget *-*-linux*oldld*] } {
-    return
-}
 
 if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
     || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
index 06583e55bb6f2a41957b94064016252bb4212bd0..418c00013db3d66bcaffe9b07f2055cb3bc50faf 100644 (file)
@@ -322,6 +322,29 @@ proc default_ld_nm { nm nmflags object } {
     }
 }
 
+#
+# is_elf_format
+#      true if the object format is known to be ELF
+#
+proc is_elf_format {} {
+    if { ![istarget *-*-sysv4*] \
+        && ![istarget *-*-unixware*] \
+        && ![istarget *-*-elf*] \
+        && ![istarget *-*-eabi*] \
+        && ![istarget *-*-linux*] \
+        && ![istarget *-*-irix5*] \
+        && ![istarget *-*-irix6*] \
+        && ![istarget *-*-solaris2*] } {
+       return 0
+    }
+
+    if { [istarget *-*-linux*aout*] \
+        || [istarget *-*-linux*oldld*] } {
+       return 0
+    }
+    return 1
+}
+
 #
 # simple_diff
 #      compares two files line-by-line
@@ -685,7 +708,11 @@ proc run_dump_test { name } {
     # Perhaps link the file(s).
     if { $run_ld } {
        set objfile "tmpdir/dump"
-       set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
+
+       # Add -L$srcdir/$subdir so that the linker command can use
+       # linker scripts in the source directory.
+       set cmd "$LD $LDFLAGS -L$srcdir/$subdir \
+                  $opts(ld) -o $objfile $objfiles"
 
        send_log "$cmd\n"
        set cmdret [catch "exec $cmd" comp_output]