aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-02-13 21:15:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-02-13 21:15:41 +0000
commita2f5a78214edc4716e6f97b97fb7839a211e8ff7 (patch)
treef5e4bbb1924e4046c38bbf624a3a029efd08be5f
parent4155fafc7f43234fc0c819a6f9c6ebaffc59e8cc (diff)
downloadgcc-a2f5a78214edc4716e6f97b97fb7839a211e8ff7.zip
gcc-a2f5a78214edc4716e6f97b97fb7839a211e8ff7.tar.gz
gcc-a2f5a78214edc4716e6f97b97fb7839a211e8ff7.tar.bz2
compiler: don't export function descriptors for unexported names
They aren't needed, and could potentially cause unlikely symbol name collisions. Also, the runtime package's reference to main could cause the runtime package to define main.main..f, which could also be defined in the main package if it does something like fmt.Print(main). That will normally work but will fail with a multiple symbol definition error when using -static-libgo. Reviewed-on: https://go-review.googlesource.com/93656 From-SVN: r257637
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc15
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index ea7ae4b..baf77e3 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7998e29eec43ede1cee925d87eef0b09da67d90b
+5d5ea2fd05dbf369ccc53c93d4846623cdea0c47
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index f50de0a..9792faa 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -1330,9 +1330,24 @@ Func_descriptor_expression::do_get_backend(Translate_context* context)
else
{
Location bloc = Linemap::predeclared_location();
+
+ // The runtime package has hash/equality functions that are
+ // referenced by type descriptors outside of the runtime, so the
+ // function descriptors must be visible even though they are not
+ // exported.
+ bool is_exported_runtime = false;
+ if (gogo->compiling_runtime()
+ && gogo->package_name() == "runtime"
+ && (no->name().find("hash") != std::string::npos
+ || no->name().find("equal") != std::string::npos))
+ is_exported_runtime = true;
+
bool is_hidden = ((no->is_function()
&& no->func_value()->enclosing() != NULL)
+ || (Gogo::is_hidden_name(no->name())
+ && !is_exported_runtime)
|| Gogo::is_thunk(no));
+
bvar = context->backend()->immutable_struct(var_name, asm_name,
is_hidden, false,
btype, bloc);