Update year range in copyright notice of binutils files
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / comm-data.exp
CommitLineData
74d44110
MR
1# Expect script for common symbol override.
2#
82704155 3# Copyright (C) 2011-2019 Free Software Foundation, Inc.
74d44110
MR
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#
24# Written by Maciej W. Rozycki <macro@codesourcery.com>
25#
26
fe9cd7ab
MR
27# This test is for ELF shared-library targets.
28if { ![is_elf_format] || ![check_shared_lib_support] } {
74d44110
MR
29 return
30}
31
fe9cd7ab
MR
32# This target requires extra GAS options when building code for shared
33# libraries.
34set AFLAGS_PIC ""
35if [istarget "tic6x-*-*"] {
36 append AFLAGS_PIC " -mpic -mpid=near"
37}
38# This target requires a non-default emulation for successful shared
39# library/executable builds.
40set LFLAGS ""
41if [istarget "tic6x-*-*"] {
42 append LFLAGS " -melf32_tic6x_le"
74d44110 43}
8988502d
MR
44# These targets do not default to linking with shared libraries.
45if { [istarget "mips*vr4100*-*-elf*"] \
46 || [istarget "mips*vr4300*-*-elf*"] \
47 || [istarget "mips*vr5000*-*-elf*"] } {
48 append LFLAGS " -call_shared"
49}
74d44110
MR
50
51set testname "Common symbol override test"
52
53# Define a global symbol.
54run_ld_link_tests [list \
55 [list \
56 "$testname (auxiliary shared object build)" \
fe9cd7ab
MR
57 "$LFLAGS -shared" "" \
58 "$AFLAGS_PIC" \
74d44110
MR
59 { comm-data1.s } \
60 { \
61 { readelf -s comm-data1.sd } \
62 } \
63 "libcomm-data.so" \
64 ] \
65]
66
67# Set the pointer size according to the ELF flavor.
68set AFLAGS ""
69if [is_elf64 "tmpdir/libcomm-data.so"] {
70 append AFLAGS " --defsym ELF64=1"
71}
fe9cd7ab
MR
72# HPUX targets use a different .comm syntax.
73if [istarget "*-*-hpux*"] {
74 append AFLAGS " --defsym HPUX=1"
75}
74d44110 76
1b857aee
NC
77# bfin does not currently support copy relocs.
78setup_xfail "bfin-*-*"
79
e0799d78
RM
80setup_xfail "arm*-*-*" "ld/13802"
81
fe9cd7ab
MR
82# List targets here that keep copy relocs rather than eliminating
83# them where possible in favour to dynamic relocs in the relevant
84# loadable sections; see also the "-z nocopyreloc" command-line
85# option and the ELIMINATE_COPY_RELOCS macro some backends use.
86set copy_reloc [expr [istarget mn10300-*-*] || [istarget vax-*-*]]
87
74d44110
MR
88# Verify that a common symbol has been converted to an undefined
89# reference to the global symbol of the same name defined above
90# and that the debug reference has been dropped.
91run_ld_link_tests [list \
92 [list \
93 "$testname" \
fe9cd7ab 94 "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
74d44110
MR
95 "$AFLAGS" \
96 { comm-data2.s } \
fe9cd7ab
MR
97 [list \
98 [list readelf -s \
99 [expr { $copy_reloc ? "comm-data2r.sd" : "comm-data2.sd"}]] \
100 [list readelf -r \
101 [expr { $copy_reloc ? "comm-data2r.rd" : "comm-data2.rd"}]] \
102 [list readelf "-x .debug_foo" \
103 [expr { $copy_reloc ? "comm-data2r.xd" : "comm-data2.xd"}]]] \
74d44110
MR
104 "comm-data" \
105 ] \
37a9e49a
L
106 [list \
107 "$testname 3a" \
897aea50 108 "-static" "" \
37a9e49a
L
109 "" \
110 { comm-data3a.s comm-data3b.s } \
111 { \
112 { readelf -s comm-data3.sd } \
113 } \
114 "comm-data3a" \
115 ] \
116 [list \
117 "$testname 3b" \
897aea50 118 "-static" "" \
37a9e49a
L
119 "" \
120 { comm-data3b.s comm-data3a.s } \
121 { \
122 { readelf -s comm-data3.sd } \
123 } \
124 "comm-data3b" \
125 ] \
74d44110 126]
This page took 0.341117 seconds and 4 git commands to generate.