aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
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/testsuite
parent46cf9fa27e13491561a643178d5ffd2b086183fb (diff)
downloadgdb-6eee141ff6d84d39ca9e364eb98818431162d6df.zip
gdb-6eee141ff6d84d39ca9e364eb98818431162d6df.tar.gz
gdb-6eee141ff6d84d39ca9e364eb98818431162d6df.tar.bz2
Add a TLS test case.
Diffstat (limited to 'gold/testsuite')
-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
5 files changed, 502 insertions, 5 deletions
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;
+}