This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
gold patch: fix problems with thin archives
- From: "Cary Coutant" <ccoutant at google dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Mon, 29 Sep 2008 14:34:05 -0700
- Subject: gold patch: fix problems with thin archives
The attached patch fixes two problems in gold with thin archives. (1)
If a thin archive is linked using -lfoo, it will not find the external
members correctly. (2) For a thin archive with external members, the
external member files are not unlocked, resulting in an internal error
in gold. The patch also includes new testcases for thin archives, now
that thin archive support can be assumed in the binutils tools.
Approved offline by Ian.
-cary
2008-09-29 Cary Coutant <ccoutant@google.com>
* archive.cc (Archive::get_file_and_offset): Use filename instead
of name to get library path.
(Archive::include_member): Unlock external member of a thin archive.
* testsuite/Makefile.am (TEST_AR): New variable.
(thin_archive_test_1): New test.
(thin_archive_test_2): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/thin_archive_main.cc: New file.
* testsuite/thin_archive_test_1.cc: New file.
* testsuite/thin_archive_test_2.cc: New file.
* testsuite/thin_archive_test_3.cc: New file.
* testsuite/thin_archive_test_4.cc: New file.
Index: archive.cc
===================================================================
RCS file: /cvs/src/src/gold/archive.cc,v
retrieving revision 1.36
diff -u -p -r1.36 archive.cc
--- archive.cc 19 Sep 2008 22:54:57 -0000 1.36
+++ archive.cc 26 Sep 2008 18:47:14 -0000
@@ -459,11 +459,11 @@ Archive::get_file_and_offset(off_t off,
// to the directory containing the archive.
if (!IS_ABSOLUTE_PATH(member_name->c_str()))
{
- const char* arch_path = this->name().c_str();
+ const char* arch_path = this->filename().c_str();
const char* basename = lbasename(arch_path);
if (basename > arch_path)
member_name->replace(0, 0,
- this->name().substr(0, basename - arch_path));
+ this->filename().substr(0, basename - arch_path));
}
if (nested_off > 0)
@@ -786,6 +786,11 @@ Archive::include_member(Symbol_table* sy
obj->read_symbols(&sd);
obj->layout(symtab, layout, &sd);
obj->add_symbols(symtab, &sd);
+
+ // If this is an external member of a thin archive, unlock the file
+ // for the next task.
+ if (obj->offset() == 0)
+ obj->unlock(this->task_);
}
else
{
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.77
diff -u -p -r1.77 Makefile.am
--- testsuite/Makefile.am 19 Sep 2008 22:54:57 -0000 1.77
+++ testsuite/Makefile.am 26 Sep 2008 18:47:14 -0000
@@ -22,6 +22,7 @@ TEST_READELF = $(top_builddir)/../binuti
TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+TEST_AR = $(top_builddir)/../binutils/ar
if PLUGINS
LIBDL = -ldl
@@ -902,6 +903,40 @@ script_test_4: basic_test.o gcctestdir/l
script_test_4.stdout: script_test_4
$(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+check_PROGRAMS += thin_archive_test_1
+thin_archive_test_1_SOURCES = thin_archive_main.cc
+thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a
+thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
+thin_archive_test_1_LDADD = libthin1.a -lthin2
+
+check_PROGRAMS += thin_archive_test_2
+thin_archive_test_2_SOURCES = thin_archive_main.cc
+thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a
+thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
+thin_archive_test_2_LDADD = -lthinall
+
+libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/libthin2.a: thin_archive_test_3.o alt/thin_archive_test_4.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+libthin3.a: thin_archive_test_1.o alt/thin_archive_test_4.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/libthin4.a: alt/thin_archive_test_2.o thin_archive_test_3.o
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+libthinall.a: libthin3.a alt/libthin4.a
+ rm -f $@
+ $(TEST_AR) crT $@ $^
+alt/thin_archive_test_2.o: thin_archive_test_2.cc
+ test -d alt || mkdir -p alt
+ $(CXXCOMPILE) -c -o $@ $<
+alt/thin_archive_test_4.o: thin_archive_test_4.cc
+ test -d alt || mkdir -p alt
+ $(CXXCOMPILE) -c -o $@ $<
+
if PLUGINS
check_PROGRAMS += plugin_test_1
Index: testsuite/Makefile.in
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.in,v
retrieving revision 1.82
diff -u -p -r1.82 Makefile.in
--- testsuite/Makefile.in 19 Sep 2008 22:54:57 -0000 1.82
+++ testsuite/Makefile.in 26 Sep 2008 18:47:14 -0000
@@ -248,7 +248,9 @@ check_PROGRAMS = object_unittest$(EXEEXT
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test relro_script_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@@ -281,6 +283,8 @@ check_PROGRAMS = object_unittest$(EXEEXT
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@thin_archive_test_2_DEPENDENCIES =
+@NATIVE_LINKER_FALSE@thin_archive_test_2_DEPENDENCIES =
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_20 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2
@@ -389,7 +393,9 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test$(EXEEXT) \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_16 =
plugin_test_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT)
basic_pic_test_SOURCES = basic_pic_test.c
@@ -599,6 +605,14 @@ script_test_3_LDADD = $(LDADD)
script_test_3_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__thin_archive_test_1_SOURCES_DIST = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_thin_archive_test_1_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_main.$(OBJEXT)
+thin_archive_test_1_OBJECTS = $(am_thin_archive_test_1_OBJECTS)
+am__thin_archive_test_2_SOURCES_DIST = thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_thin_archive_test_2_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_main.$(OBJEXT)
+thin_archive_test_2_OBJECTS = $(am_thin_archive_test_2_OBJECTS)
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)
@@ -839,6 +853,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic
$(protected_2_SOURCES) $(relro_script_test_SOURCES) \
$(relro_test_SOURCES) $(script_test_1_SOURCES) \
$(script_test_2_SOURCES) script_test_3.c \
+ $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \
$(tls_pic_test_SOURCES) $(tls_shared_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \
@@ -892,6 +907,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES)
$(am__relro_test_SOURCES_DIST) \
$(am__script_test_1_SOURCES_DIST) \
$(am__script_test_2_SOURCES_DIST) script_test_3.c \
+ $(am__thin_archive_test_1_SOURCES_DIST) \
+ $(am__thin_archive_test_2_SOURCES_DIST) \
$(am__tls_pic_test_SOURCES_DIST) \
$(am__tls_shared_gd_to_ie_test_SOURCES_DIST) \
$(am__tls_shared_gnu2_gd_to_ie_test_SOURCES_DIST) \
@@ -1089,6 +1106,7 @@ TEST_READELF = $(top_builddir)/../binuti
TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+TEST_AR = $(top_builddir)/../binutils/ar
@PLUGINS_TRUE@LIBDL = -ldl
@THREADS_TRUE@THREADSLIB = -lpthread
@OMP_SUPPORT_TRUE@TLS_TEST_C_CFLAGS = -fopenmp
@@ -1418,6 +1436,14 @@ binary_unittest_SOURCES = binary_unittes
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_SOURCES = binary_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_DEPENDENCIES =
gcctestdir/ld binary.txt
@GCC_TRUE@@NATIVE_LINKER_TRUE@binary_test_LDFLAGS = -Bgcctestdir/
-Wl,--format,binary,binary.txt,--format,elf
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_SOURCES =
thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_DEPENDENCIES =
gcctestdir/ld libthin1.a alt/libthin2.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDADD = libthin1.a -lthin2
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_SOURCES =
thin_archive_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_DEPENDENCIES =
gcctestdir/ld libthinall.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDADD = -lthinall
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1609,6 +1635,12 @@ script_test_2$(EXEEXT): $(script_test_2_
@NATIVE_LINKER_FALSE@script_test_3$(EXEEXT): $(script_test_3_OBJECTS)
$(script_test_3_DEPENDENCIES)
@NATIVE_LINKER_FALSE@ @rm -f script_test_3$(EXEEXT)
@NATIVE_LINKER_FALSE@ $(LINK) $(script_test_3_LDFLAGS)
$(script_test_3_OBJECTS) $(script_test_3_LDADD) $(LIBS)
+thin_archive_test_1$(EXEEXT): $(thin_archive_test_1_OBJECTS)
$(thin_archive_test_1_DEPENDENCIES)
+ @rm -f thin_archive_test_1$(EXEEXT)
+ $(CXXLINK) $(thin_archive_test_1_LDFLAGS)
$(thin_archive_test_1_OBJECTS) $(thin_archive_test_1_LDADD) $(LIBS)
+thin_archive_test_2$(EXEEXT): $(thin_archive_test_2_OBJECTS)
$(thin_archive_test_2_DEPENDENCIES)
+ @rm -f thin_archive_test_2$(EXEEXT)
+ $(CXXLINK) $(thin_archive_test_2_LDFLAGS)
$(thin_archive_test_2_OBJECTS) $(thin_archive_test_2_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)
@@ -1777,6 +1809,7 @@ 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)/thin_archive_main.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@
@@ -2385,6 +2418,28 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o
-T $(srcdir)/script_test_4.t
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_4.stdout: script_test_4
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_4 >
script_test_4.stdout
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthin1.a: thin_archive_test_1.o
alt/thin_archive_test_2.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libthin2.a: thin_archive_test_3.o
alt/thin_archive_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthin3.a: thin_archive_test_1.o
alt/thin_archive_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libthin4.a:
alt/thin_archive_test_2.o thin_archive_test_3.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@libthinall.a: libthin3.a alt/libthin4.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/thin_archive_test_2.o: thin_archive_test_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/thin_archive_test_4.o: thin_archive_test_4.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1:
two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms
two_file_test_2.syms gcctestdir/ld plugin_test.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/
-Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv"
two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms
two_file_test_2.syms 2>plugin_test_1.err
@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1.err: plugin_test_1
Index: testsuite/thin_archive_main.cc
===================================================================
RCS file: testsuite/thin_archive_main.cc
diff -N testsuite/thin_archive_main.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/thin_archive_main.cc 26 Sep 2008 18:47:14 -0000
@@ -0,0 +1,39 @@
+// thin_archive_main.cc -- a test case for gold
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@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 program for the thin archive tests. It calls a single
+// routine, t1, defined in libthin1.a or libthin3.a, which then references
+// other routines in the same and other libraries, to make sure that all
+// archive members are linked properly.
+
+#include <cassert>
+
+extern int t1();
+
+// Main function. Call the test function.
+
+int
+main()
+{
+ assert(t1() == 0x4321);
+ return 0;
+}
Index: testsuite/thin_archive_test_1.cc
===================================================================
RCS file: testsuite/thin_archive_test_1.cc
diff -N testsuite/thin_archive_test_1.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/thin_archive_test_1.cc 26 Sep 2008 18:47:14 -0000
@@ -0,0 +1,37 @@
+// thin_archive_test_1.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@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 tests references between files and archives. This is file 1 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t2();
+
+int
+t1()
+{
+ return (t2() << 4) | 1;
+}
Index: testsuite/thin_archive_test_2.cc
===================================================================
RCS file: testsuite/thin_archive_test_2.cc
diff -N testsuite/thin_archive_test_2.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/thin_archive_test_2.cc 26 Sep 2008 18:47:14 -0000
@@ -0,0 +1,37 @@
+// thin_archive_test_2.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@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 tests references between files and archives. This is file 2 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t3();
+
+int
+t2()
+{
+ return (t3() << 4) | 2;
+}
Index: testsuite/thin_archive_test_3.cc
===================================================================
RCS file: testsuite/thin_archive_test_3.cc
diff -N testsuite/thin_archive_test_3.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/thin_archive_test_3.cc 26 Sep 2008 18:47:14 -0000
@@ -0,0 +1,37 @@
+// thin_archive_test_3.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@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 tests references between files and archives. This is file 3 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+extern int t4();
+
+int
+t3()
+{
+ return (t4() << 4) | 3;
+}
Index: testsuite/thin_archive_test_4.cc
===================================================================
RCS file: testsuite/thin_archive_test_4.cc
diff -N testsuite/thin_archive_test_4.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/thin_archive_test_4.cc 26 Sep 2008 18:47:14 -0000
@@ -0,0 +1,35 @@
+// thin_archive_test_4.cc -- part of a test case for thin archives
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Cary Coutant <ccoutant@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 tests references between files and archives. This is file 4 of 4.
+// Each of the first three files contains a reference to the next.
+// We test the archives as follows:
+
+// Files 1 and 2 in libthin1.a, files 3 and 4 in libthin2.a.
+// Files 1 and 4 in libthin3.a, files 2 and 3 in libthin4.a, with
+// libthin3.a and libthin4.a nested inside libthinall.a.
+
+int
+t4()
+{
+ return 4;
+}