| 1 |
128 |
khays |
# Expect script for ld-x86_64 tests
|
| 2 |
|
|
# Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
| 3 |
|
|
# Free Software Foundation
|
| 4 |
|
|
#
|
| 5 |
|
|
# This file is part of the GNU Binutils.
|
| 6 |
|
|
#
|
| 7 |
|
|
# This program is free software; you can redistribute it and/or modify
|
| 8 |
|
|
# it under the terms of the GNU General Public License as published by
|
| 9 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
| 10 |
|
|
# (at your option) any later version.
|
| 11 |
|
|
#
|
| 12 |
|
|
# This program is distributed in the hope that it will be useful,
|
| 13 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
|
|
# GNU General Public License for more details.
|
| 16 |
|
|
#
|
| 17 |
|
|
# You should have received a copy of the GNU General Public License
|
| 18 |
|
|
# along with this program; if not, write to the Free Software
|
| 19 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
| 20 |
|
|
# MA 02110-1301, USA.
|
| 21 |
|
|
#
|
| 22 |
|
|
|
| 23 |
|
|
# Test x86_64 linking; all types of relocs. This tests the assembler and
|
| 24 |
|
|
# tools like objdump as well as the linker.
|
| 25 |
|
|
|
| 26 |
|
|
if { !([istarget "x86_64-*-elf*"]
|
| 27 |
|
|
|| [istarget "x86_64-*-linux*"]) } {
|
| 28 |
|
|
return
|
| 29 |
|
|
}
|
| 30 |
|
|
|
| 31 |
|
|
# List contains test-items with 3 items followed by 2 lists:
|
| 32 |
|
|
# 0:name 1:ld options 2:assembler options
|
| 33 |
|
|
# 3:filenames of assembler files 4: action and options. 5: name of output file
|
| 34 |
|
|
|
| 35 |
|
|
# Actions:
|
| 36 |
|
|
# objdump: Apply objdump options on result. Compare with regex (last arg).
|
| 37 |
|
|
# nm: Apply nm options on result. Compare with regex (last arg).
|
| 38 |
|
|
# readelf: Apply readelf options on result. Compare with regex (last arg).
|
| 39 |
|
|
|
| 40 |
|
|
set x86_64tests {
|
| 41 |
157 |
khays |
{"TLS -fpic -shared transitions"
|
| 42 |
|
|
"-shared -melf_x86_64 --no-ld-generated-unwind-info"
|
| 43 |
128 |
khays |
"--64" {tlspic1.s tlspic2.s}
|
| 44 |
|
|
{{readelf -WSsrl tlspic.rd} {objdump -drj.text tlspic.dd}
|
| 45 |
|
|
{objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
|
| 46 |
|
|
"libtlspic.so"}
|
| 47 |
157 |
khays |
{"TLS descriptor -fpic -shared transitions"
|
| 48 |
|
|
"-shared -melf_x86_64 --no-ld-generated-unwind-info"
|
| 49 |
128 |
khays |
"--64" {tlsdesc.s tlspic2.s}
|
| 50 |
|
|
{{readelf -WSsrld tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
|
| 51 |
|
|
{objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}
|
| 52 |
|
|
{objdump -drj.plt tlsdesc.pd}} "libtlsdesc.so"}
|
| 53 |
|
|
{"Helper shared library" "-shared -melf_x86_64"
|
| 54 |
|
|
"--64" {tlslib.s} {} "libtlslib.so"}
|
| 55 |
|
|
{"TLS -fpic and -fno-pic exec transitions"
|
| 56 |
157 |
khays |
"-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info"
|
| 57 |
|
|
"--64" {tlsbinpic.s tlsbin.s}
|
| 58 |
128 |
khays |
{{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
|
| 59 |
|
|
{objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
|
| 60 |
|
|
"tlsbin"}
|
| 61 |
|
|
{"TLS descriptor -fpic and -fno-pic exec transitions"
|
| 62 |
157 |
khays |
"-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info"
|
| 63 |
|
|
"--64" {tlsbindesc.s tlsbin.s}
|
| 64 |
128 |
khays |
{{readelf -WSsrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
|
| 65 |
|
|
{objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
|
| 66 |
|
|
"tlsbindesc"}
|
| 67 |
|
|
{"TLS with global dynamic and descriptors"
|
| 68 |
157 |
khays |
"-shared -melf_x86_64 --no-ld-generated-unwind-info"
|
| 69 |
|
|
"--64" {tlsgdesc.s}
|
| 70 |
128 |
khays |
{{readelf -WSsrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
|
| 71 |
|
|
"libtlsgdesc.so"}
|
| 72 |
|
|
{"TLS in debug sections" "-melf_x86_64"
|
| 73 |
|
|
"--64" {tlsg.s}
|
| 74 |
|
|
{{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
|
| 75 |
|
|
{"TLS GD->LE transition" "-melf_x86_64"
|
| 76 |
|
|
"--64" {tlsgd1.s}
|
| 77 |
|
|
{{objdump -dwr tlsgd1.dd}} "tlsgd1"}
|
| 78 |
|
|
{"TLS LD->LE transition" "-melf_x86_64"
|
| 79 |
|
|
"--64" {tlsld1.s}
|
| 80 |
|
|
{{objdump -dwr tlsld1.dd}} "tlsld1"}
|
| 81 |
|
|
{"TLS IE->LE transition" "-melf_x86_64"
|
| 82 |
|
|
"--64" {tlsie1.s}
|
| 83 |
|
|
{{objdump -dwr tlsie1.dd}} "tlsie1"}
|
| 84 |
|
|
{"Helper 64bit object 1" "-r -melf_x86_64"
|
| 85 |
|
|
"--64" {mixed1a.s} {} "libmixe1a.o"}
|
| 86 |
|
|
{"Helper 32bit object 1" "-r -melf_i386"
|
| 87 |
|
|
"--32" {mixed1b.s} {} "libmixe1b.o"}
|
| 88 |
|
|
{"Helper 64bit object 2" "-r -melf_x86_64"
|
| 89 |
|
|
"--64" {mixed2a.s} {} "libmixe2a.o"}
|
| 90 |
|
|
{"Helper 32bit object 2" "-r -melf_i386"
|
| 91 |
|
|
"--32" {mixed2b.s} {} "libmixe2b.o"}
|
| 92 |
157 |
khays |
{"Split by file with 'l' flag on section." "-split-by-file -r -melf_x86_64"
|
| 93 |
128 |
khays |
"--64" {split-by-file1.s split-by-file2.s}
|
| 94 |
|
|
{{readelf -SW split-by-file.rd}} "split-by-file.o"}
|
| 95 |
|
|
{"TLS X32 IE->LE transition" "-melf32_x86_64"
|
| 96 |
|
|
"--x32" {tlsie4.s}
|
| 97 |
|
|
{{objdump -dwr tlsie4.dd}} "tlsie4"}
|
| 98 |
|
|
{"TLS X32 GD->LE transition" "-melf32_x86_64"
|
| 99 |
|
|
"--x32" {tlsgd4.s}
|
| 100 |
|
|
{{objdump -dwr tlsgd4.dd}} "tlsgd4"}
|
| 101 |
|
|
{"Helper TLS GD->IE transition DSO" "-shared -melf_x86_64"
|
| 102 |
|
|
"--64" {tlsgd5b.s} {} "libtlsgd5.so"}
|
| 103 |
|
|
{"TLS GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so"
|
| 104 |
|
|
"--64" {tlsgd5a.s}
|
| 105 |
|
|
{{objdump -dwr tlsgd5.dd}} "tlsgd5"}
|
| 106 |
|
|
{"Helper TLS X32 GD->IE transition DSO" "-shared -melf32_x86_64"
|
| 107 |
|
|
"--x32" {tlsgd6b.s} {} "libtlsgd6.so"}
|
| 108 |
|
|
{"TLS X32 GD->IE transition" "-melf32_x86_64 tmpdir/libtlsgd6.so"
|
| 109 |
|
|
"--x32" {tlsgd6a.s}
|
| 110 |
|
|
{{objdump -dwr tlsgd6.dd}} "tlsgd6"}
|
| 111 |
|
|
{"TLS X32 LD->LE transition" "-melf32_x86_64"
|
| 112 |
|
|
"--x32" {tlsld2.s}
|
| 113 |
|
|
{{objdump -dwr tlsld2.dd}} "tlsld2"}
|
| 114 |
166 |
khays |
|
| 115 |
|
|
{"build 32-bit object with 33 locals" "-e 0" "--32" {32bit.s} {{ ld incompatible.l }} "dummy" }
|
| 116 |
|
|
{"build 64-bit object" "-e 0 --defsym foo=1" "--64" {64bit.s} {} "dummy" }
|
| 117 |
|
|
{"link mixed objects" "-e 0 tmpdir/32bit.o tmpdir/64bit.o" "" {} { { ld incompatible.l } } "mixed"}
|
| 118 |
128 |
khays |
}
|
| 119 |
|
|
|
| 120 |
|
|
run_ld_link_tests $x86_64tests
|
| 121 |
|
|
|
| 122 |
|
|
global link_output
|
| 123 |
|
|
global ld
|
| 124 |
|
|
|
| 125 |
|
|
set test_name "Mixed x86_64 and i386 input test 1"
|
| 126 |
|
|
set test mixed1
|
| 127 |
|
|
if { ![ld_simple_link $ld tmpdir/$test "-melf_x86_64 tmpdir/${test}a.o tmpdir/${test}b.o"] } {
|
| 128 |
|
|
if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] {
|
| 129 |
|
|
pass "$test_name"
|
| 130 |
|
|
} {
|
| 131 |
|
|
fail "$test_name"
|
| 132 |
|
|
}
|
| 133 |
|
|
}
|
| 134 |
|
|
|
| 135 |
|
|
set test_name "Mixed x86_64 and i386 input test 2"
|
| 136 |
|
|
set test mixed2
|
| 137 |
|
|
if { ![ld_simple_link $ld tmpdir/$test "-melf_x86_64 tmpdir/${test}a.o tmpdir/${test}b.o"] } {
|
| 138 |
|
|
if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] {
|
| 139 |
|
|
pass "$test_name"
|
| 140 |
|
|
} {
|
| 141 |
|
|
fail "$test_name"
|
| 142 |
|
|
}
|
| 143 |
|
|
}
|
| 144 |
|
|
|
| 145 |
|
|
run_dump_test "abs"
|
| 146 |
|
|
run_dump_test "abs-l1om"
|
| 147 |
|
|
run_dump_test "pcrel8"
|
| 148 |
|
|
run_dump_test "pcrel16"
|
| 149 |
|
|
run_dump_test "tlsgd2"
|
| 150 |
|
|
run_dump_test "tlsgd3"
|
| 151 |
|
|
run_dump_test "tlsie2"
|
| 152 |
|
|
run_dump_test "tlsie3"
|
| 153 |
|
|
run_dump_test "hidden1"
|
| 154 |
|
|
run_dump_test "hidden2"
|
| 155 |
|
|
run_dump_test "hidden3"
|
| 156 |
|
|
run_dump_test "protected1"
|
| 157 |
|
|
run_dump_test "protected2"
|
| 158 |
|
|
run_dump_test "protected2-l1om"
|
| 159 |
|
|
run_dump_test "protected3"
|
| 160 |
|
|
run_dump_test "protected3-l1om"
|
| 161 |
|
|
run_dump_test "tlsle1"
|
| 162 |
|
|
run_dump_test "tlspie1"
|
| 163 |
|
|
run_dump_test "unique1"
|
| 164 |
|
|
run_dump_test "nogot1"
|
| 165 |
|
|
run_dump_test "nogot2"
|
| 166 |
|
|
run_dump_test "discarded1"
|
| 167 |
|
|
run_dump_test "pr12718"
|
| 168 |
157 |
khays |
run_dump_test "pr12921"
|
| 169 |
128 |
khays |
|
| 170 |
|
|
if { ![istarget "x86_64-*-linux*"] } {
|
| 171 |
|
|
return
|
| 172 |
|
|
}
|
| 173 |
|
|
|
| 174 |
|
|
if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
|
| 175 |
|
|
unresolved "Build ILP32 start.o"
|
| 176 |
|
|
return
|
| 177 |
|
|
}
|
| 178 |
|
|
|
| 179 |
|
|
if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
|
| 180 |
|
|
unresolved "Build ia32 start.o"
|
| 181 |
|
|
return
|
| 182 |
|
|
}
|
| 183 |
|
|
|
| 184 |
|
|
if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
|
| 185 |
|
|
unresolved "Build LP64 start.o"
|
| 186 |
|
|
return
|
| 187 |
|
|
}
|
| 188 |
|
|
|
| 189 |
|
|
if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
|
| 190 |
|
|
unresolved "Build ILP32 foo.o"
|
| 191 |
|
|
return
|
| 192 |
|
|
}
|
| 193 |
|
|
|
| 194 |
|
|
if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
|
| 195 |
|
|
unresolved "Build ia32 foo.o"
|
| 196 |
|
|
return
|
| 197 |
|
|
}
|
| 198 |
|
|
|
| 199 |
|
|
if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
|
| 200 |
|
|
unresolved "Build LP64 foo.o"
|
| 201 |
|
|
return
|
| 202 |
|
|
}
|
| 203 |
|
|
|
| 204 |
|
|
run_dump_test "compressed1"
|
| 205 |
|
|
run_dump_test "ilp32-1"
|
| 206 |
|
|
run_dump_test "ilp32-2"
|
| 207 |
|
|
run_dump_test "ilp32-3"
|
| 208 |
|
|
run_dump_test "ilp32-4"
|
| 209 |
|
|
run_dump_test "ilp32-5"
|
| 210 |
157 |
khays |
run_dump_test "ilp32-6"
|
| 211 |
|
|
run_dump_test "ilp32-7"
|
| 212 |
|
|
run_dump_test "ilp32-8"
|
| 213 |
|
|
run_dump_test "ilp32-9"
|
| 214 |
166 |
khays |
run_dump_test "ilp32-10"
|
| 215 |
128 |
khays |
run_dump_test "ia32-1"
|
| 216 |
|
|
run_dump_test "ia32-2"
|
| 217 |
|
|
run_dump_test "ia32-3"
|
| 218 |
|
|
run_dump_test "lp64-1"
|
| 219 |
|
|
run_dump_test "lp64-2"
|
| 220 |
|
|
run_dump_test "lp64-3"
|
| 221 |
157 |
khays |
run_dump_test "pr13082-1a"
|
| 222 |
|
|
run_dump_test "pr13082-1b"
|
| 223 |
|
|
run_dump_test "pr13082-2a"
|
| 224 |
|
|
run_dump_test "pr13082-2b"
|
| 225 |
|
|
run_dump_test "pr13082-3a"
|
| 226 |
|
|
run_dump_test "pr13082-3b"
|
| 227 |
|
|
run_dump_test "pr13082-4a"
|
| 228 |
|
|
run_dump_test "pr13082-4b"
|
| 229 |
|
|
run_dump_test "pr13082-5a"
|
| 230 |
|
|
run_dump_test "pr13082-5b"
|
| 231 |
|
|
run_dump_test "pr13082-6a"
|
| 232 |
|
|
run_dump_test "pr13082-6b"
|
| 233 |
148 |
khays |
|
| 234 |
|
|
# Must be native with the C compiler
|
| 235 |
|
|
if { [isnative] && [which $CC] != 0 } {
|
| 236 |
|
|
run_cc_link_tests {
|
| 237 |
|
|
{"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
|
| 238 |
|
|
{simple.c} {} "libsimple.a"}
|
| 239 |
|
|
}
|
| 240 |
|
|
|
| 241 |
|
|
set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
|
| 242 |
|
|
send_log "$convertx32\n"
|
| 243 |
|
|
set got [remote_exec host "$convertx32"]
|
| 244 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 245 |
|
|
send_log "$got\n"
|
| 246 |
|
|
fail "Convert x86-64 object to x32"
|
| 247 |
|
|
return
|
| 248 |
|
|
}
|
| 249 |
|
|
|
| 250 |
|
|
run_ld_link_tests {
|
| 251 |
|
|
{"X32 DSO from x86-64 object"
|
| 252 |
|
|
"-shared -melf32_x86_64 tmpdir/simple-x32.o" "--x32"
|
| 253 |
|
|
{dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
|
| 254 |
|
|
}
|
| 255 |
|
|
}
|