ld/
[deliverable/binutils-gdb.git] / ld / testsuite / ld-tic6x / tic6x.exp
index 9bcb5543780508f4e1f0f531f7be11daf16d6c79..5d7b10757a4525d6f8dbcf7500bae793a7b52dde 100644 (file)
@@ -112,3 +112,69 @@ set shlibtests {
 }
 
 run_ld_link_tests $shlibtests
+
+if { [istarget tic6x-*-elf] } {
+    set expected_osabi "Bare-metal C6000"
+} elseif { [istarget tic6x-*-uclinux] } {
+    set expected_osabi "Linux C6000"
+} else {
+    return
+}
+
+if { ![ld_assemble_flags $as "-mpic -mpid=near" $srcdir/$subdir/shlib-1.s tmpdir/shlib-1.o]
+     || ![ld_assemble_flags $as "-mpic -mpid=near" $srcdir/$subdir/shlib-2.s tmpdir/shlib-2.o]
+     || ![ld_assemble $as $srcdir/$subdir/shlib-app-1.s tmpdir/shlib-app-1.o]
+     || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-1.s tmpdir/shlib-1b.o]
+     || ![ld_assemble_flags $as "-mpic -mpid=near -mbig-endian" $srcdir/$subdir/shlib-2.s tmpdir/shlib-2b.o]
+     || ![ld_assemble_flags $as -mbig-endian $srcdir/$subdir/shlib-app-1.s tmpdir/shlib-app-1b.o]
+     || ![ld_simple_link $ld tmpdir/libtest.so "-shared tmpdir/shlib-1.o tmpdir/shlib-2.o"]
+     || ![ld_simple_link $ld tmpdir/libtestb.so "-shared -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
+     || ![ld_simple_link $ld tmpdir/shlib.o "-r tmpdir/shlib-1.o tmpdir/shlib-2.o"]
+     || ![ld_simple_link $ld tmpdir/shlibb.o "-r -EB tmpdir/shlib-1b.o tmpdir/shlib-2b.o"]
+     || ![ld_simple_link $ld tmpdir/dynapp-1 "tmpdir/libtest.so tmpdir/shlib-app-1.o"]
+     || ![ld_simple_link $ld tmpdir/dynapp-1b "-EB tmpdir/libtestb.so tmpdir/shlib-app-1b.o"] } {
+    unresolved "TIC6X OSABI tests"
+    return
+}
+
+# A procedure to check the OS/ABI field in the ELF header of a binary file.
+proc check_osabi_tic6x { test_name binary_file } {
+    global READELF
+    global READELFFLAGS
+    global expected_osabi
+
+    set cmd "$READELF $READELFFLAGS --file-header $binary_file"
+    send_log "$cmd\n"
+    set got [remote_exec host [concat sh -c [list "$cmd >dump.out"]] "" "/dev/null"]
+
+    if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+       send_log "$got\n"
+       unresolved "$test_name"
+       remote_file build delete "dump.out"
+       return
+    }
+    remote_upload host "dump.out"
+
+    if { ![regexp "\n\[ \]*OS/ABI:\[ \]*(.+)\n\[ \]*ABI" \
+          [file_contents dump.out] nil osabi] } {
+       verbose "proc check_osabi_tic6x: Readelf failed to extract an ELF header from $binary_file"
+       unresolved "$test_name"
+    } elseif { $osabi == $expected_osabi } {
+       pass "$test_name"
+    } else {
+       verbose "Expected OSABI: $expected_osabi, Obtained osabi: $osabi"
+       fail "$test_name"
+    }
+    remote_file build delete "dump.out"
+    remote_file host delete "dump.out"
+}
+
+check_osabi_tic6x "C6X shared library OSABI, LE" tmpdir/libtest.so
+check_osabi_tic6x "C6X shared library OSABI, BE" tmpdir/libtestb.so
+check_osabi_tic6x "C6X dynamic app OSABI, LE" tmpdir/dynapp-1
+check_osabi_tic6x "C6X dynamic app OSABI, BE" tmpdir/dynapp-1b
+
+set expected_osabi "UNIX - System V"
+
+check_osabi_tic6x "C6X relocatable link OSABI, LE" tmpdir/shlib.o
+check_osabi_tic6x "C6X relocatable link OSABI, BE" tmpdir/shlibb.o
This page took 0.033403 seconds and 4 git commands to generate.