summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-25 22:08:31 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-25 22:08:31 +0000
commitdc5e52161fe493db7c467ab5d2bca209ee1ae883 (patch)
tree047bbcbef9a1b2d83cf20f62170c7df12ca50eff /gcc/cp
parent2f96475c32ccd16122473fdadc5ab6f1885f5351 (diff)
downloadgcc-dc5e52161fe493db7c467ab5d2bca209ee1ae883.tar.gz
PR libgcj/21692
cp/ * cp-tree.h (make_alias_for): Declare. * decl2.c (build_java_method_aliases): New. (cp_finish_file): Call it. * method.c (make_alias_for): Split out from ... (make_alias_for_thunk): ... here. java/ * Make-lang.in (java/mangle.o): Depend on LANGHOOKS_DEF_H. * class.c (build_class_ref): Set DECL_CLASS_FIELD_P and DECL_CONTEXT; avoid pushdecl_top_level. (build_dtable_decl): Set DECL_VTABLE_P and DECL_CONTEXT. (layout_class): Don't SET_DECL_ASSEMBLER_NAME. (layout_class_method): Likewise. * decl.c (java_mark_cni_decl_local): New. (java_mark_class_local): Use it. * java-tree.h (DECL_LOCAL_CNI_METHOD_P): New. (DECL_CLASS_FIELD_P, DECL_VTABLE_P): New. (struct lang_decl_func): Add local_cni; (struct lang_decl_var): Add class_field, vtable. (java_mangle_decl): Declare. * lang.c (LANG_HOOKS_SET_DECL_ASSEMBLER_NAME): New. * mangle.c: Remove dup obstack.h; include langhooks-def.h. (mangle_obstack_1): New. (java_mangle_decl): Remove obstack argument. Call mangle_class_field, mangle_vtable, and mangle_local_cni_method_decl. Fall back to lhd_set_decl_assembler_name for things that don't need mangling. (mangle_class_field): Rename from java_mangle_class_field, make static, don't call init_mangling or finish_mangling. (mangle_vtable): Similarly. (mangle_local_cni_method_decl): New. (init_mangling): Remove obstack argument. Use &mangle_obstack_1, gcc_assert, and MANGLE_RAW_STRING. (finish_mangling): Use gcc_assert, remove if 0 debugging code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100171 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl2.c47
-rw-r--r--gcc/cp/method.c27
4 files changed, 78 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a54ca60803e..25092d7b866 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-25 Richard Henderson <rth@redhat.com>
+
+ PR libgcj/21692
+ * cp-tree.h (make_alias_for): Declare.
+ * decl2.c (build_java_method_aliases): New.
+ (cp_finish_file): Call it.
+ * method.c (make_alias_for): Split out from ...
+ (make_alias_for_thunk): ... here.
+
2005-05-25 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/21686
@@ -248,8 +257,8 @@
2005-05-02 Paolo Bonzini <bonzini@gnu.org>
- * semantics.c (finish_call_expr): Call resolve_overloaded_builtin
- for BUILT_IN_MD built-ins.
+ * semantics.c (finish_call_expr): Call resolve_overloaded_builtin
+ for BUILT_IN_MD built-ins.
2005-05-02 Michael Matz <matz@suse.de>
@@ -310,7 +319,7 @@
2005-04-22 Per Bothner <per@bothner.com>
* decl.c (make_rtl_for_nonlocal_decl): Don't try get_fileinfo if
- input_filename is NULL, as it is for (say) __PRETTY_FUNCTION__.
+ input_filename is NULL, as it is for (say) __PRETTY_FUNCTION__.
2005-04-22 Alexandre Oliva <aoliva@redhat.com>
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 1a2399b878f..fc0e20ce37c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3923,6 +3923,7 @@ extern void synthesize_method (tree);
extern tree implicitly_declare_fn (special_function_kind, tree, bool);
extern tree lazily_declare_fn (special_function_kind, tree);
extern tree skip_artificial_parms_for (tree, tree);
+extern tree make_alias_for (tree, tree);
/* In optimize.c */
extern bool maybe_clone_body (tree);
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
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 9470cd5997d..37822bea78e 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -258,16 +258,10 @@ static GTY (()) int thunk_labelno;
/* Create a static alias to function. */
-static tree
-make_alias_for_thunk (tree function)
+tree
+make_alias_for (tree function, tree newid)
{
- tree alias;
- char buf[256];
-
- ASM_GENERATE_INTERNAL_LABEL (buf, "LTHUNK", thunk_labelno);
- thunk_labelno++;
- alias = build_decl (FUNCTION_DECL, get_identifier (buf),
- TREE_TYPE (function));
+ tree alias = build_decl (FUNCTION_DECL, newid, TREE_TYPE (function));
DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (function);
cxx_dup_lang_specific_decl (alias);
DECL_CONTEXT (alias) = NULL;
@@ -296,8 +290,23 @@ make_alias_for_thunk (tree function)
TREE_USED (alias) = 1;
SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));
TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias)) = 1;
+ return alias;
+}
+
+static tree
+make_alias_for_thunk (tree function)
+{
+ tree alias;
+ char buf[256];
+
+ ASM_GENERATE_INTERNAL_LABEL (buf, "LTHUNK", thunk_labelno);
+ thunk_labelno++;
+
+ alias = make_alias_for (function, get_identifier (buf));
+
if (!flag_syntax_only)
assemble_alias (alias, DECL_ASSEMBLER_NAME (function));
+
return alias;
}