]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-elf/comm-data.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / comm-data.exp
CommitLineData
74d44110
MR
1# Expect script for common symbol override.
2#
d87bef3a 3# Copyright (C) 2011-2023 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 50
74d44110 51# Define a global symbol.
6bd454ca 52set testname "Common symbol override test"
74d44110
MR
53run_ld_link_tests [list \
54 [list \
55 "$testname (auxiliary shared object build)" \
fe9cd7ab
MR
56 "$LFLAGS -shared" "" \
57 "$AFLAGS_PIC" \
74d44110
MR
58 { comm-data1.s } \
59 { \
60 { readelf -s comm-data1.sd } \
61 } \
62 "libcomm-data.so" \
63 ] \
64]
65
6bd454ca
AM
66# Set the pointer size according to the ELF flavor.
67set AFLAGS ""
68if [is_elf64 "tmpdir/libcomm-data.so"] {
69 append AFLAGS " --defsym ELF64=1"
70}
71# HPUX targets use a different .comm syntax.
72if [istarget "*-*-hpux*"] {
73 append AFLAGS " --defsym HPUX=1"
74}
75
1fc47f80 76# bfin-elf does not currently support copy relocs.
1b857aee 77setup_xfail "bfin-*-*"
1fc47f80 78clear_xfail "bfin-*-linux-uclibc*"
e0799d78 79
74d44110
MR
80# Verify that a common symbol has been converted to an undefined
81# reference to the global symbol of the same name defined above
82# and that the debug reference has been dropped.
83run_ld_link_tests [list \
84 [list \
85 "$testname" \
fe9cd7ab 86 "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
74d44110
MR
87 "$AFLAGS" \
88 { comm-data2.s } \
fe9cd7ab 89 [list \
c4b126b8
L
90 [list readelf -s comm-data2.sd] \
91 [list readelf -r comm-data2.rd] \
92 [list readelf "-x .debug_foo" comm-data2.xd]] \
74d44110
MR
93 "comm-data" \
94 ] \
37a9e49a
L
95 [list \
96 "$testname 3a" \
897aea50 97 "-static" "" \
37a9e49a
L
98 "" \
99 { comm-data3a.s comm-data3b.s } \
100 { \
101 { readelf -s comm-data3.sd } \
102 } \
103 "comm-data3a" \
104 ] \
105 [list \
106 "$testname 3b" \
897aea50 107 "-static" "" \
37a9e49a
L
108 "" \
109 { comm-data3b.s comm-data3a.s } \
110 { \
111 { readelf -s comm-data3.sd } \
112 } \
113 "comm-data3b" \
114 ] \
6bd454ca
AM
115 [list \
116 "libpr26580-1.so" \
117 "$LFLAGS -shared" "" \
118 "$AFLAGS_PIC $AFLAGS" \
119 { pr26580-b.s } \
120 { } \
121 "libpr26580-1.so" \
122 ] \
7ba11550
AM
123 [list \
124 "pr26580-1" \
125 "$LFLAGS --as-needed -Ltmpdir -lpr26580-1" "" \
126 "$AFLAGS" \
127 { pr26580-a.s } \
128 { {readelf -s pr26580-1.sd} } \
129 "pr26580-1" \
130 ] \
131 [list \
132 "pr26580-2" \
133 "$LFLAGS --no-as-needed -Ltmpdir -lpr26580-1" "" \
134 "$AFLAGS" \
135 { pr26580-a.s } \
136 { {readelf -s pr26580-2.sd} } \
137 "pr26580-2" \
138 ] \
74d44110 139]