| 1 | # Expect script for ld-sparc tests |
| 2 | # Copyright (C) 2002-2020 Free Software Foundation, Inc. |
| 3 | # |
| 4 | # This file is part of the GNU Binutils. |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
| 19 | # MA 02110-1301, USA. |
| 20 | # |
| 21 | |
| 22 | # Test SPARC linking; all types of relocs. This tests the assembler and |
| 23 | # tools like objdump as well as the linker. |
| 24 | |
| 25 | if {[istarget "sparc-*-vxworks"]} { |
| 26 | set sparcvxworkstests { |
| 27 | {"VxWorks shared library test 1" |
| 28 | "-shared -Tvxworks1.ld --hash-style=sysv" "" |
| 29 | "-KPIC" {vxworks1-lib.s} |
| 30 | {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd} |
| 31 | {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}} |
| 32 | "libvxworks1.so"} |
| 33 | {"VxWorks executable test 1 (dynamic)" \ |
| 34 | "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" "" |
| 35 | "" {vxworks1.s} |
| 36 | {{readelf {--relocs --wide} vxworks1.rd} {objdump -dr vxworks1.dd}} |
| 37 | "vxworks1"} |
| 38 | {"VxWorks executable test 2 (dynamic)" \ |
| 39 | "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" "" |
| 40 | "" {vxworks2.s} |
| 41 | {{readelf --segments vxworks2.sd}} |
| 42 | "vxworks2"} |
| 43 | {"VxWorks executable test 2 (static)" |
| 44 | "-Tvxworks1.ld --hash-style=sysv" "" |
| 45 | "" {vxworks2.s} |
| 46 | {{readelf --segments vxworks2-static.sd}} |
| 47 | "vxworks2"} |
| 48 | } |
| 49 | run_ld_link_tests $sparcvxworkstests |
| 50 | run_dump_test "vxworks1-static" |
| 51 | } |
| 52 | |
| 53 | if { !([istarget "sparc*-*-elf*"] |
| 54 | || [istarget "sparc*-sun-solaris*"] |
| 55 | || [istarget "sparc*-*-linux*"]) } { |
| 56 | return |
| 57 | } |
| 58 | |
| 59 | # List contains test-items with 3 items followed by 2 lists: |
| 60 | # 0:name 1:ld early options 2:ld late options 3:assembler options |
| 61 | # 4:filenames of assembler files 5: action and options. 6: name of output file |
| 62 | |
| 63 | # Actions: |
| 64 | # objdump: Apply objdump options on result. Compare with regex (last arg). |
| 65 | # nm: Apply nm options on result. Compare with regex (last arg). |
| 66 | # readelf: Apply readelf options on result. Compare with regex (last arg). |
| 67 | |
| 68 | set sparctests { |
| 69 | {"32-bit: TLS -fpic -shared transitions" |
| 70 | "-shared -melf32_sparc --hash-style=sysv" "" |
| 71 | "--32 -K PIC" {tlssunpic32.s tlspic.s} |
| 72 | {{readelf -WSsrl tlssunpic32.rd} {objdump -drj.text tlssunpic32.dd} |
| 73 | {objdump -sj.got tlssunpic32.sd} {objdump -sj.tdata tlssunpic32.td}} |
| 74 | "libtlssunpic32.so"} |
| 75 | {"32-bit: Helper shared library" |
| 76 | "-shared -melf32_sparc -version-script tlslib.ver" "" |
| 77 | "--32 -K PIC" {tlslib.s} {} "libtlslib32.so"} |
| 78 | {"32-bit: Another helper shared library" "-shared -melf32_sparc" "" |
| 79 | "--32 -K PIC" {tlssunbinpic32.s} {} "libtlssunbinpic32.so"} |
| 80 | {"32-bit: TLS -fpic and -fno-pic exec transitions" |
| 81 | "-melf32_sparc --hash-style=sysv tmpdir/libtlslib32.so tmpdir/tlssunbinpic32.o" "" |
| 82 | "--32" {tlssunbin32.s} |
| 83 | {{readelf -WSsrl tlssunbin32.rd} {objdump -drj.text tlssunbin32.dd} |
| 84 | {objdump -sj.got tlssunbin32.sd} {objdump -sj.tdata tlssunbin32.td}} |
| 85 | "tlssunbin32"} |
| 86 | {"32-bit: TLS -fno-pic -shared" |
| 87 | "-shared -melf32_sparc --hash-style=sysv" "" |
| 88 | "--32" {tlssunnopic32.s tlsnopic.s} |
| 89 | {{readelf -WSsrl tlssunnopic32.rd} {objdump -drj.text tlssunnopic32.dd} |
| 90 | {objdump -sj.got tlssunnopic32.sd}} "libtlssunnopic32.so"} |
| 91 | {"32-bit: TLS in debug sections" "-melf32_sparc" "" |
| 92 | "--32" {tlsg32.s} |
| 93 | {{objdump -sj.debug_foobar tlsg32.sd}} "tlsg32"} |
| 94 | {"32-bit: TLS -fpie" "-melf32_sparc -pie tmpdir/libtlslib32.so" "" |
| 95 | "--32 -K PIC" {tlspie32.s} |
| 96 | {{objdump -drj.text tlspie32.dd}} "tlspie32"} |
| 97 | {"32-bit: GOTDATA relocations" |
| 98 | "-shared -melf32_sparc --hash-style=sysv" "" |
| 99 | "--32 -K PIC" {gotop32.s} |
| 100 | {{readelf -WSsrl gotop32.rd} {objdump -drj.text gotop32.dd} |
| 101 | {objdump -sj.got gotop32.sd} {objdump -sj.data gotop32.td}} |
| 102 | "libgotop32.so"} |
| 103 | {"relaxed call WDISP30 relocation" "-static -melf32_sparc -relax" "" |
| 104 | "--32" {wdispcall.s} |
| 105 | {{objdump -dj.wdispcall wdispcall.dd}} "wdispcall"} |
| 106 | } |
| 107 | set sparc64tests { |
| 108 | {"64-bit: TLS -fpic -shared transitions" |
| 109 | "-shared -melf64_sparc --hash-style=sysv" "" |
| 110 | "--64 -Av9 -K PIC" {tlssunpic64.s tlspic.s} |
| 111 | {{readelf -WSsrl tlssunpic64.rd} {objdump -drj.text tlssunpic64.dd} |
| 112 | {objdump -sj.got tlssunpic64.sd} {objdump -sj.tdata tlssunpic64.td}} |
| 113 | "libtlssunpic64.so"} |
| 114 | {"64-bit: Helper shared library" |
| 115 | "-shared -melf64_sparc -version-script tlslib.ver" "" |
| 116 | "--64 -Av9 -K PIC" {tlslib.s} {} "libtlslib64.so"} |
| 117 | {"64-bit: Another helper shared library" "-shared -melf64_sparc" "" |
| 118 | "--64 -Av9 -K PIC" {tlssunbinpic64.s} {} "libtlssunbinpic64.so"} |
| 119 | {"64-bit: TLS -fpic and -fno-pic exec transitions" |
| 120 | "-melf64_sparc --hash-style=sysv tmpdir/libtlslib64.so tmpdir/tlssunbinpic64.o" "" |
| 121 | "--64 -Av9" {tlssunbin64.s} |
| 122 | {{readelf -WSsrl tlssunbin64.rd} {objdump -drj.text tlssunbin64.dd} |
| 123 | {objdump -sj.got tlssunbin64.sd} {objdump -sj.tdata tlssunbin64.td}} |
| 124 | "tlssunbin64"} |
| 125 | {"64-bit: TLS -fno-pic -shared" |
| 126 | "-shared -melf64_sparc --hash-style=sysv" "" |
| 127 | "--64 -Av9" {tlssunnopic64.s tlsnopic.s} |
| 128 | {{readelf -WSsrl tlssunnopic64.rd} {objdump -drj.text tlssunnopic64.dd} |
| 129 | {objdump -sj.got tlssunnopic64.sd}} "libtlssunnopic64.so"} |
| 130 | {"64-bit: TLS in debug sections" "-melf64_sparc" "" |
| 131 | "--64 -Av9" {tlsg64.s} |
| 132 | {{objdump -sj.debug_foobar tlsg64.sd}} "tlsg64"} |
| 133 | {"64-bit: TLS -fpie" "-melf64_sparc -pie tmpdir/libtlslib64.so" "" |
| 134 | "--64 -Av9 -K PIC" {tlspie64.s} |
| 135 | {{objdump -drj.text tlspie64.dd}} "tlspie64"} |
| 136 | {"64-bit: GOTDATA relocations" |
| 137 | "-shared -melf64_sparc --hash-style=sysv" "" |
| 138 | "--64 -Av9 -K PIC" {gotop64.s} |
| 139 | {{readelf -WSsrl gotop64.rd} {objdump -drj.text gotop64.dd} |
| 140 | {objdump -sj.got gotop64.sd} {objdump -sj.data gotop64.td}} |
| 141 | "libgotop64.so"} |
| 142 | } |
| 143 | |
| 144 | if { ![istarget "sparc64-*-elf*"] } { |
| 145 | run_ld_link_tests $sparctests |
| 146 | } |
| 147 | |
| 148 | if { !([istarget "sparc-*-elf*"] |
| 149 | || [istarget "sparc-sun-solaris2.5*"] |
| 150 | || [istarget "sparc-sun-solaris2.6"]) } { |
| 151 | run_ld_link_tests $sparc64tests |
| 152 | } |
| 153 | |
| 154 | if { [istarget "sparc*-*-linux*"] && [isnative] } { |
| 155 | run_ld_link_exec_tests [list \ |
| 156 | [list \ |
| 157 | "32-bit: mixed GOTDATA/GOT relocations" \ |
| 158 | "-pie -m32" \ |
| 159 | "" \ |
| 160 | { gotop-hidden.c got-hidden32.s } \ |
| 161 | "gotop-hidden32" \ |
| 162 | "pass.out" \ |
| 163 | "-fPIE -m32" \ |
| 164 | ] \ |
| 165 | ] |
| 166 | } |
| 167 | |
| 168 | if { [istarget "sparc64-*-linux*"] && [isnative] } { |
| 169 | run_ld_link_exec_tests [list \ |
| 170 | [list \ |
| 171 | "64-bit: mixed GOTDATA/GOT relocations" \ |
| 172 | "-pie -m64" \ |
| 173 | "" \ |
| 174 | { gotop-hidden.c got-hidden64.s } \ |
| 175 | "gotop-hidden64" \ |
| 176 | "pass.out" \ |
| 177 | "-fPIE -m64" \ |
| 178 | ] \ |
| 179 | ] |
| 180 | } |