Remove x86 NaCl target support
[deliverable/binutils-gdb.git] / ld / testsuite / ld-x86-64 / dwarfreloc.exp
CommitLineData
b2064611 1# Expect script for DWARF relocation test.
b3adc24a 2# Copyright (C) 2008-2020 Free Software Foundation, Inc.
b2064611
JK
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#
23# Written by Jan Kratochvil (jan.kratochvil@redhat.com)
24#
25# Test PR ld/3290 Comment 8+9. DW_FORM_ref_addr used in dwarfreloc2.s was left
26# unrelocated as its target symbol from dwarfreloc1.s became LOCAL due to its
27# `ld -r'.
28#
29# <1><57>: Abbrev Number: 2 (DW_TAG_variable)
5a68afcf 30# <58> DW_AT_name : i2
b2064611 31# ...
5a68afcf 32# <5d> DW_AT_type : <0x32>
b2064611 33# vs.
5a68afcf 34# <5d> DW_AT_type : <0x0>
b2064611
JK
35
36# Only the testcase .s files are arch-dependent, the relocations are cross-arch.
bbd19b19 37if { !([istarget "x86_64-*-elf*"] || [istarget "x86_64-*-linux*"]) } {
b2064611
JK
38 return
39}
40
41set build_tests_ld {
b8871f35
L
42 {"Build dwarfreloc1xa.o"
43 "-r" "" "--elf-stt-common=no"
44 {dwarfreloc1.s} {} "dwarfreloc1xa.o"}
45 {"Build dwarfreloc1xb.o"
46 "-r" "" "--elf-stt-common=yes"
47 {dwarfreloc1.s} {} "dwarfreloc1xb.o"}
48 {"Build dwarfreloc2a.o"
49 "-r" "" "--elf-stt-common=no"
50 {dwarfreloc2.s} {} "dwarfreloc2xa.o"}
51 {"Build dwarfreloc2b.o"
52 "-r" "" "--elf-stt-common=yes"
53 {dwarfreloc2.s} {} "dwarfreloc2xb.o"}
b2064611
JK
54}
55
56run_ld_link_tests $build_tests_ld
57
b8871f35 58set testname "Link dwarfreloc1xa.o and dwarfreloc2xa.o to dwarfreloca.o"
d9816402 59if [ld_link $ld "tmpdir/dwarfreloca.o" "-r tmpdir/dwarfreloc1xa.o tmpdir/dwarfreloc2xa.o"] {
b8871f35
L
60 pass $testname
61} else {
62 fail $testname
63}
64
65set testname "Link dwarfreloc1xb.o and dwarfreloc2xb.o to dwarfrelocb.o"
d9816402 66if [ld_link $ld "tmpdir/dwarfrelocb.o" "-r tmpdir/dwarfreloc1xb.o tmpdir/dwarfreloc2xb.o"] {
b2064611
JK
67 pass $testname
68} else {
69 fail $testname
70}
71
72# The code is copied from `ld-lib.exp'. We cannot use the functions there as
73# they expect source (.s or .c) files while we to check a `ld -r' output (.o).
74
b8871f35
L
75set testname "Check dwarfreloca.o readelf"
76set dumpfile "dwarfreloc.rd"
77set cmd "$READELF --debug-dump=info tmpdir/dwarfreloca.o"
78set status [remote_exec host [concat sh -c [list "$cmd >dump.out 2>ld.stderr"]] "" "/dev/null"]
79send_log "$cmd\n"
80remote_upload host "ld.stderr"
81set comp_output [prune_warnings [file_contents "ld.stderr"]]
82remote_file host delete "ld.stderr"
83remote_file build delete "ld.stderr"
84
85if ![string match "" $comp_output] then {
86 send_log "$comp_output\n"
87 fail $testname
88} else {
89 remote_upload host "dump.out"
90 if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then {
91 verbose "output is [file_contents "dump.out"]" 2
92 fail $testname
93 } else {
94 pass $testname
95 }
96 remote_file build delete "dump.out"
97 remote_file host delete "dump.out"
98}
99
100set testname "Check dwarfrelocb.o readelf"
b2064611 101set dumpfile "dwarfreloc.rd"
b8871f35 102set cmd "$READELF --debug-dump=info tmpdir/dwarfrelocb.o"
b2064611
JK
103set status [remote_exec host [concat sh -c [list "$cmd >dump.out 2>ld.stderr"]] "" "/dev/null"]
104send_log "$cmd\n"
105remote_upload host "ld.stderr"
106set comp_output [prune_warnings [file_contents "ld.stderr"]]
107remote_file host delete "ld.stderr"
108remote_file build delete "ld.stderr"
109
110if ![string match "" $comp_output] then {
111 send_log "$comp_output\n"
112 fail $testname
113} else {
114 remote_upload host "dump.out"
115 if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then {
116 verbose "output is [file_contents "dump.out"]" 2
117 fail $testname
118 } else {
119 pass $testname
120 }
121 remote_file build delete "dump.out"
122 remote_file host delete "dump.out"
123}
This page took 0.541221 seconds and 4 git commands to generate.