fea7751
2004-11-27  Jakub Jelinek  <jakub@redhat.com>
fea7751
fea7751
	* config.gcc (ia64*-*-linux*): If native and libelf is installed,
fea7751
	use ia64/t-glibc-no-libunwind instead of the other t-*unwind*
fea7751
	fragments.
fea7751
	* config/ia64/t-glibc-no-libunwind: New file.
fea7751
	* config/ia64/change-symver.c: New file.
fea7751
	* config/ia64/unwind-ia64.c: If USE_SYMVER_GLOBAL and SHARED,
fea7751
	define _Unwind_* to __symverglobal_Unwind_*.
fea7751
	(alias): Undefine.
fea7751
	(symverglobal): Define.  Use it on _Unwind_*.
fea7751
	* config/ia64/mkmap-symver-multi.awk: New file.
fea7751
	* config/ia64/libgcc-ia64-no-libunwind.ver: New file.
fea7751
fea7751
--- gcc/config.gcc.jj	2004-10-04 08:55:44.000000000 -0400
fea7751
+++ gcc/config.gcc	2004-11-13 05:23:50.000000000 -0500
fea7751
@@ -1185,9 +1185,16 @@ ia64*-*-freebsd*)
fea7751
 	;;
fea7751
 ia64*-*-linux*)
fea7751
 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h ia64/sysv4.h ia64/linux.h"
fea7751
-	tmake_file="${tmake_file} ia64/t-ia64 t-libunwind ia64/t-glibc"
fea7751
-	if test x$with_system_libunwind != xyes ; then
fea7751
-		tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind"
fea7751
+	tmake_file="${tmake_file} ia64/t-ia64"
fea7751
+	if test x${target} = x${host} && test x${target} = x${build} \
fea7751
+	   && grep gelf_getverdef /usr/include/gelf.h > /dev/null 2>&1 \
fea7751
+	   && test -f /usr/lib/libelf.so; then
fea7751
+		tmake_file="${tmake_file} ia64/t-glibc-no-libunwind"
fea7751
+	else
fea7751
+		tmake_file="${tmake_file} t-libunwind ia64/t-glibc"
fea7751
+		if test x$with_system_libunwind != xyes ; then
fea7751
+			tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind"
fea7751
+		fi
fea7751
 	fi
fea7751
 	target_cpu_default="MASK_GNU_AS|MASK_GNU_LD"
fea7751
 	extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o"
