This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcj on OpenBSD


Kurt Miller wrote:

> I've been working on getting gcj up and running on OpenBSD/i386.
> Currently I'm working on adding gcj to gcc 4.2 port. I'm pretty far
> along with the work: enabled dwarf2 exceptions, thread model posix, etc.
> The build completes but gcj-dbtool segfaults and gij too. The segfault
> occurs when initializing the class loader because engine is null.
> 
> Could anyone suggest some ideas for diagnosing the root cause of this?

This happens because class registration hasn't been done.  gcc generates
a magic section called .jcr, and this is a list of pointers to classes.

On x86_64 a .jcr section in an .o file with two classes looks like this:

RELOCATION RECORDS FOR [.jcr]:
OFFSET           TYPE              VALUE
0000000000000000 R_X86_64_64       P::class$
0000000000000008 R_X86_64_64       Hello::class$

And the .init section:

0000000000400bb0 <_init>:
  400bb0:       48 83 ec 08             sub    $0x8,%rsp
  400bb4:       e8 63 01 00 00          callq  400d1c <call_gmon_start>
  400bb9:       e8 f2 01 00 00          callq  400db0 <frame_dummy>
  400bbe:       e8 2d 04 00 00          callq  400ff0 <__do_global_ctors_aux>
  400bc3:       48 83 c4 08             add    $0x8,%rsp
  400bc7:       c3                      retq

which calls (*_Jv_RegisterClasses)

0000000000400db0 <frame_dummy>:
  400db0:       55                      push   %rbp
  400db1:       48 83 3d 87 04 20 00    cmpq   $0x0,0x200487(%rip)        # 601240 <__JCR_LIST__>
  400db8:       00
  400db9:       48 89 e5                mov    %rsp,%rbp
  400dbc:       74 1a                   je     400dd8 <frame_dummy+0x28>
  400dbe:       41 bb 18 0c 40 00       mov    $0x400c18 <_Jv_RegisterClasses@plt>,%r11d
  400dc4:       4d 85 db                test   %r11,%r11
  400dc7:       74 0f                   je     400dd8 <frame_dummy+0x28>
  400dc9:       bf 40 12 60 00          mov    $0x601240 <__JCR_LIST__>,%edi
  400dce:       c9                      leaveq
  400dcf:       41 ff e3                jmpq   *%r11
  400dd2:       66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
  400dd8:       c9                      leaveq
  400dd9:       c3                      retq

I suspect that this mechanism is not working on BSD.

Andrew.


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