x86: Update GNU_PROPERTY_X86_XXX macros
[deliverable/binutils-gdb.git] / binutils / testsuite / binutils-all / compress.exp
index 8787e771edac986c1d6eb7000404bdcd0484c585..948d20a4516bf368a948cba6f8a5959db15d8436 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 2010-2015 Free Software Foundation, Inc.
+#   Copyright (C) 2010-2018 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
@@ -39,7 +39,12 @@ if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --com
     return
 }
 
-set got [remote_exec host "cmp ${testfile}.o ${compressedfile}.o"]
+if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
+    unsupported "compressed debug sections with zlib-gnu"
+    return
+}
+
+set got [remote_exec host "cmp ${testfile}.o ${compressedfile}gnu.o"]
 # Use it to set up xfail.
 set exec_output [lindex $got 1]
 if [string match "" $exec_output] then {
@@ -136,8 +141,8 @@ if ![string match "" $got] then {
 
 # Xfail this test if there are no compressed sections.
 setup_xfail "$compression_used$target_triplet"
-set testname "objcopy compress debug sections in archive"
-set got [binutils_run $OBJCOPY "--compress-debug-sections ${copyfile}.a ${compressedcopyfile}.a"]
+set testname "objcopy compress debug sections in archive with zlib-gnu"
+set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${copyfile}.a ${compressedcopyfile}.a"]
 if ![string match "" $got] then {
     fail "objcopy ($testname)"
 } else {
@@ -157,6 +162,7 @@ if ![string match "" $got] then {
     }
 }
 
+setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -169,6 +175,7 @@ if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
     pass "$testname"
 }
 
+setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections 3"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -228,13 +235,13 @@ if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --
     return
 }
 
-set src1 ${compressedfile}gnu.o
+set src1 ${compressedfile}gabi.o
 set src2 ${compressedfile}.o
 set status [remote_exec build cmp "${src1} ${src2}"]
 set exec_output [lindex $status 1]
 set exec_output [prune_warnings $exec_output]
 if ![string match "" $exec_output] then {
-    fail "compressed debug sections with zlib-gnu"
+    fail "compressed debug sections with zlib-gabi"
     return
 }
 
@@ -248,13 +255,13 @@ if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o -
     return
 }
 
-set src1 ${compressedfile2}gnu.o
+set src1 ${compressedfile2}gabi.o
 set src2 ${compressedfile2}.o
 set status [remote_exec build cmp "${src1} ${src2}"]
 set exec_output [lindex $status 1]
 set exec_output [prune_warnings $exec_output]
 if ![string match "" $exec_output] then {
-    fail "compressed debug sections with zlib-gnu"
+    fail "compressed debug sections with zlib-gabi"
     return
 }
 
@@ -292,13 +299,13 @@ if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o -
     return
 }
 
-set src1 ${compressedfile3}gnu.o
+set src1 ${compressedfile3}gabi.o
 set src2 ${compressedfile3}.o
 set status [remote_exec build cmp "${src1} ${src2}"]
 set exec_output [lindex $status 1]
 set exec_output [prune_warnings $exec_output]
 if ![string match "" $exec_output] then {
-    fail "compressed debug sections with zlib-gnu"
+    fail "compressed debug sections with zlib-gabi"
     return
 }
 
@@ -539,13 +546,13 @@ if ![string match "" $got] then {
     }
 }
 
+setup_xfail "nds32*-*-*"
 set testname "objcopy compress debug sections in archive with zlib-gabi"
 set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
 if ![string match "" $got] then {
     fail "objcopy ($testname)"
 } else {
-    set got [remote_exec host "$OBJDUMP -s -j .debug_info
-    ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
+    set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
 
     if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
        fail "$testname (reason: unexpected output)"
@@ -560,6 +567,7 @@ if ![string match "" $got] then {
     }
 }
 
+setup_xfail "nds32*-*-*"
 set testname "objdump compress debug sections 3 with zlib-gabi"
 set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
@@ -571,3 +579,181 @@ if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
 } else {
     pass "$testname"
 }
