* final.c (compute_alignments): Make it static.
[official-gcc.git] / libjava / darwin.cc
blobd427ba7cd1948dbda7ec0a7d3402b52f78ff9403
1 /* darwin.cc - class loader stuff for Darwin. */
3 /* Copyright (C) 2004 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #include <config.h>
13 #include <jvm.h>
15 /* In theory, we should be able to do:
16 #include <mach-o/getsect.h>
17 #include <mach-o/dyld.h>
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. */
23 #include <stdint.h>
24 struct mach_header;
25 extern "C" void _dyld_register_func_for_add_image
26 (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
27 extern "C" void _dyld_register_func_for_remove_image
28 (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
29 extern "C" char *getsectdatafromheader
30 (const struct mach_header *mhp, const char *segname, const char *sectname,
31 uint32_t *size);
33 /* When a new image is loaded, look to see if it has a jcr section
34 and if so register the classes listed in it. */
36 static void
37 darwin_java_register_dyld_add_image_hook (const struct mach_header *mh,
38 intptr_t slide)
40 char *fde;
41 uint32_t sz;
43 fde = getsectdatafromheader (mh, "__DATA", "jcr", &sz);
44 if (! fde)
45 return;
47 /* As far as I can tell, you're only supposed to load shared
48 libraries while having a lock on java.lang.Class. So there's
49 no need to synchronize on anything here. (I'm not sure how exactly
50 you can ensure this given lazy library loading. FIXME.) */
52 _Jv_RegisterClasses_Counted ((const jclass *) (fde + slide),
53 sz / sizeof (jclass *));
56 static struct darwin_constructor_s{
57 darwin_constructor_s()
59 _dyld_register_func_for_add_image
60 (darwin_java_register_dyld_add_image_hook);
61 /* At present, you mustn't unload any java plugin. */
63 } darwin_constructor;