2009-05-26 Doug Kwan <dougkwan@google.com>
authorDoug Kwan <dougkwan@google.com>
Tue, 26 May 2009 22:52:56 +0000 (22:52 +0000)
committerDoug Kwan <dougkwan@google.com>
Tue, 26 May 2009 22:52:56 +0000 (22:52 +0000)
        * 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.

gold/options.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/exclude_libs_test.c
gold/testsuite/exclude_libs_test.sh
gold/testsuite/exclude_libs_test_3.c [new file with mode: 0644]

index 78e14dcd305545200af13d3ef4260d9f59ac3870..0844d53ed6075dc0808aff38c2786e0a817a6f7a 100644 (file)
@@ -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;
     }
index aeee0a67b9347d439022426fb8ca34eff2f8dc92..5208e063127aa654e0a4f7a6187f93c00af62caa 100644 (file)
@@ -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
index c4ad51b120c00e57e7a609d9b6d9d3502e4d8071..53b7bf8fdb192d5929674b22f5da0f1fd507d3a0 100644 (file)
@@ -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:
index 3cb564587ebdd65480ae9fb831e46521e501378c..85441a0c11c42e18512ada8d06fac61c4799fead 100644 (file)
@@ -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;
 }
 
index a82be89a680fb6618145cc329c9298ba586a670f..65ce03b26c002a6d7258bfac7b53c22fdb96821b 100755 (executable)
@@ -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 (file)
index 0000000..b4e2635
--- /dev/null
@@ -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)
+{
+}
This page took 0.034757 seconds and 4 git commands to generate.