[PATCH] Make --start-lib/--end-lib block on previous add symbols tasks

Cary Coutant ccoutant@google.com
Fri Aug 20 01:00:00 GMT 2010


>> Ian or Cary, could one of you submit this for me?  I don't have CVS write
>> access.
>
> Hmmm, with Neil's patch applied to my sources, my test case is still
> running the tasks out of order. Investigating...
>
> (There was a typo in testsuite/Makefile.am -- should have been
> libstart_lib_test.a instead of lib_start_lib_test.a -- but I fixed
> that and it's still failing.)

Oops, also forgot the -Bgcctestdir/ on the link command in the new test case.

Fixed and committed. The patch as committed is attached.

-cary


2010-08-19  Neil Vachharajani  <nvachhar@google.com>
            Cary Coutant  <ccoutant@google.com>

        * gold/archive.h (Add_lib_group_symbols): Add readsyms_blocker_, adjust
        constructor, and set_blocker.
        * gold/archive.cc (Add_lib_group_symbols::is_runnable): Also check
        readsyms_blocker_.
        * gold/readsyms.cc (Read_symbols::do_lib_group): Also pass
        this->this_blocker_ to Add_lib_group_symbols::set_blocker.
        * testsuite/Makefile.am (start_lib_test): New test case.
        * testsuite/Makefile.in: Regenerate.
        * testsuite/start_lib_test_main.c: New file.
        * testsuite/start_lib_test_1.c: New file.
        * testsuite/start_lib_test_2.c: New file.
        * testsuite/start_lib_test_3.c: New file.
-------------- next part --------------
Index: archive.cc
===================================================================
RCS file: /cvs/src/src/gold/archive.cc,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -p -r1.56 -r1.57
--- archive.cc	12 Aug 2010 22:01:11 -0000	1.56
+++ archive.cc	20 Aug 2010 00:35:12 -0000	1.57
@@ -1118,6 +1118,8 @@ Lib_group::print_stats()
 Task_token*
 Add_lib_group_symbols::is_runnable()
 {
+  if (this->readsyms_blocker_ != NULL && this->readsyms_blocker_->is_blocked())
+    return this->readsyms_blocker_;
   if (this->this_blocker_ != NULL && this->this_blocker_->is_blocked())
     return this->this_blocker_;
   return NULL;
Index: archive.h
===================================================================
RCS file: /cvs/src/src/gold/archive.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -p -r1.29 -r1.30
--- archive.h	12 Aug 2010 22:01:11 -0000	1.29
+++ archive.h	20 Aug 2010 00:35:12 -0000	1.30
@@ -495,7 +495,8 @@ class Add_lib_group_symbols : public Tas
                         Input_objects* input_objects,
                         Lib_group* lib, Task_token* next_blocker)
       : symtab_(symtab), layout_(layout), input_objects_(input_objects),
-        lib_(lib), this_blocker_(NULL), next_blocker_(next_blocker)
+        lib_(lib), readsyms_blocker_(NULL), this_blocker_(NULL),
+        next_blocker_(next_blocker)
   { }
 
   ~Add_lib_group_symbols();
@@ -513,9 +514,10 @@ class Add_lib_group_symbols : public Tas
 
   // Set the blocker to use for this task.
   void
-  set_blocker(Task_token* this_blocker)
+  set_blocker(Task_token* readsyms_blocker, Task_token* this_blocker)
   {
-    gold_assert(this->this_blocker_ == NULL);
+    gold_assert(this->readsyms_blocker_ == NULL && this->this_blocker_ == NULL);
+    this->readsyms_blocker_ = readsyms_blocker;
     this->this_blocker_ = this_blocker;
   }
 
@@ -530,6 +532,7 @@ class Add_lib_group_symbols : public Tas
   Layout* layout_;
   Input_objects* input_objects_;
   Lib_group * lib_;
+  Task_token* readsyms_blocker_;
   Task_token* this_blocker_;
   Task_token* next_blocker_;
 };
