OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [darwin.cc] - Blame information for rev 763

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 753 jeremybenn
/* darwin.cc - class loader stuff for Darwin.  */
2
 
3
/* Copyright (C) 2004, 2007  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
This software is copyrighted work licensed under the terms of the
8
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9
details.  */
10
 
11
#include <config.h>
12
 
13
#include <jvm.h>
14
 
15
/* In theory, we should be able to do:
16
   #include <mach-o/getsect.h>
17
   #include <mach-o/dyld.h>
18
 
19
   but all the types in these headers changed between Panther and Tiger,
20
   so the only way to be avoid type mismatches is to declare the routines
21
   ourself.  */
22
 
23
#include <stdint.h>
24
#if !defined (__LP64__)
25
  struct mach_header;
26
# define JAVA_MACH_HEADER mach_header
27
# define  mh_size_t uint32_t
28
  extern "C" void _dyld_register_func_for_add_image
29
    (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
30
  extern "C" void _dyld_register_func_for_remove_image
31
    (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
32
  extern "C" char *getsectdatafromheader
33
    (const struct mach_header *mhp, const char *segname, const char *sectname,
34
     uint32_t *size);
35
# define GETSECTDATA getsectdatafromheader
36
#else
37
  struct mach_header_64;
38
# define JAVA_MACH_HEADER mach_header_64
39
# define mh_size_t uint64_t
40
  extern "C" void _dyld_register_func_for_add_image
41
    (void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
42
  extern "C" void _dyld_register_func_for_remove_image
43
    (void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
44
  extern "C" char *getsectdatafromheader_64
45
    (const struct mach_header_64 *mhp, const char *segname,
46
     const char *sectname, uint64_t *size);
47
# define GETSECTDATA getsectdatafromheader_64
48
#endif
49
 
50
/* When a new image is loaded, look to see if it has a jcr section
51
   and if so register the classes listed in it.  */
52
 
53
static void
54
darwin_java_register_dyld_add_image_hook (const struct JAVA_MACH_HEADER *mh,
55
                                          intptr_t slide)
56
{
57
  char *fde;
58
  mh_size_t sz;
59
 
60
  fde = GETSECTDATA (mh, "__DATA", "jcr", &sz);
61
  if (! fde)
62
    return;
63
 
64
  /* As far as I can tell, you're only supposed to load shared
65
     libraries while having a lock on java.lang.Class.  So there's
66
     no need to synchronize on anything here.  (I'm not sure how exactly
67
     you can ensure this given lazy library loading.  FIXME.)  */
68
 
69
  _Jv_RegisterClasses_Counted ((const jclass *) (fde + slide),
70
                               sz / sizeof (jclass *));
71
}
72
 
73
static struct darwin_constructor_s{
74
  darwin_constructor_s()
75
  {
76
    _dyld_register_func_for_add_image
77
      (darwin_java_register_dyld_add_image_hook);
78
    /* At present, you mustn't unload any java plugin.  */
79
  };
80
} darwin_constructor;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.