[PATCH] Make java compiled resources public.

David Daney ddaney@avtrex.com
Thu Dec 20 09:50:00 GMT 2007


This patch makes java compiled resources public symbols.  This is needed
so that when statically linking to libgcj, the resource files in
libgcj.a can be linked by passing -u to the linker.  In 4.2 we could
statically link java.util.Currency, but in 4.3 this class now depends on
an compiled core:/ resource file.  Without this patch it is impossible
(or at least very awkward) to force the resource file to be linked.

There are two changes:  The first is to generate a name for the resource
that is a mangled version of the resource name.  Second, make the
resource names public.  This allows us to force the resource to be
linked by referring to the symbol from either the linker command line or
some other object that is being linked.

The mangling is as follows:

The resource name is broken into path components by '/' characters. Each
component then has an '_' prepended and all '.' -> "$_" and '$' ->
"$$".  The length of each component is then prepended to this and all
are concatenated together and preceeded by "_ZGr".  "Gr" being an unused
special-name designator that could be thought of as representing
GNU-resource.  For example:

"java/util/iso4217.properties" mangles as:
"_ZGr5_java5_util20_iso4217$_properties"

These symbols seem to pass through the demangler unaffected (GNU nm
2.17.50.0.6-5.fc6 20061020 from FC6).

If the patch is accepted, I will follow up with a demangler patch that
handles this new mangling.

Tested on x86_64-pc-linux-gnu with bootstrap and make check in libjava
with no FAILures.

OK to commit?

2007-12-20  David Daney  <ddaney@avtrex.com>

    * resource.c (Jr_count): Remove.
    (compile_resource_data): Call java_mangle_resource_name to generate
    decl name.  Make resource decl public.
    * mangle.c (append_resource_name_hunk): New function.
    (java_mangle_resource_name): Same.
    * java-tree.h (java_mangle_resource_name): Declare new function.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: resource.diff
Type: text/x-patch
Size: 3739 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20071220/8ea67b23/attachment.bin>


More information about the Gcc-patches mailing list