(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-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.
--- /dev/null
+#...
+\.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
--- /dev/null
+# 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
--- /dev/null
+# 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
+}
--- /dev/null
+ .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
--- /dev/null
+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;
+}
# 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 {
}
}
+#
+# 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
# 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]