]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - binutils/testsuite/binutils-all/objcopy.exp
Add Visium support to binutils
[thirdparty/binutils-gdb.git] / binutils / testsuite / binutils-all / objcopy.exp
index 68f090948351c8476c4b2ee2ad6b43804b90da72..c83825a3d104134260687c6c59e91ef5b66589c1 100644 (file)
@@ -1,6 +1,4 @@
-#   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-#   2004, 2006, 2007
-#   Free Software Foundation, Inc.
+#   Copyright (C) 1994-2014 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -79,16 +77,15 @@ proc objcopy_test {testname srcfile} {
        # files in the first place, and may order things a little
        # differently. Those systems should use setup_xfail here.
 
-       setup_xfail "h8300-*-rtems*" "h8300-*-coff"
+       setup_xfail "h8300-*-coff"
        setup_xfail "h8500-*-rtems*" "h8500-*-coff"
        setup_xfail "hppa*-*-*"
        setup_xfail "i960-*"
        setup_xfail "m68*-*-*coff" "m68*-*-hpux*" "m68*-*-lynxos*"
        setup_xfail "m68*-*-sysv*" "m68*-apple-aux*"
        setup_xfail "m8*-*"
-       setup_xfail "or32-*-rtems*" "or32-*-coff"
-       setup_xfail "sh-*-coff*" "sh-*-rtems*" 
-       setup_xfail "tic4x-*-*" "tic80-*-*" "w65-*"
+       setup_xfail "sh-*-coff*"
+       setup_xfail "tic80-*-*" "w65-*"
 
        clear_xfail "hppa*64*-*-hpux*" "hppa*-*-linux*" "hppa*-*-lites*"
        clear_xfail "hppa*-*-*n*bsd*" "hppa*-*-rtems*" "*-*-*elf*"
