]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-elf/comm-data.exp
Copyright update for binutils
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / comm-data.exp
1 # Expect script for common symbol override.
2 #
3 # Copyright (C) 2011-2016 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
45 set testname "Common symbol override test"
46
47 # Define a global symbol.
48 run_ld_link_tests [list \
49 [list \
50 "$testname (auxiliary shared object build)" \
51 "$LFLAGS -shared" "" \
52 "$AFLAGS_PIC" \
53 { comm-data1.s } \
54 { \
55 { readelf -s comm-data1.sd } \
56 } \
57 "libcomm-data.so" \
58 ] \
59 ]
60
61 # Set the pointer size according to the ELF flavor.
62 set AFLAGS ""
63 if [is_elf64 "tmpdir/libcomm-data.so"] {
64 append AFLAGS " --defsym ELF64=1"
65 }
66 # HPUX targets use a different .comm syntax.
67 if [istarget "*-*-hpux*"] {
68 append AFLAGS " --defsym HPUX=1"
69 }
70
71 setup_xfail "arm*-*-*" "ld/13802"
72
73 # List targets here that keep copy relocs rather than eliminating
74 # them where possible in favour to dynamic relocs in the relevant
75 # loadable sections; see also the "-z nocopyreloc" command-line
76 # option and the ELIMINATE_COPY_RELOCS macro some backends use.
77 set copy_reloc [expr [istarget mn10300-*-*] || [istarget vax-*-*]]
78
79 # Verify that a common symbol has been converted to an undefined
80 # reference to the global symbol of the same name defined above
81 # and that the debug reference has been dropped.
82 run_ld_link_tests [list \
83 [list \
84 "$testname" \
85 "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
86 "$AFLAGS" \
87 { comm-data2.s } \
88 [list \
89 [list readelf -s \
90 [expr { $copy_reloc ? "comm-data2r.sd" : "comm-data2.sd"}]] \
91 [list readelf -r \
92 [expr { $copy_reloc ? "comm-data2r.rd" : "comm-data2.rd"}]] \
93 [list readelf "-x .debug_foo" \
94 [expr { $copy_reloc ? "comm-data2r.xd" : "comm-data2.xd"}]]] \
95 "comm-data" \
96 ] \
97 [list \
98 "$testname 3a" \
99 "-static" "" \
100 "" \
101 { comm-data3a.s comm-data3b.s } \
102 { \
103 { readelf -s comm-data3.sd } \
104 } \
105 "comm-data3a" \
106 ] \
107 [list \
108 "$testname 3b" \
109 "-static" "" \
110 "" \
111 { comm-data3b.s comm-data3a.s } \
112 { \
113 { readelf -s comm-data3.sd } \
114 } \
115 "comm-data3b" \
116 ] \
117 ]