Index: readsyms.cc
===================================================================
RCS file: /cvs/src/src/gold/readsyms.cc,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -r1.44 -r1.45
--- readsyms.cc	12 Aug 2010 22:01:11 -0000	1.44
+++ readsyms.cc	20 Aug 2010 00:35:12 -0000	1.45
@@ -248,7 +248,7 @@ Read_symbols::do_lib_group(Workqueue* wo
 					     m, NULL, next_blocker));
     }
 
-  add_lib_group_symbols->set_blocker(next_blocker);
+  add_lib_group_symbols->set_blocker(next_blocker, this->this_blocker_);
   workqueue->queue_soon(add_lib_group_symbols);
 
   return true;
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/testsuite/Makefile.am,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -p -r1.141 -r1.142
--- testsuite/Makefile.am	19 Aug 2010 22:50:16 -0000	1.141
+++ testsuite/Makefile.am	20 Aug 2010 00:35:12 -0000	1.142
@@ -1750,6 +1750,15 @@ strong_ref_weak_def_1.so: strong_ref_wea
 strong_ref_weak_def.stdout: strong_ref_weak_def_1.so
 	$(TEST_READELF) -sWD $< > $@
 
+# Test that --start-lib and --end-lib function correctly.
+check_PROGRAMS += start_lib_test
+start_lib_test: start_lib_test_main.o libstart_lib_test.a start_lib_test_2.o start_lib_test_3.o \
+	gcctestdir/ld
+	$(LINK) -Bgcctestdir/ -o $@ start_lib_test_main.o -L. -lstart_lib_test \
+		-Wl,--start-lib start_lib_test_2.o start_lib_test_3.o -Wl,--end-lib
+libstart_lib_test.a: start_lib_test_1.o
+	$(TEST_AR) rc $@ $^
+
 endif GCC
 endif NATIVE_LINKER
 
Index: testsuite/start_lib_test_1.c
===================================================================
RCS file: testsuite/start_lib_test_1.c
diff -N testsuite/start_lib_test_1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/start_lib_test_1.c	20 Aug 2010 00:35:13 -0000	1.1
@@ -0,0 +1,32 @@
+/* start_lib_test_1.c -- test --start-lib/--end-lib.
+
+   Copyright 2010 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 a test of the --start-lib and --end-lib options.  */
+
+extern void t1 (void);
+extern void t2 (void);
+
+void
+t1 (void)
+{
+  t2 ();
+}
Index: testsuite/start_lib_test_2.c
===================================================================
RCS file: testsuite/start_lib_test_2.c
diff -N testsuite/start_lib_test_2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/start_lib_test_2.c	20 Aug 2010 00:35:13 -0000	1.1
@@ -0,0 +1,30 @@
+/* start_lib_test_2.c -- test --start-lib/--end-lib.
+
+   Copyright 2010 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 a test of the --start-lib and --end-lib options.  */
+
+extern void t2 (void);
+
+void
+t2 (void)
+{
+}
Index: testsuite/start_lib_test_3.c
===================================================================
RCS file: testsuite/start_lib_test_3.c
diff -N testsuite/start_lib_test_3.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/start_lib_test_3.c	20 Aug 2010 00:35:13 -0000	1.1
@@ -0,0 +1,30 @@
+/* start_lib_test_3.c -- test --start-lib/--end-lib.
+
+   Copyright 2010 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 a test of the --start-lib and --end-lib options.  */
+
+extern void t3 (void);
+
+void
+t3 (void)
+{
+}
Index: testsuite/start_lib_test_main.c
===================================================================
RCS file: testsuite/start_lib_test_main.c
diff -N testsuite/start_lib_test_main.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/start_lib_test_main.c	20 Aug 2010 00:35:13 -0000	1.1
@@ -0,0 +1,33 @@
+/* start_lib_test_main.c -- test --start-lib/--end-lib.
+
+   Copyright 2010 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 a test of the --start-lib and --end-lib options.  */
+
+extern void t1 (void);
+
+int
+main (int argc __attribute__ ((unused)),
+      char** argv __attribute__ ((unused)))
+{
+  t1 ();
+  return 0;
+}


More information about the Binutils mailing list