aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1994-09-28 00:06:27 +0000
committerIan Lance Taylor <ian@airs.com>1994-09-28 00:06:27 +0000
commit9de5523bb6f20557d5bc61697293be73233f8368 (patch)
treed6fd773ca0827570e3a1278e392084cfa8e43609 /ld/testsuite
parent8352254c2ee7cb1ffcf434550c177b06c54e4202 (diff)
downloadgdb-9de5523bb6f20557d5bc61697293be73233f8368.zip
gdb-9de5523bb6f20557d5bc61697293be73233f8368.tar.gz
gdb-9de5523bb6f20557d5bc61697293be73233f8368.tar.bz2
* ld.scripts: New directory.
* ld.scripts/defined.exp, ld.scripts/defined.s: New files. * ld.scripts/defined.t: New file. * lib/ld.exp (default_ld_simple_link): New function. (default_ld_assemble, default_ld_nm): New functions. * config/default.exp: Rename from unix-ld.exp. (ld_simple_link, ld_assemble, ld_nm): New functions.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/.Sanitize1
-rw-r--r--ld/testsuite/ChangeLog8
-rw-r--r--ld/testsuite/config/.Sanitize2
-rw-r--r--ld/testsuite/config/default.exp (renamed from ld/testsuite/config/unix-ld.exp)24
-rw-r--r--ld/testsuite/ld.scripts/.Sanitize38
-rw-r--r--ld/testsuite/ld.scripts/defined.exp34
-rw-r--r--ld/testsuite/ld.scripts/defined.s2
-rw-r--r--ld/testsuite/ld.scripts/defined.t5
-rw-r--r--ld/testsuite/lib/ld.exp90
9 files changed, 203 insertions, 1 deletions
diff --git a/ld/testsuite/.Sanitize b/ld/testsuite/.Sanitize
index b3d3a71..19c4f45 100644
--- a/ld/testsuite/.Sanitize
+++ b/ld/testsuite/.Sanitize
@@ -28,6 +28,7 @@ config
lib
ld.bootstrap
ld.cdtest
+ld.scripts
Things-to-lose:
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 12c1920..f2df1ea 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,13 @@
Tue Sep 27 14:59:51 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
+ * ld.scripts: New directory.
+ * ld.scripts/defined.exp, ld.scripts/defined.s: New files.
+ * ld.scripts/defined.t: New file.
+ * lib/ld.exp (default_ld_simple_link): New function.
+ (default_ld_assemble, default_ld_nm): New functions.
+ * config/default.exp: Rename from unix-ld.exp.
+ (ld_simple_link, ld_assemble, ld_nm): New functions.
+
* config/unix-ld.exp: Set ld using findfile.
* lib/ld.exp (default_ld_relocate): Return a value. Change format
of log messages.
diff --git a/ld/testsuite/config/.Sanitize b/ld/testsuite/config/.Sanitize
index 291f4a9..298cac8 100644
--- a/ld/testsuite/config/.Sanitize
+++ b/ld/testsuite/config/.Sanitize
@@ -23,7 +23,7 @@ Do-first:
Things-to-keep:
-unix-ld.exp
+default.exp
Things-to-lose:
diff --git a/ld/testsuite/config/unix-ld.exp b/ld/testsuite/config/default.exp
index 99ffb53..bdf3b08 100644
--- a/ld/testsuite/config/unix-ld.exp
+++ b/ld/testsuite/config/default.exp
@@ -93,6 +93,14 @@ proc ld_link { ld target objects } {
}
#
+# ld_simple_link
+# link a program using ld, without including any libraries
+#
+proc ld_simple_link { ld target objects } {
+ default_ld_simple_link $ld $target $objects
+}
+
+#
# ld_compile
# compile an object using $cc
#
@@ -101,6 +109,22 @@ proc ld_compile { cc source object } {
}
#
+# ld_assemble
+# assemble a file
+#
+proc ld_assemble { as source object } {
+ default_ld_assemble $as $source $object
+}
+
+#
+# ld_nm
+# run nm on a file
+#
+proc ld_nm { nm object } {
+ default_ld_nm $nm $object
+}
+
+#
# ld_exec
# execute ithe target
#
diff --git a/ld/testsuite/ld.scripts/.Sanitize b/ld/testsuite/ld.scripts/.Sanitize
new file mode 100644
index 0000000..3f2a02e
--- /dev/null
+++ b/ld/testsuite/ld.scripts/.Sanitize
@@ -0,0 +1,38 @@
+# .Sanitize for ld dejagnu testsuites
+
+# Each directory to survive it's way into a release will need a file
+# like this one called "./.Sanitize". All keyword lines must exist,
+# and must exist in the order specified by this file. Each directory
+# in the tree will be processed, top down, in the following order..
+
+# Hash started lines like this one are comments and will be deleted
+# before anything else is done. Blank lines will also be squashed
+# out.
+
+# The lines between the "Do-first:" line and the "Things-to-keep:"
+# line are executed as a /bin/sh shell script before anything else is
+# done in this directory.
+
+Do-first:
+
+# All files listed between the "Things-to-keep:" line and the
+# "Do-last:" line will be kept. All other files will be removed.
+# Directories listed in this section will have their own Sanitize
+# called. Directories not listed will be removed in their entirety
+# with rm -rf.
+
+Things-to-keep:
+
+defined.exp
+defined.s
+defined.t
+
+Things-to-lose:
+
+# The lines between the "Do-last:" line and the end of the file
+# are executed as a /bin/sh shell script after everything else is
+# done.
+
+Do-last:
+
+#eof
diff --git a/ld/testsuite/ld.scripts/defined.exp b/ld/testsuite/ld.scripts/defined.exp
new file mode 100644
index 0000000..d551f08
--- /dev/null
+++ b/ld/testsuite/ld.scripts/defined.exp
@@ -0,0 +1,34 @@
+# Test DEFINED in a linker script.
+# By Ian Lance Taylor, Cygnus Support.
+
+if ![file isdirectory tmpdir] {catch "exec mkdir tmpdir" status}
+
+set as [findfile $base_dir/../gas/as.new $base_dir/../gas/as.new [transform as]]
+set nm [findfile $base_dir/../binutils/nm.new $base_dir/../binutils/nm.new [transform nm]]
+
+if ![ld_assemble $as $srcdir$subdir/defined.s tmpdir/def.o] { return }
+
+set prms_id 5699
+
+if ![ld_simple_link $ld tmpdir/def "-T $srcdir$subdir/defined.t tmpdir/def.o"] {
+ fail DEFINED
+} else {
+ if [ld_nm $nm tmpdir/def] {
+ if {![info exists nm_output(value1)] \
+ || ![info exists nm_output(value2)]} {
+ perror "bad output from $nm"
+ } else {
+ if {$nm_output(value1) != 1} {
+ fail "DEFINED (value1 == $nm_output(value1))"
+ } else {
+ if {$nm_output(value2) != 2} {
+ fail "DEFINED (value2 == $nm_output(value2))"
+ } else {
+ pass DEFINED
+ }
+ }
+ }
+ }
+}
+
+set prms_id 0
diff --git a/ld/testsuite/ld.scripts/defined.s b/ld/testsuite/ld.scripts/defined.s
new file mode 100644
index 0000000..a364bbb
--- /dev/null
+++ b/ld/testsuite/ld.scripts/defined.s
@@ -0,0 +1,2 @@
+ .globl defined
+ defined = 1
diff --git a/ld/testsuite/ld.scripts/defined.t b/ld/testsuite/ld.scripts/defined.t
new file mode 100644
index 0000000..d1e4748
--- /dev/null
+++ b/ld/testsuite/ld.scripts/defined.t
@@ -0,0 +1,5 @@
+SECTIONS {
+ .text : { *(.text) }
+}
+value1 = DEFINED (defined) ? 1 : 2;
+value2 = DEFINED (undefined) ? 1 : 2;
diff --git a/ld/testsuite/lib/ld.exp b/ld/testsuite/lib/ld.exp
index ee395c2..039bee6 100644
--- a/ld/testsuite/lib/ld.exp
+++ b/ld/testsuite/lib/ld.exp
@@ -75,6 +75,30 @@ proc default_ld_link { ld target objects } {
}
#
+# default_ld_simple_link
+# link a program using ld, without including any libraries
+#
+proc default_ld_simple_link { ld target objects } {
+
+ if { [file exists $ld] == 0 } then {
+ perror "$ld does not exist"
+ return 0
+ }
+
+ send_log "$ld -o $target $objects\n"
+ verbose "$ld -o $target $objects"
+
+ catch "exec $ld -o $target $objects" exec_output
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ return 0
+ }
+}
+
+#
# default_ld_compile
# compile an object using cc
#
@@ -103,6 +127,72 @@ proc default_ld_compile { cc source object } {
}
#
+# default_ld_assemble
+# assemble a file
+#
+proc default_ld_assemble { as source object } {
+ global ASFLAGS
+
+ if {[which $as] == 0} then {
+ perror "$as does not exist"
+ return 0
+ }
+
+ if ![info exists ASFLAGS] { set ASFLAGS "" }
+
+ send_log "$as $ASFLAGS -o $object $source\n"
+ verbose "$as $ASFLAGS -o $object $source"
+
+ catch "exec $as $ASFLAGS -o $object $source" exec_output
+ if [string match "" $exec_output] then {
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose "$exec_output"
+ perror "$source: assembly failed"
+ return 0
+ }
+}
+
+#
+# default_ld_nm
+# run nm on a file, putting the result in the array nm_output
+#
+proc default_ld_nm { nm object } {
+ global NMFLAGS
+ global nm_output
+
+ if {[which $nm] == 0} then {
+ perror "$nm does not exist"
+ return 0
+ }
+
+ if ![info exists NMFLAGS] { set NMFLAGS "" }
+
+ send_log "$nm $NMFLAGS $object >tmpdir/nm.out\n"
+ verbose "$nm $NMFLAGS $object >tmpdir/nm.out"
+
+ catch "exec $nm $NMFLAGS $object >tmpdir/nm.out" exec_output
+ if [string match "" $exec_output] then {
+ set file [open tmpdir/nm.out r]
+ while { [gets $file line] != -1 } {
+ verbose "$line" 2
+ if [regexp "^(\[0-9a-fA-F\]+) \[a-zA-Z0-9\] (.+)$" $line whole value name] {
+ verbose "Setting nm_output($name) to 0x$value" 2
+ set nm_output($name) 0x$value
+ }
+ }
+ close $file
+ return 1
+ } else {
+ send_log "$exec_output\n"
+ verbose $exec_output
+ perror "$object: nm failed"
+ return 0
+ }
+}
+
+#
# simple_diff
# compares two files line-by-line
# returns differences if exist