diff options
author | Doug Kwan <dougkwan@google.com> | 2009-05-26 22:52:56 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2009-05-26 22:52:56 +0000 |
commit | 2fdd743f6d30838e94d0c23518028513e6803095 (patch) | |
tree | c82d549ef87c282155cf898bb40bd0a50a37d496 /gold | |
parent | 68d7e96a436ae00396227dca4668999b7a4bceef (diff) | |
download | gdb-2fdd743f6d30838e94d0c23518028513e6803095.zip gdb-2fdd743f6d30838e94d0c23518028513e6803095.tar.gz gdb-2fdd743f6d30838e94d0c23518028513e6803095.tar.bz2 |
2009-05-26 Doug Kwan <dougkwan@google.com>
* options.cc (General_options::parse_exclude_libs). Fix a comment.
(General_options::check_excluded_libs): Strip off directories in
archive name before matching like GNU ld does.
* testsuite/Makefile.am (MOSTLYCLEANFILES,
exclude_libs_test_DEPENDENCIES): Add alt/libexclude_libs_test_3.a
(exclude_libs_test_LDFLAGS): Add linker option
-Wl,--exclude-libs,libexclude_libs_test_3
(exclude_libs_test_LADD): Add alt/libexclude_libs_test_3.a as
an explicit archive without using -l.
(alt/libexclude_libs_test_3.a): New make rule.
* testsuite/Makefile.in: Regenerate.
* testsuite/exclude_libs_test.c : Declare lib3_default().
(main): Call it.
* exclude_libs_test.sh: Add tests for alt/exclude_libs_test_3.a.
* exclude_libs_test_3.c: New file.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/options.cc | 15 | ||||
-rw-r--r-- | gold/testsuite/Makefile.am | 15 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 22 | ||||
-rw-r--r-- | gold/testsuite/exclude_libs_test.c | 2 | ||||
-rwxr-xr-x | gold/testsuite/exclude_libs_test.sh | 4 | ||||
-rw-r--r-- | gold/testsuite/exclude_libs_test_3.c | 24 |
6 files changed, 62 insertions, 20 deletions
diff --git a/gold/options.cc b/gold/options.cc index 78e14dc..0844d53 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -403,7 +403,7 @@ General_options::parse_end_group(const char*, const char*, } // The function add_excluded_libs() in ld/ldlang.c of GNU ld breaks up a list -// of names seperated by commas or semi-colons and puts them in a linked list. +// of names seperated by commas or colons and puts them in a linked list. // We implement the same parsing of names here but store names in an unordered // map to speed up searching of names. @@ -444,18 +444,21 @@ General_options::check_excluded_libs (const std::string &name) const if (p != excluded_libs_.end()) return true; + // First strip off any directories in name. + const char *basename = lbasename(name.c_str()); + // Try finding an exact match. - p = excluded_libs_.find(name); + p = excluded_libs_.find(std::string(basename)); if (p != excluded_libs_.end()) return true; // Try matching NAME without ".a" at the end. - size_t length = name.length(); + size_t length = strlen(basename); if ((length >= 2) - && (name[length-2] == '.') - && (name[length-1] == 'a')) + && (basename[length - 2] == '.') + && (basename[length - 1] == 'a')) { - p = excluded_libs_.find(name.substr(0, length - 2)); + p = excluded_libs_.find(std::string(basename, length - 2)); if (p != excluded_libs_.end()) return true; } diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index aeee0a6..5208e06 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1055,19 +1055,24 @@ check_PROGRAMS += exclude_libs_test check_SCRIPTS += exclude_libs_test.sh check_DATA += exclude_libs_test.syms MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \ - libexclude_libs_test_2.a + libexclude_libs_test_2.a alt/libexclude_libs_test_3.a exclude_libs_test_SOURCES = exclude_libs_test.c exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \ - libexclude_libs_test_2.a -exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. \ - -Wl,--exclude-libs,dummy:libexclude_libs_test_1 -exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 + libexclude_libs_test_2.a alt/libexclude_libs_test_3.a +exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \ + -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \ + -Wl,--exclude-libs,libexclude_libs_test_3 +exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \ + alt/libexclude_libs_test_3.a exclude_libs_test.syms: exclude_libs_test $(TEST_READELF) -sW $< >$@ 2>/dev/null libexclude_libs_test_1.a: exclude_libs_test_1.o $(TEST_AR) rc $@ $^ libexclude_libs_test_2.a: exclude_libs_test_2.o $(TEST_AR) rc $@ $^ +alt/libexclude_libs_test_3.a: exclude_libs_test_3.o + test -d alt || mkdir -p alt + $(TEST_AR) rc $@ $^ endif GCC endif NATIVE_LINKER diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index c4ad51b..53b7bf8 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -322,10 +322,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_25 = exclude_libs_test.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_26 = exclude_libs_test.syms @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.syms libexclude_libs_test_1.a \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a +@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a alt/libexclude_libs_test_3.a -@GCC_FALSE@exclude_libs_test_DEPENDENCIES = -@NATIVE_LINKER_FALSE@exclude_libs_test_DEPENDENCIES = subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -1512,12 +1510,15 @@ binary_unittest_SOURCES = binary_unittest.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDADD = -lthinall @GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_SOURCES = exclude_libs_test.c @GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a +@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a alt/libexclude_libs_test_3.a -@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--exclude-libs,dummy:libexclude_libs_test_1 +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. -Lalt \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--exclude-libs,dummy:libexclude_libs_test_1 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--exclude-libs,libexclude_libs_test_3 + +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a -@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -1532,9 +1533,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign testsuite/Makefile + $(AUTOMAKE) --gnu testsuite/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -2609,6 +2610,9 @@ uninstall-am: uninstall-info-am @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ @GCC_TRUE@@NATIVE_LINKER_TRUE@libexclude_libs_test_2.a: exclude_libs_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ +@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libexclude_libs_test_3.a: exclude_libs_test_3.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ # 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/exclude_libs_test.c b/gold/testsuite/exclude_libs_test.c index 3cb5645..85441a0 100644 --- a/gold/testsuite/exclude_libs_test.c +++ b/gold/testsuite/exclude_libs_test.c @@ -1,5 +1,6 @@ extern void lib1_default (void); extern void lib2_default (void); +extern void lib3_default (void); int main (int argc __attribute__ ((unused)), @@ -7,6 +8,7 @@ main (int argc __attribute__ ((unused)), { lib1_default (); lib2_default (); + lib3_default (); return 0; } diff --git a/gold/testsuite/exclude_libs_test.sh b/gold/testsuite/exclude_libs_test.sh index a82be89..65ce03b 100755 --- a/gold/testsuite/exclude_libs_test.sh +++ b/gold/testsuite/exclude_libs_test.sh @@ -55,5 +55,9 @@ check "exclude_libs_test.syms" "lib2_default" "DEFAULT" check "exclude_libs_test.syms" "lib2_protected" "PROTECTED" check "exclude_libs_test.syms" "lib2_internal" "INTERNAL" check "exclude_libs_test.syms" "lib2_hidden" "HIDDEN" +check "exclude_libs_test.syms" "lib3_default" "HIDDEN" +check "exclude_libs_test.syms" "lib3_protected" "HIDDEN" +check "exclude_libs_test.syms" "lib3_internal" "INTERNAL" +check "exclude_libs_test.syms" "lib3_hidden" "HIDDEN" exit 0 diff --git a/gold/testsuite/exclude_libs_test_3.c b/gold/testsuite/exclude_libs_test_3.c new file mode 100644 index 0000000..b4e2635 --- /dev/null +++ b/gold/testsuite/exclude_libs_test_3.c @@ -0,0 +1,24 @@ +void lib3_default (void); +void lib3_hidden (void); +void lib3_internal (void); +void lib3_protected (void); + +void __attribute__((visibility ("default"))) +lib3_default (void) +{ +} + +void __attribute__((visibility ("hidden"))) +lib3_hidden (void) +{ +} + +void __attribute__((visibility ("internal"))) +lib3_internal (void) +{ +} + +void __attribute__((visibility ("protected"))) +lib3_protected (void) +{ +} |