summaryrefslogtreecommitdiffstats
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 970c6381cc6..732e429a134 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2731,6 +2731,50 @@ cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
return NULL;
}
+/* Java requires that we be able to reference a local address for a
+ method, and not be confused by PLT entries. If hidden aliases are
+ supported, emit one for each java function that we've emitted. */
+
+static void
+build_java_method_aliases (void)
+{
+ struct cgraph_node *node;
+
+#ifndef HAVE_GAS_HIDDEN
+ return;
+#endif
+
+ for (node = cgraph_nodes; node ; node = node->next)
+ {
+ tree fndecl = node->decl;
+
+ if (TREE_ASM_WRITTEN (fndecl)
+ && DECL_CONTEXT (fndecl)
+ && TYPE_P (DECL_CONTEXT (fndecl))
+ && TYPE_FOR_JAVA (DECL_CONTEXT (fndecl))
+ && TARGET_USE_LOCAL_THUNK_ALIAS_P (fndecl))
+ {
+ /* Mangle the name in a predictable way; we need to reference
+ this from a java compiled object file. */
+ tree oid, nid, alias;
+ const char *oname;
+ char *nname;
+
+ oid = DECL_ASSEMBLER_NAME (fndecl);
+ oname = IDENTIFIER_POINTER (oid);
+ gcc_assert (oname[0] == '_' && oname[1] == 'Z');
+ nname = ACONCAT (("_ZGA", oname+2, NULL));
+ nid = get_identifier (nname);
+
+ alias = make_alias_for (fndecl, nid);
+ TREE_PUBLIC (alias) = 1;
+ DECL_VISIBILITY (alias) = VISIBILITY_HIDDEN;
+
+ assemble_alias (alias, oid);
+ }
+ }
+}
+
/* This routine is called from the last rule in yyparse ().
Its job is to create all the code needed to initialize and
destroy the global aggregates. We do the destruction
@@ -3062,6 +3106,9 @@ cp_finish_file (void)
check_global_declarations (VEC_address (tree, pending_statics),
VEC_length (tree, pending_statics));
+ /* Generate hidden aliases for Java. */
+ build_java_method_aliases ();
+
finish_repo ();
/* The entire file is now complete. If requested, dump everything
OpenPOWER on IntegriCloud