1 # export.at -- test symbol exports -*- Autotest -*-
3 # Copyright (C) 2007 Free Software Foundation, Inc.
4 # Written by Ralf Wildenhues, 2007
6 # This file is part of GNU Libtool.
8 # GNU Libtool is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
13 # GNU Libtool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING. If not, a copy
20 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 AT_SETUP([Export test])
26 AT_KEYWORDS([libtool])
28 AT_CHECK([$LIBTOOL --features | grep 'disable shared libraries' && (exit 77)],
30 AT_CHECK([eval `$LIBTOOL --config | sed -n '/^archive_expsym_cmds=/,/^$/p'`
31 test -n "$archive_expsym_cmds" || echo false >can-hide
32 case $archive_expsym_cmds in
33 *-retain-symbols-file*) echo false >can-hide ;;
36 test -s can-hide && can_hide=false
38 LDFLAGS="$LDFLAGS -no-undefined"
43 [[/* all kinds of data items */
52 extern const int v5, v6;
53 extern const char *v7;
54 extern const char v8[];
55 extern int (*const v12) (void);
58 const char* v7 = "\01foo";
59 const char v8[] = "\01bar";
60 int v9(void) { return v2 + 1; }
62 int (*v11) (void) = v9;
63 int (*const v12) (void) = v9;
65 typedef struct { int arr[1000]; } large;
67 large v14 = { { 0 } };
68 large v15 = { { 1 } };
70 int w1 (void) { return 0; }
96 #if defined(LIBA_DLL_IMPORT)
97 # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
98 # define LIBA_SCOPE extern __declspec(dllimport)
101 #if !defined(LIBA_SCOPE)
102 # define LIBA_SCOPE extern
109 LIBA_SCOPE const int v5, v6;
110 extern const char* v7;
111 extern const char v8[];
113 extern int (*v10) (void);
114 extern int (*v11) (void);
115 LIBA_SCOPE int (*const v12) (void);
120 typedef struct { int arr[1000]; } large;
121 extern large v13, v14, v15;
125 char s = v7[0] + v8[0];
126 return s + v1 + v3 + v4 + v5 + v6 + v9() + v11() + v12()
127 + v13.arr[0] + v14.arr[0] + v15.arr[0]
134 /* these symbols should not be exported */
138 extern int w1 (void);
148 AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c],[0],[ignore],[ignore])
149 AT_CHECK([$CC $CPPFLAGS -DLIBA_DLL_IMPORT $CFLAGS -c main.c],[0],[ignore],[ignore])
150 AT_CHECK([$CC $CPPFLAGS $CFLAGS -c broken.c],[0],[ignore],[ignore])
152 for exportsyms in '' '-export-symbols-regex "v.*"' '-export-symbols asyms'
154 # case 1: shared library built from object.
155 LT_AT_CHECK([eval '$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo \
156 -rpath $libdir' $exportsyms], [], [ignore], [ignore])
157 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT liba.la],
158 [], [ignore], [ignore])
159 LT_AT_EXEC_CHECK([./main])
160 if test -n "$exportsyms" && $can_hide; then
161 AT_CHECK([if $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o broken broken.$OBJEXT liba.la
162 then (exit 1); else :; fi], [], [ignore], [ignore])
165 # case 2: shared library built from convenience archive.
166 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o libconv.la a.lo],
167 [], [ignore], [ignore])
168 LT_AT_CHECK([eval '$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la libconv.la \
169 -rpath $libdir' $exportsyms], [], [ignore], [ignore])
170 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT liba.la],
171 [], [ignore], [ignore])
172 LT_AT_EXEC_CHECK([./main])
173 if test -n "$exportsyms" && $can_hide; then
174 AT_CHECK([if $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o broken broken.$OBJEXT liba.la
175 then (exit 1); else :; fi], [], [ignore], [ignore])
179 AT_CHECK([$can_hide || (exit 77)])