gkeating    02/11/07 12:33:26

  Modified:    live/gcc3/gcc ChangeLog config.gcc crtstuff.c dwarf2out.c
                        unwind-dw2-fde-glibc.c unwind-dw2-fde.c
                        unwind-dw2-fde.h unwind-dw2.c unwind.inc
               live/gcc3/gcc/config darwin.c darwin.h
               live/gcc3/gcc/config/i386 t-darwin
               live/gcc3/gcc/config/rs6000 t-darwin
               live/gcc3/gcc/testsuite ChangeLog
               live/gcc3/gcc/testsuite/g++.old-deja/g++.eh badalloc1.C
  Added:       live/gcc3/gcc unwind-dw2-fde-darwin.c
               live/gcc3/gcc/config darwin-crt2.c t-darwin
  Log:
  Merge new EH patches from FSF.
  
  Revision  Changes    Path
  1.21      +23 -0     src/live/gcc3/gcc/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/ChangeLog,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ChangeLog 2002/10/24 23:42:32     1.20
  +++ ChangeLog 2002/11/07 20:33:17     1.21
  @@ -1,3 +1,26 @@
  +2002-11-05  Geoffrey Keating  <[EMAIL PROTECTED]>
  +
  +     * config.gcc: Don't create crtbegin, crtend on Darwin; do create
  +     crt2.o.  Rearrange t-darwin makefiles.
  +     * crtstuff.c [OBJECT_FORMAT_MACHO]: Delete.
  +     * unwind-dw2-fde-darwin.c: New.
  +     * unwind-dw2-fde-glibc.c: Correct comment.
  +     * unwind-dw2-fde.c (__register_frame_info_bases)
  +     [DWARF2_OBJECT_END_PTR_EXTENSION]: Clear fde_end.
  +     (classify_object_over_fdes): Use last_fde.
  +     (add_fdes): Likewise.
  +     (linear_search_fdes): Likewise.
  +     * unwind-dw2-fde.h (struct object)
  +     [DWARF2_OBJECT_END_PTR_EXTENSION]: Add fde_end field.
  +     (last_fde): New.
  +     * config/darwin.h (STARTFILE_SPEC): Include crt2.o not crtbegin.o.
  +     (ENDFILE_SPEC): No crtend.o.
  +     * config/t-darwin: New.
  +     * config/i386/t-darwin: Delete.
  +     * config/darwin-crt2.c: New.
  +     * config/rs6000/t-darwin: Delete contents duplicated in t-rs6000
  +     or config/t-darwin.
  +
   2002-10-20  Richard Henderson  <[EMAIL PROTECTED]>
   
        * target.h (struct gcc_target): Line wrap.
  
  
  
  1.52      +4 -4      src/live/gcc3/gcc/config.gcc
  
  Index: config.gcc
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/config.gcc,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- config.gcc        2002/10/24 23:42:46     1.51
  +++ config.gcc        2002/11/07 20:33:19     1.52
  @@ -984,8 +984,8 @@
   i[34567]86-*-darwin*)
        tm_file="${tm_file} darwin.h i386/darwin.h"
        tm_p_file="${tm_p_file} darwin-protos.h"
  -     tmake_file=i386/t-darwin
        # APPLE LOCAL begin darwin host
  +     tmake_file="t-darwin i386/t-darwin"
        xmake_file=i386/x-darwin
        # Override the usual setting, since Apple's GCC has lame bugs
        # and can't handle the initializers.  Someday the bugs will be
  @@ -996,7 +996,7 @@
        target_gtfiles="\$(srcdir)/config/darwin.c"
        c_target_objs="darwin-c.o"
        cxx_target_objs="darwin-c.o"
  -     extra_parts="crtbegin.o crtend.o"
  +     extra_parts="crt2.o"
        # Darwin linker does collect2 functionality
        use_collect2=no
        ;;
  @@ -1962,7 +1962,7 @@
   powerpc-*-darwin*)
        tm_file="${tm_file} darwin.h rs6000/darwin.h"
        tm_p_file="${tm_p_file} darwin-protos.h"
  -     tmake_file=rs6000/t-darwin
  +     tmake_file="rs6000/t-rs6000 t-darwin rs6000/t-darwin"
        # APPLE LOCAL begin darwin host
        xmake_file=rs6000/x-darwin
        # Override the usual setting, since Apple's GCC has lame bugs
  @@ -1974,7 +1974,7 @@
        target_gtfiles="\$(srcdir)/config/darwin.c"
        c_target_objs="darwin-c.o"
        cxx_target_objs="darwin-c.o"
  -     extra_parts="crtbegin.o crtend.o"
  +     extra_parts="crt2.o"
        # Darwin linker does collect2 functionality
        use_collect2=no
        extra_headers=altivec.h
  
  
  
  1.18      +0 -244    src/live/gcc3/gcc/crtstuff.c
  
  Index: crtstuff.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/crtstuff.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- crtstuff.c        2002/10/24 23:42:52     1.17
  +++ crtstuff.c        2002/11/07 20:33:19     1.18
  @@ -126,168 +126,6 @@
   /* Likewise for _Jv_RegisterClasses.  */
   extern void _Jv_RegisterClasses (void *) TARGET_ATTRIBUTE_WEAK;
   
  -/* APPLE LOCAL begin C++ EH */
  -#ifdef DARWIN
  -
  -#ifdef CRT_BEGIN
  -
  -/* Homemade decls substituting for getsect.h and dyld.h, so cross
  -   compilation works.  */
  -struct mach_header;
  -extern char *getsectdatafromheader (struct mach_header *, const char *,
  -                                 const char *, unsigned long *);
  -extern void _dyld_register_func_for_add_image
  -  (void (*) (struct mach_header *, unsigned long));
  -extern void _dyld_register_func_for_remove_image
  -  (void (*) (struct mach_header *, unsigned long));
  -
  -extern void __darwin_gcc3_preregister_frame_info (void);
  -
  -#define USE_KEYMGR   1
  -
  -#if USE_KEYMGR
  -
  -/* Grody stuff here until we get keymgr.h in gcc3.  */
  -extern void _init_keymgr ();
  -extern void *_keymgr_get_and_lock_processwide_ptr (unsigned key);
  -extern void _keymgr_set_and_unlock_processwide_ptr (unsigned key, void *ptr);
  -
  -extern void *__keymgr_global[];
  -typedef struct _Sinfo_Node {
  -        unsigned int size ;             /*size of this node*/
  -        unsigned short major_version ;  /*API major version.*/
  -        unsigned short minor_version ;  /*API minor version.*/
  -        } _Tinfo_Node ;
  -
  -/* KeyMgr 3.x is the first one supporting GCC3 stuff natively.  */
  -#define KEYMGR_API_MAJOR_GCC3           3       
  -/* ... with these keys.  */
  -#define KEYMGR_GCC3_LIVE_IMAGE_LIST  301     /* loaded images  */
  -#define KEYMGR_GCC3_DW2_OBJ_LIST     302     /* Dwarf2 object list  */   
  -
  -/*
  -THE FOLLOWING ROUTINES ARE TEMPORARY!
  -THEY ARE COPIES OF ROUTINES IN KEYMGR (and won't be used if your keymgr
  -is new enough.)
  -*/
  -
  -static void
  -darwin_unwind_dyld_add_image_hook (struct mach_header *mh, unsigned long slide)
  -{
  -  struct __live_images *l = (struct __live_images *)calloc (1, sizeof (*l));
  -  l->mh = mh;
  -  l->vm_slide = slide;
  -  l->this_size = sizeof (*l);
  -  l->next = (struct __live_images *)
  -     _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  -  _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST, l);
  -}
  -
  -static void
  -darwin_unwind_dyld_remove_image_hook (struct mach_header *m, unsigned long s)
  -{
  -  struct __live_images *top, **lip, *destroy = NULL;
  -
  -  /* Look for it in the list of live images and delete it.  */
  -
  -  top = (struct __live_images *)
  -        _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  -  for (lip = &top; *lip != NULL; lip = &(*lip)->next)
  -    {
  -      if ((*lip)->mh == m && (*lip)->vm_slide == s)
  -        {
  -          destroy = *lip;
  -          *lip = destroy->next;                      /* unlink DESTROY  */
  -
  -          if (destroy->this_size != sizeof (*destroy))       /* sanity check  */
  -            abort ();
  -
  -          break;
  -        }
  -    }
  -  _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST, top);
  -
  -  /* Now that we have unlinked this from the image list, toss it.  */
  -  if (destroy != NULL)
  -    {
  -      if (destroy->destructor != NULL)
  -     (*destroy->destructor) (destroy);
  -      free (destroy);
  -    }
  -}
  -
  -#else        /* ! USE_KEYMGR  */
  -
  -static void
  -darwin_unwind_dyld_add_image_hook (struct mach_header *mh,
  -                                unsigned long vm_slide)
  -{
  -  unsigned long sz;
  -  char *fde;
  -
  -  fde = getsectdatafromheader (mh, "__DATA", "__eh_frame", &sz);
  -
  -#if 0
  -    printf ("add_image_hook: mach_header %08x vm_slide %08x "
  -         "<fde %08x>\n", mh, vm_slide, fde);
  -#endif
  -
  -  if (fde)
  -    {
  -      struct object *ob = (struct object *) malloc (sizeof (struct object));
  -
  -      __register_frame_info (fde + vm_slide, ob);
  -    }
  -}
  -
  -static void
  -darwin_unwind_dyld_remove_image_hook (struct mach_header *mh,
  -                                   unsigned long vm_slide)
  -{
  -  unsigned long sz;
  -  char *fde;
  -
  -  fde = getsectdatafromheader (mh, "__DATA", "__eh_frame", &sz);
  -#if 0
  -    printf ("remove_image_hook: mach_header %08x vm_slide %08x "
  -         "<fde %08x>\n", mh, vm_slide, fde);
  -#endif
  -
  -  if (fde)
  -    __deregister_frame_info (fde + vm_slide);
  -}
  -#endif
  -
  -void
  -__darwin_gcc3_preregister_frame_info ()
  -{
  -#if USE_KEYMGR
  -  const _Tinfo_Node *info;
  -  _init_keymgr ();
  -  info = (_Tinfo_Node *)__keymgr_global[2];
  -  if (info != NULL)
  -    {
  -      if (info->major_version >= KEYMGR_API_MAJOR_GCC3)
  -     return;
  -      /* Otherwise, use our own add_image_hooks.  */
  -    }
  -#endif 
  -  _dyld_register_func_for_add_image (darwin_unwind_dyld_add_image_hook);
  -  _dyld_register_func_for_remove_image (darwin_unwind_dyld_remove_image_hook);
  -}
  -
  -#elif defined(CRT_END) /* ! CRT_BEGIN */
  -
  -/* This is now deprectated.  IT WILL BE GOING AWAY SOON!!  */
  -__private_extern__ long __gcc3_EH_FRAME_END__ = 0;
  -
  -#endif
  -
  -#else  /* ! DARWIN  */
  -/* APPLE LOCAL end C++ EH */
  -
  -#ifndef OBJECT_FORMAT_MACHO
  -
   #ifdef OBJECT_FORMAT_ELF
   
   /*  Declare a pointer to void function type.  */
  @@ -702,85 +540,3 @@
   #else /* ! CRT_BEGIN && ! CRT_END */
   #error "One of CRT_BEGIN or CRT_END must be defined."
   #endif
  -
  -#else  /* OBJECT_FORMAT_MACHO */
  -
  -/* Crt stuff for Mach-O (NeXT and Darwin).
  -
  -   The theory of this is that each dynamically-loadable module,
  -   including the main program itself, must have been positioned by
  -   dyld before any frame info can be registered.  So we set up the
  -   registration functions as dyld hooks, using a "preregistration"
  -   function that is called directly from the system crt1.o.  */
  -
  -#ifdef CRT_BEGIN
  -
  -/* Homemade decls substituting for getsect.h and dyld.h, so cross
  -   compilation works.  */
  -struct mach_header;
  -extern char *getsectdatafromheader (struct mach_header *, const char *,
  -                                 const char *, unsigned long *);
  -extern void _dyld_register_func_for_add_image
  -  (void (*) (struct mach_header *, unsigned long));
  -extern void _dyld_register_func_for_remove_image
  -  (void (*) (struct mach_header *, unsigned long));
  -
  -extern void __darwin_gcc3_preregister_frame_info (void);
  -
  -static void
  -unwind_dyld_add_image_hook (struct mach_header *mh,
  -                         unsigned long vm_slide)
  -{
  -  unsigned long sz;
  -  char *fde;
  -
  -  fde = getsectdatafromheader (mh, "__TEXT", "__eh_frame", &sz);
  -  if (fde)
  -    {
  -      struct object *ob = (struct object *) malloc (sizeof (struct object));
  -
  -      __register_frame_info (fde + vm_slide, ob);
  -    }
  -}
  -
  -static void
  -unwind_dyld_remove_image_hook (struct mach_header *mh,
  -                            unsigned long vm_slide)
  -{
  -  unsigned long sz;
  -  char *fde;
  -
  -  fde = getsectdatafromheader (mh, "__TEXT", "__eh_frame", &sz);
  -
  -  if (fde)
  -    __deregister_frame_info (fde + vm_slide);
  -}
  -
  -/* Call this routine from the system crt1.o.  The call is standard in
  -   Darwin 6.x (Mac OS X 10.2) and later; for earlier systems, you
  -   would need to modify crt.c in the Csu project.  (This isn't great,
  -   but other alternatives run afoul of linker semantics.  This
  -   function is declared as common and tested before being called, so
  -   that programs compiled by older GCCs still link and run.)  */
  -
  -void
  -__darwin_gcc3_preregister_frame_info ()
  -{
  -  _dyld_register_func_for_add_image (unwind_dyld_add_image_hook);
  -  _dyld_register_func_for_remove_image (unwind_dyld_remove_image_hook);
  -}
  -
  -#elif defined(CRT_END) /* ! CRT_BEGIN */
  -
  -/* Install a single zero word at the end of the __eh_frame section.  */
  -
  -asm (".section __TEXT,__eh_frame");
  -asm (".long 0");
  -
  -#else /* ! CRT_BEGIN && ! CRT_END */
  -#error "One of CRT_BEGIN or CRT_END must be defined."
  -#endif
  -
  -#endif  /* OBJECT_FORMAT_MACHO  */
  -/* APPLE LOCAL C++ EH */
  -#endif /* DARWIN */
  
  
  
  1.51      +10 -16    src/live/gcc3/gcc/dwarf2out.c
  
  Index: dwarf2out.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/dwarf2out.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- dwarf2out.c       2002/10/24 23:42:54     1.50
  +++ dwarf2out.c       2002/11/07 20:33:19     1.51
  @@ -203,7 +203,7 @@
     const char *dw_fde_end;
     dw_cfi_ref dw_fde_cfi;
     unsigned funcdef_number;
  -  /* APPLE LOCAL begin C++ EH  */
  +  /* APPLE LOCAL begin coalescing  */
   #ifdef COALESCED_UNWIND_INFO
     const char *dw_real_name;
     /* Is this symbol coalesced?  */
  @@ -213,7 +213,7 @@
     unsigned public : 1;
     unsigned private_extern : 1;
   #endif
  -  /* APPLE LOCAL end C++ EH  */
  +  /* APPLE LOCAL end coalescing  */
     unsigned all_throwers_are_sibcalls : 1;
     unsigned nothrow : 1;
     unsigned uses_eh_lsda : 1;
  @@ -1937,13 +1937,13 @@
     else
       named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG);
   
  -  /* APPLE LOCAL begin C++ EH  */
  +  /* APPLE LOCAL begin coalescing  */
   #ifdef COALESCED_UNWIND_INFO
     /* We could probably mark the CIE as coalesced as well, since they're
        all the same (or are they?!)  */
     ASM_OUTPUT_LABEL (asm_out_file, "EH_unwind_info");
   #endif
  -  /* APPLE LOCAL end C++ EH  */
  +  /* APPLE LOCAL end coalescing  */
   
     ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh);
     ASM_OUTPUT_LABEL (asm_out_file, section_start_label);
  @@ -2043,16 +2043,10 @@
         dw2_asm_output_data_uleb128 (augmentation_size, "Augmentation size");
         if (eh_personality_libfunc)
        {
  -       /* APPLE LOCAL begin C++ EH  turly 20020327  */
  -#ifdef DW2_ENCODE_PERSONALITY_FUNC
  -       DW2_ENCODE_PERSONALITY_FUNC (eh_personality_libfunc);
  -#else
          dw2_asm_output_data (1, per_encoding, "Personality (%s)",
                               eh_data_format_name (per_encoding));
          dw2_asm_output_encoded_addr_rtx (per_encoding,
                                           eh_personality_libfunc, NULL);
  -#endif
  -       /* APPLE LOCAL end C++ EH  turly 20020327  */
        }
   
         if (any_lsda_needed)
  @@ -2083,7 +2077,7 @@
          && !fde->uses_eh_lsda)
        continue;
   
  -      /* APPLE LOCAL begin C++ EH  */
  +      /* APPLE LOCAL begin coalescing  */
   #ifdef COALESCED_UNWIND_INFO
         ASM_OUTPUT_COAL_UNWIND_LABEL (asm_out_file, fde->dw_real_name,
                                    fde->coalesced, 
  @@ -2093,7 +2087,7 @@
                                      || fde->private_extern
                                      || fde->explicit);
   #endif
  -      /* APPLE LOCAL end C++ EH  */
  +      /* APPLE LOCAL end coalescing  */
   
         ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, FDE_LABEL, for_eh + i * 2);
         ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + i * 2);
  @@ -2110,7 +2104,7 @@
   
         if (for_eh)
        {
  -       /* APPLE LOCAL begin C++ EH  */
  +       /* APPLE LOCAL begin coalescing  */
   #ifdef COALESCED_UNWIND_INFO
          if (fde->coalesced)
            dw2_asm_output_encoded_addr_rtx (fde_encoding,
  @@ -2118,7 +2112,7 @@
                   "FDE initial location");
          else
   #endif
  -       /* APPLE LOCAL end C++ EH  */
  +       /* APPLE LOCAL end coalescing  */
          dw2_asm_output_encoded_addr_rtx (fde_encoding,
                   gen_rtx_SYMBOL_REF (Pmode, fde->dw_fde_begin),
                   "FDE initial location");
  @@ -2263,7 +2257,7 @@
     fde->uses_eh_lsda = cfun->uses_eh_lsda;
     fde->all_throwers_are_sibcalls = cfun->all_throwers_are_sibcalls;
   
  -  /* APPLE LOCAL begin C++ EH  */
  +  /* APPLE LOCAL begin coalescing  */
   #ifdef COALESCED_UNWIND_INFO
     fde->coalesced = DECL_COALESCED (current_function_decl);
     /* Sorry about this hackery: this is the only way I can figure out
  @@ -2277,7 +2271,7 @@
     fde->public = TREE_PUBLIC(current_function_decl);
     fde->private_extern = DECL_PRIVATE_EXTERN(current_function_decl);
   #endif
  -  /* APPLE LOCAL end C++ EH  */
  +  /* APPLE LOCAL end coalescing  */
   
     args_size = old_args_size = 0;
   
  
  
  
  1.2       +13 -7     src/live/gcc3/gcc/unwind-dw2-fde-glibc.c
  
  Index: unwind-dw2-fde-glibc.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/unwind-dw2-fde-glibc.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- unwind-dw2-fde-glibc.c    2001/12/29 19:37:08     1.1
  +++ unwind-dw2-fde-glibc.c    2002/11/07 20:33:20     1.2
  @@ -1,4 +1,4 @@
  -/* Copyright (C) 2001 Free Software Foundation, Inc.
  +/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
      Contributed by Jakub Jelinek <[EMAIL PROTECTED]>.
   
      This file is part of GNU CC.
  @@ -29,11 +29,17 @@
      segment and dl_iterate_phdr to avoid register/deregister calls at
      DSO load/unload.  */
   
  +#ifndef _GNU_SOURCE
  +#define _GNU_SOURCE 1
  +#endif
  +
   #include "auto-host.h" /* For HAVE_LD_EH_FRAME_HDR.  */
   #include "tconfig.h"
  +#ifndef inhibit_libc
   #include <stddef.h>
   #include <stdlib.h>
   #include <link.h>
  +#endif
   #include "tsystem.h"
   #include "dwarf2.h"
   #include "unwind.h"
  @@ -42,7 +48,7 @@
   #include "unwind-dw2-fde.h"
   #include "gthr.h"
   
  -#if defined(HAVE_LD_EH_FRAME_HDR) \
  +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
       && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
        || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
   
  @@ -73,9 +79,9 @@
     unsigned char table_enc;
   };
   
  -/* Like base_of_encoded_value, but take the base from a struct object
  -   instead of an _Unwind_Context.  */
  -   
  +/* Like base_of_encoded_value, but take the base from a struct
  +   unw_eh_callback_data instead of an _Unwind_Context.  */
  +
   static _Unwind_Ptr
   base_from_cb_data (unsigned char encoding, struct unw_eh_callback_data *data)
   {
  @@ -88,7 +94,7 @@
       case DW_EH_PE_pcrel:
       case DW_EH_PE_aligned:
         return 0;
  -                                 
  +
       case DW_EH_PE_textrel:
         return (_Unwind_Ptr) data->tbase;
       case DW_EH_PE_datarel:
  @@ -151,7 +157,7 @@
       {
         /* For dynamicly linked executables and shared libraries,
         DT_PLTGOT is the gp value for that object.  */
  -      ElfW(Dyn) *dyn = (ElfW(Dyn) *)(p_dynamic->p_vaddr + load_base);
  +      ElfW(Dyn) *dyn = (ElfW(Dyn) *) (p_dynamic->p_vaddr + load_base);
         for (; dyn->d_tag != DT_NULL ; dyn++)
        if (dyn->d_tag == DT_PLTGOT)
          {
  
  
  
  1.31      +10 -246   src/live/gcc3/gcc/unwind-dw2-fde.c
  
  Index: unwind-dw2-fde.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/unwind-dw2-fde.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- unwind-dw2-fde.c  2002/09/10 20:53:31     1.30
  +++ unwind-dw2-fde.c  2002/11/07 20:33:20     1.31
  @@ -1,5 +1,5 @@
   /* Subroutines needed for unwinding stack frames for exception handling.  */
  -/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
  +/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
      Contributed by Jason Merrill <[EMAIL PROTECTED]>.
   
   This file is part of GCC.
  @@ -38,203 +38,7 @@
   #include "unwind-dw2-fde.h"
   #include "gthr.h"
   #endif
  -/* APPLE LOCAL declare string functions */
  -#include <string.h>
   
  -/* APPLE LOCAL begin fde end extension */
  -#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
  -static inline int VALID_FDE_P(struct object *OB, struct dwarf_fde *FDE)
  -{
  -  if ((char *)FDE < OB->dwarf_fde_end) 
  -    {
  -      if (FDE->length <= 0)
  -     {
  -       printf ("####\n#### FDE %p (OB %p, fde_end %p) has zero length!"
  -               "Aborting.\n####\n", FDE, OB, OB->dwarf_fde_end);
  -       abort();
  -     }
  -      else
  -     return 1;
  -    }
  -  return 0;
  -}
  -#else
  -#define VALID_FDE_P(OB, FDE) ((FDE)->length != 0)
  -#endif
  -/* APPLE LOCAL end fde end extension */
  -
  -#define Dprintf if (0) printf
  -
  -/* APPLE LOCAL begin EH runtime  turly 20020208  */
  -#ifdef __APPLE__
  -
  -#undef __GTHREAD_MUTEX_INIT
  -#undef __GTHREAD_MUTEX_INIT_FUNCTION
  -
  -/* KeyMgr stuff  */
  -#define KEYMGR_GCC3_LIVE_IMAGE_LIST     301     /* loaded images  */
  -#define KEYMGR_GCC3_DW2_OBJ_LIST        302     /* Dwarf2 object list  */
  -
  -extern void *_keymgr_get_and_lock_processwide_ptr (int);
  -extern void _keymgr_set_and_unlock_processwide_ptr (int, void *);
  -extern void _keymgr_unlock_processwide_ptr (int); 
  -
  -extern char *getsectdatafromheader (struct mach_header*, const char*,
  -                     const char *, unsigned long *);
  -
  -static struct km_object_info {
  -  struct object *seen_objects;
  -  struct object *unseen_objects;
  -  unsigned spare[2];
  -} *the_obj_info = 0;
  -
  -/* Bits in the examined_p field of struct __live_images.  */
  -enum {
  -  EXAMINED_IMAGE_MASK = 1,   /* We've seen this one.  */
  -  ALLOCED_IMAGE_MASK = 2,    /* We had to alloc a duplicate FDE  */
  -                             /* (there was a missing NULL terminator!)  */
  -  IMAGE_IS_TEXT_MASK = 4     /* This image is in the TEXT segment.  */
  -};
  -
  -/* Now just redefine the SEEN_OBJECTS and UNSEEN_OBJECTS vars to be
  -   accessed via "the_obj_info".  */
  -#define seen_objects  the_obj_info->seen_objects
  -#define unseen_objects the_obj_info->unseen_objects
  -
  -/* IMAGE has already been removed from the KEYMGR_GCC3_LIVE_IMAGE_LIST.
  -   Called by KeyMgr (which will delete the struct after we return.)  */
  -
  -static void live_image_destructor (struct __live_images *image)
  -{
  -  if (image->object_info)
  -    {
  -      /* Free any sorted arrays.  */
  -      __deregister_frame_info_bases (image->fde);
  -
  -      free (image->object_info);
  -      image->object_info = NULL;
  -      if (image->examined_p & ALLOCED_IMAGE_MASK)
  -     free (image->fde);
  -    }
  -}
  -
  -/* This is called just before the call to __gthread_mutex_lock () every time
  -   we want to lock access to the "seen" and "unseen" variables.
  -   We scan the live image list and use it to populate these vars.  */
  - 
  -static void init_object_mutex_once (void)  
  -{
  -  struct __live_images *image;
  -  the_obj_info = (struct km_object_info *)
  -         _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST);
  -  if (! the_obj_info)
  -    {
  -#ifndef DWARF2_OBJECT_END_PTR_EXTENSION
  -      extern int __gcc3_EH_FRAME_END__[];
  -      /* Refer to this to force it to be brought in.  */
  -      if (__gcc3_EH_FRAME_END__[0] != 0)
  -     abort ();
  -#endif
  -      the_obj_info = (struct km_object_info *)
  -                             calloc (1, sizeof (*the_obj_info));
  -    }
  -  image = (struct __live_images *)
  -         _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  -
  -  while (image != NULL)
  -    {
  -      /* For future expansion (read: bug-fix patches :-), we only use
  -      the lowest bit to hold the EXAMINED status.  */
  -
  -      if (! (image->examined_p & EXAMINED_IMAGE_MASK))
  -     {
  -       char *fde;
  -       unsigned long sz;
  -
  -       image->examined_p |= EXAMINED_IMAGE_MASK;
  -
  -       fde = getsectdatafromheader (image->mh, "__DATA", "__eh_frame", &sz);
  -       if (fde == NULL)
  -         {
  -           fde = getsectdatafromheader (image->mh, "__TEXT",
  -                                        "__eh_frame", &sz);
  -           if (fde != NULL)
  -             image->examined_p |= IMAGE_IS_TEXT_MASK;
  -         }
  -
  -       /* If .eh_frame is empty, don't register at all.  */
  -       if (fde != NULL && sz > 0
  -#ifndef DWARF2_OBJECT_END_PTR_EXTENSION
  -             && *(uword *)(fde + image->vm_slide) != 0
  -#endif
  -          )
  -         {
  -           void *real_fde = (fde + image->vm_slide);
  -           struct object *ob = (struct object *)
  -                                     calloc (1, sizeof (struct object));
  -  
  -#ifndef DWARF2_OBJECT_END_PTR_EXTENSION
  -           if (*(uword *) ((char *)real_fde + sz - sizeof (uword)) != 0)
  -             {
  -               char *new_fde;
  -
  -               /* For now, just malloc an extra 4 bytes and stuff in
  -                  the zero terminator.  This "should never happen" so it's
  -                  probably OK to do this.  */
  -               Dprintf ("\n#### missing NULL FDE terminator for FDE %p. "
  -                       "Reallocating, copying, and adding one.\n",
  -                       real_fde);
  -               new_fde = (char *)malloc (sz + sizeof (uword));
  -               memcpy (new_fde, real_fde, sz);
  -               *(uword *)(new_fde + sz) = 0;
  -               real_fde = new_fde;
  -               image->examined_p |= ALLOCED_IMAGE_MASK;
  -             }
  -#else
  -          ob->dwarf_fde_end = real_fde + sz;
  -#endif
  -           /* Inline a call to __register_frame_info_bases () below.
  -              (We can't call it unless we relinquish the lock.  */
  -
  -           ob->pc_begin = (void *)-1;
  -           ob->tbase = 0;
  -           ob->dbase = 0;
  -           ob->u.single = real_fde;
  -           ob->s.i = 0;
  -           ob->s.b.encoding = DW_EH_PE_omit;
  -  
  -           ob->next = unseen_objects;
  -           unseen_objects = ob;
  -
  -           Dprintf ("Adding image %p (slide %lx) FDE %p, ob %p\n",
  -                     image->mh, image->vm_slide, real_fde, ob);
  -
  -           image->destructor = live_image_destructor;
  -           image->fde = real_fde;
  -           image->object_info = ob;
  -         }
  -     }
  -      image = image->next;
  -    }
  -  _keymgr_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  -}
  -
  -#undef __gthread_mutex_lock
  -#undef __gthread_mutex_unlock
  -
  -#define __gthread_mutex_lock(X)              /* nothing  */
  -#define __gthread_mutex_unlock(X)    keymgr_unlocker ()
  -static void keymgr_unlocker (void)
  -{  
  -  if (!the_obj_info) abort ();
  -  Dprintf ("## the_obj_info %p (seen: %p, unseen: %p)\n",
  -             the_obj_info, seen_objects, unseen_objects);
  -
  -  _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST,
  -                                                     the_obj_info);
  -}
  -
  -#else        /* ! __APPLE__  */
   /* The unseen_objects list contains objects that have been registered
      but not yet categorized in any way.  The seen_objects list has had
      it's pc_begin and count fields initialized at minimum, and is sorted
  @@ -264,8 +68,6 @@
   #else
   #define init_object_mutex_once()
   #endif
  -/* APPLE LOCAL end EH runtime  turly 20020208  */
  -#endif  /* __APPLE__  */
   
   /* Called from crtbegin.o to register the unwind info for an object.  */
   
  @@ -283,6 +85,9 @@
     ob->u.single = begin;
     ob->s.i = 0;
     ob->s.b.encoding = DW_EH_PE_omit;
  +#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
  +  ob->fde_end = NULL;
  +#endif
   
     init_object_mutex_once ();
     __gthread_mutex_lock (&object_mutex);
  @@ -380,7 +185,6 @@
         {
        ob = *p;
        *p = ob->next;
  -     Dprintf ("## deregister: FDE %p was on unseen\n", begin);
        goto out;
         }
   
  @@ -390,7 +194,6 @@
        if ((*p)->u.sort->orig_data == begin)
          {
            ob = *p;
  -         Dprintf ("## deregister: FDE %p was on seen (sorted)\n", begin);
            *p = ob->next;
            free (ob->u.sort);
            goto out;
  @@ -400,14 +203,12 @@
         {
        if ((*p)->u.single == begin)
          {
  -         Dprintf ("## deregister: FDE %p was on seen (unsorted)\n", begin);
            ob = *p;
            *p = ob->next;
            goto out;
          }
         }
   
  -  Dprintf ("## deregister: FDE %p was not in seen_objects - abort!\n", begin);
     __gthread_mutex_unlock (&object_mutex);
     abort ();
   
  @@ -466,7 +267,6 @@
     _Unwind_Word utmp;
     _Unwind_Sword stmp;
   
  -  Dprintf("get cie encoding for %p\n", cie);
     aug = cie->augmentation;
     if (aug[0] != 'z')
       return DW_EH_PE_absptr;
  @@ -805,17 +605,11 @@
     int encoding = DW_EH_PE_absptr;
     _Unwind_Ptr base = 0;
   
  -  Dprintf("classify object %p fde %p\n", ob, this_fde);
  -  /* APPLE LOCAL EH VALID_FDE_P  */
  -  for (; VALID_FDE_P (ob, this_fde); this_fde = next_fde (this_fde))
  +  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
       {
         struct dwarf_cie *this_cie;
         _Unwind_Ptr mask, pc_begin;
   
  -      Dprintf ("this_fde now %p, CIE delta %x\n", this_fde, this_fde->CIE_delta);
  -      Dprintf ("next_fde is %p, length %d\n",
  -           next_fde (this_fde), next_fde (this_fde)->length);
  -
         /* Skip CIEs.  */
         if (this_fde->CIE_delta == 0)
        continue;
  @@ -823,14 +617,11 @@
         /* Determine the encoding for this FDE.  Note mixed encoded
         objects for later.  */
         this_cie = get_cie (this_fde);
  -      Dprintf ("this_cie now %p\n", this_cie);
         if (this_cie != last_cie)
        {
  -       Dprintf("not the last cie (%p)\n", last_cie);
          last_cie = this_cie;
          encoding = get_cie_encoding (this_cie);
          base = base_from_object (encoding, ob);
  -       Dprintf("encoding is %d, base is %x\n", encoding, base);
          if (ob->s.b.encoding == DW_EH_PE_omit)
            ob->s.b.encoding = encoding;
          else if (ob->s.b.encoding != encoding)
  @@ -839,7 +630,7 @@
   
         read_encoded_value_with_base (encoding, base, this_fde->pc_begin,
                                    &pc_begin);
  -      Dprintf("pc_begin is %x\n", pc_begin);
  +
         /* Take care to ignore link-once functions that were removed.
         In these cases, the function address will be NULL, but if
         the encoding is smaller than a pointer a true NULL may not
  @@ -858,7 +649,6 @@
        ob->pc_begin = (void *) pc_begin;
       }
   
  -  Dprintf("  return %d\n", (unsigned int)count);
     return count;
   }
   
  @@ -869,15 +659,10 @@
     int encoding = ob->s.b.encoding;
     _Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
   
  -  Dprintf("add this_fde %p, ob %p, accu %p\n", this_fde, ob, accu);
  -  /* APPLE LOCAL EH VALID_FDE_P  */
  -  for (; VALID_FDE_P (ob, this_fde); this_fde = next_fde (this_fde))
  +  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
       {
         struct dwarf_cie *this_cie;
   
  -      Dprintf ("next_fde is %p, length %d\n",
  -           next_fde (this_fde), next_fde (this_fde)->length);
  -
         /* Skip CIEs.  */
         if (this_fde->CIE_delta == 0)
        continue;
  @@ -937,13 +722,11 @@
     size_t count;
   
     count = ob->s.b.count;
  -  Dprintf("init object %p, count %d, u.array %p\n", ob, (unsigned int)count, 
ob->u.array);
     if (count == 0)
       {
         if (ob->s.b.from_array)
        {
          fde **p = ob->u.array;
  -       Dprintf ("doing array\n");
          for (count = 0; *p; ++p)
            count += classify_object_over_fdes (ob, *p);
        }
  @@ -962,7 +745,7 @@
   
     if (!start_fde_sort (&accu, count))
       return;
  -  Dprintf("fde sort started OK\n");
  +
     if (ob->s.b.from_array)
       {
         fde **p;
  @@ -973,7 +756,6 @@
       add_fdes (ob, &accu, ob->u.single);
   
     end_fde_sort (ob, &accu, count);
  -  Dprintf("fde sort ended OK\n");
   
     /* Save the original fde pointer, since this is the key by which the
        DSO will deregister the object.  */
  @@ -981,7 +763,6 @@
     ob->u.sort = accu.linear;
   
     ob->s.b.sorted = 1;
  -  Dprintf("init_object done\n");
   }
   
   /* A linear search through a set of FDEs for the given PC.  This is
  @@ -995,15 +776,11 @@
     int encoding = ob->s.b.encoding;
     _Unwind_Ptr base = base_from_object (ob->s.b.encoding, ob);
   
  -  /* APPLE LOCAL EH VALID_FDE_P  */
  -  for (; VALID_FDE_P (ob, this_fde); this_fde = next_fde (this_fde))
  +  for (; ! last_fde (ob, this_fde); this_fde = next_fde (this_fde))
       {
         struct dwarf_cie *this_cie;
         _Unwind_Ptr pc_begin, pc_range;
   
  -      Dprintf ("next_fde is %p, length %d\n",
  -           next_fde (this_fde), next_fde (this_fde)->length);
  -
         /* Skip CIEs.  */
         if (this_fde->CIE_delta == 0)
        continue;
  @@ -1066,8 +843,7 @@
   {
     struct fde_vector *vec = ob->u.sort;
     size_t lo, hi;
  -      
  -  Dprintf ("binary search unenc obj %p pc_begin %p, pc=%p, %d count\n", ob, 
ob->pc_begin, pc, (unsigned int)vec->count);
  +
     for (lo = 0, hi = vec->count; lo < hi; )
       {
         size_t i = (lo + hi) / 2;
  @@ -1078,7 +854,6 @@
         pc_begin = ((void **) f->pc_begin)[0];
         pc_range = ((uaddr *) f->pc_begin)[1];
   
  -      Dprintf("testing range %p + %x\n", pc_begin, pc_range);
         if (pc < pc_begin)
        hi = i;
         else if (pc >= pc_begin + pc_range)
  @@ -1097,8 +872,6 @@
     int encoding = ob->s.b.encoding;
     _Unwind_Ptr base = base_from_object (encoding, ob);
     size_t lo, hi;
  -      
  -  Dprintf ("binary search single enc obj %p pc_begin %p, pc=%p\n", ob, 
ob->pc_begin, pc);
   
     for (lo = 0, hi = vec->count; lo < hi; )
       {
  @@ -1111,7 +884,6 @@
                                        &pc_begin);
         read_encoded_value_with_base (encoding & 0x0F, 0, p, &pc_range);
   
  -      Dprintf("testing range %x + %x\n", pc_begin, pc_range);
         if ((_Unwind_Ptr) pc < pc_begin)
        hi = i;
         else if ((_Unwind_Ptr) pc >= pc_begin + pc_range)
  @@ -1129,8 +901,6 @@
     struct fde_vector *vec = ob->u.sort;
     size_t lo, hi;
   
  -  Dprintf ("binary search mixed end obj %p pc_begin %p, pc=%p\n", ob, ob->pc_begin, 
pc);
  -
     for (lo = 0, hi = vec->count; lo < hi; )
       {
         size_t i = (lo + hi) / 2;
  @@ -1159,7 +929,6 @@
   static fde *
   search_object (struct object* ob, void *pc)
   {
  -  Dprintf ("searching obj %p pc_begin %p, pc=%p\n", ob, ob->pc_begin, pc);
     /* If the data hasn't been sorted, try to do this now.  We may have
        more memory available than last time we tried.  */
     if (! ob->s.b.sorted)
  @@ -1210,9 +979,6 @@
     init_object_mutex_once ();
     __gthread_mutex_lock (&object_mutex);
   
  -  Dprintf("in _Unwind_Find_FDE pc %p\n", pc);
  -  Dprintf("seen_objects %p, unseen_objects %p\n", seen_objects, unseen_objects);
  -
     /* Linear search through the classified objects, to find the one
        containing the pc.  Note that pc_begin is sorted descending, and
        we expect objects to be non-overlapping.  */
  @@ -1220,7 +986,6 @@
       if (pc >= ob->pc_begin)
         {
        f = search_object (ob, pc);
  -     Dprintf("a. seen_objects %p, ob %p, f %p\n", seen_objects, ob, f);
        if (f)
          goto fini;
        break;
  @@ -1233,7 +998,6 @@
   
         unseen_objects = ob->next;
         f = search_object (ob, pc);
  -      Dprintf("b. seen_objects %p, ob %p, f %p\n", seen_objects, ob, f);
   
         /* Insert the object into the classified list.  */
         for (p = &seen_objects; *p ; p = &(*p)->next)
  
  
  
  1.7       +11 -1     src/live/gcc3/gcc/unwind-dw2-fde.h
  
  Index: unwind-dw2-fde.h
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/unwind-dw2-fde.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- unwind-dw2-fde.h  2002/08/02 10:05:36     1.6
  +++ unwind-dw2-fde.h  2002/11/07 20:33:20     1.7
  @@ -62,7 +62,7 @@
     } s;
   
   #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
  -  char *dwarf_fde_end;
  +  char *fde_end;
   #endif
   
     struct object *next;
  @@ -164,3 +164,13 @@
   }
   
   extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
  +
  +static inline int
  +last_fde (struct object *obj, fde *f)
  +{
  +#ifdef DWARF2_OBJECT_END_PTR_EXTENSION
  +  return (char *)f == obj->fde_end || f->length == 0;
  +#else
  +  return f->length == 0;
  +#endif
  +}
  
  
  
  1.19      +0 -39     src/live/gcc3/gcc/unwind-dw2.c
  
  Index: unwind-dw2.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/unwind-dw2.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- unwind-dw2.c      2002/08/02 10:05:36     1.18
  +++ unwind-dw2.c      2002/11/07 20:33:20     1.19
  @@ -26,10 +26,7 @@
   #include "unwind-pe.h"
   #include "unwind-dw2-fde.h"
   #include "gthr.h"
  -/* APPLE LOCAL FSF candidate */
  -#include <string.h>
   
  -#define Dprintf if (0) printf
   
   #ifndef __USING_SJLJ_EXCEPTIONS__
   
  @@ -174,8 +171,6 @@
   inline void
   _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
   {
  -  Dprintf("in _Unwind_SetGR context %p index %d val %d\n", context, index, val);
  -  Dprintf("  reg addr is %p\n", (_Unwind_Word *) context->reg[index]);
     * (_Unwind_Word *) context->reg[index] = val;
   }
   
  @@ -282,13 +277,6 @@
         /* "P" indicates a personality routine in the CIE augmentation.  */
         else if (aug[0] == 'P')
        {
  -       /* APPLE LOCAL begin C++ EH  turly 20020327  */
  -#ifdef DW2_PERSONALITY_FUNC_ENCODED_P
  -       if (DW2_PERSONALITY_FUNC_ENCODED_P (p))
  -         DW2_DECODE_PERSONALITY_FUNC (p, fs->personality);
  -       else
  -#endif
  -       /* APPLE LOCAL end C++ EH  turly 20020327  */
          p = read_encoded_value (context, *p, p + 1,
                                  (_Unwind_Ptr *) &fs->personality);
          aug += 1;
  @@ -742,8 +730,6 @@
          offset = (_Unwind_Sword) utmp * fs->data_align;
          fs->regs.reg[reg].how = REG_SAVED_OFFSET;
          fs->regs.reg[reg].loc.offset = offset;
  -       Dprintf("execute_cfa_program reg %d REG_SAVED_OFFSET offset %d\n",
  -              reg, offset);
        }
         else if ((insn & 0xc0) == DW_CFA_restore)
        {
  @@ -776,8 +762,6 @@
          offset = (_Unwind_Sword) utmp * fs->data_align;
          fs->regs.reg[reg].how = REG_SAVED_OFFSET;
          fs->regs.reg[reg].loc.offset = offset;
  -       Dprintf("execute_cfa_program reg %d REG_SAVED_OFFSET offset %d\n",
  -              reg, offset);
          break;
   
        case DW_CFA_restore_extended:
  @@ -865,8 +849,6 @@
          offset = stmp * fs->data_align;
          fs->regs.reg[reg].how = REG_SAVED_OFFSET;
          fs->regs.reg[reg].loc.offset = offset;
  -       Dprintf("execute_cfa_program reg %d REG_SAVED_OFFSET offset %d\n",
  -              reg, offset);
          break;
   
        case DW_CFA_def_cfa_sf:
  @@ -901,8 +883,6 @@
          offset = (_Unwind_Word) utmp * fs->data_align;
          fs->regs.reg[reg].how = REG_SAVED_OFFSET;
          fs->regs.reg[reg].loc.offset = -offset;
  -       Dprintf("execute_cfa_program reg %d REG_SAVED_OFFSET offset %d\n",
  -              reg, fs->regs.reg[reg].loc.offset);
          break;
   
        default:
  @@ -923,13 +903,11 @@
     struct dwarf_cie *cie;
     const unsigned char *aug, *insn, *end;
   
  -  Dprintf("in uw_frame_state_for\n");
     memset (fs, 0, sizeof (*fs));
     context->args_size = 0;
     context->lsda = 0;
   
     fde = _Unwind_Find_FDE (context->ra - 1, &context->bases);
  -  Dprintf("found fde = %p\n", fde);
     if (fde == NULL)
       {
         /* Couldn't find frame unwind info for this function.  Try a
  @@ -947,17 +925,12 @@
   
     fs->pc = context->bases.func;
   
  -  Dprintf("to get cie\n");
  -
  -
     cie = get_cie (fde);
     insn = extract_cie_info (cie, context, fs);
     if (insn == NULL)
       /* CIE contained unknown augmentation.  */
       return _URC_FATAL_PHASE1_ERROR;
   
  -  Dprintf("got cie\n");
  -
     /* First decode all the insns in the CIE.  */
     end = (unsigned char *) next_fde ((struct dwarf_fde *) cie);
     execute_cfa_program (insn, end, context, fs);
  @@ -1054,7 +1027,6 @@
     void *cfa;
     long i;
   
  -  Dprintf("uw_update_context_1 context %p\n", context);
     /* Compute this frame's CFA.  */
     switch (fs->cfa_how)
       {
  @@ -1099,11 +1071,9 @@
        break;
         case REG_SAVED_OFFSET:
        context->reg[i] = cfa + fs->regs.reg[i].loc.offset;
  -     Dprintf("REG_SAVED_OFFSET context %p reg %ld is at %p\n", context, i, 
context->reg[i]);
        break;
         case REG_SAVED_REG:
        context->reg[i] = orig_context.reg[fs->regs.reg[i].loc.reg];
  -     Dprintf("REG_SAVED_REG context %p reg %ld is at %p\n", context, i, 
context->reg[i]);
        break;
         case REG_SAVED_EXP:
        {
  @@ -1115,7 +1085,6 @@
          val = execute_stack_op (exp, exp + len, &orig_context,
                                  (_Unwind_Ptr) cfa);
          context->reg[i] = (void *) val;
  -       Dprintf("REG_SAVED_EXP context %p reg %ld is at %p\n", context, i, 
context->reg[i]);
        }
        break;
         }
  @@ -1158,16 +1127,12 @@
     void *ra = __builtin_extract_return_addr (__builtin_return_address (0));
     _Unwind_FrameState fs;
   
  -  Dprintf("begin uw_init_context_1 %p\n", context);
  -
     memset (context, 0, sizeof (struct _Unwind_Context));
     context->ra = ra;
   
     if (uw_frame_state_for (context, &fs) != _URC_NO_REASON)
       abort ();
   
  -  Dprintf("middle uw_init_context_1 %p\n", context);
  -
     /* Force the frame state to use the known cfa value.  */
     context->cfa = outer_cfa;
     fs.cfa_how = CFA_REG_OFFSET;
  @@ -1220,14 +1185,10 @@
       init_dwarf_reg_size_table ();
   #endif
   
  -  Dprintf("in uw_install_context_1\n");
     for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
       {
         void *c = current->reg[i];
         void *t = target->reg[i];
  -      if (t && c && t != c)
  -     Dprintf("Installing reg %ld, %x over %x\n",
  -             i, *((int *)t), *((int *)c));
         if (t && c && t != c)
        memcpy (c, t, dwarf_reg_size_table[i]);
       }
  
  
  
  1.12      +2 -21     src/live/gcc3/gcc/unwind.inc
  
  Index: unwind.inc
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/unwind.inc,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- unwind.inc        2002/08/02 10:05:37     1.11
  +++ unwind.inc        2002/11/07 20:33:20     1.12
  @@ -35,7 +35,6 @@
   {
     _Unwind_Reason_Code code;
   
  -  Dprintf("in _Unwind_RaiseException_Phase2\n");
     while (1)
       {
         _Unwind_FrameState fs;
  @@ -43,25 +42,20 @@
   
         code = uw_frame_state_for (context, &fs);
   
  -      Dprintf("got frame state in _Unwind_RaiseException_Phase2\n");
         /* Identify when we've reached the designated handler context.  */
         match_handler = (uw_identify_context (context) == exc->private_2
                       ? _UA_HANDLER_FRAME : 0);
   
         if (code != _URC_NO_REASON)
  -     {
  -       Dprintf("some error encountered\n");
        /* Some error encountered.  Usually the unwinder doesn't
           diagnose these and merely crashes.  */
        return _URC_FATAL_PHASE2_ERROR;
  -     }
  -      Dprintf("about to run personality %p, context %p\n", (void *)fs.personality, 
context);
  +
         /* Unwind successful.  Run the personality routine, if any.  */
         if (fs.personality)
        {
          code = (*fs.personality) (1, _UA_CLEANUP_PHASE | match_handler,
                                    exc->exception_class, exc, context);
  -       Dprintf("personality returns %d (m_h is %d)\n", code, match_handler);
          if (code == _URC_INSTALL_CONTEXT)
            break;
          if (code != _URC_CONTINUE_UNWIND) 
  @@ -86,14 +80,10 @@
     struct _Unwind_Context this_context, cur_context;
     _Unwind_Reason_Code code;
   
  -  Dprintf("begin unwind exc %p\n", exc);
     /* Set up this_context to describe the current stack frame.  */
     uw_init_context (&this_context);
  -  Dprintf("in _Unwind_RaiseException begin, set context %p from %p\n",
  -      &cur_context, &this_context);
     cur_context = this_context;
   
  -  Dprintf("begin search, exc %p\n", exc);
     /* Phase 1: Search.  Unwind the stack, calling the personality routine
        with the _UA_SEARCH_PHASE flag set.  Do not modify the stack yet.  */
     while (1)
  @@ -104,7 +94,6 @@
         first time through the loop, that means __cxa_throw.  */
         code = uw_frame_state_for (&cur_context, &fs);
   
  -      Dprintf("got a frame state\n");
         if (code == _URC_END_OF_STACK)
        /* Hit end of stack with no handler found.  */
        return _URC_END_OF_STACK;
  @@ -128,21 +117,17 @@
         /* Update cur_context to describe the same frame as fs.  */
         uw_update_context (&cur_context, &fs);
       }
  -  Dprintf("finished search\n");
  +
     /* Indicate to _Unwind_Resume and associated subroutines that this
        is not a forced unwind.  Further, note where we found a handler.  */
     exc->private_1 = 0;
     exc->private_2 = uw_identify_context (&cur_context);
   
  -  Dprintf("in _Unwind_RaiseException begin, set context %p from %p\n",
  -      &cur_context, &this_context);
     cur_context = this_context;
     code = _Unwind_RaiseException_Phase2 (exc, &cur_context);
     if (code != _URC_INSTALL_CONTEXT)
       return code;
   
  -  Dprintf("about to install context, this=%p, cur=%p\n",
  -      &this_context, &cur_context);
     uw_install_context (&this_context, &cur_context);
   }
   
  @@ -231,12 +216,8 @@
     struct _Unwind_Context this_context, cur_context;
     _Unwind_Reason_Code code;
   
  -  Dprintf("_Unwind_Resume begin exc %p\n", exc);
     uw_init_context (&this_context);
     cur_context = this_context;
  -
  -  Dprintf("_Unwind_Resume after init context exc %p cur_context %p\n",
  -      exc, &cur_context);
   
     /* Choose between continuing to process _Unwind_RaiseException
        or _Unwind_ForcedUnwind.  */
  
  
  
  1.1                  src/live/gcc3/gcc/unwind-dw2-fde-darwin.c
  
  Index: unwind-dw2-fde-darwin.c
  ===================================================================
  /* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  
     This file is part of GNU CC.
  
     GNU CC is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2, or (at your option)
     any later version.
  
     GNU CC is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
     along with GNU CC; see the file COPYING.  If not, write to
     the Free Software Foundation, 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.  */
  
  /* As a special exception, if you link this library with other files,
     some of which are compiled with GCC, to produce an executable,
     this library does not by itself cause the resulting executable
     to be covered by the GNU General Public License.
     This exception does not however invalidate any other reasons why
     the executable file might be covered by the GNU General Public License.  */
  
  /* Locate the FDE entry for a given address, using Darwin's keymgr support.  */
  
  #include "tconfig.h"
  #include <string.h>
  #include <stdlib.h>
  #include "dwarf2.h"
  #include "unwind.h"
  #define NO_BASE_OF_ENCODED_VALUE
  #define DWARF2_OBJECT_END_PTR_EXTENSION
  #include "unwind-pe.h"
  #include "unwind-dw2-fde.h"
  /* Carefully don't include gthr.h.  */
  
  typedef int __gthread_mutex_t;
  #define __gthread_mutex_lock(x)  (void)(x)
  #define __gthread_mutex_unlock(x) (void)(x)
  
  static fde * _Unwind_Find_registered_FDE (void *pc, 
                                          struct dwarf_eh_bases *bases);
  
  #define _Unwind_Find_FDE _Unwind_Find_registered_FDE
  #include "unwind-dw2-fde.c"
  #undef _Unwind_Find_FDE
  
  /* KeyMgr stuff.  */
  #define KEYMGR_GCC3_LIVE_IMAGE_LIST     301     /* loaded images  */
  #define KEYMGR_GCC3_DW2_OBJ_LIST        302     /* Dwarf2 object list  */
  
  extern void *_keymgr_get_and_lock_processwide_ptr (int);
  extern void _keymgr_set_and_unlock_processwide_ptr (int, void *);
  extern void _keymgr_unlock_processwide_ptr (int);
  
  struct mach_header;
  extern char *getsectdatafromheader (struct mach_header*, const char*,
                        const char *, unsigned long *);
  
  /* This is referenced from KEYMGR_GCC3_DW2_OBJ_LIST.  */
  struct km_object_info {
    struct object *seen_objects;
    struct object *unseen_objects;
    unsigned spare[2];
  };
  
  /* Node of KEYMGR_GCC3_LIVE_IMAGE_LIST.  Info about each resident image.  */
  struct live_images {
    unsigned long this_size;                      /* sizeof (live_images)  */
    struct mach_header *mh;                       /* the image info  */
    unsigned long vm_slide;
    void (*destructor)(struct live_images *);     /* destructor for this  */
    struct live_images *next;
    unsigned int examined_p;
    void *fde;
    void *object_info;
    unsigned long info[2];                        /* Future use.  */
  };
  
  /* Bits in the examined_p field of struct live_images.  */
  enum {
    EXAMINED_IMAGE_MASK = 1,    /* We've seen this one.  */
    ALLOCED_IMAGE_MASK = 2,     /* The FDE entries were allocated by
                                   malloc, and must be freed.  This isn't
                                   used by newer libgcc versions.  */
    IMAGE_IS_TEXT_MASK = 4      /* This image is in the TEXT segment.  */
  };
  
  /* Delete any data we allocated on a live_images structure.
     IMAGE has already been removed from the KEYMGR_GCC3_LIVE_IMAGE_LIST.
     Called by KeyMgr (which will delete the struct after we return.)  */
  
  static void 
  live_image_destructor (struct live_images *image)
  {
    if (image->object_info)
      {
        /* Free any sorted arrays.  */
        __deregister_frame_info_bases (image->fde);
  
        free (image->object_info);
        image->object_info = NULL;
        if (image->examined_p & ALLOCED_IMAGE_MASK)
        free (image->fde);
      }
  }
  
  /* Run through the list of live images.  If we can allocate memory,
     give each unseen image a new `struct object'.  Even if we can't,
     check whether the PC is inside the FDE of each unseen image.
   */
   
  static inline fde *
  examine_objects (void *pc, struct dwarf_eh_bases *bases, int dont_alloc)
  {
    fde *result = NULL;
    struct live_images *image;
  
    image = _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  
    for (; image != NULL; image = image->next)
      if ((image->examined_p & EXAMINED_IMAGE_MASK) == 0)
        {
        char *fde;
        unsigned long sz;
        
        fde = getsectdatafromheader (image->mh, "__DATA", "__eh_frame", &sz);
        if (fde == NULL)
          {
            fde = getsectdatafromheader (image->mh, "__TEXT",
                                         "__eh_frame", &sz);
            if (fde != NULL)
              image->examined_p |= IMAGE_IS_TEXT_MASK;
          }
        
        /* If .eh_frame is empty, don't register at all.  */
        if (fde != NULL && sz > 0)
          {
            char *real_fde = (fde + image->vm_slide);
            struct object *ob = NULL;
            struct object panicob;
            
            if (! dont_alloc)
              ob = calloc (1, sizeof (struct object));
            dont_alloc |= ob == NULL;
            if (dont_alloc)
              ob = &panicob;
            
            ob->pc_begin = (void *)-1;
            ob->tbase = 0;
            ob->dbase = 0;
            ob->u.single = (struct dwarf_fde *)real_fde;
            ob->s.i = 0;
            ob->s.b.encoding = DW_EH_PE_omit;
            ob->fde_end = real_fde + sz;
            
            if (! dont_alloc)
              {
                ob->next = unseen_objects;
                unseen_objects = ob;
                
                image->destructor = live_image_destructor;
                image->object_info = ob;
                
                image->examined_p |= EXAMINED_IMAGE_MASK;
              }
            image->fde = real_fde;
            
            result = search_object (ob, pc);
            if (result)
              {
                int encoding;
                
                bases->tbase = ob->tbase;
                bases->dbase = ob->dbase;
                
                encoding = ob->s.b.encoding;
                if (ob->s.b.mixed_encoding)
                  encoding = get_fde_encoding (result);
                read_encoded_value_with_base (encoding, 
                                              base_from_object (encoding, ob),
                                              result->pc_begin, 
                                              (_Unwind_Ptr *)&bases->func);
                break;
              }
          }
        else
          image->examined_p |= EXAMINED_IMAGE_MASK;
        }
  
    _keymgr_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
  
    return result;
  }
  
  fde *
  _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
  {
    struct km_object_info *the_obj_info;
    fde *ret = NULL;
  
    the_obj_info = 
      _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST);
    if (! the_obj_info)
      the_obj_info = calloc (1, sizeof (*the_obj_info));
    
    if (the_obj_info != NULL)
      {
        seen_objects = the_obj_info->seen_objects;
        unseen_objects = the_obj_info->unseen_objects;
    
        ret = _Unwind_Find_registered_FDE (pc, bases);
      }
    
    /* OK, didn't find it in the list of FDEs we've seen before,
       so go through and look at the new ones.  */
    if (ret == NULL)
      ret = examine_objects (pc, bases, the_obj_info == NULL);
  
    if (the_obj_info != NULL)
      {
        the_obj_info->seen_objects = seen_objects;
        the_obj_info->unseen_objects = unseen_objects;
        _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST,
                                              the_obj_info);
      }
    return ret;
  }
  
  
  
  1.81      +0 -16     src/live/gcc3/gcc/config/darwin.c
  
  Index: darwin.c
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/config/darwin.c,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- darwin.c  2002/10/24 23:44:36     1.80
  +++ darwin.c  2002/11/07 20:33:23     1.81
  @@ -52,9 +52,6 @@
   };
   /* APPLE LOCAL end PFE */
   
  -/* APPLE LOCAL C++ EH */
  -rtx personality_libfunc_used = 0;
  -
   extern void machopic_output_stub PARAMS ((FILE *, const char *, const char *));
   
   static int machopic_data_defined_p PARAMS ((const char *));
  @@ -1108,19 +1105,6 @@
                            GET_MODE_ALIGNMENT (Pmode), 1);
        }
       }
  -
  -  /* APPLE LOCAL begin C++ EH  */
  -  /* Output a ".reference __gxx_personality_v0" to keep linking semantics
  -     the same (we used to make a direct reference to this symbol, but now
  -     it's encoded so that the __eh_frame section can live in __TEXT.)  */
  -  /*** temporarily disabled ("0 &&") for compatibility with -all_load ***/
  -  if ( 0 && personality_libfunc_used)
  -    {
  -      const char *str = XSTR (personality_libfunc_used, 0);
  -      str = darwin_strip_name_encoding (str);
  -      fprintf (asm_out_file, ".reference _%s\n", str);
  -    }
  -  /* APPLE LOCAL end C++ EH  */
   }
   
   int 
  
  
  
  1.184     +9 -68     src/live/gcc3/gcc/config/darwin.h
  
  Index: darwin.h
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/config/darwin.h,v
  retrieving revision 1.183
  retrieving revision 1.184
  diff -u -r1.183 -r1.184
  --- darwin.h  2002/10/24 23:44:36     1.183
  +++ darwin.h  2002/11/07 20:33:24     1.184
  @@ -301,26 +301,23 @@
   #undef       LIB_SPEC
   #define LIB_SPEC "%{!static:-lSystem}"
   
  -#undef LIBGCC_SPEC
  -#define LIBGCC_SPEC "%{static:-lgcc_static} \
  -                     %{!static:-lgcc}"
  -
   /* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
   
  -/* APPLE LOCAL begin C++ EH */
   #undef       STARTFILE_SPEC
   #define STARTFILE_SPEC  \
  -  "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o -lcrtbegin.o}} \
  -    %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o -lcrtbegin.o}}"
  +  "%{pg:%{static:-lgcrt0.o}%{!static:-lgcrt1.o} -lcrt2.o} \
  +    %{!pg:%{static:-lcrt0.o}%{!static:-lcrt1.o} -lcrt2.o}"
   
  -#undef       ENDFILE_SPEC
  -#define ENDFILE_SPEC \
  -  "-lcrtend.o"
  +/* The native Darwin linker doesn't necessarily place files in the order
  +   that they're specified on the link line.  Thus, it is pointless
  +   to put anything in ENDFILE_SPEC.  */
  +/* #define ENDFILE_SPEC "" */
   
   #undef       DOLLARS_IN_IDENTIFIERS
   #define DOLLARS_IN_IDENTIFIERS 2
   
   /* We use Dbx symbol format.  */
  +
   #define DBX_DEBUGGING_INFO 1
   
   /* Also enable Dwarf 2 as an option.  */
  @@ -524,9 +521,6 @@
   #undef       MAX_OFILE_ALIGNMENT
   #define MAX_OFILE_ALIGNMENT 0x8000
   
  -#define ASM_OUTPUT_RELOC_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2)  \
  -  darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 1)
  -
   /* Create new Mach-O sections.  */
   
   #undef       SECTION_FUNCTION
  @@ -887,7 +881,7 @@
   
   #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
   
  -/* APPLE LOCAL begin C++ EH turly 20020208  */
  +/* APPLE LOCAL begin coalescing  */
   /* The __eh_frame section attributes: a "normal" section by default.  */
   #define EH_FRAME_SECTION_ATTR        /*nothing*/
   
  @@ -960,66 +954,13 @@
      ? (DW_EH_PE_pcrel | DW_EH_PE_indirect) : \
        ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
   
  -/*** temporarily disabled ("XXX_") for compatibility with -all_load ***/
  -#define XXX_DW2_ENCODE_PERSONALITY_FUNC(ADDR)                                \
  -  do {                                                                       \
  -      const char *str = XSTR (ADDR, 0);                                      \
  -      extern rtx personality_libfunc_used;                           \
  -      personality_libfunc_used = (ADDR);                             \
  -      str += strlen (str) - 2;                                               \
  -      dw2_asm_output_data (1, 0, "(encoding");                               \
  -      dw2_asm_output_data (1, 'g', "for");                           \
  -      dw2_asm_output_data (1, str[0], "personality");                        \
  -      dw2_asm_output_data (1, str[1], "function");                   \
  -      str = darwin_strip_name_encoding (XSTR (ADDR, 0));                     \
  -      dw2_asm_output_data (1, 0xff, "%s)", str);                     \
  -  } while (0)
  -
  -/* TRUE if PTR encodes a personality function.
  -   For now, all we know about is __gxx_personality_v0, encoded
  -   by {0, 'g', 'v', '0', 0xff}.  */
  -
  -/*** temporarily disabled ("XXX_") for compatibility with -all_load ***/
  -#define XXX_DW2_PERSONALITY_FUNC_ENCODED_P(PTR)                              \
  -  (PTR[0] == 0 && PTR[1] == 'g' && PTR[2] == 'v'                     \
  -                             && PTR[3] == '0' && PTR[4] == 0xFF)
  -
  -/* Fromage to "extract" the encoded personality function.  Bump PTR.  */
  -/*** temporarily disabled ("XXX_") for compatibility with -all_load ***/
  -#define XXX_DW2_DECODE_PERSONALITY_FUNC(PTR, PFUNC)                  \
  -  do {                                                                       \
  -    if (DW2_PERSONALITY_FUNC_ENCODED_P (PTR)) {                              \
  -      extern int __gxx_personality_v0 ();                            \
  -      PFUNC = __gxx_personality_v0;                                  \
  -      PTR += 5;                                                              \
  -    }                                                                        \
  -  } while (0)
  -
   #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) 
 \
         if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) {                        
 \
        darwin_non_lazy_pcrel (ASM_OUT_FILE, ADDR);                                    
 \
        goto DONE;                                                                     
 \
         }
  -
  -
  -/* Node of KEYMGR_GCC3_LIVE_IMAGE_LIST.  Info about each resident image.  */
  -struct __live_images {
  -  unsigned long this_size;                      /* sizeof (live_images)  */
  -  struct mach_header *mh;                       /* the image info  */
  -  unsigned long vm_slide;
  -  void (*destructor)(struct __live_images *);   /* destructor for this  */
  -  struct __live_images *next;
  -  unsigned int examined_p;
  -  void *fde;
  -  void *object_info;
  -  unsigned long info[2];                        /* GCC3 use  */
  -};
  -
  -/* Define if we want the "struct object" in unwind-dw2-fde.h to be extended
  -   with a "dwarf_fde_end" field.  */
  -#define DWARF2_OBJECT_END_PTR_EXTENSION
   
  -/* APPLE LOCAL end C++ EH turly 20020208  */
  +/* APPLE LOCAL end coalescing  */
   /* APPLE FIXME set up to add rs6000 pragmas... */
   /* APPLE LOCAL OS pragma hook */
   #undef REGISTER_OS_PRAGMAS
  
  
  
  1.1                  src/live/gcc3/gcc/config/darwin-crt2.c
  
  Index: darwin-crt2.c
  ===================================================================
  /* KeyMgr backwards-compatibility support for Darwin.
     Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  
  This file is part of GCC.
  
  GCC is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free
  Software Foundation; either version 2, or (at your option) any later
  version.
  
  In addition to the permissions in the GNU General Public License, the
  Free Software Foundation gives you unlimited permission to link the
  compiled version of this file into combinations with other programs,
  and to distribute those combinations without any restriction coming
  from the use of this file.  (The General Public License restrictions
  do apply in other respects; for example, they cover modification of
  the file, and distribution when not linked into a combine
  executable.)
  
  GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.
  
  You should have received a copy of the GNU General Public License
  along with GCC; see the file COPYING.  If not, write to the Free
  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.  */
  
  /* It is incorrect to include config.h here, because this file is being
     compiled for the target, and hence definitions concerning only the host
     do not apply.  */
  
  #include "tconfig.h"
  #include "tsystem.h"
  
  /* Homemade decls substituting for getsect.h and dyld.h, so cross
     compilation works.  */
  struct mach_header;
  extern char *getsectdatafromheader (struct mach_header *, const char *,
                                    const char *, unsigned long *);
  extern void _dyld_register_func_for_add_image
    (void (*) (struct mach_header *, unsigned long));
  extern void _dyld_register_func_for_remove_image
    (void (*) (struct mach_header *, unsigned long));
  
  extern void __darwin_gcc3_preregister_frame_info (void);
  
  /* These are from "keymgr.h".  */
  extern void _init_keymgr (void);
  extern void *_keymgr_get_and_lock_processwide_ptr (unsigned key);
  extern void _keymgr_set_and_unlock_processwide_ptr (unsigned key, void *ptr);
  
  extern void *__keymgr_global[];
  typedef struct _Sinfo_Node {
          unsigned int size ;             /*size of this node*/
          unsigned short major_version ;  /*API major version.*/
          unsigned short minor_version ;  /*API minor version.*/
          } _Tinfo_Node ;
  
  /* KeyMgr 3.x is the first one supporting GCC3 stuff natively.  */
  #define KEYMGR_API_MAJOR_GCC3           3       
  /* ... with these keys.  */
  #define KEYMGR_GCC3_LIVE_IMAGE_LIST   301     /* loaded images  */
  #define KEYMGR_GCC3_DW2_OBJ_LIST      302     /* Dwarf2 object list  */   
  
  /* Node of KEYMGR_GCC3_LIVE_IMAGE_LIST.  Info about each resident image.  */
  struct live_images {
    unsigned long this_size;                      /* sizeof (live_images)  */
    struct mach_header *mh;                       /* the image info  */
    unsigned long vm_slide;
    void (*destructor)(struct live_images *);     /* destructor for this  */
    struct live_images *next;
    unsigned int examined_p;
    void *fde;
    void *object_info;
    unsigned long info[2];                        /* Future use.  */
  };
  
  
  /* These routines are used only on Darwin versions before 10.2.
     Later versions have equivalent code in the system.  
     Eventually, they might go away, although it might be a long time...  */
  
  static void darwin_unwind_dyld_remove_image_hook 
    (struct mach_header *m, unsigned long s);
  static void darwin_unwind_dyld_remove_image_hook 
    (struct mach_header *m, unsigned long s);
  extern void __darwin_gcc3_preregister_frame_info (void);
       
  static void
  darwin_unwind_dyld_add_image_hook (struct mach_header *mh, unsigned long slide)
  {
    struct live_images *l = (struct live_images *)calloc (1, sizeof (*l));
    l->mh = mh;
    l->vm_slide = slide;
    l->this_size = sizeof (*l);
    l->next = (struct live_images *)
        _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
    _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST, l);
  }
  
  static void
  darwin_unwind_dyld_remove_image_hook (struct mach_header *m, unsigned long s)
  {
    struct live_images *top, **lip, *destroy = NULL;
  
    /* Look for it in the list of live images and delete it.  */
  
    top = (struct live_images *)
           _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
    for (lip = &top; *lip != NULL; lip = &(*lip)->next)
      {
        if ((*lip)->mh == m && (*lip)->vm_slide == s)
          {
            destroy = *lip;
            *lip = destroy->next;                       /* unlink DESTROY  */
  
            if (destroy->this_size != sizeof (*destroy))        /* sanity check  */
              abort ();
  
            break;
          }
      }
    _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST, top);
  
    /* Now that we have unlinked this from the image list, toss it.  */
    if (destroy != NULL)
      {
        if (destroy->destructor != NULL)
        (*destroy->destructor) (destroy);
        free (destroy);
      }
  }
  
  void
  __darwin_gcc3_preregister_frame_info (void)
  {
    const _Tinfo_Node *info;
    _init_keymgr ();
    info = (_Tinfo_Node *)__keymgr_global[2];
    if (info != NULL)
      {
        if (info->major_version >= KEYMGR_API_MAJOR_GCC3)
        return;
        /* Otherwise, use our own add_image_hooks.  */
      }
  
    _dyld_register_func_for_add_image (darwin_unwind_dyld_add_image_hook);
    _dyld_register_func_for_remove_image (darwin_unwind_dyld_remove_image_hook);
  }
  
  
  
  1.1                  src/live/gcc3/gcc/config/t-darwin
  
  Index: t-darwin
  ===================================================================
  darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) $(RTL_BASE_H) \
            $(REGS_H) hard-reg-set.h insn-config.h conditions.h output.h \
            insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h \
            function.h $(GGC_H) $(TM_P_H) gt-darwin.h
        $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  
  darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) \
            $(TREE_H) $(C_TREE_H) c-pragma.h toplev.h cpplib.h $(TM_P_H)
        $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  
  gt-darwin.h : s-gtype ; @true
  
  # Explain how to build crt2.o
  $(T)crt2$(objext): $(srcdir)/config/darwin-crt2.c $(GCC_PASSES) \
        $(TCONFIG_H) tsystem.h
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) \
          -c $(srcdir)/config/darwin-crt2.c -o $(T)crt2$(objext)
  
  # Use unwind-dw2-fde-darwin
  LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-darwin.c \
    $(srcdir)/unwind-sjlj.c
  LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c
  
  
  
  1.8       +1 -15     src/live/gcc3/gcc/config/i386/t-darwin
  
  Index: t-darwin
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/config/i386/t-darwin,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- t-darwin  2002/08/02 10:07:04     1.7
  +++ t-darwin  2002/11/07 20:33:25     1.8
  @@ -1,3 +1,4 @@
  +# APPLE LOCAL entire file
   # /* APPLE LOCAL begin libcc_kext */
   # 'libcc_kext.a' is runtime support routines for the Darwin kernel and 
