This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Java compiler patch: compile resource files into executables


On Mon, Sep 03, 2001 at 02:16:05PM -0700, Anthony Green wrote:
> Zack wrote:
> > Let me give a simple example of the sort of code one would like to be
> > able to write.
> 
> Here's an example of using `gcj -R' with a C program.  However, now that I've
> given it some thought, I don't think we should document the format in user
> documentation.  _Jv_RegisterResouce is part of the gcj ABI, and promoting it's
> use elsewhere just seems wrong.  It certainly makes it tricky to link together
> gcj code and C code using this hack.

It certainly looks a lot less generally useful than I was hoping.

I'd like to see a version of this feature that _was_ usable without
reference to gcj internal interfaces.  There isn't any widely portable
way to generate an object file with contents as specified.  (Yes, I'm
aware of the features of the GNU linker that can do this, but the GNU
linker is much less portable than gcc.)

Let me wave hands a bit and invent something both you and I might be
able to use.  Suppose "gcj -R foo" generates equivalent assembly to

.section	.gnu.resinfo,"a"
	.long	foo_data
	.long	foo_name
	.long	.Lde0-foo_data
	.long	.Lne0-foo_name

.section	.rodata

	.globl	foo_data
	.type	foo_data,@object
foo_data:
	; data here...
	; ...
	; ...
.Lde0:

	.globl	foo_name
	.type	foo_name,@object
foo_name:
	.asciz	"foo"
.Lne0:

	.globl	foo_size
	.type	foo_size,@object
foo_size:
	.long	.Lde0-foo_data

All the information a C program would care about is then accessible
through the foo_name, foo_data, and foo_size global symbols.  The Java
runtime can use linker magic to determine the start and length of the
.gnu.resinfo segment, treat it as an array, and scan down it calling
_Jv_RegisterResource.

Perhaps the global symbols ought to be in the reserved namespace;
_Rfoo_data etc.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]