]> oss.titaniummirror.com Git - msp430-binutils.git/blobdiff - binutils/testsuite/binutils-all/objcopy.exp
Merge commit 'upstream/2.20'
[msp430-binutils.git] / binutils / testsuite / binutils-all / objcopy.exp
index e05e622fb26e60ad9f4a39abc6addeb9cc9b7097..de9b11670eaf9d12034662fa53ff1d55047332e5 100644 (file)
@@ -1,5 +1,5 @@
 #   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-#   2004, 2006, 2007
+#   2004, 2006, 2007, 2009
 #   Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -194,7 +194,7 @@ if ![string match "" $got] then {
                verbose $line
                fail "objcopy -O srec"
            } else {
-               set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${copyfile}.srec"]
+               set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -f ${srecfile}"]
                if ![regexp "file format srec" $got] then {
                    send_log "objdump failed\n"
                    fail "objcopy -O srec"
@@ -485,6 +485,7 @@ proc copy_setup { } {
     global subdir
     global gcc_gas_flag
     global test_prog
+    global host_triplet
     
     set res [build_wrapper testglue.o]
     set flags { debug }
@@ -513,8 +514,11 @@ proc copy_setup { } {
     set status [lindex $result 0]
 
     if { $status != "pass"  } {
-       send_log "cannot run executable, status = ${status}\n"
-       return 3
+       send_log "cannot run executable, status = ${status} on ${host_triplet}\n"
+       if { [istarget $host_triplet] } {
+         return 3
+       }
+      set status "pass"
     }
 
     return 0
@@ -524,6 +528,7 @@ proc copy_setup { } {
 
 proc copy_executable { prog flags test1 test2 } {
     global test_prog
+    global host_triplet
 
     if [is_remote host] {
        set testfile [remote_download host tmpdir/$test_prog]
@@ -578,6 +583,8 @@ proc copy_executable { prog flags test1 test2 } {
        setup_xfail "arm*-*-pe"
        setup_xfail "thumb*-*-coff"
        setup_xfail "thumb*-*-pe"
+       setup_xfail "x86_64-*-mingw*"
+       setup_xfail "*-*-cygwin*"
     
        fail $test1
     }
@@ -588,6 +595,9 @@ proc copy_executable { prog flags test1 test2 } {
 
     set output [remote_load target tmpdir/copyprog]
     set status [lindex $output 0]
+    if { ![istarget $host_triplet] } {
+      set status "pass"
+    }
     if { $status != "pass" } {
        fail $test2
     } else {
@@ -600,7 +610,9 @@ proc copy_executable { prog flags test1 test2 } {
 proc strip_executable { prog flags test } {
     global NM
     global NMFLAGS
+    global host_triplet
 
+    remote_file build delete tmpdir/striprog
     remote_download build tmpdir/copyprog tmpdir/striprog
     if [is_remote host] {
        set copyfile [remote_download host tmpdir/striprog]
@@ -620,6 +632,9 @@ proc strip_executable { prog flags test } {
 
     set result [remote_load target tmpdir/striprog]
     set status [lindex $result 0]
+    if { ![istarget $host_triplet] } {
+      set status "pass"
+    }
     if { $status != "pass" } {
        fail $test
         return
@@ -638,7 +653,9 @@ proc strip_executable { prog flags test } {
 proc strip_executable_with_saving_a_symbol { prog flags test } {
     global NM
     global NMFLAGS
+    global host_triplet
 
+    remote_file build delete tmpdir/striprog
     remote_download build tmpdir/copyprog tmpdir/striprog
     if [is_remote host] {
        set copyfile [remote_download host tmpdir/striprog]
@@ -658,6 +675,9 @@ proc strip_executable_with_saving_a_symbol { prog flags test } {
 
     set result [remote_load target tmpdir/striprog]
     set status [lindex $result 0]
+    if { ![istarget $host_triplet] } {
+      set status "pass"
+    }
     if { $status != "pass" } {
        fail $test
         return
@@ -681,10 +701,41 @@ proc strip_executable_with_saving_a_symbol { prog flags test } {
     pass $test
 }
 
+# Test keeping only debug symbols of an executable
+
+proc keep_debug_symbols_and_test_copy { prog1 flags1 test1 prog2 flags2 test2 } {
+    global NM
+    global NMFLAGS
+
+    remote_file build delete tmpdir/striprog
+    remote_download build tmpdir/copyprog tmpdir/striprog
+    if [is_remote host] {
+       set copyfile [remote_download host tmpdir/striprog]
+    } else {
+       set copyfile tmpdir/striprog
+    }
+
+    set exec_output [binutils_run $prog1 "$flags1 ${copyfile}"]
+    if ![string match "" $exec_output] {
+       fail $test1
+       return
+    }
+    pass $test1
+
+    set exec_output [binutils_run $prog2 "$flags2 ${copyfile}"]
+    if ![string match "" $exec_output] {
+       fail $test2
+       return
+    }
+    pass $test2
+}
+
 set test1 "simple objcopy of executable"
 set test2 "run objcopy of executable"
 set test3 "run stripped executable"
 set test4 "run stripped executable with saving a symbol"
+set test5 "keep only debug data"
+set test6 "simple objcopy of debug data"
 
 switch [copy_setup] {
     "1" {
@@ -695,17 +746,23 @@ switch [copy_setup] {
        untested $test2
        untested $test3
        untested $test4
+       untested $test5
+       untested $test6
     }
     "3" {
        copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" ""
        unsupported $test2
        unsupported $test3
        unsupported $test4
+       unsupported $test5
+       unsupported $test6
     }
     "0" {
        copy_executable "$OBJCOPY" "$OBJCOPYFLAGS" "$test1" "$test2"
        strip_executable "$STRIP" "$STRIPFLAGS" "$test3"
        strip_executable_with_saving_a_symbol "$STRIP" "-K main -K _main $STRIPFLAGS" "$test4"
+       keep_debug_symbols_and_test_copy "$STRIP" "--only-keep-debug $STRIPFLAGS" "$test5" \
+                                        "$OBJCOPY" "$OBJCOPYFLAGS" "$test6"
     }
 }
 
@@ -722,23 +779,32 @@ proc objcopy_test_readelf {testname srcfile} {
     }
 
     verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"
-    catch "exec $OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" exec_output
-    if ![string match "" $exec_output] then {
+    set exec_output [remote_exec host "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o"]
+    if { [lindex $exec_output 0] != 0
+        || ![string match "" [lindex $exec_output 1]] } then {
        fail "objcopy ($testname)"
        return
     }
 
     verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out"
-    catch "exec $READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" exec_output
-    set exec_output [prune_warnings $exec_output]
+    set exec_output [remote_exec host "$READELF -a tmpdir/bintest.o" "" "/dev/null" "tmpdir/bintest.o.out"]
+    if { [lindex $exec_output 0] != 0 } then {
+       unresolved "objcopy ($testname)"
+       return
+    }
+    set exec_output [prune_warnings [lindex $exec_output 1]]
     if ![string match "" $exec_output] then {
        unresolved "objcopy ($testname)"
        return
     }
 
     verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out"
-    catch "exec $READELF -a tmpdir/copy.o > tmpdir/copy.o.out" exec_output
-    set exec_output [prune_warnings $exec_output]
+    set exec_output [remote_exec host "$READELF -a tmpdir/copy.o" "" "/dev/null" "tmpdir/copy.o.out"]
+    if { [lindex $exec_output 0] != 0 } then {
+       unresolved "objcopy ($testname)"
+       return
+    }
+    set exec_output [prune_warnings [lindex $exec_output 1]]
     if ![string match "" $exec_output] then {
        unresolved "objcopy ($testname)"
        return
@@ -765,16 +831,27 @@ if { ([istarget "ia64-*-elf*"]
 if [is_elf_format] {
     objcopy_test "ELF unknown section type" unknown.s
     objcopy_test_readelf "ELF group" group.s
+    objcopy_test_readelf "ELF group" group-2.s
+    objcopy_test_readelf "ELF group" group-3.s
+    objcopy_test_readelf "ELF group" group-4.s
     run_dump_test "copy-1"
 }
 
 run_dump_test "copy-2"
 run_dump_test "copy-3"
+run_dump_test "copy-4"
 
 if [is_elf_format] {
     run_dump_test "strip-1"
     run_dump_test "strip-2"
     run_dump_test "strip-3"
+    run_dump_test "strip-4"
+    run_dump_test "strip-5"
+    run_dump_test "strip-6"
+    run_dump_test "strip-7"
+    run_dump_test "strip-8"
+    run_dump_test "strip-9"
+    run_dump_test "strip-10"
 
     if { [istarget "i*86-*"] || [istarget "x86_64-*-*"] } {
        # Check to make sure we don't strip a symbol named in relocations.
@@ -796,5 +873,7 @@ if [is_elf_format] {
     }
 
     run_dump_test "localize-hidden-1"
+    run_dump_test "testranges"
+    run_dump_test "testranges-ia64"
 }
 run_dump_test "localize-hidden-2"