OSDN Git Service

PR target/47766
[pf3gnuchains/gcc-fork.git] / boehm-gc / dyn_load.c
index dfe0a3c..f1e3e8e 100644 (file)
@@ -26,7 +26,7 @@
  * None of this is safe with dlclose and incremental collection.
  * But then not much of anything is safe in the presence of dlclose.
  */
-#if defined(__linux__) && !defined(_GNU_SOURCE)
+#if (defined(__linux__) || defined(__GLIBC__)) && !defined(_GNU_SOURCE)
     /* Can't test LINUX, since this must be define before other includes */
 #   define _GNU_SOURCE
 #endif
 #   undef GC_must_restore_redefined_dlopen
 # endif
 
-#if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE)) \
+#if (defined(DYNAMIC_LOADING) \
+       || defined(MSWIN32)   \
+       || defined(MSWINCE)   \
+       || defined(CYGWIN32)) \
     && !defined(PCR)
 #if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \
-    !defined(MSWIN32) && !defined(MSWINCE) && \
+    !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) && \
     !(defined(ALPHA) && defined(OSF1)) && \
     !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
     !defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \
 #   define l_addr      lm_addr
 #   define l_name      lm_name
 #endif
+#ifdef IRIX5
+#   include <elf.h>
+#   if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */
+     /* Don't include <obj_list.h> here. */
+#     include <obj.h>
+#   else /* N32 or N64 ABIs */
+#     include <objlist.h>
+#   endif
+#endif
+
+#if defined(NETBSD)
+#   include <machine/elf_machdep.h>
+#   define ELFSIZE ARCH_ELFSIZE
+#endif
 
 #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
     (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \
 /* Newer versions of GNU/Linux define this macro.  We
  * define it similarly for any ELF systems that don't.  */
 #  ifndef ElfW
-#    ifdef __NetBSD__
-#      if ELFSIZE == 32
+#    if defined(FREEBSD)
+#      if __ELF_WORD_SIZE == 32
 #        define ElfW(type) Elf32_##type
 #      else
 #        define ElfW(type) Elf64_##type
 #      endif
 #    else
-#      if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32
-#        define ElfW(type) Elf32_##type
+#      ifdef NETBSD
+#        if ELFSIZE == 32
+#          define ElfW(type) Elf32_##type
+#        else
+#          define ElfW(type) Elf64_##type
+#        endif
 #      else
-#        define ElfW(type) Elf64_##type
+#        if !defined(ELF_CLASS) || ELF_CLASS == ELFCLASS32
+#          define ElfW(type) Elf32_##type
+#        else
+#          define ElfW(type) Elf64_##type
+#       endif
 #      endif
 #    endif
 #  endif
 
+/* An user-supplied routine that is called to determine if a DSO must
+   be scanned by the gc.  */
+static int (*GC_has_static_roots)(const char *, void *, size_t);
+/* Register the routine.  */
+void
+GC_register_has_static_roots_callback 
+  (int (*callback)(const char *, void *, size_t))
+{
+  GC_has_static_roots = callback;
+}
+
 #if defined(SUNOS5DL) && !defined(USE_PROC_FOR_LIBRARIES)
 
 #ifdef LINT
     Elf32_Dyn _DYNAMIC;
 #endif
 
+#define obj_offset(lm) ((unsigned long)(lm->l_addr))
+
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
@@ -165,6 +203,8 @@ GC_FirstDLOpenedLinkMap()
     struct link_dynamic _DYNAMIC;
 #endif
 
+#define obj_offset(lm) ((unsigned long)(lm->l_addr))
+
 static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
@@ -199,9 +239,59 @@ static ptr_t GC_first_common()
 
 #endif  /* SUNOS4 ... */
 
-# if defined(SUNOS4) || defined(SUNOS5DL)
+#if defined(IRIX5) && !defined(USE_PROC_FOR_LIBRARIES)
+
+/* Provide struct link map. */
+#  if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */
+/* Provide our own version of struct obj_list in <obj_list.h> with
+   correctly typed data member.  */
+struct obj_list {
+    struct obj *data;
+    struct obj_list *next;
+    struct obj_list *prev;
+} objList;
+
+struct link_map {
+    objList l_ol;
+};
+
+extern objList *__rld_obj_head;
+
+/* Map field names */
+#    define l_next     l_ol.next
+#    define l_addr     l_ol.data->o_pelfhdr    
+
+#    define obj_offset(lm) \
+       ((unsigned long)(lm->l_ol.o_praw - (char *)lm->l_ol.o_base_address))
+#  else /* N32 or N64 ABIs */
+struct link_map {
+    ElfW(Obj_Info) l_oi;
+};
+
+extern ElfW(Obj_Info) *__rld_obj_head;
+
+/* Map field names */
+#    define l_next     l_oi.oi_next
+#    define l_addr     l_oi.oi_ehdr
+
+/* See gdb/solib-irix.c (fetch_lm_info).  */
+#    define obj_offset(lm) \
+        ((unsigned long)(lm->l_oi.oi_ehdr - lm->l_oi.oi_orig_ehdr))
+#  endif
+
+static struct link_map *
+GC_FirstDLOpenedLinkMap()
+{
+    return (struct link_map *)__rld_obj_head;
+}
+
+#endif /* IRIX5 ... */
+
+# if defined(SUNOS4) || defined(SUNOS5DL) || defined(IRIX5)
 /* Add dynamic library data sections to the root set.          */
-# if !defined(PCR) && !defined(GC_SOLARIS_THREADS) && defined(THREADS)
+# if !defined(PCR) \
+     && !defined(GC_SOLARIS_PTHREADS) && !defined(GC_IRIX_THREADS) \
+     && defined(THREADS)
 #   ifndef SRC_M3
        --> fix mutual exclusion with dlopen
 #   endif  /* We assume M3 programs don't call dlopen for now */
@@ -214,7 +304,7 @@ void GC_register_dynamic_libraries()
   
 
   for (lm = GC_FirstDLOpenedLinkMap();
-       lm != (struct link_map *) 0;  lm = lm->l_next)
+       lm != (struct link_map *) 0;  lm = (struct link_map *) lm->l_next)
     {
 #     ifdef SUNOS4
        struct exec *e;
@@ -225,7 +315,7 @@ void GC_register_dynamic_libraries()
                    ((char *) (N_BSSADDR(*e) + e->a_bss + lm->lm_addr)),
                    TRUE);
 #     endif
