aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-07 17:10:10 +0000
committerIan Lance Taylor <iant@google.com>2007-10-07 17:10:10 +0000
commit6eee141ff6d84d39ca9e364eb98818431162d6df (patch)
treecf13d55adff30ab67d0ab5a0e296007fc02521f7 /gold
parent46cf9fa27e13491561a643178d5ffd2b086183fb (diff)
downloadgdb-6eee141ff6d84d39ca9e364eb98818431162d6df.zip
gdb-6eee141ff6d84d39ca9e364eb98818431162d6df.tar.gz
gdb-6eee141ff6d84d39ca9e364eb98818431162d6df.tar.bz2
Add a TLS test case.
Diffstat (limited to 'gold')
-rw-r--r--gold/Makefile.in2
-rwxr-xr-xgold/configure55
-rw-r--r--gold/configure.ac4
-rw-r--r--gold/testsuite/Makefile.am64
-rw-r--r--gold/testsuite/Makefile.in121
-rw-r--r--gold/testsuite/tls_test.cc137
-rw-r--r--gold/testsuite/tls_test.h39
-rw-r--r--gold/testsuite/tls_test_main.cc146
8 files changed, 562 insertions, 6 deletions
diff --git a/gold/Makefile.in b/gold/Makefile.in
index a2e4100..b687104 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -207,6 +207,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TARGETOBJS = @TARGETOBJS@
+TLS_FALSE = @TLS_FALSE@
+TLS_TRUE = @TLS_TRUE@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
diff --git a/gold/configure b/gold/configure
index f7192cd..adfd485 100755
--- a/gold/configure
+++ b/gold/configure
@@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar TARGETOBJS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE YACC RANLIB ac_ct_RANLIB LN_S USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE NATIVE_LINKER_TRUE NATIVE_LINKER_FALSE GCC_TRUE GCC_FALSE FN_PTRS_IN_SO_WITHOUT_PIC_TRUE FN_PTRS_IN_SO_WITHOUT_PIC_FALSE WARN_CFLAGS NO_WERROR WARN_CXXFLAGS LFS_CXXFLAGS LIBOBJS CXXCPP EGREP MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar TARGETOBJS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE YACC RANLIB ac_ct_RANLIB LN_S USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE NATIVE_LINKER_TRUE NATIVE_LINKER_FALSE GCC_TRUE GCC_FALSE FN_PTRS_IN_SO_WITHOUT_PIC_TRUE FN_PTRS_IN_SO_WITHOUT_PIC_FALSE TLS_TRUE TLS_FALSE WARN_CFLAGS NO_WERROR WARN_CXXFLAGS LFS_CXXFLAGS LIBOBJS CXXCPP EGREP MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -4419,6 +4419,50 @@ else
fi
+cat >conftest.$ac_ext <<_ACEOF
+__thread int i = 1;
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ tls=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+tls=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+if test "$tls" = "yes"; then
+ TLS_TRUE=
+ TLS_FALSE='#'
+else
+ TLS_TRUE='#'
+ TLS_FALSE=
+fi
+
+
GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
@@ -5593,6 +5637,13 @@ echo "$as_me: error: conditional \"FN_PTRS_IN_SO_WITHOUT_PIC\" was never defined
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${TLS_TRUE}" && test -z "${TLS_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"TLS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"TLS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -6224,6 +6275,8 @@ s,@GCC_TRUE@,$GCC_TRUE,;t t
s,@GCC_FALSE@,$GCC_FALSE,;t t
s,@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@,$FN_PTRS_IN_SO_WITHOUT_PIC_TRUE,;t t
s,@FN_PTRS_IN_SO_WITHOUT_PIC_FALSE@,$FN_PTRS_IN_SO_WITHOUT_PIC_FALSE,;t t
+s,@TLS_TRUE@,$TLS_TRUE,;t t
+s,@TLS_FALSE@,$TLS_FALSE,;t t
s,@WARN_CFLAGS@,$WARN_CFLAGS,;t t
s,@NO_WERROR@,$NO_WERROR,;t t
s,@WARN_CXXFLAGS@,$WARN_CXXFLAGS,;t t
diff --git a/gold/configure.ac b/gold/configure.ac
index d01ab91..af62d4a 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -150,6 +150,10 @@ AM_CONDITIONAL(FN_PTRS_IN_SO_WITHOUT_PIC, [
*) true;;
esac])
+dnl Test for __thread support.
+AC_COMPILE_IFELSE([__thread int i = 1;], [tls=yes], [tls=no])
+AM_CONDITIONAL(TLS, test "$tls" = "yes")
+
AM_BINUTILS_WARNINGS
WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//'`
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index b2f56dc..4460a18 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -45,6 +45,23 @@ NATIVE_PROGS += \
endif
+if TLS
+
+NATIVE_PROGS += \
+ tls_test \
+ tls_pic_test \
+ tls_static_test \
+ tls_static_pic_test \
+ tls_shared_test
+
+if FN_PTRS_IN_SO_WITHOUT_PIC
+
+NATIVE_PROGS += \
+ tls_shared_nonpic_test
+
+endif
+endif
+
NATIVE_TESTING = \
basic_test \
basic_pic_test \
@@ -252,5 +269,52 @@ exception_shared_2.so: exception_test_2_pic.o
exception_shared.so: exception_test_1_pic.o exception_test_2_pic.o
$(CXXLINK) -shared exception_test_1_pic.o exception_test_2_pic.o
+if TLS
+
+tls_test_SOURCES = tls_test.cc tls_test_main.cc tls_test.h
+tls_test_DEPENDENCIES = gcctestdir/ld
+tls_test_LDFLAGS = -Bgcctestdir/
+tls_test_LDADD = -lpthread
+
+tls_pic_test_SOURCES = tls_test_main.cc
+tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o
+tls_pic_test_LDFLAGS = -Bgcctestdir/
+tls_pic_test_LDADD = tls_test_pic.o -lpthread
+
+tls_static_test_SOURCES = tls_test.cc tls_test_main.cc
+tls_static_test_DEPENDENCIES = gcctestdir/ld
+tls_static_test_LDFLAGS = -Bgcctestdir/ -static
+tls_static_test_LDADD = -lpthread
+
+tls_static_pic_test_SOURCES = tls_test_main.cc
+tls_static_pic_test_DEPENDENCIES = gcctestdir/ld
+tls_static_pic_test_LDFLAGS = -Bgcctestdir/ -static
+tls_static_pic_test_LDADD = tls_test_pic.o -lpthread
+
+tls_shared_test_SOURCES = tls_test_main.cc
+tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
+tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+tls_shared_test_LDADD = tls_test_shared.so -lpthread
+
+tls_test_pic.o: tls_test.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+
+tls_test_shared.so: tls_test_pic.o
+ $(CXXLINK) -shared tls_test_pic.o
+
+if FN_PTRS_IN_SO_WITHOUT_PIC
+
+tls_shared_nonpic_test_SOURCES = tls_test_main.cc
+tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
+tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
+
+tls_test_shared_nonpic.so: tls_test.o
+ $(CXXLINK) -shared tls_test.o
+
+endif
+
+endif
+
endif
endif
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 6cf79cc..371ec68 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -49,7 +49,17 @@ target_triplet = @target@
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_nonpic_test \
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_nonpic_test
-check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_2)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_2 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_static_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_static_pic_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_test
+
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_3 = \
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_nonpic_test
+
+check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_4)
@GCC_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a \
@@ -79,6 +89,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_2)
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@tls_test_DEPENDENCIES =
+@NATIVE_LINKER_FALSE@tls_test_DEPENDENCIES =
+@TLS_FALSE@tls_test_DEPENDENCIES =
+@GCC_FALSE@tls_static_test_DEPENDENCIES =
+@NATIVE_LINKER_FALSE@tls_static_test_DEPENDENCIES =
+@TLS_FALSE@tls_static_test_DEPENDENCIES =
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -105,7 +121,14 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_same_shared_nonpic_test$(EXEEXT) \
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_12_nonpic_test$(EXEEXT) \
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_separate_shared_21_nonpic_test$(EXEEXT)
-@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_2 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_2 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_static_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_static_pic_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_test$(EXEEXT)
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_3 = tls_shared_nonpic_test$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_4 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ constructor_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ constructor_static_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test$(EXEEXT) \
@@ -121,7 +144,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_same_shared_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_12_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_21_test$(EXEEXT) \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__EXEEXT_1)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__EXEEXT_1) $(am__EXEEXT_2) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__EXEEXT_3)
am__constructor_static_test_SOURCES_DIST = constructor_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_constructor_static_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ constructor_test.$(OBJEXT)
@@ -186,6 +210,28 @@ object_unittest_OBJECTS = $(am_object_unittest_OBJECTS)
object_unittest_LDADD = $(LDADD)
object_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1)
+am__tls_pic_test_SOURCES_DIST = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_pic_test_OBJECTS = tls_test_main.$(OBJEXT)
+tls_pic_test_OBJECTS = $(am_tls_pic_test_OBJECTS)
+am__tls_shared_nonpic_test_SOURCES_DIST = tls_test_main.cc
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_shared_nonpic_test_OBJECTS = tls_test_main.$(OBJEXT)
+tls_shared_nonpic_test_OBJECTS = $(am_tls_shared_nonpic_test_OBJECTS)
+am__tls_shared_test_SOURCES_DIST = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_shared_test_OBJECTS = tls_test_main.$(OBJEXT)
+tls_shared_test_OBJECTS = $(am_tls_shared_test_OBJECTS)
+am__tls_static_pic_test_SOURCES_DIST = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_static_pic_test_OBJECTS = tls_test_main.$(OBJEXT)
+tls_static_pic_test_OBJECTS = $(am_tls_static_pic_test_OBJECTS)
+am__tls_static_test_SOURCES_DIST = tls_test.cc tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_static_test_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test.$(OBJEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test_main.$(OBJEXT)
+tls_static_test_OBJECTS = $(am_tls_static_test_OBJECTS)
+am__tls_test_SOURCES_DIST = tls_test.cc tls_test_main.cc tls_test.h
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_test_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test.$(OBJEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test_main.$(OBJEXT)
+tls_test_OBJECTS = $(am_tls_test_OBJECTS)
am__two_file_same_shared_nonpic_test_SOURCES_DIST = \
two_file_test_main.cc
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_two_file_same_shared_nonpic_test_OBJECTS = two_file_test_main.$(OBJEXT)
@@ -270,7 +316,10 @@ SOURCES = $(libgoldtest_a_SOURCES) $(constructor_static_test_SOURCES) \
$(exception_shared_1_test_SOURCES) \
$(exception_shared_2_test_SOURCES) \
$(exception_static_test_SOURCES) $(exception_test_SOURCES) \
- $(object_unittest_SOURCES) \
+ $(object_unittest_SOURCES) $(tls_pic_test_SOURCES) \
+ $(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \
+ $(tls_static_pic_test_SOURCES) $(tls_static_test_SOURCES) \
+ $(tls_test_SOURCES) \
$(two_file_same_shared_nonpic_test_SOURCES) \
$(two_file_same_shared_test_SOURCES) \
$(two_file_separate_shared_12_nonpic_test_SOURCES) \
@@ -291,6 +340,12 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) \
$(am__exception_shared_2_test_SOURCES_DIST) \
$(am__exception_static_test_SOURCES_DIST) \
$(am__exception_test_SOURCES_DIST) $(object_unittest_SOURCES) \
+ $(am__tls_pic_test_SOURCES_DIST) \
+ $(am__tls_shared_nonpic_test_SOURCES_DIST) \
+ $(am__tls_shared_test_SOURCES_DIST) \
+ $(am__tls_static_pic_test_SOURCES_DIST) \
+ $(am__tls_static_test_SOURCES_DIST) \
+ $(am__tls_test_SOURCES_DIST) \
$(am__two_file_same_shared_nonpic_test_SOURCES_DIST) \
$(am__two_file_same_shared_test_SOURCES_DIST) \
$(am__two_file_separate_shared_12_nonpic_test_SOURCES_DIST) \
@@ -376,6 +431,8 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TARGETOBJS = @TARGETOBJS@
+TLS_FALSE = @TLS_FALSE@
+TLS_TRUE = @TLS_TRUE@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
@@ -450,7 +507,8 @@ INCLUDES = -D_GNU_SOURCE \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_same_shared_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_12_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_21_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_1)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_1) $(am__append_2) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_3)
@GCC_TRUE@@NATIVE_LINKER_TRUE@NATIVE_TESTING = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_pic_test \
@@ -592,6 +650,30 @@ object_unittest_SOURCES = object_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_separate_shared_21_test_LDADD = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_shared_2.so exception_shared_1.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_SOURCES = tls_test.cc tls_test_main.cc tls_test.h
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_LDFLAGS = -Bgcctestdir/
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_LDADD = -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_pic_test_SOURCES = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_pic_test_DEPENDENCIES = gcctestdir/ld tls_test_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_pic_test_LDFLAGS = -Bgcctestdir/
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_pic_test_LDADD = tls_test_pic.o -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_test_SOURCES = tls_test.cc tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_test_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_test_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_test_LDADD = -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_pic_test_SOURCES = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_pic_test_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_pic_test_LDFLAGS = -Bgcctestdir/ -static
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_pic_test_LDADD = tls_test_pic.o -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_test_SOURCES = tls_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_test_LDADD = tls_test_shared.so -lpthread
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_SOURCES = tls_test_main.cc
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
all: all-am
.SUFFIXES:
@@ -665,6 +747,24 @@ exception_test$(EXEEXT): $(exception_test_OBJECTS) $(exception_test_DEPENDENCIES
object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENCIES)
@rm -f object_unittest$(EXEEXT)
$(CXXLINK) $(object_unittest_LDFLAGS) $(object_unittest_OBJECTS) $(object_unittest_LDADD) $(LIBS)
+tls_pic_test$(EXEEXT): $(tls_pic_test_OBJECTS) $(tls_pic_test_DEPENDENCIES)
+ @rm -f tls_pic_test$(EXEEXT)
+ $(CXXLINK) $(tls_pic_test_LDFLAGS) $(tls_pic_test_OBJECTS) $(tls_pic_test_LDADD) $(LIBS)
+tls_shared_nonpic_test$(EXEEXT): $(tls_shared_nonpic_test_OBJECTS) $(tls_shared_nonpic_test_DEPENDENCIES)
+ @rm -f tls_shared_nonpic_test$(EXEEXT)
+ $(CXXLINK) $(tls_shared_nonpic_test_LDFLAGS) $(tls_shared_nonpic_test_OBJECTS) $(tls_shared_nonpic_test_LDADD) $(LIBS)
+tls_shared_test$(EXEEXT): $(tls_shared_test_OBJECTS) $(tls_shared_test_DEPENDENCIES)
+ @rm -f tls_shared_test$(EXEEXT)
+ $(CXXLINK) $(tls_shared_test_LDFLAGS) $(tls_shared_test_OBJECTS) $(tls_shared_test_LDADD) $(LIBS)
+tls_static_pic_test$(EXEEXT): $(tls_static_pic_test_OBJECTS) $(tls_static_pic_test_DEPENDENCIES)
+ @rm -f tls_static_pic_test$(EXEEXT)
+ $(CXXLINK) $(tls_static_pic_test_LDFLAGS) $(tls_static_pic_test_OBJECTS) $(tls_static_pic_test_LDADD) $(LIBS)
+tls_static_test$(EXEEXT): $(tls_static_test_OBJECTS) $(tls_static_test_DEPENDENCIES)
+ @rm -f tls_static_test$(EXEEXT)
+ $(CXXLINK) $(tls_static_test_LDFLAGS) $(tls_static_test_OBJECTS) $(tls_static_test_LDADD) $(LIBS)
+tls_test$(EXEEXT): $(tls_test_OBJECTS) $(tls_test_DEPENDENCIES)
+ @rm -f tls_test$(EXEEXT)
+ $(CXXLINK) $(tls_test_LDFLAGS) $(tls_test_OBJECTS) $(tls_test_LDADD) $(LIBS)
two_file_same_shared_nonpic_test$(EXEEXT): $(two_file_same_shared_nonpic_test_OBJECTS) $(two_file_same_shared_nonpic_test_DEPENDENCIES)
@rm -f two_file_same_shared_nonpic_test$(EXEEXT)
$(CXXLINK) $(two_file_same_shared_nonpic_test_LDFLAGS) $(two_file_same_shared_nonpic_test_OBJECTS) $(two_file_same_shared_nonpic_test_LDADD) $(LIBS)
@@ -713,6 +813,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testmain.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_test_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_main.Po@am__quote@
@@ -1022,6 +1124,15 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -shared exception_test_2_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_shared.so: exception_test_1_pic.o exception_test_2_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -shared exception_test_1_pic.o exception_test_2_pic.o
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_pic.o: tls_test.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_shared.so: tls_test_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -shared tls_test_pic.o
+
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_shared_nonpic.so: tls_test.o
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -shared tls_test.o
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/gold/testsuite/tls_test.cc b/gold/testsuite/tls_test.cc
new file mode 100644
index 0000000..a666433
--- /dev/null
+++ b/gold/testsuite/tls_test.cc
@@ -0,0 +1,137 @@
+// tls_test.cc -- test TLS variables for gold
+
+// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// This provides a set of test functions for TLS variables. The
+// functions are called by a main function in tls_test_main.cc. This
+// lets us test TLS access from a shared library. We currently don't
+// bother to test TLS access between two different files, on the
+// theory that that is no more complicated than ordinary variable
+// access between files.
+
+// We start two threads, and stop the second one. Then we run the
+// first thread through the following cases. Then we let the second
+// thread continue, and run it through the same set of cases. All the
+// actual thread manipulation is in tls_test_main.cc.
+
+// 1 Access to an uninitialized global thread variable.
+// 2 Access to an uninitialized static thread variable.
+// 3 Access to an initialized global thread variable.
+// 4 Access to an initialized static thread variable.
+// 5 Taking the address of a global thread variable.
+// 6 Taking the address of a static thread variable.
+// 7 Verify that the above tests left the variables set correctly.
+
+#include "tls_test.h"
+
+__thread int v1;
+static __thread int v2;
+__thread int v3 = 3;
+static __thread int v4 = 4;
+__thread int v5;
+static __thread int v6;
+
+bool
+t1()
+{
+ if (v1 != 0)
+ return false;
+ v1 = 10;
+ return true;
+}
+
+bool
+t2()
+{
+ if (v2 != 0)
+ return false;
+ v2 = 20;
+ return true;
+}
+
+bool
+t3()
+{
+ if (v3 != 3)
+ return false;
+ v3 = 30;
+ return true;
+}
+
+bool
+t4()
+{
+ if (v4 != 4)
+ return false;
+ v4 = 40;
+ return true;
+}
+
+// For test 5 the main function calls f5b(f5a()), then calls t5().
+
+int*
+f5a()
+{
+ return &v5;
+}
+
+void
+f5b(int* p)
+{
+ *p = 50;
+}
+
+bool
+t5()
+{
+ return v5 == 50;
+}
+
+// For test 5 the main function calls f6b(f6a()), then calls t6().
+
+int*
+f6a()
+{
+ return &v6;
+}
+
+void
+f6b(int* p)
+{
+ *p = 60;
+}
+
+bool
+t6()
+{
+ return v6 == 60;
+}
+
+bool
+t7()
+{
+ return (v1 == 10
+ && v2 == 20
+ && v3 == 30
+ && v4 == 40
+ && v5 == 50
+ && v6 == 60);
+}
diff --git a/gold/testsuite/tls_test.h b/gold/testsuite/tls_test.h
new file mode 100644
index 0000000..b260cad
--- /dev/null
+++ b/gold/testsuite/tls_test.h
@@ -0,0 +1,39 @@
+// tls_test.h -- test TLS variables for gold, header file -*- C++ -*-
+
+// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// This is the header file for the TLS test. See tls_test.cc for more
+// information.
+
+extern bool t1();
+extern bool t2();
+extern bool t3();
+extern bool t4();
+
+extern int* f5a();
+extern void f5b(int*);
+extern bool t5();
+
+extern int* f6a();
+extern void f6b(int*);
+extern bool t6();
+
+extern bool t7();
diff --git a/gold/testsuite/tls_test_main.cc b/gold/testsuite/tls_test_main.cc
new file mode 100644
index 0000000..b029092
--- /dev/null
+++ b/gold/testsuite/tls_test_main.cc
@@ -0,0 +1,146 @@
+// tls_test.cc -- test TLS variables for gold, main function
+
+// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>.
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+// This is the main function for the TLS test. See tls_test.cc for
+// more information.
+
+#include <cassert>
+#include <pthread.h>
+
+#include "tls_test.h"
+
+struct Mutex_set
+{
+ pthread_mutex_t mutex1;
+ pthread_mutex_t mutex2;
+ pthread_mutex_t mutex3;
+};
+
+Mutex_set mutexes1 = { PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_MUTEX_INITIALIZER };
+
+Mutex_set mutexes2 = { PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_MUTEX_INITIALIZER } ;
+
+// The body of the thread function. This gets a lock on the first
+// mutex, runs the tests, and then unlocks the second mutex. Then it
+// locks the third mutex, and the runs the verification test again.
+
+void*
+thread_routine(void* arg)
+{
+ Mutex_set* pms = static_cast<Mutex_set*>(arg);
+
+ // Lock the first mutex.
+ int err = pthread_mutex_lock(&pms->mutex1);
+ assert(err == 0);
+
+ // Run the tests.
+ assert(t1());
+ assert(t2());
+ assert(t3());
+ assert(t4());
+ f5b(f5a());
+ assert(t5());
+ f6b(f6a());
+ assert(t6());
+ assert(t7());
+
+ // Unlock the second mutex.
+ err = pthread_mutex_unlock(&pms->mutex2);
+ assert(err == 0);
+
+ // Lock the third mutex.
+ err = pthread_mutex_lock(&pms->mutex3);
+ assert(err == 0);
+
+ assert(t7());
+
+ return 0;
+}
+
+// The main function.
+
+int
+main()
+{
+ // Set up the mutex locks. We want the first thread to start right
+ // away, tell us when it is done with the first part, and wait for
+ // us to release it. We want the second thread to wait to start,
+ // tell us when it is done with the first part, and wait for us to
+ // release it.
+ int err = pthread_mutex_lock(&mutexes1.mutex2);
+ assert(err == 0);
+ err = pthread_mutex_lock(&mutexes1.mutex3);
+ assert(err == 0);
+
+ err = pthread_mutex_lock(&mutexes2.mutex1);
+ assert(err == 0);
+ err = pthread_mutex_lock(&mutexes2.mutex2);
+ assert(err == 0);
+ err = pthread_mutex_lock(&mutexes2.mutex3);
+ assert(err == 0);
+
+ pthread_t thread1;
+ err = pthread_create(&thread1, NULL, thread_routine, &mutexes1);
+ assert(err == 0);
+
+ pthread_t thread2;
+ err = pthread_create(&thread2, NULL, thread_routine, &mutexes2);
+ assert(err == 0);
+
+ // Wait for the first thread to complete the first part.
+ err = pthread_mutex_lock(&mutexes1.mutex2);
+ assert(err == 0);
+
+ // Tell the second thread to start.
+ err = pthread_mutex_unlock(&mutexes2.mutex1);
+ assert(err == 0);
+
+ // Wait for the second thread to complete the first part.
+ err = pthread_mutex_lock(&mutexes2.mutex2);
+ assert(err == 0);
+
+ // Tell the first thread to continue and finish.
+ err = pthread_mutex_unlock(&mutexes1.mutex3);
+ assert(err == 0);
+
+ // Wait for the first thread to finish.
+ void* thread_val;
+ err = pthread_join(thread1, &thread_val);
+ assert(err == 0);
+ assert(thread_val == 0);
+
+ // Tell the second thread to continue and finish.
+ err = pthread_mutex_unlock(&mutexes2.mutex3);
+ assert(err == 0);
+
+ // Wait for the second thread to finish.
+ err = pthread_join(thread2, &thread_val);
+ assert(err == 0);
+ assert(thread_val == 0);
+
+ // All done.
+ return 0;
+}