diff options
author | Richard Henderson <rth@gcc.gnu.org> | 2005-05-25 15:08:31 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2005-05-25 15:08:31 -0700 |
commit | 6de33afa78e19bee96963ec3771c352a488287e1 (patch) | |
tree | 047bbcbef9a1b2d83cf20f62170c7df12ca50eff /gcc/cp/decl2.c | |
parent | 81fc305201e8913727cb61303c4812730a95c59c (diff) | |
download | gcc-6de33afa78e19bee96963ec3771c352a488287e1.zip gcc-6de33afa78e19bee96963ec3771c352a488287e1.tar.gz gcc-6de33afa78e19bee96963ec3771c352a488287e1.tar.bz2 |
re PR libgcj/21692 (unexpected java.lang.NoClassDefFoundError)
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.
From-SVN: r100171
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 970c638..732e429 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 |