]>
Commit | Line | Data |
---|---|---|
1 | # Expect script for common symbol override. | |
2 | # | |
3 | # Copyright (C) 2011-2022 Free Software Foundation, Inc. | |
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 | ||
27 | # This test is for ELF shared-library targets. | |
28 | if { ![is_elf_format] || ![check_shared_lib_support] } { | |
29 | return | |
30 | } | |
31 | ||
32 | # This target requires extra GAS options when building code for shared | |
33 | # libraries. | |
34 | set AFLAGS_PIC "" | |
35 | if [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. | |
40 | set LFLAGS "" | |
41 | if [istarget "tic6x-*-*"] { | |
42 | append LFLAGS " -melf32_tic6x_le" | |
43 | } | |
44 | # These targets do not default to linking with shared libraries. | |
45 | if { [istarget "mips*vr4100*-*-elf*"] \ | |
46 | || [istarget "mips*vr4300*-*-elf*"] \ | |
47 | || [istarget "mips*vr5000*-*-elf*"] } { | |
48 | append LFLAGS " -call_shared" | |
49 | } | |
50 | ||
51 | # Set the pointer size according to the ELF flavor. | |
52 | set AFLAGS "" | |
53 | if [is_elf64 "tmpdir/libcomm-data.so"] { | |
54 | append AFLAGS " --defsym ELF64=1" | |
55 | } | |
56 | # HPUX targets use a different .comm syntax. | |
57 | if [istarget "*-*-hpux*"] { | |
58 | append AFLAGS " --defsym HPUX=1" | |
59 | } | |
60 | ||
61 | set testname "Common symbol override test" | |
62 | ||
63 | # Define a global symbol. | |
64 | run_ld_link_tests [list \ | |
65 | [list \ | |
66 | "$testname (auxiliary shared object build)" \ | |
67 | "$LFLAGS -shared" "" \ | |
68 | "$AFLAGS_PIC" \ | |
69 | { comm-data1.s } \ | |
70 | { \ | |
71 | { readelf -s comm-data1.sd } \ | |
72 | } \ | |
73 | "libcomm-data.so" \ | |
74 | ] \ | |
75 | [list \ | |
76 | "libpr26580-1.so" \ | |
77 | "$LFLAGS -shared" "" \ | |
78 | "$AFLAGS_PIC $AFLAGS" \ | |
79 | { pr26580-b.s } \ | |
80 | { } \ | |
81 | "libpr26580-1.so" \ | |
82 | ] \ | |
83 | ] | |
84 | ||
85 | # bfin-elf does not currently support copy relocs. | |
86 | setup_xfail "bfin-*-*" | |
87 | clear_xfail "bfin-*-linux-uclibc*" | |
88 | ||
89 | # Verify that a common symbol has been converted to an undefined | |
90 | # reference to the global symbol of the same name defined above | |
91 | # and that the debug reference has been dropped. | |
92 | run_ld_link_tests [list \ | |
93 | [list \ | |
94 | "$testname" \ | |
95 | "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \ | |
96 | "$AFLAGS" \ | |
97 | { comm-data2.s } \ | |
98 | [list \ | |
99 | [list readelf -s comm-data2.sd] \ | |
100 | [list readelf -r comm-data2.rd] \ | |
101 | [list readelf "-x .debug_foo" comm-data2.xd]] \ | |
102 | "comm-data" \ | |
103 | ] \ | |
104 | [list \ | |
105 | "$testname 3a" \ | |
106 | "-static" "" \ | |
107 | "" \ | |
108 | { comm-data3a.s comm-data3b.s } \ | |
109 | { \ | |
110 | { readelf -s comm-data3.sd } \ | |
111 | } \ | |
112 | "comm-data3a" \ | |
113 | ] \ | |
114 | [list \ | |
115 | "$testname 3b" \ | |
116 | "-static" "" \ | |
117 | "" \ | |
118 | { comm-data3b.s comm-data3a.s } \ | |
119 | { \ | |
120 | { readelf -s comm-data3.sd } \ | |
121 | } \ | |
122 | "comm-data3b" \ | |
123 | ] \ | |
124 | [list \ | |
125 | "pr26580-1" \ | |
126 | "$LFLAGS --as-needed -Ltmpdir -lpr26580-1" "" \ | |
127 | "$AFLAGS" \ | |
128 | { pr26580-a.s } \ | |
129 | { {readelf -s pr26580-1.sd} } \ | |
130 | "pr26580-1" \ | |
131 | ] \ | |
132 | [list \ | |
133 | "pr26580-2" \ | |
134 | "$LFLAGS --no-as-needed -Ltmpdir -lpr26580-1" "" \ | |
135 | "$AFLAGS" \ | |
136 | { pr26580-a.s } \ | |
137 | { {readelf -s pr26580-2.sd} } \ | |
138 | "pr26580-2" \ | |
139 | ] \ | |
140 | ] |