* symtab.cc (Symbol_table::add_from_dynobj): If we see a protected

symbol, change it to have default visibility.
	* testsuite/protected_1.cc: New file.
	* testsuite/protected_2.cc: New file.
	* testsuite/protected_3.cc: New file.
	* testsuite/protected_main_1.cc: New file.
	* testsuite/protected_main_2.cc: New file.
	* testsuite/protected_main_3.cc: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
	(protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
	(protected_1_LDFLAGS, protected_1_LDADD): Define.
	(protected_1.so): New target.
	(protected_1_pic.o, protected_2_pic.o): New targets.
	(protected_3_pic.o): New target.
	(check_PROGRAMS): Add protected_2.
	(protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
	(protected_2_LDFLAGS, protected_2_LDADD): Define.
	* testsuite/Makefile.in: Rebuild.
This commit is contained in:
Ian Lance Taylor 2008-05-06 22:24:26 +00:00
parent b5dd68e231
commit 8bdcdf2c77
11 changed files with 310 additions and 11 deletions

View file

@ -1,5 +1,24 @@
2008-05-06 Ian Lance Taylor <iant@google.com>
* symtab.cc (Symbol_table::add_from_dynobj): If we see a protected
symbol, change it to have default visibility.
* testsuite/protected_1.cc: New file.
* testsuite/protected_2.cc: New file.
* testsuite/protected_3.cc: New file.
* testsuite/protected_main_1.cc: New file.
* testsuite/protected_main_2.cc: New file.
* testsuite/protected_main_3.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add protected_1.
(protected_1_SOURCES, protected_1_DEPENDENCIES): Define.
(protected_1_LDFLAGS, protected_1_LDADD): Define.
(protected_1.so): New target.
(protected_1_pic.o, protected_2_pic.o): New targets.
(protected_3_pic.o): New target.
(check_PROGRAMS): Add protected_2.
(protected_2_SOURCES, protected_2_DEPENDENCIES): Define.
(protected_2_LDFLAGS, protected_2_LDADD): Define.
* testsuite/Makefile.in: Rebuild.
* options.h (DEFINE_var): Add set_user_set_##varname__.
(DEFINE_bool_alias): New macro.
(class General_options): Define -Bstatic using DEFINE_bool_alias

View file

@ -56,7 +56,9 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/../config/gettext-sister.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/nls.m4 $(top_srcdir)/../config/po.m4 \
$(top_srcdir)/../config/nls.m4 \
$(top_srcdir)/../config/override.m4 \
$(top_srcdir)/../config/po.m4 \
$(top_srcdir)/../config/proginstall.m4 \
$(top_srcdir)/../config/progtest.m4 \
$(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/configure.ac

View file

@ -942,7 +942,21 @@ Symbol_table::add_from_dynobj(
|| sym.get_st_visibility() == elfcpp::STV_HIDDEN)
continue;
unsigned int st_name = sym.get_st_name();
// A protected symbol in a shared library must be treated as a
// normal symbol when viewed from outside the shared library.
// Implement this by overriding the visibility here.
elfcpp::Sym<size, big_endian>* psym = &sym;
unsigned char symbuf[sym_size];
elfcpp::Sym<size, big_endian> sym2(symbuf);
if (sym.get_st_visibility() == elfcpp::STV_PROTECTED)
{
memcpy(symbuf, p, sym_size);
elfcpp::Sym_write<size, big_endian> sw(symbuf);
sw.put_st_other(elfcpp::STV_DEFAULT, sym.get_st_nonvis());
psym = &sym2;
}
unsigned int st_name = psym->get_st_name();
if (st_name >= sym_name_size)
{
dynobj->error(_("bad symbol name offset %u at %zu"),
@ -953,7 +967,7 @@ Symbol_table::add_from_dynobj(
const char* name = sym_names + st_name;
bool is_ordinary;
unsigned int st_shndx = dynobj->adjust_sym_shndx(i, sym.get_st_shndx(),
unsigned int st_shndx = dynobj->adjust_sym_shndx(i, psym->get_st_shndx(),
&is_ordinary);
Sized_symbol<size>* res;
@ -963,7 +977,7 @@ Symbol_table::add_from_dynobj(
Stringpool::Key name_key;
name = this->namepool_.add(name, true, &name_key);
res = this->add_from_object(dynobj, name, name_key, NULL, 0,
false, sym, st_shndx, is_ordinary,
false, *psym, st_shndx, is_ordinary,
st_shndx);
}
else
@ -998,7 +1012,7 @@ Symbol_table::add_from_dynobj(
{
// This symbol does not have a version.
res = this->add_from_object(dynobj, name, name_key, NULL, 0,
false, sym, st_shndx, is_ordinary,
false, *psym, st_shndx, is_ordinary,
st_shndx);
}
else
@ -1030,14 +1044,14 @@ Symbol_table::add_from_dynobj(
&& !is_ordinary
&& name_key == version_key)
res = this->add_from_object(dynobj, name, name_key, NULL, 0,
false, sym, st_shndx, is_ordinary,
false, *psym, st_shndx, is_ordinary,
st_shndx);
else
{
const bool def = (!hidden
&& st_shndx != elfcpp::SHN_UNDEF);
res = this->add_from_object(dynobj, name, name_key, version,
version_key, def, sym, st_shndx,
version_key, def, *psym, st_shndx,
is_ordinary, st_shndx);
}
}
@ -1047,7 +1061,7 @@ Symbol_table::add_from_dynobj(
// earlier object, in which case it can't be aliased here.
if (st_shndx != elfcpp::SHN_UNDEF
&& is_ordinary
&& sym.get_st_type() == elfcpp::STT_OBJECT
&& psym->get_st_type() == elfcpp::STT_OBJECT
&& res->source() == Symbol::FROM_OBJECT
&& res->object() == dynobj)
object_symbols.push_back(res);

View file

@ -750,6 +750,28 @@ check_DATA += ver_test_7.syms
ver_test_7.syms: ver_test_7.so
$(TEST_READELF) -s $< >$@ 2>/dev/null
check_PROGRAMS += protected_1
protected_1_SOURCES = \
protected_main_1.cc protected_main_2.cc protected_main_3.cc
protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
protected_1_LDADD = protected_1.so
protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
$(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
protected_1_pic.o: protected_1.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
protected_2_pic.o: protected_2.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
protected_3_pic.o: protected_3.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
check_PROGRAMS += protected_2
protected_2_SOURCES = protected_main_1.cc protected_3.cc
protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
protected_2_LDADD = protected_1.so
check_PROGRAMS += script_test_1
script_test_1_SOURCES = script_test_1.cc
script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t

View file

@ -226,7 +226,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
# Test symbol versioning.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_19 = ver_test ver_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6 script_test_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6 protected_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2 script_test_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2 justsyms \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test script_test_3
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@ -263,7 +264,9 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/../config/gettext-sister.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/nls.m4 $(top_srcdir)/../config/po.m4 \
$(top_srcdir)/../config/nls.m4 \
$(top_srcdir)/../config/override.m4 \
$(top_srcdir)/../config/po.m4 \
$(top_srcdir)/../config/proginstall.m4 \
$(top_srcdir)/../config/progtest.m4 \
$(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/configure.ac
@ -339,6 +342,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_15 = ver_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) \
@ -495,6 +500,18 @@ object_unittest_LDADD = $(LDADD)
object_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
am__protected_1_SOURCES_DIST = protected_main_1.cc protected_main_2.cc \
protected_main_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_protected_1_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_1.$(OBJEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_2.$(OBJEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_3.$(OBJEXT)
protected_1_OBJECTS = $(am_protected_1_OBJECTS)
am__protected_2_SOURCES_DIST = protected_main_1.cc protected_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_protected_2_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_1.$(OBJEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_3.$(OBJEXT)
protected_2_OBJECTS = $(am_protected_2_OBJECTS)
am__script_test_1_SOURCES_DIST = script_test_1.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_script_test_1_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1.$(OBJEXT)
@ -736,6 +753,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(initpri1_SOURCES) $(justsyms_SOURCES) many_sections_r_test.c \
$(many_sections_test_SOURCES) $(object_unittest_SOURCES) \
$(protected_1_SOURCES) $(protected_2_SOURCES) \
$(script_test_1_SOURCES) $(script_test_2_SOURCES) \
script_test_3.c $(tls_pic_test_SOURCES) \
$(tls_shared_gd_to_ie_test_SOURCES) \
@ -782,7 +800,9 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \
many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \
$(object_unittest_SOURCES) $(am__script_test_1_SOURCES_DIST) \
$(object_unittest_SOURCES) $(am__protected_1_SOURCES_DIST) \
$(am__protected_2_SOURCES_DIST) \
$(am__script_test_1_SOURCES_DIST) \
$(am__script_test_2_SOURCES_DIST) script_test_3.c \
$(am__tls_pic_test_SOURCES_DIST) \
$(am__tls_shared_gd_to_ie_test_SOURCES_DIST) \
@ -1262,6 +1282,16 @@ binary_unittest_SOURCES = binary_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_LDADD = ver_test_2.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_SOURCES = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_1.cc protected_main_2.cc protected_main_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_DEPENDENCIES = gcctestdir/ld protected_1.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_LDADD = protected_1.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_2_SOURCES = protected_main_1.cc protected_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_2_DEPENDENCIES = gcctestdir/ld protected_1.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_2_LDADD = protected_1.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_SOURCES = script_test_1.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
@ -1420,6 +1450,12 @@ many_sections_test$(EXEEXT): $(many_sections_test_OBJECTS) $(many_sections_test_
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)
protected_1$(EXEEXT): $(protected_1_OBJECTS) $(protected_1_DEPENDENCIES)
@rm -f protected_1$(EXEEXT)
$(CXXLINK) $(protected_1_LDFLAGS) $(protected_1_OBJECTS) $(protected_1_LDADD) $(LIBS)
protected_2$(EXEEXT): $(protected_2_OBJECTS) $(protected_2_DEPENDENCIES)
@rm -f protected_2$(EXEEXT)
$(CXXLINK) $(protected_2_LDFLAGS) $(protected_2_OBJECTS) $(protected_2_LDADD) $(LIBS)
script_test_1$(EXEEXT): $(script_test_1_OBJECTS) $(script_test_1_DEPENDENCIES)
@rm -f script_test_1$(EXEEXT)
$(CXXLINK) $(script_test_1_LDFLAGS) $(script_test_1_OBJECTS) $(script_test_1_LDADD) $(LIBS)
@ -1572,6 +1608,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_r_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_3.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_3.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_test_2a.Po@am__quote@
@ -2123,6 +2163,15 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_7.syms: ver_test_7.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -s $< >$@ 2>/dev/null
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_pic.o: protected_1.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_2_pic.o: protected_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_3_pic.o: protected_3.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2.o: justsyms_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2r.o: justsyms_2.o gcctestdir/ld $(srcdir)/justsyms.t

View file

@ -0,0 +1,33 @@
// protected_1.cc -- a test case for gold
// Copyright 2008 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.
// The function f1 is protected, which means that other callers in the
// same shared library will call this version.
int
f1() __attribute__ ((__visibility__ ("protected")));
int
f1()
{
return 1;
}

View file

@ -0,0 +1,31 @@
// protected_2.cc -- a test case for gold
// Copyright 2008 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 should call the protected version of f1.
extern int f1();
bool
t1()
{
return f1() == 1;
}

View file

@ -0,0 +1,33 @@
// protected_2.cc -- a test case for gold
// Copyright 2008 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 will also call the protected version of f1. In some versions
// of the test this will be overridden by a version in the main
// program.
extern int f1();
bool
t2()
{
return f1() == 1;
}

View file

@ -0,0 +1,36 @@
// protected_main_1.cc -- a test case for gold
// Copyright 2008 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.
#include <cassert>
// This function in the shared library will call the protected version
// of f1 in the shared library.
extern bool t1();
extern bool t2();
int
main()
{
assert(t1());
assert(t2());
}

View file

@ -0,0 +1,29 @@
// protected_main_2.cc -- a test case for gold
// Copyright 2008 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 version of f1 will not be called by the shared library code.
int
f1()
{
return 2;
}

View file

@ -0,0 +1,31 @@
// protected_main_3.cc -- a test case for gold
// Copyright 2008 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 should call the unprotected version of f1.
extern int f1();
bool
t2()
{
return f1() == 2;
}