@@ -131,6 +128,10 @@ if ![string match "" $got] then {
     set found_rev [regexp -lineanchor $want $revdata -> revdata]
 
     if {$found_orig == 0 || $found_rev == 0} then {
+       # som doesn't have a .data section
+       setup_xfail "hppa*-*-hpux*"
+       clear_xfail "hppa*64*-*-hpux*"
+
         fail "objcopy --reverse-bytes"
     } else {
         scan $origdata "%2x%2x%2x%2x" b1 b2 b3 b4
@@ -144,6 +145,43 @@ if ![string match "" $got] then {
     }
 }
 
+# Test interleaved copy of multiple byte width
+
+set sequence_file sequence_file
+set file [open ${sequence_file} w]
+puts ${file} "12345678"
+close ${file}
+
+if [is_remote host] {
+    remote_upload host ${sequence_file} tmpdir/sequence_file
+    set sequence_file tmpdir/sequence_file
+}
+
+set got [binutils_run $OBJCOPY "-I binary -i 4 -b 0 --interleave-width 2 ${sequence_file} ${copyfile}"]
+
+if ![string match "" $got] then {
+    fail "objcopy -i --interleave-width"
+} else {
+    if [is_remote host] {
+       remote_upload host ${copyfile} tmpdir/interleave_output
+       set interleave_output tmpdir/interleave_output
+    } else {
+       set interleave_output ${copyfile}
+    }
+
+    set file [open ${interleave_output} r]
+    gets $file line
+    send_log "$line\n"
+    verbose $line
+
+    if ![string match "1256" $line] then {
+       fail "objcopy -i --interleave-width"
+    }
+    pass "objcopy -i --interleave-width"
+
+    close $file
+}
+
 # Test generating S records.
 
 # We make the srec filename 8.3 compatible. Note that the header string
@@ -365,6 +403,7 @@ proc strip_test { } {
     global NMFLAGS
     global srcdir
     global subdir
+    global READELF
 
     set test "strip"
 
@@ -373,6 +412,19 @@ proc strip_test { } {
        return
     }
 
+    set osabi_fail "false"
+    if [is_elf_format] {
+       verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.in"
+       set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.in"]
+       if { [lindex $exec_output 0] != 0 } then {
+           unresolved "$test preserving OS/ABI"        
+           set osabi_fail "true"
+       } else {
+           verbose -log "grep OS/ABI tmpdir/osabi.in"
+           catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in
+       }
+    }
+
     if [is_remote host] {
        set archive libstrip.a
        set objfile [remote_download host tmpdir/testprog.o]
@@ -387,21 +439,40 @@ proc strip_test { } {
     set exec_output [binutils_run $AR "rc $archive ${objfile}"]
     if ![string match "" $exec_output] {
        fail $test
+       unresolved "$test preserving OS/ABI"    
        return
     }
 
     set exec_output [binutils_run $STRIP "-g $archive"]
     if ![string match "" $exec_output] {
        fail $test
+       unresolved "$test preserving OS/ABI"    
        return
     }
 
     set exec_output [binutils_run $STRIP "$STRIPFLAGS $archive"]
     if ![string match "" $exec_output] {
        fail $test
+       unresolved "$test preserving OS/ABI"    
        return
     }
 
+    if { $osabi_fail != "true" && [is_elf_format] } {
+       verbose -log "$READELF -a tmpdir/testprog.o > tmpdir/osabi.out"
+       set exec_output [remote_exec host "$READELF -h tmpdir/testprog.o" "" "/dev/null" "tmpdir/osabi.out"]
+       if { [lindex $exec_output 0] != 0 } then {
+           unresolved "$test preserving OS/ABI"        
+       } else {
+           verbose -log "grep OS/ABI tmpdir/osabi.out"
+           catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
+           if { "$osabi_in" == "$osabi_out" } {
+               pass "$test preserving OS/ABI"
+           } else {
+               fail "$test preserving OS/ABI"
+           }
+       }
+    }
+
     if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } {
        untested $test
        return
@@ -490,7 +561,7 @@ proc copy_setup { } {
     set res [build_wrapper testglue.o]
     set flags { debug }
     
-    if { [istarget *-*-uclinux*] } {
+    if { [istarget *-*-uclinux*] && ![istarget tic6x-*-*] } {
        return 1
     }
     
@@ -501,7 +572,8 @@ proc copy_setup { } {
        set add_libs ""
     }
 
-    if { [istarget *-*-linux*] } {
+    if { [istarget *-*-linux*]
+        || [istarget *-*-gnu*] } {
        foreach i $gcc_gas_flag {
            set flags "additional_flags=$i $flags"
        }
@@ -578,12 +650,9 @@ proc copy_executable { prog flags test1 test2 } {
        # mips_elf_sym_is_global.
        setup_xfail "mips*-*-elf"
 
-       setup_xfail "*arm*-*-coff"
-       setup_xfail "xscale-*-coff"
+       setup_xfail "arm*-*-coff"
        setup_xfail "arm*-*-pe"
-       setup_xfail "thumb*-*-coff"
-       setup_xfail "thumb*-*-pe"
-       setup_xfail "x86_64-*-mingw*"
+       setup_xfail "*-*-mingw*"
        setup_xfail "*-*-cygwin*"
     
        fail $test1
@@ -610,6 +679,7 @@ proc copy_executable { prog flags test1 test2 } {
 proc strip_executable { prog flags test } {
     global NM
     global NMFLAGS
+    global READELF
     global host_triplet
 
     remote_file build delete tmpdir/striprog
@@ -620,6 +690,19 @@ proc strip_executable { prog flags test } {
        set copyfile tmpdir/striprog
     }
 
+    set osabi_fail "false"
+    if [is_elf_format] {
+       verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.in"
+       set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.in"]
+       if { [lindex $exec_output 0] != 0 } then {
+           unresolved "$test preserving OS/ABI"        
+           set osabi_fail "true"
+       } else {
+           verbose -log "grep OS/ABI tmpdir/osabi.in"
+           catch "exec grep OS/ABI tmpdir/osabi.in" osabi_in
+       }
+     }
+
     set exec_output [binutils_run $prog "$flags ${copyfile}"]
     if ![string match "" $exec_output] {
        fail $test
@@ -640,6 +723,22 @@ proc strip_executable { prog flags test } {
         return
     }
 
+    if { $osabi_fail != "true" && [is_elf_format] } {
+       verbose -log "$READELF -a ${copyfile} > tmpdir/osabi.out"
+       set exec_output [remote_exec host "$READELF -h ${copyfile}" "" "/dev/null" "tmpdir/osabi.out"]
+       if { [lindex $exec_output 0] != 0 } then {
+           unresolved "$test preserving OS/ABI"        
+       } else {
+           verbose -log "grep OS/ABI tmpdir/osabi.out"
+           catch "exec grep OS/ABI tmpdir/osabi.out" osabi_out
+           if { "$osabi_in" == "$osabi_out" } {
+               pass "$test preserving OS/ABI"
+           } else {
+               fail "$test preserving OS/ABI"
+           }
+       }
+    }
+
     set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
     if ![string match "*: no symbols*" $exec_output] {
        fail $test
@@ -834,7 +933,10 @@ if [is_elf_format] {
     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 "group-5"
+    run_dump_test "group-6"
     run_dump_test "copy-1"
+    run_dump_test "note-1"
 }
 
 run_dump_test "copy-2"
@@ -851,6 +953,13 @@ if [is_elf_format] {
     run_dump_test "strip-7"
     run_dump_test "strip-8"
     run_dump_test "strip-9"
+    # Non-EABI ARM targets will set OSABI to ARM
+    if { ![istarget "*-*-hpux*"]
+        && ![istarget "msp*-*-*"]
+        && ![istarget "visium-*-*"]
+         && !([istarget "arm*-*-*"] && ![istarget "arm-*-*eabi*"])} {
+       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.
@@ -871,8 +980,29 @@ if [is_elf_format] {
        }
     }
 
+    # The symbol table for some MIPS targets is sorted differently than
+    # the ELF canonical order, so the regexps in localize-hidden-1.d fail
+    # to match.  These tests must be matched to targets for which
+    # targ_defvec=mips_elf32_be_vec,
+    # targ_defvec=mips_elf32_le_vec,
+    # targ_defvec=mips_elf32_n_be_vec or
+    # targ_defvec=mips_elf32_n_le_vec in config.bfd.  When syncing,
+    # don't forget that earlier case-matches trump later ones.
+    if { ![istarget "mips*-sde-elf*"] && ![istarget "mips*-mti-elf*"]
+        && ![istarget "mips*-img-elf*"]
+         && ![istarget "mips64*-*-openbsd*"] } {
+       setup_xfail "mips*-*-irix5*" "mips*-*-irix6*" "mips*-*-elf*" \
+           "mips*-*-rtems*" "mips*-*-windiss" "mips*-*-none" \
+           "mips*-*-openbsd*" "mips*-*-chorus*"
+    }
     run_dump_test "localize-hidden-1"
+    run_dump_test "testranges"
+    run_dump_test "testranges-ia64"
+
+    run_dump_test "add-section"
+    run_dump_test "add-empty-section"
+
+    run_dump_test "exclude-1a"
+    run_dump_test "exclude-1b"
 }
 run_dump_test "localize-hidden-2"
-run_dump_test "testranges"
-run_dump_test "testranges-ia64"