[Patch 1/2] Add demangling for java resource files to libiberty

David Daney ddaney@avtrex.com
Wed Jan 16 12:59:00 GMT 2008


This is the first of a two part patch to make embedded java resources
public symbols in libgcj.a.

The patch is motivated by the fact that there are no references to the
resource files.  So when doing static linking there is no easy way to
make the linker include them in the compiled object.

The patches give the resource files public visibility with a mangled
name, this allows them to be forced into the output object.  The names
are given hidden visibility so that they do not pollute the namespace of
libgcj.so.

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"

This first part is to libiberty's demangler so that the mangling can be reversed.

OK to commit?

Tested on x86_64-pc-linux-gnu with no regressions.  Also tested with mipsel-linux-nm -C on a patched libgcj.a where it produces the expected results.

include/
2008-01-14  David Daney  <ddaney@avtrex.com>

	* demangle.h (demangle_component_type):  Add
	DEMANGLE_COMPONENT_JAVA_RESOURCE,
	DEMANGLE_COMPONENT_COMPOUND_NAME, and
	DEMANGLE_COMPONENT_CHARACTER as new enum values.
	(demangle_component): Add struct s_character to union u.

libiberty/
2008-01-14  David Daney  <ddaney@avtrex.com>

	* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_JAVA_RESOURCE,
	DEMANGLE_COMPONENT_COMPOUND_NAME, and
	DEMANGLE_COMPONENT_CHARACTER cases.
	(d_make_comp): Handle DEMANGLE_COMPONENT_COMPOUND_NAME and
	DEMANGLE_COMPONENT_JAVA_RESOURCE cases.
	(d_make_character): New function.
	(d_java_resource_part): Same.
	(d_java_resource): Same.
	(d_special_name): Handle "Gr" case.
	(d_print_comp): Handle DEMANGLE_COMPONENT_JAVA_RESOURCE,
	DEMANGLE_COMPONENT_COMPOUND_NAME, and
	DEMANGLE_COMPONENT_CHARACTER cases.
	(testsuite/demangle-expected): Add test for java resource name
	mangling.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: demangle.patch
Type: text/x-patch
Size: 6932 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20080116/ae9f0e1f/attachment.bin>


More information about the Binutils mailing list