aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-12 17:32:20 +0000
committerIan Lance Taylor <iant@google.com>2007-10-12 17:32:20 +0000
commite03748586c49e8ad61ee2e4103668eb4ba3fc0e3 (patch)
treea8810f1a35c4f7a7c9557e0c0462605d10428305
parent2152e0479e9f184ba5d55e16f40cda6db7721d67 (diff)
downloadgdb-e03748586c49e8ad61ee2e4103668eb4ba3fc0e3.zip
gdb-e03748586c49e8ad61ee2e4103668eb4ba3fc0e3.tar.gz
gdb-e03748586c49e8ad61ee2e4103668eb4ba3fc0e3.tar.bz2
From Craig Silverstein: expand the TLS test to a second file, to test
IE to LE conversion.
-rw-r--r--gold/testsuite/Makefile.am23
-rw-r--r--gold/testsuite/Makefile.in32
-rw-r--r--gold/testsuite/tls_test.cc60
-rw-r--r--gold/testsuite/tls_test.h9
-rw-r--r--gold/testsuite/tls_test_file2.cc27
-rw-r--r--gold/testsuite/tls_test_main.cc8
6 files changed, 130 insertions, 29 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index c3e2928..8e1adb6 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -287,25 +287,25 @@ exception_shared.so: 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_SOURCES = tls_test.cc tls_test_file2.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_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o
tls_pic_test_LDFLAGS = -Bgcctestdir/
-tls_pic_test_LDADD = tls_test_pic.o -lpthread
+tls_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o -lpthread
-tls_static_test_SOURCES = tls_test.cc tls_test_main.cc
+tls_static_test_SOURCES = tls_test.cc tls_test_file2.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_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o
tls_static_pic_test_LDFLAGS = -Bgcctestdir/ -static
-tls_static_pic_test_LDADD = tls_test_pic.o -lpthread
+tls_static_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o -lpthread
tls_shared_test_SOURCES = tls_test_main.cc
tls_shared_test_DEPENDENCIES = gcctestdir/ld tls_test_shared.so
@@ -315,8 +315,11 @@ 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
+tls_test_file2_pic.o: tls_test_file2.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+
+tls_test_shared.so: tls_test_pic.o tls_test_file2_pic.o
+ $(CXXLINK) -shared tls_test_pic.o tls_test_file2_pic.o
if FN_PTRS_IN_SO_WITHOUT_PIC
@@ -325,8 +328,8 @@ 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
+tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o
+ $(CXXLINK) -shared tls_test.o tls_test_file2.o
endif
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 4d38843..56e6a09 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -231,14 +231,18 @@ 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
+am__tls_static_test_SOURCES_DIST = tls_test.cc tls_test_file2.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_file2.$(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
+am__tls_test_SOURCES_DIST = tls_test.cc tls_test_file2.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_file2.$(OBJEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test_main.$(OBJEXT)
tls_test_OBJECTS = $(am_tls_test_OBJECTS)
am__two_file_pic_test_SOURCES_DIST = two_file_test_main.cc
@@ -691,22 +695,22 @@ 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_SOURCES = tls_test.cc tls_test_file2.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_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_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_pic_test_LDADD = tls_test_pic.o tls_test_file2_pic.o -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_static_test_SOURCES = tls_test.cc tls_test_file2.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_DEPENDENCIES = gcctestdir/ld tls_test_pic.o tls_test_file2_pic.o
@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_static_pic_test_LDADD = tls_test_pic.o tls_test_file2_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,.
@@ -861,6 +865,7 @@ distclean-compile:
@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_file2.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@
@@ -1175,11 +1180,14 @@ uninstall-am: uninstall-info-am
@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
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_file2_pic.o: tls_test_file2.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 tls_test_file2_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -shared tls_test_pic.o tls_test_file2_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
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_shared_nonpic.so: tls_test.o tls_test_file2.o
+@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXLINK) -shared tls_test.o tls_test_file2.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
index a666433..995e20b 100644
--- a/gold/testsuite/tls_test.cc
+++ b/gold/testsuite/tls_test.cc
@@ -38,7 +38,11 @@
// 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.
+// 8 Like test 1, but with the thread variable defined in another file.
+// 9 Like test 3, but with the thread variable defined in another file.
+// 10 Like test 5, but with the thread variable defined in another file.
+// last Verify that the above tests left the variables set correctly.
+
#include "tls_test.h"
@@ -49,6 +53,11 @@ static __thread int v4 = 4;
__thread int v5;
static __thread int v6;
+// These variables are defined in tls_test_file2.cc
+extern __thread int o1;
+extern __thread int o2;
+extern __thread int o3;
+
bool
t1()
{
@@ -105,7 +114,7 @@ t5()
return v5 == 50;
}
-// For test 5 the main function calls f6b(f6a()), then calls t6().
+// For test 6 the main function calls f6b(f6a()), then calls t6().
int*
f6a()
@@ -125,13 +134,56 @@ t6()
return v6 == 60;
}
+// The slot for t7() is unused.
+
+bool
+t8()
+{
+ if (o1 != 0)
+ return false;
+ o1 = 10;
+ return true;
+}
+
+bool
+t9()
+{
+ if (o2 != 2)
+ return false;
+ o2 = 20;
+ return true;
+}
+
+// For test 10 the main function calls f10b(f10a()), then calls t10().
+
+int*
+f10a()
+{
+ return &o3;
+}
+
+void
+f10b(int* p)
+{
+ *p = 30;
+}
+
+bool
+t10()
+{
+ return o3 == 30;
+}
+
bool
-t7()
+t_last()
{
return (v1 == 10
&& v2 == 20
&& v3 == 30
&& v4 == 40
&& v5 == 50
- && v6 == 60);
+ && v6 == 60
+ && o1 == 10
+ && o2 == 20
+ && o3 == 30);
}
diff --git a/gold/testsuite/tls_test.h b/gold/testsuite/tls_test.h
index b260cad..1a1b6fd 100644
--- a/gold/testsuite/tls_test.h
+++ b/gold/testsuite/tls_test.h
@@ -36,4 +36,11 @@ extern int* f6a();
extern void f6b(int*);
extern bool t6();
-extern bool t7();
+extern bool t8();
+extern bool t9();
+
+extern int* f10a();
+extern void f10b(int*);
+extern bool t10();
+
+extern bool t_last();
diff --git a/gold/testsuite/tls_test_file2.cc b/gold/testsuite/tls_test_file2.cc
new file mode 100644
index 0000000..103681a
--- /dev/null
+++ b/gold/testsuite/tls_test_file2.cc
@@ -0,0 +1,27 @@
+// 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 is the definition of a thread-local variable in another file.
+
+__thread int o1;
+__thread int o2 = 2;
+__thread int o3;
diff --git a/gold/testsuite/tls_test_main.cc b/gold/testsuite/tls_test_main.cc
index dfa46c6..8b2d585 100644
--- a/gold/testsuite/tls_test_main.cc
+++ b/gold/testsuite/tls_test_main.cc
@@ -78,7 +78,11 @@ thread_routine(void* arg)
check("t5", t5());
f6b(f6a());
check("t6", t6());
- check("t7", t7());
+ check("t8", t8());
+ check("t9", t9());
+ f10b(f10a());
+ check("t10", t10());
+ check("t_last", t_last());
// Unlock the second mutex.
err = pthread_mutex_unlock(&pms->mutex2);
@@ -88,7 +92,7 @@ thread_routine(void* arg)
err = pthread_mutex_lock(&pms->mutex3);
assert(err == 0);
- check("t7", t7());
+ check("t_last", t_last());
return 0;
}