aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/lib/ld.exp
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/lib/ld.exp')
-rw-r--r--ld/testsuite/lib/ld.exp90
1 files changed, 90 insertions, 0 deletions
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