dynamically-loaded drivers.
   # No exit/abort/malloc support available, and everything is compiled with '-static 
-fno-exceptions'.
  @@ -34,9 +35,6 @@
   BOOT_CFLAGS = -g -O2 -no-cpp-precomp
   # APPLE LOCAL end cpp-precomp
   
  -# APPLE LOCAL C++ EH
  -CRTSTUFF_T_CFLAGS= -DDARWIN
  -
   dp-bit.c: $(srcdir)/config/fp-bit.c
        cat $(srcdir)/config/fp-bit.c > dp-bit.c
   
  @@ -44,20 +42,8 @@
        echo '#define FLOAT' > fp-bit.c
        cat $(srcdir)/config/fp-bit.c >> fp-bit.c
   
  -darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) $(RTL_BASE_H) \
  -          $(REGS_H) hard-reg-set.h insn-config.h conditions.h output.h \
  -          insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h \
  -          function.h $(GGC_H) $(TM_P_H) gt-darwin.h
  -     $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  -
  -darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) \
  -         $(TREE_H) $(C_TREE_H) c-pragma.h toplev.h cpplib.h $(TM_P_H)
  -     $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  -
   # APPLE LOCAL no soft-float multilibs
   
   # APPLE LOCAL PFE
   darwin.o : config.h $(PFE_H) $(PFE_HEADER_H)
   i386.o : config.h $(PFE_H) $(PFE_HEADER_H)
  -
  -gt-darwin.h : s-gtype ; @true
  
  
  
  1.22      +0 -27     src/live/gcc3/gcc/config/rs6000/t-darwin
  
  Index: t-darwin
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/config/rs6000/t-darwin,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- t-darwin  2002/08/02 10:07:51     1.21
  +++ t-darwin  2002/11/07 20:33:25     1.22
  @@ -39,31 +39,6 @@
   BOOT_CFLAGS = -g -O2 -no-cpp-precomp
   # APPLE LOCAL end cpp-precomp
   
  -# We want fine grained libraries, so use the new code to build the
  -# floating point emulation libraries.
  -FPBIT = fp-bit.c
  -DPBIT = dp-bit.c
  -
  -# APPLE LOCAL C++ EH
  -CRTSTUFF_T_CFLAGS= -DDARWIN
  -
  -dp-bit.c: $(srcdir)/config/fp-bit.c
  -     cat $(srcdir)/config/fp-bit.c > dp-bit.c
  -
  -fp-bit.c: $(srcdir)/config/fp-bit.c
  -     echo '#define FLOAT' > fp-bit.c
  -     cat $(srcdir)/config/fp-bit.c >> fp-bit.c
  -
  -darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) $(RTL_BASE_H) \
  -          $(REGS_H) hard-reg-set.h insn-config.h conditions.h output.h \
  -          insn-attr.h flags.h $(TREE_H) $(EXPR_H) reload.h \
  -          function.h $(GGC_H) $(TM_P_H) gt-darwin.h
  -     $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  -
  -darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) \
  -         $(TREE_H) $(C_TREE_H) c-pragma.h toplev.h cpplib.h $(TM_P_H)
  -     $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
  -
   # Build the libraries for both hard and soft floating point
   
   # APPLE LOCAL no soft-float multilibs
  @@ -85,5 +60,3 @@
   #$(srcdir)/config/rs6000/vec.h: $(srcdir)/config/rs6000/vec.ops \
   #                           $(srcdir)/config/rs6000/builtin.ops
   #    (cd $(srcdir)/config/rs6000; ops-to-gp -gcc vec.ops builtin.ops)
  -
  -gt-darwin.h : s-gtype ; @true
  
  
  
  1.20      +5 -0      src/live/gcc3/gcc/testsuite/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/testsuite/ChangeLog,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ChangeLog 2002/10/24 23:49:26     1.19
  +++ ChangeLog 2002/11/07 20:33:25     1.20
  @@ -1,3 +1,8 @@
  +2002-11-05  Geoffrey Keating  <[EMAIL PROTECTED]>
  +
  +     * g++.old-deja/g++.eh/badalloc1.C: XFAIL excess errors test on
  +     Darwin.
  +
   2002-10-20  Zdenek Dvorak  <[EMAIL PROTECTED]>
   
        * testsuite/gcc.dg/i386-sse-3.c: Add tests for _mm_srli_si128 and
  
  
  
  1.6       +2 -2      src/live/gcc3/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
  
  Index: badalloc1.C
  ===================================================================
  RCS file: /cvs/Darwin/src/live/gcc3/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- badalloc1.C       2001/12/29 22:00:47     1.5
  +++ badalloc1.C       2002/11/07 20:33:26     1.6
  @@ -1,5 +1,5 @@
  -// excess errors test - XFAIL xstormy16-*-*
  -// Copyright (C) 2000 Free Software Foundation, Inc.
  +// excess errors test - XFAIL xstormy16-*-* *-*-darwin*
  +// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
   // Contributed by Nathan Sidwell 6 June 2000 <[EMAIL PROTECTED]>
   
   // Check we can throw a bad_alloc exception when malloc dies.
  
  
  


Reply via email to