fea7751
--- gcc/config/ia64/t-glibc-no-libunwind.jj	2004-02-18 10:27:36.000000000 -0500
fea7751
+++ gcc/config/ia64/t-glibc-no-libunwind	2004-11-15 09:56:33.000000000 -0500
fea7751
@@ -0,0 +1,30 @@
fea7751
+# Don't use system libunwind library on IA-64 GLIBC based system,
fea7751
+# but make _Unwind_* symbols unversioned, so that created programs
fea7751
+# are usable even when libgcc_s uses libunwind.
fea7751
+LIB2ADDEH += $(srcdir)/config/ia64/fde-glibc.c
fea7751
+SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64-no-libunwind.ver
fea7751
+SHLIB_MKMAP = $(srcdir)/config/ia64/mkmap-symver-multi.awk
fea7751
+
fea7751
+SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
fea7751
+	-Wl,--soname=$(SHLIB_SONAME) \
fea7751
+	-Wl,--version-script=$(SHLIB_MAP) \
fea7751
+	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ $(SHLIB_OBJS) -lc && \
fea7751
+	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
fea7751
+	if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \
fea7751
+	  mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \
fea7751
+		$(SHLIB_DIR)/$(SHLIB_SONAME).backup; \
fea7751
+	else true; fi && \
fea7751
+	gcc -O2 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tweak \
96e022d
+	  $$(gcc_srcdir)/config/ia64/change-symver.c -lelf && \
fea7751
+	$(SHLIB_DIR)/$(SHLIB_SONAME).tweak $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \
fea7751
+	GCC_3.4.2 _GLOBAL_ \
fea7751
+	_Unwind_GetGR _Unwind_RaiseException _Unwind_GetRegionStart _Unwind_SetIP \
fea7751
+	_Unwind_GetIP _Unwind_GetLanguageSpecificData _Unwind_Resume \
fea7751
+	_Unwind_DeleteException _Unwind_SetGR _Unwind_ForcedUnwind \
fea7751
+	_Unwind_Backtrace _Unwind_FindEnclosingFunction _Unwind_GetCFA \
fea7751
+	_Unwind_Resume_or_Rethrow _Unwind_GetBSP && \
fea7751
+	rm -f $(SHLIB_DIR)/$(SHLIB_SONAME).tweak && \
fea7751
+	mv $(SHLIB_DIR)/$(SHLIB_SONAME).tmp $(SHLIB_DIR)/$(SHLIB_SONAME) && \
fea7751
+	$(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
fea7751
+
fea7751
+TARGET_LIBGCC2_CFLAGS += -DUSE_SYMVER_GLOBAL
fea7751
--- gcc/config/ia64/change-symver.c.jj	2004-02-18 10:27:36.000000000 -0500
fea7751
+++ gcc/config/ia64/change-symver.c	2004-11-13 05:23:50.000000000 -0500
fea7751
@@ -0,0 +1,211 @@
fea7751
+#define _GNU_SOURCE 1
fea7751
+#define _FILE_OFFSET_BITS 64
fea7751
+#include <endian.h>
fea7751
+#include <errno.h>
fea7751
+#include <error.h>
fea7751
+#include <fcntl.h>
fea7751
+#include <fnmatch.h>
fea7751
+#include <gelf.h>
fea7751
+#include <stdlib.h>
fea7751
+#include <string.h>
fea7751
+#include <unistd.h>
fea7751
+
fea7751
+int
fea7751
+compute_veridx (const char *name, Elf *elf, Elf_Data *verd, GElf_Shdr *verd_shdr)
fea7751
+{
fea7751
+  if (strcmp (name, "_GLOBAL_") == 0)
fea7751
+    return 1;
fea7751
+
fea7751
+  int cnt;
fea7751
+  size_t offset = 0;
fea7751
+  for (cnt = verd_shdr->sh_info; --cnt >= 0; )
fea7751
+    {
fea7751
+      GElf_Verdef defmem;
fea7751
+      GElf_Verdef *def;
fea7751
+      GElf_Verdaux auxmem;
fea7751
+      GElf_Verdaux *aux;
fea7751
+      unsigned int auxoffset;
fea7751
+
fea7751
+      /* Get the data at the next offset.  */
fea7751
+      def = gelf_getverdef (verd, offset, &defmem);
fea7751
+      if (def == NULL)
fea7751
+	break;
fea7751
+
fea7751
+      auxoffset = offset + def->vd_aux;
fea7751
+      aux = gelf_getverdaux (verd, auxoffset, &auxmem);
fea7751
+      if (aux == NULL)
fea7751
+	break;
fea7751
+
fea7751
+      if (strcmp (name, elf_strptr (elf, verd_shdr->sh_link,
fea7751
+		  aux->vda_name)) == 0)
fea7751
+	return def->vd_ndx;
fea7751
+
fea7751
+      /* Find the next offset.  */
fea7751
+      offset += def->vd_next;
fea7751
+    }
fea7751
+
fea7751
+  return -1;
fea7751
+}
fea7751
+
fea7751
+int
fea7751
+main (int argc, char **argv)
fea7751
+{
fea7751
+  if (argc < 4)
fea7751
+    error (1, 0, "Usage: change_symver library from_symver to_symver symbol...\nExample: change_symver libfoo.so FOO_1.0 *global* bar baz");
fea7751
+
fea7751
+  const char *fname = argv[1];
fea7751
+
fea7751
+  /* Open the file.  */
fea7751
+  int fd;
fea7751
+  fd = open (fname, O_RDWR);
fea7751
+  if (fd == -1)
fea7751
+    error (1, errno, fname);
fea7751
+
fea7751
+  elf_version (EV_CURRENT);
fea7751
+
fea7751
+  /* Now get the ELF descriptor.  */
fea7751
+  Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
fea7751
+  if (elf == NULL || elf_kind (elf) != ELF_K_ELF)
fea7751
+    error (1, 0, "Couldn't open %s: %s", fname, elf_errmsg (-1));
fea7751
+
fea7751
+  size_t shstrndx;
fea7751
+  /* Get the section header string table index.  */
fea7751
+  if (elf_getshstrndx (elf, &shstrndx) < 0)
fea7751
+    error (1, 0, "cannot get shstrndx from %s", fname);
fea7751
+
fea7751
+  GElf_Ehdr ehdr_mem;
fea7751
+  GElf_Ehdr *ehdr;
fea7751
+
fea7751
+  /* We need the ELF header in a few places.  */
fea7751
+  ehdr = gelf_getehdr (elf, &ehdr_mem);
fea7751
+  if (ehdr == NULL)
fea7751
+    error (1, 0, "couldn't get ELF headers %s: %s", fname, elf_errmsg (-1));
fea7751
+
fea7751
+  Elf_Scn *scn = NULL;
fea7751
+  GElf_Shdr shdr_mem, verd_shdr, ver_shdr, dynsym_shdr;
fea7751
+  Elf_Data *ver = NULL, *verd = NULL, *dynsym = NULL;
fea7751
+
fea7751
+  while ((scn = elf_nextscn (elf, scn)) != NULL)
fea7751
+    {
fea7751
+      GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
fea7751
+
fea7751
+      if (shdr == NULL)
fea7751
+	error (1, 0, "couldn't get shdr from %s", fname);
fea7751
+
fea7751
+      if ((shdr->sh_flags & SHF_ALLOC) != 0)
fea7751
+	{
fea7751
+	  const char *name = elf_strptr (elf, shstrndx, shdr->sh_name);
fea7751
+	  Elf_Data **p;
fea7751
+
fea7751
+	  if (strcmp (name, ".gnu.version") == 0)
fea7751
+	    {
fea7751
+	      p = &ver;
fea7751
+	      ver_shdr = *shdr;
fea7751
+	    }
fea7751
+	  else if (strcmp (name, ".gnu.version_d") == 0)
fea7751
+	    {
fea7751
+	      p = &verd;
fea7751
+	      verd_shdr = *shdr;
fea7751
+	    }
fea7751
+	  else if (strcmp (name, ".dynsym") == 0)
fea7751
+	    {
fea7751
+	      p = &dynsym;
fea7751
+	      dynsym_shdr = *shdr;
fea7751
+	    }
fea7751
+	  else
fea7751
+	    continue;
fea7751
+
fea7751
+	  if (*p != NULL)
fea7751
+	    error (1, 0, "Two %s sections in %s", name, fname);
fea7751
+	  *p = elf_getdata (scn, NULL);
fea7751
+	  if (*p == NULL || elf_getdata (scn, *p) != NULL)
fea7751
+	    error (1, 0, "No data or non-contiguous data in %s section in %s",
fea7751
+		   name, fname);
fea7751
+	}
fea7751
+    }
fea7751
+
fea7751
+  if (ver == NULL || verd == NULL || dynsym == NULL)
fea7751
+    error (1, 0, "Couldn't find one of the needed sections in %s", fname);
fea7751
+
fea7751
+  int from_idx = compute_veridx (argv[2], elf, verd, &verd_shdr);
fea7751
+  if (from_idx == -1)
fea7751
+    error (1, 0, "Could not find symbol version %s in %s", argv[2], fname);
fea7751
+
fea7751
+  int to_idx = compute_veridx (argv[3], elf, verd, &verd_shdr);
fea7751
+  if (to_idx == -1)
fea7751
+    error (1, 0, "Could not find symbol version %s in %s", argv[3], fname);
fea7751
+
fea7751
+  if (dynsym_shdr.sh_entsize != gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version)
fea7751
+      || dynsym_shdr.sh_size % dynsym_shdr.sh_entsize
fea7751
+      || ver_shdr.sh_entsize != 2
fea7751
+      || (ver_shdr.sh_size & 1)
fea7751
+      || dynsym_shdr.sh_size / dynsym_shdr.sh_entsize != ver_shdr.sh_size / 2)
fea7751
+    error (1, 0, "Unexpected sh_size or sh_entsize in %s", fname);
fea7751
+
fea7751
+  size_t nentries = ver_shdr.sh_size / 2;
fea7751
+  size_t cnt;
fea7751
+  GElf_Versym array[nentries];
fea7751
+  for (cnt = 0; cnt < nentries; ++cnt)
fea7751
+    {
fea7751
+      GElf_Versym vsymmem;
fea7751
+      GElf_Versym *vsym;
fea7751
+
fea7751
+      vsym = gelf_getversym (ver, cnt, &vsymmem);
fea7751
+      if (vsym == NULL)
fea7751
+	error (1, 0, "gelt_getversym failed in %s: %s", fname, elf_errmsg (-1));
fea7751
+
fea7751
+      array[cnt] = *vsym;
fea7751
+      if (*vsym != from_idx)
fea7751
+	continue;
fea7751
+
fea7751
+      GElf_Sym sym_mem;
fea7751
+      GElf_Sym *sym;
fea7751
+      sym = gelf_getsym (dynsym, cnt, &sym_mem);
fea7751
+      if (sym == NULL)
fea7751
+	error (1, 0, "gelt_getsym failed in %s: %s", fname, elf_errmsg (-1));
fea7751
+
fea7751
+      const char *name = elf_strptr (elf, dynsym_shdr.sh_link, sym->st_name);
fea7751
+
fea7751
+      int argn;
fea7751
+      for (argn = 4; argn < argc; ++argn)
fea7751
+	if (fnmatch (argv[argn], name, 0) == 0)
fea7751
+	  {
fea7751
+	    array[cnt] = to_idx;
fea7751
+	    break;
fea7751
+	  }
fea7751
+    }
fea7751
+
fea7751
+  if (sizeof (array[0]) != 2)
fea7751
+    abort ();
fea7751
+
fea7751
+#if __BYTE_ORDER == __LITTLE_ENDIAN
fea7751
+  if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
fea7751
+    ;
fea7751
+  else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
fea7751
+#elif __BYTE_ORDER == __BIG_ENDIAN
fea7751
+  if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
fea7751
+    ;
fea7751
+  else if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
fea7751
+#else
fea7751
+# error Unsupported endianity
fea7751
+#endif
fea7751
+    {
fea7751
+      for (cnt = 0; cnt < nentries; ++cnt)
fea7751
+	array[cnt] = ((array[cnt] & 0xff) << 8) | ((array[cnt] & 0xff00) >> 8);
fea7751
+    }
fea7751
+  else
fea7751
+    error (1, 0, "Unknown EI_DATA %d in %s", ehdr->e_ident[EI_DATA], fname);
fea7751
+
fea7751
+  if (elf_end (elf) != 0)
fea7751
+    error (1, 0, "couldn't close %s: %s", fname, elf_errmsg (-1));
fea7751
+
fea7751
+  if (lseek (fd, ver_shdr.sh_offset, SEEK_SET) != (off_t) ver_shdr.sh_offset)
fea7751
+    error (1, 0, "failed to seek to %zd in %s", (size_t) ver_shdr.sh_offset,
fea7751
+	   fname);
fea7751
+
fea7751
+  if (write (fd, array, 2 * nentries) != (ssize_t) (2 * nentries))
fea7751
+    error (1, 0, "failed to write .gnu.version section into %s", fname);
fea7751
+
fea7751
+  close (fd);
fea7751
+  return 0;
fea7751
+}
fea7751
--- gcc/config/ia64/unwind-ia64.c.jj	2004-10-04 08:55:57.000000000 -0400
fea7751
+++ gcc/config/ia64/unwind-ia64.c	2004-11-15 09:07:45.000000000 -0500
fea7751
@@ -51,6 +51,51 @@
fea7751
 #define UNW_FLAG_UHANDLER(x)	((x) & 0x0000000200000000L)