-#     ifdef SUNOS5DL
+#     if defined(SUNOS5DL) || defined(IRIX5)
        ElfW(Ehdr) * e;
         ElfW(Phdr) * p;
         unsigned long offset;
@@ -234,7 +324,7 @@ void GC_register_dynamic_libraries()
         
        e = (ElfW(Ehdr) *) lm->l_addr;
         p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff));
-        offset = ((unsigned long)(lm->l_addr));
+        offset = obj_offset(lm);
         for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) {
           switch( p->p_type ) {
             case PT_LOAD:
@@ -358,7 +448,7 @@ GC_bool GC_register_main_static_data()
 {
   return FALSE;
 }
-  
+
 # define HAVE_REGISTER_MAIN_STATIC_DATA
 
 #endif /* USE_PROC_FOR_LIBRARIES */
@@ -368,7 +458,7 @@ GC_bool GC_register_main_static_data()
 /* For glibc 2.2.4+.  Unfortunately, it doesn't work for older */
 /* versions.  Thanks to Jakub Jelinek for most of the code.    */
 
-# if defined(LINUX) /* Are others OK here, too? */ \
+# if (defined(LINUX) || defined (__GLIBC__)) /* Are others OK here, too? */ \
      && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
          || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) 
 
@@ -376,6 +466,16 @@ GC_bool GC_register_main_static_data()
 /* It may still not be available in the library on the target system.   */
 /* Thus we also treat it as a weak symbol.                             */
 #define HAVE_DL_ITERATE_PHDR
+#pragma weak dl_iterate_phdr
+#endif
+
+# if (defined(FREEBSD) && __FreeBSD__ >= 7)
+/* On the FreeBSD system, any target system at major version 7 shall    */
+/* have dl_iterate_phdr; therefore, we need not make it weak as above.  */
+#define HAVE_DL_ITERATE_PHDR
+#endif
+
+#if defined(HAVE_DL_ITERATE_PHDR)
 
 static int GC_register_dynlib_callback(info, size, ptr)
      struct dl_phdr_info * info;
@@ -398,6 +498,11 @@ static int GC_register_dynlib_callback(info, size, ptr)
        {
          if( !(p->p_flags & PF_W) ) break;
          start = ((char *)(p->p_vaddr)) + info->dlpi_addr;
+
+         if (GC_has_static_roots 
+             && !GC_has_static_roots(info->dlpi_name, start, p->p_memsz))
+           break;
+
          GC_add_roots_inner(start, start + p->p_memsz, TRUE);
        }
       break;
@@ -412,8 +517,6 @@ static int GC_register_dynlib_callback(info, size, ptr)
 
 /* Return TRUE if we succeed, FALSE if dl_iterate_phdr wasn't there. */
 
-#pragma weak dl_iterate_phdr
-
 GC_bool GC_register_dynamic_libraries_dl_iterate_phdr()
 {
   if (dl_iterate_phdr) {
@@ -480,7 +583,6 @@ static struct link_map *
 GC_FirstDLOpenedLinkMap()
 {
     ElfW(Dyn) *dp;
-    struct r_debug *r;
     static struct link_map *cachedResult = 0;
 
     if( _DYNAMIC == 0) {
@@ -489,6 +591,12 @@ GC_FirstDLOpenedLinkMap()
     if( cachedResult == 0 ) {
         int tag;
         for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) {
+           /* FIXME: The DT_DEBUG header is not mandated by the        */
+           /* ELF spec.  This code appears to be dependent on          */
+           /* idiosynchracies of older GNU tool chains.  If this code  */
+           /* fails for you, the real problem is probably that it is   */
+           /* being used at all.  You should be getting the            */
+           /* dl_iterate_phdr version.                                 */
             if( tag == DT_DEBUG ) {
                 struct link_map *lm
                         = ((struct r_debug *)(dp->d_un.d_ptr))->r_map;
@@ -544,7 +652,7 @@ void GC_register_dynamic_libraries()
 
 #endif /* LINUX */
 
-#if defined(IRIX5) || (defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX))
+#if defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX)
 
 #include <sys/procfs.h>
 #include <sys/stat.h>
@@ -613,7 +721,8 @@ void GC_register_dynamic_libraries()
     }
     for (i = 0; i < needed_sz; i++) {
         flags = addr_map[i].pr_mflags;
-        if ((flags & (MA_BREAK | MA_STACK | MA_PHYS)) != 0) goto irrelevant;
+        if ((flags & (MA_BREAK | MA_STACK | MA_PHYS
+                     | MA_FETCHOP | MA_NOTCACHED)) != 0) goto irrelevant;
         if ((flags & (MA_READ | MA_WRITE)) != (MA_READ | MA_WRITE))
             goto irrelevant;
           /* The latter test is empirically useless in very old Irix   */
@@ -672,9 +781,9 @@ void GC_register_dynamic_libraries()
        fd = -1;
 }
 
-# endif /* USE_PROC || IRIX5 */
+# endif /* USE_PROC */
 
-# if defined(MSWIN32) || defined(MSWINCE)
+# if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
 
 # define WIN32_LEAN_AND_MEAN
 # define NOSERVICE
@@ -718,7 +827,7 @@ void GC_register_dynamic_libraries()
     }
 # endif
 
-# ifdef MSWINCE
+# if defined(MSWINCE) || defined(CYGWIN32)
   /* Do we need to separately register the main static data segment? */
   GC_bool GC_register_main_static_data()
   {
@@ -753,25 +862,27 @@ void GC_register_dynamic_libraries()
  
   /* Should [start, start+len) be treated as a frame buffer    */
   /* and ignored?                                              */
-  /* Unfortunately, we currently have no real way to tell      */
-  /* automatically, and rely largely on user input.            */
-  /* FIXME: If we had more data on this phenomenon (e.g.       */
-  /* is start aligned to a MB multiple?) we should be able to  */
-  /* do better.                                                        */
+  /* Unfortunately, we currently are not quite sure how to tell        */
+  /* this automatically, and rely largely on user input.       */
+  /* We expect that any mapping with type MEM_MAPPED (which    */
+  /* apparently excludes library data sections) can be safely  */
+  /* ignored.  But we're too chicken to do that in this        */
+  /* version.                                                  */
   /* Based on a very limited sample, it appears that:          */
-  /*   - Frame buffer mappings appear as mappings of length    */
-  /*     2**n MB - 192K.  (We guess the 192K can vary a bit.)  */
-  /*   - Have a stating address at best 64K aligned.           */
-  /* I'd love more information about the mapping, since I      */
-  /* can't reproduce the problem.                              */
-  static GC_bool is_frame_buffer(ptr_t start, size_t len)
+  /*   - Frame buffer mappings appear as mappings of large     */
+  /*     length, usually a bit less than a power of two.       */
+  /*   - The definition of "a bit less" in the above cannot    */
+  /*     be made more precise.                                 */
+  /*   - Have a starting address at best 64K aligned.          */
+  /*   - Have type == MEM_MAPPED.                              */
+  static GC_bool is_frame_buffer(ptr_t start, size_t len, DWORD tp)
   {
     static GC_bool initialized = FALSE;
 #   define MB (1024*1024)
 #   define DEFAULT_FB_MB 15
 #   define MIN_FB_MB 3
 
-    if (GC_disallow_ignore_fb) return FALSE;
+    if (GC_disallow_ignore_fb || tp != MEM_MAPPED) return FALSE;
     if (!initialized) {
       char * ignore_fb_string =  GETENV("GC_IGNORE_FB");
 
@@ -823,6 +934,13 @@ void GC_register_dynamic_libraries()
   }
 # endif /* DEBUG_VIRTUALQUERY */
 
+# ifdef CYGWIN32
+#   define GC_wnt (TRUE)
+# else
+    extern GC_bool GC_wnt;  /* Is Windows NT derivative.       */
+                           /* Defined and set in os_dep.c.     */
+# endif
+
   void GC_register_dynamic_libraries()
   {
     MEMORY_BASIC_INFORMATION buf;
@@ -864,7 +982,12 @@ void GC_register_dynamic_libraries()
                 * !is_frame_buffer(p, buf.RegionSize, buf.Type)
                 * instead of just checking for MEM_IMAGE.
                 * If something breaks, change it back. */
-               && buf.Type == MEM_IMAGE) {
+               /* There is some evidence that we cannot always
+                * ignore MEM_PRIVATE sections under Windows ME
+                * and predecessors.  Hence we now also check for
+                * that case.   */
+               && (buf.Type == MEM_IMAGE ||
+                   !GC_wnt && buf.Type == MEM_PRIVATE)) {  
 #              ifdef DEBUG_VIRTUALQUERY
                  GC_dump_meminfo(&buf);
 #              endif
@@ -881,7 +1004,7 @@ void GC_register_dynamic_libraries()
     GC_cond_add_roots(base, limit);
   }
 
-#endif /* MSWIN32 || MSWINCE */
+#endif /* MSWIN32 || MSWINCE || CYGWIN32 */
   
 #if defined(ALPHA) && defined(OSF1)
 
@@ -1097,68 +1220,167 @@ void GC_register_dynamic_libraries()
 
 /*#define DARWIN_DEBUG*/
 
+/* Writeable sections generally available on Darwin.  */
 const static struct { 
         const char *seg;
         const char *sect;
 } GC_dyld_sections[] = {
         { SEG_DATA, SECT_DATA },
+        /* Used by FSF GCC, but not by OSX system tools, so far.  */
+        { SEG_DATA, "__static_data" }, 
         { SEG_DATA, SECT_BSS },
-        { SEG_DATA, SECT_COMMON }
+        { SEG_DATA, SECT_COMMON },
+        /* FSF GCC - zero-sized object sections for targets supporting section
+           anchors.  */
+        { SEG_DATA, "__zobj_data" },
+        { SEG_DATA, "__zobj_bss" }
 };
-    
+
+/* Additional writeable sections:
+
+   GCC on Darwin constucts aligned sections "on demand", where the alignment
+   size is embedded in the section name.  Furthermore, there are distintions
+   between sections containing private vs. public symbols.
+
+   It also constructs sections specifically for zero-sized objects, when the
+   target supports section anchors.  */
+const char * GC_dyld_add_sect_fmts[] = 
+{
+  "__bss%u",
+  "__pu_bss%u",
+  "__zo_bss%u",
+  "__zo_pu_bss%u",
+  NULL
+} ;
+
+/* Currently, mach-o will allow up to a max of 2^15 alignment in an
+   object file.  */
+#define L2_MAX_OFILE_ALIGNMENT 15
+
+  
 #ifdef DARWIN_DEBUG
-static const char *GC_dyld_name_for_hdr(struct mach_header *hdr) {
-    unsigned long i,c;
-    c = _dyld_image_count();
-    for(i=0;i<c;i++) if(_dyld_get_image_header(i) == hdr)
-        return _dyld_get_image_name(i);
-    return NULL;
+static const char *
+GC_dyld_name_for_hdr (const struct GC_MACH_HEADER *hdr)
+{
+  unsigned long i,c;
+  c = _dyld_image_count();
+  for (i=0;i<c;i++) 
+    if(_dyld_get_image_header(i) == hdr)
+      return _dyld_get_image_name(i);
+  return NULL;
 }
 #endif
-        
+
+
 /* This should never be called by a thread holding the lock */
-static void GC_dyld_image_add(struct mach_header* hdr, unsigned long slide) {
-    unsigned long start,end,i;
-    const struct section *sec;
-    for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
-        sec = getsectbynamefromheader(
-            hdr,GC_dyld_sections[i].seg,GC_dyld_sections[i].sect);
-            if(sec == NULL || sec->size == 0) continue;
-            start = slide + sec->addr;
-            end = start + sec->size;
-#              ifdef DARWIN_DEBUG
-                GC_printf4("Adding section at %p-%p (%lu bytes) from image %s\n",
-                start,end,sec->size,GC_dyld_name_for_hdr(hdr));
-#                      endif
-        GC_add_roots((char*)start,(char*)end);
-        }
-#      ifdef DARWIN_DEBUG
-    GC_print_static_roots();
-#      endif
+static void 
+GC_dyld_image_add (const struct GC_MACH_HEADER *hdr, intptr_t slide)
+{
+  char secnam[16];
+  unsigned long start,end,i,j;
+  const struct GC_MACH_SECTION *sec;
+  const char *fmt;
+
+  if (GC_no_dls)
+    return;
+
+  for (i=0; i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]); i++)
+    {
+      sec = GC_GETSECTBYNAME (hdr, GC_dyld_sections[i].seg,
+                             GC_dyld_sections[i].sect);
+      if(sec == NULL || sec->size == 0)
+       continue;
+
+      start = slide + sec->addr;
+      end = start + sec->size;
+
+#     ifdef DARWIN_DEBUG
+      GC_printf5("Adding section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
+                GC_dyld_sections[i].sect, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
+#      endif
+      GC_add_roots((char*)start,(char*)end);
+    }
+
+  /* Sections constructed on demand.  */
+  j=0;
+  while ((fmt = GC_dyld_add_sect_fmts[j]) != NULL)
+    {
+      /* Add our manufactured aligned BSS sections.  */
+      for (i=0; i<=L2_MAX_OFILE_ALIGNMENT; i++)
+       {
+         snprintf (secnam, 16, fmt, (unsigned)i);
+         sec = GC_GETSECTBYNAME (hdr, SEG_DATA, secnam);
+         if (sec == NULL || sec->size == 0)
+           continue;
+         start = slide + sec->addr;
+         end = start + sec->size;
+#        ifdef DARWIN_DEBUG
+         GC_printf5("Adding section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
+                secnam, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
+#        endif
+         GC_add_roots((char*)start,(char*)end);
+       }
+      j++;
+    } 
+# ifdef DARWIN_DEBUG
+  GC_print_static_roots();
+# endif
 }
 
 /* This should never be called by a thread holding the lock */
-static void GC_dyld_image_remove(struct mach_header* hdr, unsigned long slide) {
-    unsigned long start,end,i;
-    const struct section *sec;
-    for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
-        sec = getsectbynamefromheader(
-            hdr,GC_dyld_sections[i].seg,GC_dyld_sections[i].sect);
-        if(sec == NULL || sec->size == 0) continue;
-        start = slide + sec->addr;
-        end = start + sec->size;
-#              ifdef DARWIN_DEBUG
-            GC_printf4("Removing section at %p-%p (%lu bytes) from image %s\n",
-                start,end,sec->size,GC_dyld_name_for_hdr(hdr));
-#              endif
-        GC_remove_roots((char*)start,(char*)end);
+static void 
+GC_dyld_image_remove (const struct GC_MACH_HEADER *hdr, intptr_t slide)
+{
+  char secnam[16];
+  unsigned long start,end,i,j;
+  const struct GC_MACH_SECTION *sec;
+  const char *fmt;
+
+  for (i=0; i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]); i++)
+    {
+      sec = GC_GETSECTBYNAME (hdr, GC_dyld_sections[i].seg,
+                             GC_dyld_sections[i].sect);
+      if(sec == NULL || sec->size == 0)
+       continue;
+
+      start = slide + sec->addr;
+      end = start + sec->size;
+#     ifdef DARWIN_DEBUG
+      GC_printf5("Removing section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
+                  GC_dyld_sections[i].sect, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
+#      endif
+      GC_remove_roots((char*)start,(char*)end);
+    }
+
+  /* Remove our on-demand sections.  */
+  j=0;
+  while ((fmt = GC_dyld_add_sect_fmts[j]) != NULL)
+    {
+      for (i=0; i<=L2_MAX_OFILE_ALIGNMENT; i++)
+       {
+         snprintf (secnam, 16, fmt, (unsigned)i);
+         sec = GC_GETSECTBYNAME (hdr, SEG_DATA, secnam);
+         if (sec == NULL || sec->size == 0)
+           continue;
+         start = slide + sec->addr;
+         end = start + sec->size;
+#        ifdef DARWIN_DEBUG
+         GC_printf5("Removing section __DATA,%s at %p-%p (%lu bytes) from image %s\n",
+                     secnam, start,end,sec->size,GC_dyld_name_for_hdr(hdr));
+#        endif
+         GC_remove_roots((char*)start,(char*)end);
+       }
+      j++;
     }
-#      ifdef DARWIN_DEBUG
-    GC_print_static_roots();
-#      endif
+
+# ifdef DARWIN_DEBUG
+  GC_print_static_roots();
+# endif
 }
 
-void GC_register_dynamic_libraries() {
+void 
+GC_register_dynamic_libraries() 
+{
     /* Currently does nothing. The callbacks are setup by GC_init_dyld() 
     The dyld library takes it from there. */
 }
@@ -1169,15 +1391,18 @@ void GC_register_dynamic_libraries() {
    This should be called BEFORE any thread in created and WITHOUT the
    allocation lock held. */
    
-void GC_init_dyld() {
+void 
+GC_init_dyld()
+{
   static GC_bool initialized = FALSE;
   char *bind_fully_env = NULL;
   
-  if(initialized) return;
+  if(initialized)
+    return;
   
-#   ifdef DARWIN_DEBUG
+# ifdef DARWIN_DEBUG
   GC_printf0("Registering dyld callbacks...\n");
-#   endif
+# endif
   
   /* Apple's Documentation:
      When you call _dyld_register_func_for_add_image, the dynamic linker runtime
@@ -1190,27 +1415,28 @@ void GC_init_dyld() {
      linked in the future
   */
   
-    _dyld_register_func_for_add_image(GC_dyld_image_add);
-    _dyld_register_func_for_remove_image(GC_dyld_image_remove);
+  _dyld_register_func_for_add_image(GC_dyld_image_add);
+  _dyld_register_func_for_remove_image(GC_dyld_image_remove);
 
-    /* Set this early to avoid reentrancy issues. */
-    initialized = TRUE;
+  /* Set this early to avoid reentrancy issues. */
+  initialized = TRUE;
 
-    bind_fully_env = getenv("DYLD_BIND_AT_LAUNCH");
+  bind_fully_env = getenv("DYLD_BIND_AT_LAUNCH");
     
-    if (bind_fully_env == NULL) {
-#   ifdef DARWIN_DEBUG
+  if (bind_fully_env == NULL)
+    {
+#     ifdef DARWIN_DEBUG
       GC_printf0("Forcing full bind of GC code...\n");
-#   endif
+#     endif
       
-      if(!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
-        GC_abort("_dyld_bind_fully_image_containing_address failed");
+      if (!_dyld_bind_fully_image_containing_address((unsigned long*)GC_malloc))
+       GC_abort("_dyld_bind_fully_image_containing_address failed");
     }
-
 }
 
 #define HAVE_REGISTER_MAIN_STATIC_DATA
-GC_bool GC_register_main_static_data()
+GC_bool 
+GC_register_main_static_data (void)
 {
   /* Already done through dyld callbacks */
   return FALSE;