+
+proc convert_test { testname  as_flags  objcop_flags } {
+    global srcdir
+    global subdir
+    global testfile3
+    global copyfile
+    global OBJCOPY
+    global OBJDUMP
+
+    if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o "$as_flags"] } then {
+       unresolved "$testname"
+       return
+    }
+
+    set got [binutils_run $OBJCOPY "$objcop_flags ${testfile3}.o ${copyfile}.o"]
+    if ![string match "" $got] then {
+       fail "objcopy ($testname)"
+       return
+    }
+
+    set got [remote_exec host "$OBJDUMP -W ${copyfile}.o" "" "/dev/null" "objdump.out"]
+
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$testname (reason: unexpected output)"
+       send_log $got
+       send_log "\n"
+       return
+    }
+
+    if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
+       fail "$testname"
+    } else {
+       pass "$testname"
+    }
+}
+
+if { ([istarget "x86_64-*-elf*"]
+       || [istarget "x86_64-*-linux*"]) } {
+    set testname "Convert x86-64 object with zlib-gabi to x32 (1)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64"
+
+    set testname "Convert x86-64 object with zlib-gabi to x32 (2)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
+
+    set testname "Convert x86-64 object with zlib-gabi to x32 (3)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --decompress-debug-sections"
+
+    set testname "Convert x86-64 object with zlib-gnu to x32 (1)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64"
+
+    set testname "Convert x86-64 object with zlib-gnu to x32 (2)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
+
+    set testname "Convert x86-64 object with zlib-gnu to x32 (3)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --decompress-debug-sections"
+
+    set testname "Convert x86-64 object to x32 (1)"
+    convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64"
+
+    set testname "Convert x86-64 object to x32 (2)"
+    convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
+
+    set testname "Convert x86-64 object to x32 (3)"
+    convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
+
+
+    set testname "Convert x32 object with zlib-gabi to x86-64 (1)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64"
+
+    set testname "Convert x32 object with zlib-gabi to x86-64 (2)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
+
+    set testname "Convert x32 object with zlib-gabi to x86-64 (3)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --decompress-debug-sections"
+
+    set testname "Convert x32 object with zlib-gnu to x86-64 (1)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64"
+
+    set testname "Convert x32 object with zlib-gnu to x86-64 (2)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
+
+    set testname "Convert x32 object with zlib-gnu to x86-64 (3)"
+    convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --decompress-debug-sections"
+
+    set testname "Convert x32 object to x86-64 (1)"
+    convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64"
+
+    set testname "Convert x32 object to x86-64 (2)"
+    convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
+
+    set testname "Convert x32 object to x86-64 (3)"
+    convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
+}
+
+proc test_gnu_debuglink {} {
+    global srcdir
+    global subdir
+    global env
+    global STRIP
+    global OBJCOPY
+    global OBJDUMP
+
+    set test "gnu-debuglink"
+
+    if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog exectuable debug] != "" } {
+       unsupported "$test (build)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump)"
+       return
+    }
+    if { [binutils_run $STRIP "--strip-debug --remove-section=.comment --remove-section=.note tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
+       fail "$test (strip)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--only-keep-debug --decompress-debug-sections tmpdir/testprog tmpdir/testprog.decompress"] != "" } {
+       fail "$test (objcopy decompress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--only-keep-debug --compress-debug-sections tmpdir/testprog tmpdir/testprog.compress"] != "" } {
+       fail "$test (objcopy compress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.decompress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
+       fail "$test (objcopy link decompress)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.decompress.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump decompress)"
+       return
+    }
+    if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.compress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
+       fail "$test (objcopy link compress)"
+       return
+    }
+    set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.compress.dump"]
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       fail "$test (objcopy dump compress)"
+       return
+    }
+
+    set src1 tmpdir/testprog.dump
+    set src2 tmpdir/testprog.compress.dump
+    send_log "cmp ${src1} ${src2}\n"
+    verbose "cmp ${src1} ${src2}"
+    set status [remote_exec build cmp "${src1} ${src2}"]
+    set exec_output [lindex $status 1]
+    set exec_output [prune_warnings $exec_output]
+    if ![string match "" $exec_output] then {
+       send_log "$exec_output\n"
+       verbose "$exec_output" 1
+       fail "$test (objdump 1)"
+    } else {
+       pass "$test (objdump 1)"
+    }
+
+    set src1 tmpdir/testprog.decompress.dump
+    set src2 tmpdir/testprog.compress.dump
+    send_log "cmp ${src1} ${src2}\n"
+    verbose "cmp ${src1} ${src2}"
+    set status [remote_exec build cmp "${src1} ${src2}"]
+    set exec_output [lindex $status 1]
+    set exec_output [prune_warnings $exec_output]
+    if ![string match "" $exec_output] then {
+       send_log "$exec_output\n"
+       verbose "$exec_output" 1
+       fail "$test (objdump 2)"
+    } else {
+       pass "$test (objdump 2)"
+    }
+}
+
+if {[is_elf_format]} then {
+    test_gnu_debuglink
+}
This page took 0.027196 seconds and 4 git commands to generate.