From a360aedd0fd0e2c02c0896046bec126e6ad72308 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 16 Oct 2007 23:09:45 +0000 Subject: [PATCH] From Craig Silverstein: check that we get environ right. --- gold/testsuite/Makefile.am | 13 ++++++++-- gold/testsuite/Makefile.in | 31 +++++++++++++++++++----- gold/testsuite/weak_test.cc | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 gold/testsuite/weak_test.cc diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 0221ee7a912..cfa2f1c54f7 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -17,7 +17,11 @@ INCLUDES = -D_GNU_SOURCE \ -DLOCALEDIR="\"$(datadir)/locale\"" \ @INCINTL@ +TESTS = object_unittest +check_SCRIPTS = + if GCC + if NATIVE_LINKER NATIVE_PROGS = \ @@ -37,7 +41,8 @@ NATIVE_PROGS = \ exception_shared_2_test \ exception_same_shared_test \ exception_separate_shared_12_test \ - exception_separate_shared_21_test + exception_separate_shared_21_test \ + weak_test if FN_PTRS_IN_SO_WITHOUT_PIC @@ -83,7 +88,7 @@ NATIVE_TESTING = \ endif endif -TESTS = object_unittest $(NATIVE_TESTING) +TESTS += $(NATIVE_TESTING) check_LIBRARIES = libgoldtest.a libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc @@ -97,6 +102,7 @@ check_PROGRAMS = object_unittest $(NATIVE_PROGS) object_unittest_SOURCES = object_unittest.cc if GCC + if NATIVE_LINKER gcctestdir/ld: ../ld-new @@ -291,6 +297,9 @@ 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 +weak_test_SOURCES = weak_test.cc +weak_test_LDFLAGS = -Bgcctestdir/ + if TLS tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 35fbb42e38c..302e2030b3c 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -155,6 +155,7 @@ 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@ weak_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__EXEEXT_1) $(am__EXEEXT_2) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__EXEEXT_3) $(am__EXEEXT_4) am__constructor_static_test_SOURCES_DIST = constructor_test.cc @@ -323,6 +324,13 @@ am__two_file_test_SOURCES_DIST = two_file_test_1.cc two_file_test_2.cc \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT) two_file_test_OBJECTS = $(am_two_file_test_OBJECTS) two_file_test_LDADD = $(LDADD) +am__weak_test_SOURCES_DIST = weak_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT) +weak_test_OBJECTS = $(am_weak_test_OBJECTS) +weak_test_LDADD = $(LDADD) +weak_test_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/../depcomp am__depfiles_maybe = depfiles @@ -357,7 +365,8 @@ SOURCES = $(libgoldtest_a_SOURCES) $(constructor_static_test_SOURCES) \ $(two_file_shared_1_test_SOURCES) \ $(two_file_shared_2_nonpic_test_SOURCES) \ $(two_file_shared_2_test_SOURCES) \ - $(two_file_static_test_SOURCES) $(two_file_test_SOURCES) + $(two_file_static_test_SOURCES) $(two_file_test_SOURCES) \ + $(weak_test_SOURCES) DIST_SOURCES = $(libgoldtest_a_SOURCES) \ $(am__constructor_static_test_SOURCES_DIST) \ $(am__constructor_test_SOURCES_DIST) \ @@ -386,7 +395,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) \ $(am__two_file_shared_2_nonpic_test_SOURCES_DIST) \ $(am__two_file_shared_2_test_SOURCES_DIST) \ $(am__two_file_static_test_SOURCES_DIST) \ - $(am__two_file_test_SOURCES_DIST) + $(am__two_file_test_SOURCES_DIST) \ + $(am__weak_test_SOURCES_DIST) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -528,6 +538,8 @@ INCLUDES = -D_GNU_SOURCE \ -DLOCALEDIR="\"$(datadir)/locale\"" \ @INCINTL@ +TESTS = object_unittest $(NATIVE_TESTING) +check_SCRIPTS = @GCC_TRUE@@NATIVE_LINKER_TRUE@NATIVE_PROGS = constructor_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ constructor_static_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test \ @@ -545,8 +557,9 @@ 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) $(am__append_2) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_3) $(am__append_4) +@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test $(am__append_1) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_2) $(am__append_3) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(am__append_4) @GCC_TRUE@@NATIVE_LINKER_TRUE@NATIVE_TESTING = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_pic_test \ @@ -554,7 +567,6 @@ INCLUDES = -D_GNU_SOURCE \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_pic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(NATIVE_PROGS) -TESTS = object_unittest $(NATIVE_TESTING) check_LIBRARIES = libgoldtest.a libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc DEPENDENCIES = \ @@ -699,6 +711,8 @@ 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@weak_test_SOURCES = weak_test.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_test_LDFLAGS = -Bgcctestdir/ @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/ @@ -853,6 +867,9 @@ two_file_static_test$(EXEEXT): $(two_file_static_test_OBJECTS) $(two_file_static two_file_test$(EXEEXT): $(two_file_test_OBJECTS) $(two_file_test_DEPENDENCIES) @rm -f two_file_test$(EXEEXT) $(CXXLINK) $(two_file_test_LDFLAGS) $(two_file_test_OBJECTS) $(two_file_test_LDADD) $(LIBS) +weak_test$(EXEEXT): $(weak_test_OBJECTS) $(weak_test_DEPENDENCIES) + @rm -f weak_test$(EXEEXT) + $(CXXLINK) $(weak_test_LDFLAGS) $(weak_test_OBJECTS) $(weak_test_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -874,6 +891,7 @@ distclean-compile: @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@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_test.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @@ -1039,7 +1057,8 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_LIBRARIES) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) $(check_LIBRARIES) $(check_PROGRAMS) \ + $(check_SCRIPTS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile diff --git a/gold/testsuite/weak_test.cc b/gold/testsuite/weak_test.cc new file mode 100644 index 00000000000..9c725ed040f --- /dev/null +++ b/gold/testsuite/weak_test.cc @@ -0,0 +1,47 @@ +// weak_test.cc -- test handling of weak symbols for gold + +// Copyright 2006, 2007 Free Software Foundation, Inc. +// Written by Ian Lance Taylor . + +// 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 test that we correctly deal with weak symbols defined in +// other libraries (in this case, libc). We need to make sure we +// copy the associated GLOBAL reloc when we copy a WEAK reloc. + + +#include + +int +main() +{ + extern char** environ; // defined in libc + if (environ == NULL) + { + fprintf(stderr, "FAILED the environ test: environ is NULL\n"); + return 1; + } + return 0; +} -- 2.30.2