fea7751
 #define UNW_LENGTH(x)		((x) & 0x00000000ffffffffL)
fea7751
 
fea7751
+#if defined (USE_SYMVER_GLOBAL) && defined (SHARED)
fea7751
+extern _Unwind_Reason_Code __symverglobal_Unwind_Backtrace
fea7751
+  (_Unwind_Trace_Fn, void *);
fea7751
+extern void __symverglobal_Unwind_DeleteException
fea7751
+  (struct _Unwind_Exception *);
fea7751
+extern void * __symverglobal_Unwind_FindEnclosingFunction (void *);
fea7751
+extern _Unwind_Reason_Code __symverglobal_Unwind_ForcedUnwind
fea7751
+  (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
fea7751
+extern _Unwind_Word __symverglobal_Unwind_GetCFA
fea7751
+  (struct _Unwind_Context *);
fea7751
+extern _Unwind_Word __symverglobal_Unwind_GetBSP
fea7751
+  (struct _Unwind_Context *);
fea7751
+extern _Unwind_Word __symverglobal_Unwind_GetGR
fea7751
+  (struct _Unwind_Context *, int );
fea7751
+extern _Unwind_Ptr __symverglobal_Unwind_GetIP (struct _Unwind_Context *);
fea7751
+extern void *__symverglobal_Unwind_GetLanguageSpecificData
fea7751
+  (struct _Unwind_Context *);
fea7751
+extern _Unwind_Ptr __symverglobal_Unwind_GetRegionStart
fea7751
+  (struct _Unwind_Context *);
fea7751
+extern _Unwind_Reason_Code __symverglobal_Unwind_RaiseException
fea7751
+  (struct _Unwind_Exception *);
fea7751
+extern void __symverglobal_Unwind_Resume (struct _Unwind_Exception *);
fea7751
+extern _Unwind_Reason_Code __symverglobal_Unwind_Resume_or_Rethrow
fea7751
+   (struct _Unwind_Exception *);
fea7751
+extern void __symverglobal_Unwind_SetGR
fea7751
+  (struct _Unwind_Context *, int, _Unwind_Word);
fea7751
+extern void __symverglobal_Unwind_SetIP
fea7751
+  (struct _Unwind_Context *, _Unwind_Ptr);
fea7751
+#define _Unwind_Backtrace __symverglobal_Unwind_Backtrace
fea7751
+#define _Unwind_DeleteException __symverglobal_Unwind_DeleteException
fea7751
+#define _Unwind_FindEnclosingFunction __symverglobal_Unwind_FindEnclosingFunction
fea7751
+#define _Unwind_ForcedUnwind __symverglobal_Unwind_ForcedUnwind
fea7751
+#define _Unwind_GetBSP __symverglobal_Unwind_GetBSP
fea7751
+#define _Unwind_GetCFA __symverglobal_Unwind_GetCFA
fea7751
+#define _Unwind_GetGR __symverglobal_Unwind_GetGR
fea7751
+#define _Unwind_GetIP __symverglobal_Unwind_GetIP
fea7751
+#define _Unwind_GetLanguageSpecificData __symverglobal_Unwind_GetLanguageSpecificData
fea7751
+#define _Unwind_GetRegionStart __symverglobal_Unwind_GetRegionStart
fea7751
+#define _Unwind_RaiseException __symverglobal_Unwind_RaiseException
fea7751
+#define _Unwind_Resume __symverglobal_Unwind_Resume
fea7751
+#define _Unwind_Resume_or_Rethrow __symverglobal_Unwind_Resume_or_Rethrow
fea7751
+#define _Unwind_SetGR __symverglobal_Unwind_SetGR
fea7751
+#define _Unwind_SetIP __symverglobal_Unwind_SetIP
fea7751
+#endif
fea7751
+
fea7751
 enum unw_application_register
fea7751
 {
fea7751
   UNW_AR_BSP,
fea7751
@@ -2402,4 +2447,44 @@ alias (_Unwind_SetGR);
fea7751
 alias (_Unwind_SetIP);
fea7751
 #endif
fea7751
 
fea7751
+#if defined (USE_SYMVER_GLOBAL) && defined (SHARED)
fea7751
+#undef alias
fea7751
+#define symverglobal(name, version) \
fea7751
+__typeof (__symverglobal##name) __symverlocal##name		\
fea7751
+  __attribute__ ((alias ("__symverglobal" #name)));		\
fea7751
+__asm__ (".symver __symverglobal" #name"," #name "@@GCC_3.4.2");\
fea7751
+__asm__ (".symver __symverlocal" #name"," #name "@" #version)
fea7751
+
fea7751
+#undef _Unwind_Backtrace
fea7751
+#undef _Unwind_DeleteException
fea7751
+#undef _Unwind_FindEnclosingFunction
fea7751
+#undef _Unwind_ForcedUnwind
fea7751
+#undef _Unwind_GetBSP
fea7751
+#undef _Unwind_GetCFA
fea7751
+#undef _Unwind_GetGR
fea7751
+#undef _Unwind_GetIP
fea7751
+#undef _Unwind_GetLanguageSpecificData
fea7751
+#undef _Unwind_GetRegionStart
fea7751
+#undef _Unwind_RaiseException
fea7751
+#undef _Unwind_Resume
fea7751
+#undef _Unwind_Resume_or_Rethrow
fea7751
+#undef _Unwind_SetGR
fea7751
+#undef _Unwind_SetIP
fea7751
+symverglobal (_Unwind_Backtrace, GCC_3.3);
fea7751
+symverglobal (_Unwind_DeleteException, GCC_3.0);
fea7751
+symverglobal (_Unwind_FindEnclosingFunction, GCC_3.3);
fea7751
+symverglobal (_Unwind_ForcedUnwind, GCC_3.0);
fea7751
+symverglobal (_Unwind_GetBSP, GCC_3.3.2);
fea7751
+symverglobal (_Unwind_GetCFA, GCC_3.3);
fea7751
+symverglobal (_Unwind_GetGR, GCC_3.0);
fea7751
+symverglobal (_Unwind_GetIP, GCC_3.0);
fea7751
+symverglobal (_Unwind_GetLanguageSpecificData, GCC_3.0);
fea7751
+symverglobal (_Unwind_GetRegionStart, GCC_3.0);
fea7751
+symverglobal (_Unwind_RaiseException, GCC_3.0);
fea7751
+symverglobal (_Unwind_Resume, GCC_3.0);
fea7751
+symverglobal (_Unwind_Resume_or_Rethrow, GCC_3.3);
fea7751
+symverglobal (_Unwind_SetGR, GCC_3.0);
fea7751
+symverglobal (_Unwind_SetIP, GCC_3.0);
fea7751
+#endif
fea7751
+
fea7751
 #endif
fea7751
--- gcc/config/ia64/mkmap-symver-multi.awk.jj	2004-02-18 10:27:36.000000000 -0500
fea7751
+++ gcc/config/ia64/mkmap-symver-multi.awk	2004-11-15 09:46:50.000000000 -0500
fea7751
@@ -0,0 +1,133 @@
fea7751
+# Generate an ELF symbol version map a-la Solaris and GNU ld.
fea7751
+#	Contributed by Richard Henderson <rth@cygnus.com>
fea7751
+#
fea7751
+# This file is part of GCC.
fea7751
+#
fea7751
+# GCC is free software; you can redistribute it and/or modify it under
fea7751
+# the terms of the GNU General Public License as published by the Free
fea7751
+# Software Foundation; either version 2, or (at your option) any later
fea7751
+# version.
fea7751
+#
fea7751
+# GCC is distributed in the hope that it will be useful, but WITHOUT
fea7751
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fea7751
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
fea7751
+# License for more details.
fea7751
+#
fea7751
+# You should have received a copy of the GNU General Public License
fea7751
+# along with GCC; see the file COPYING.  If not, write to the Free
fea7751
+# Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
fea7751
+# 02110-1301, USA.
fea7751
+
fea7751
+BEGIN {
fea7751
+  state = "nm";
fea7751
+  sawsymbol = 0;
fea7751
+}
fea7751
+
fea7751
+# Remove comment and blank lines.
fea7751
+/^ *#/ || /^ *$/ {
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+# We begin with nm input.  Collect the set of symbols that are present
fea7751
+# so that we can not emit them into the final version script -- Solaris
fea7751
+# complains at us if we do.
fea7751
+
fea7751
+state == "nm" && /^%%/ {
fea7751
+  state = "ver";
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+state == "nm" && ($1 == "U" || $2 == "U") {
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+state == "nm" && NF == 3 {
fea7751
+  if ($3 ~ /^[^@]*@GCC_[0-9.]*$/) {
fea7751
+    def[$3] = 1
fea7751
+    tl=$3
fea7751
+    sub(/^.*@/,"",tl)
fea7751
+    ver[$3] = tl
fea7751
+  } else {
fea7751
+    sub(/@@?GCC_[0-9.]*$/,"",$3)
fea7751
+    def[$3] = 1;
fea7751
+  }
fea7751
+  sawsymbol = 1;
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+state == "nm" {
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+# Now we process a simplified variant of the Solaris symbol version
fea7751
+# script.  We have one symbol per line, no semicolons, simple markers
fea7751
+# for beginning and ending each section, and %inherit markers for
fea7751
+# describing version inheritence.  A symbol may appear in more than
fea7751
+# one symbol version, and the last seen takes effect.
fea7751
+
fea7751
+NF == 3 && $1 == "%inherit" {
fea7751
+  inherit[$2] = $3;
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+NF == 2 && $2 == "{" {
fea7751
+  libs[$1] = 1;
fea7751
+  thislib = $1;
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+$1 == "}" {
fea7751
+  thislib = "";
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+{
fea7751
+  ver[$1] = thislib;
fea7751
+  next;
fea7751
+}
fea7751
+
fea7751
+END {
fea7751
+  if (!sawsymbol)
fea7751
+    {
fea7751
+      print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2;;
fea7751
+      exit 1;
fea7751
+    }
fea7751
+  for (l in libs)
fea7751
+    output(l);
fea7751
+}
fea7751
+
fea7751
+function output(lib) {
fea7751
+  if (done[lib])
fea7751
+    return;
fea7751
+  done[lib] = 1;
fea7751
+  if (inherit[lib])
fea7751
+    output(inherit[lib]);
fea7751
+
fea7751
+  empty=1
fea7751
+  for (sym in ver)
fea7751
+    if ((ver[sym] == lib) && (sym in def))
fea7751
+      {
fea7751
+	if (empty)
fea7751
+	  {
fea7751
+	    printf("%s {\n", lib);
fea7751
+	    printf("  global:\n");
fea7751
+	    empty = 0;
fea7751
+	  }
fea7751
+	symp = sym;
fea7751
+	sub(/@GCC_[0-9.]*$/,"",symp);
fea7751
+	printf("\t%s;\n", symp);
fea7751
+	if (dotsyms)
fea7751
+	  printf("\t.%s;\n", symp);
fea7751
+      }
fea7751
+
fea7751
+  if (empty)
fea7751
+    {
fea7751
+      for (l in libs)
fea7751
+	if (inherit[l] == lib)
fea7751
+	  inherit[l] = inherit[lib];
fea7751
+    }
fea7751
+  else if (inherit[lib])
fea7751
+    printf("} %s;\n", inherit[lib]);
fea7751
+  else
fea7751
+    printf ("\n  local:\n\t*;\n};\n");
fea7751
+}
fea7751
--- gcc/config/ia64/libgcc-ia64-no-libunwind.ver.jj	2004-02-18 10:27:36.000000000 -0500
fea7751
+++ gcc/config/ia64/libgcc-ia64-no-libunwind.ver	2004-11-15 09:19:56.000000000 -0500
fea7751
@@ -0,0 +1,17 @@
fea7751
+GCC_3.4.2 {
fea7751
+  _Unwind_GetGR
fea7751
+  _Unwind_RaiseException
fea7751
+  _Unwind_GetRegionStart
fea7751
+  _Unwind_SetIP
fea7751
+  _Unwind_GetIP
fea7751
+  _Unwind_GetLanguageSpecificData
fea7751
+  _Unwind_Resume
fea7751
+  _Unwind_DeleteException
fea7751
+  _Unwind_SetGR
fea7751
+  _Unwind_ForcedUnwind
fea7751
+  _Unwind_Backtrace
fea7751
+  _Unwind_FindEnclosingFunction
fea7751
+  _Unwind_GetCFA
fea7751
+  _Unwind_Resume_or_Rethrow
fea7751
+  _Unwind_GetBSP
fea7751
+}