This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
jc1 problem with variable-sized types
- To: java-discuss AT sourceware.cygnus dot com
- Subject: jc1 problem with variable-sized types
- From: Per Bothner <per AT bothner dot com>
- Date: 13 Sep 1999 20:19:29 -0700
While debugging my application, I noticed that the assembly
label for Class's vtable was awfuly close to the next label
(for a Class object). I looked at the compiled assembler code .class,
and found a lot of .size directives that were too small.
I am guessing that this might cause the assembler or linker to do
someting bad. The sizes were too small for Utf8Const objects,
and for vtables. In both cases we are talking about variable-sized
data structues, but where the compiler was using TYPE_SIZE of the
DECL_TYPE of a fix-length (global) type to generate the size
for the .size directive.
I'm not sure if this is the correct fix. The sizes seem more reasonable
now, but my application (Kawa) still crashes. But I probably won't
have time to look any deeper at this until I get back from vacation,
and this patch may help others.
1999-09-13 Per Bothner <per@bothner.com>
* class.c (build_utf8_ref): Set type of utf8 DECL to the size of the
(variable-length) initializer, so .size directives will work.
(make_class_data): Likewise for vtable array.
Index: class.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/java/class.c,v
retrieving revision 1.45
diff -u -r1.45 class.c
--- class.c 1999/09/11 22:22:57 1.45
+++ class.c 1999/09/14 03:07:40
@@ -605,7 +605,7 @@
}
*buf_ptr = '\0';
- decl = build_decl (VAR_DECL, get_identifier (buf), utf8const_type);
+ decl = build_decl (VAR_DECL, get_identifier (buf), ctype);
/* FIXME get some way to force this into .text, not .data. */
TREE_STATIC (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
@@ -1098,6 +1098,7 @@
DECL_ARTIFICIAL (dtable_decl) = 1;
DECL_IGNORED_P (dtable_decl) = 1;
TREE_PUBLIC (dtable_decl) = 1;
+ TREE_TYPE (dtable_decl) = TREE_TYPE (dtable);
rest_of_decl_compilation (dtable_decl, (char*) 0, 1, 0);
}
--
--Per Bothner
bothner@pacbell.net per@bothner.com http://www.bothner.com/~per/