This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Always put descriptor wrappers in their own section


This patch to the Go frontend always puts descriptor wrapper functions
in their own section.  This lets the linker GC them.  That is convenient
since we must generate a wrapper for every top-level exported function,
although most of them will never be used.  We can only know whether they
are used or not at link time.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.8 branch.

Ian

diff -r bc1ad842d946 go/gogo.cc
--- a/go/gogo.cc	Wed Jul 24 15:24:12 2013 -0700
+++ b/go/gogo.cc	Fri Aug 02 09:58:44 2013 -0700
@@ -3582,6 +3582,12 @@
   Named_object* dno = gogo->start_function(name, new_fntype, false, loc);
   dno->func_value()->is_descriptor_wrapper_ = true;
 
+  // Put the wrapper in a unique section so that it can be discarded
+  // by the linker if it is not needed.  Every top-level function will
+  // get a wrapper, in case there is a reference other than a call
+  // from some other package, but most will not need one.
+  dno->func_value()->set_in_unique_section();
+
   gogo->start_block(loc);
 
   Expression* fn = Expression::make_func_reference(no, NULL, loc);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]