From eae7a19e39c1c18f7f5cd7c31a84035dc8b3ed72 Mon Sep 17 00:00:00 2001 From: John Marino Date: Fri, 29 Apr 2011 23:04:59 +0200 Subject: [PATCH] GCC: Upgrade to 4.4.6; improved exception handling In addition to 70 bug fixes provided by GNU, this version handles exceptions through the new rtld, which is important to C++. This compiler also now incorporates MD_UNWIND_SUPPORT from gnat-aux, but it's not clear if C++ utilizes this frame unwinding or not yet. --- contrib/gcc-4.4/README.DELETED | 45 ++++- contrib/gcc-4.4/README.DRAGONFLY | 19 +-- .../gcc/config/i386/dragonfly-unwind.h | 158 ++++++++++++++++++ contrib/gcc-4.4/gcc/config/i386/dragonfly.h | 2 +- contrib/gcc-4.4/gcc/crtstuff.c | 15 +- contrib/gcc-4.4/gcc/unwind-dw2-fde-glibc.c | 8 +- gnu/lib/gcc44/libgcc/Makefile | 2 +- gnu/usr.bin/cc44/Makefile.inc | 2 +- gnu/usr.bin/cc44/cc_prep/auto-host.h | 6 +- 9 files changed, 219 insertions(+), 38 deletions(-) create mode 100644 contrib/gcc-4.4/gcc/config/i386/dragonfly-unwind.h diff --git a/contrib/gcc-4.4/README.DELETED b/contrib/gcc-4.4/README.DELETED index fa3c6d6305..27fb9751f7 100644 --- a/contrib/gcc-4.4/README.DELETED +++ b/contrib/gcc-4.4/README.DELETED @@ -3,10 +3,20 @@ ChangeLog ChangeLog.tree-ssa INSTALL/ MAINTAINERS +Makefile.def +Makefile.in +Makefile.tpl MD5SUMS NEWS +boehm-gc/ compile config/ +config-ml.in +config.guess +config.rpath +config.sub +configure +configure.ac contrib/ depcomp fixincludes/ @@ -37,6 +47,7 @@ gcc/LANGUAGES gcc/ONEWS gcc/acinclude.m4 gcc/aclocal.m4 +gcc/ada/ gcc/collect2.c gcc/collect2.h gcc/config/alpha/ @@ -294,6 +305,12 @@ gcc/config/x-hpux gcc/config/x-linux gcc/config/x-solaris gcc/config/xtensa/ +gcc/config.build +gcc/config.gcc +gcc/config.host +gcc/config.in +gcc/configure +gcc/configure.ac gcc/cp/ChangeLog gcc/cp/ChangeLog-1993 gcc/cp/ChangeLog-1994 @@ -345,6 +362,7 @@ gcc/emutls.c gcc/exec-tool.in gcc/fix-header.c gcc/fixproto +gcc/fortran/ gcc/fp-test.c gcc/gccbug.in gcc/gcov-dump.c @@ -376,6 +394,7 @@ gcc/gthr-solaris.h gcc/gthr-tpf.h gcc/gthr-vxworks.h gcc/gthr-win32.h +gcc/java/ gcc/limitx.h gcc/limity.h gcc/mips-tdump.c @@ -395,25 +414,28 @@ gcc/sdbout.h gcc/sort-protos gcc/sys-protos.h gcc/sys-types.h +gcc/testsuite/ gcc/tlink.c gcc/tree-browser.c gcc/tree-browser.def gcc/unwind-compat.c -gcc/unwind-compat.h gcc/unwind-dw2-fde-compat.c gcc/unwind-dw2-fde-darwin.c -gcc/unwind-dw2-fde-glibc.c gcc/vmsdbg.h gcc/xcoff.h gcc/xcoffout.h +gnattools/ include/ChangeLog include/ChangeLog-9103 include/symcat.h include/xtensa-config.h install-sh intl/ +libada/ libcpp/ChangeLog libcpp/aclocal.m4 +libcpp/configure +libcpp/configure.ac libcpp/makedepend.c libcpp/makeucnid.c libcpp/po/ @@ -421,6 +443,8 @@ libcpp/ucnid.tab libdecnumber/ChangeLog libdecnumber/aclocal.m4 libdecnumber/bid/ +libdecnumber/configure +libdecnumber/configure.ac libdecnumber/decBasic.c libdecnumber/decCommon.c libdecnumber/decDouble.c @@ -440,6 +464,7 @@ libdecnumber/decRound.h libdecnumber/decSingle.c libdecnumber/decSingle.h libdecnumber/decSingleSymbols.h +libffi/ libgcc/ChangeLog libgcc/config/alpha/ libgcc/config/avr/ @@ -464,6 +489,8 @@ libgcc/config/sparc/ libgcc/config/t-slibgcc-darwin libgcc/config/t-softfp libgcc/config/t-tls +libgcc/configure +libgcc/configure.ac libgcc/empty.mk libgcc/fixed-obj.mk libgcc/gen-fixed.sh @@ -471,6 +498,7 @@ libgcc/gstdint.h libgcc/shared-object.mk libgcc/siditi-object.mk libgcc/static-object.mk +libgfortran/ libgomp/ libiberty/ChangeLog libiberty/_doprnt.c @@ -486,6 +514,8 @@ libiberty/calloc.c libiberty/clock.c libiberty/config/ libiberty/config.h-vms +libiberty/configure +libiberty/configure.ac libiberty/copying-lib.texi libiberty/copysign.c libiberty/ffs.c @@ -541,6 +571,7 @@ libiberty/vprintf.c libiberty/vsnprintf.c libiberty/vsprintf.c libiberty/waitpid.c +libjava/ libmudflap/ libobjc/ChangeLog libobjc/README.threads @@ -548,6 +579,8 @@ libobjc/THREADS libobjc/THREADS.MACH libobjc/acinclude.m4 libobjc/aclocal.m4 +libobjc/configure +libobjc/configure.ac libobjc/libobjc.def libobjc/libobjc_entry.c libobjc/makefile.dos @@ -565,6 +598,8 @@ libobjc/thr-vxworks.c libobjc/thr-win32.c libssp/ChangeLog libssp/aclocal.m4 +libssp/configure +libssp/configure.ac libssp/libtool-version libstdc++-v3/ChangeLog libstdc++-v3/ChangeLog-1998 @@ -601,9 +636,7 @@ libstdc++-v3/config/locale/generic/ctype_members.cc libstdc++-v3/config/locale/gnu/ libstdc++-v3/config/locale/ieee_1003.1-2001/ libstdc++-v3/config/os/aix/ -libstdc++-v3/config/os/bsd/darwin/ -libstdc++-v3/config/os/bsd/freebsd/ -libstdc++-v3/config/os/bsd/netbsd/ +libstdc++-v3/config/os/bsd/ libstdc++-v3/config/os/djgpp/ libstdc++-v3/config/os/generic/ctype_base.h libstdc++-v3/config/os/generic/ctype_inline.h @@ -619,6 +652,8 @@ libstdc++-v3/config/os/solaris/ libstdc++-v3/config/os/tpf/ libstdc++-v3/config/os/uclibc/ libstdc++-v3/config/os/vxworks/ +libstdc++-v3/configure +libstdc++-v3/configure.ac libstdc++-v3/crossconfig.m4 libstdc++-v3/doc/ libstdc++-v3/fragment.am diff --git a/contrib/gcc-4.4/README.DRAGONFLY b/contrib/gcc-4.4/README.DRAGONFLY index 174d33aad1..8cad555b56 100644 --- a/contrib/gcc-4.4/README.DRAGONFLY +++ b/contrib/gcc-4.4/README.DRAGONFLY @@ -1,23 +1,20 @@ - GCC-4.4.5 AS USED BY DRAGONFLY + GCC-4.4.6 AS USED BY DRAGONFLY This directory contains a selected set of files from the GNU - gcc-4.4.5 distribution, using the `core', `g++' and `objc' parts, - which are 197MB together, but we really only need 53MB of those. - No files have been moved or modified from their extracted position. + gcc-4.4.6 distribution; the subset occupies about 53MB. ON THE VENDOR BRANCH (vendor/GCC44), DO NOT CREATE OR EDIT ANY FILES IN THIS DIRECTORY HIERARCHY! THIS HIERARCHY REPRESENTS AN EXACT COPY, MINUS UNNEEDED FILES, OF THE GNU GCC DISTRIBUTION. All modifications are made in the master or release branches! - The file README.DELETED contains a list of deleted files. - -SHA1 (gcc-core-4.4.5.tar.bz2) = 8e2202cde3be496f0452219c60311f8fe36f87f6 -SHA1 ( gcc-g++-4.4.5.tar.bz2) = cdbf1fc7b367c084b16e8f25089e2bd98fcdf4dc -SHA1 (gcc-objc-4.4.5.tar.bz2) = d21df03f2f49bf1463422d0b9c68fd44f9c04b5f + file = gcc-4.4.6.tar.bz2 + date = 16 April 2011 + size = 63135296 + sha1 = fc5e6c60b03650f6508470c088440d3d9360adf9 The following files have been added or patched: @@ -32,9 +29,11 @@ SHA1 (gcc-objc-4.4.5.tar.bz2) = d21df03f2f49bf1463422d0b9c68fd44f9c04b5f /libgcc/config.host /gcc/c-format.c /gcc/c-opts.c - /gcc/config.gcc + /gcc/crtstuff.c /gcc/tree-inline.c + /gcc/unwind-dw2-fde-glibc.c /gcc/config/dragonfly.h + /gcc/config/i386/dragonfly-unwind.h /gcc/config/i386/dragonfly.h /gcc/config/i386/dragonfly64.h /gcc/config/i386/i386.c diff --git a/contrib/gcc-4.4/gcc/config/i386/dragonfly-unwind.h b/contrib/gcc-4.4/gcc/config/i386/dragonfly-unwind.h new file mode 100644 index 0000000000..b50d2b21d4 --- /dev/null +++ b/contrib/gcc-4.4/gcc/config/i386/dragonfly-unwind.h @@ -0,0 +1,158 @@ +/* DWARF2 EH unwinding support for DragonFly BSD: AMD x86-64 and x86. + Copyright (C) 2010 John Marino */ + +/* Do code reading to identify a signal frame, and set the frame + state data appropriately. See unwind-dw2.c for the structs. */ + +#include +#include +#include +#include +#include + + +#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg + +#ifdef __x86_64__ +#define MD_FALLBACK_FRAME_STATE_FOR x86_64_dragonfly_fallback_frame_state + + +static void +x86_64_sigtramp_range (unsigned char **start, unsigned char **end) +{ + unsigned long ps_strings; + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + sysctl (mib, 2, &ps_strings, &len, NULL, 0); + + *start = (unsigned char *)ps_strings - 32; + *end = (unsigned char *)ps_strings; +} + + +static _Unwind_Reason_Code +x86_64_dragonfly_fallback_frame_state +(struct _Unwind_Context *context, _Unwind_FrameState *fs) +{ + unsigned char *pc = context->ra; + unsigned char *sigtramp_start, *sigtramp_end; + struct sigframe *sf; + long new_cfa; + + x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end); + if (pc >= sigtramp_end || pc < sigtramp_start) + return _URC_END_OF_STACK; + + sf = (struct sigframe *) context->cfa; + new_cfa = sf->REG_NAME(rsp); + fs->regs.cfa_how = CFA_REG_OFFSET; + /* Register 7 is rsp */ + fs->regs.cfa_reg = 7; + fs->regs.cfa_offset = new_cfa - (long) context->cfa; + + /* The SVR4 register numbering macros aren't usable in libgcc. */ + fs->regs.reg[0].how = REG_SAVED_OFFSET; + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(rax) - new_cfa; + fs->regs.reg[1].how = REG_SAVED_OFFSET; + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(rdx) - new_cfa; + fs->regs.reg[2].how = REG_SAVED_OFFSET; + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(rcx) - new_cfa; + fs->regs.reg[3].how = REG_SAVED_OFFSET; + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(rbx) - new_cfa; + fs->regs.reg[4].how = REG_SAVED_OFFSET; + fs->regs.reg[4].loc.offset = (long)&sf->REG_NAME(rsi) - new_cfa; + fs->regs.reg[5].how = REG_SAVED_OFFSET; + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(rdi) - new_cfa; + fs->regs.reg[6].how = REG_SAVED_OFFSET; + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(rbp) - new_cfa; + fs->regs.reg[8].how = REG_SAVED_OFFSET; + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(r8) - new_cfa; + fs->regs.reg[9].how = REG_SAVED_OFFSET; + fs->regs.reg[9].loc.offset = (long)&sf->REG_NAME(r9) - new_cfa; + fs->regs.reg[10].how = REG_SAVED_OFFSET; + fs->regs.reg[10].loc.offset = (long)&sf->REG_NAME(r10) - new_cfa; + fs->regs.reg[11].how = REG_SAVED_OFFSET; + fs->regs.reg[11].loc.offset = (long)&sf->REG_NAME(r11) - new_cfa; + fs->regs.reg[12].how = REG_SAVED_OFFSET; + fs->regs.reg[12].loc.offset = (long)&sf->REG_NAME(r12) - new_cfa; + fs->regs.reg[13].how = REG_SAVED_OFFSET; + fs->regs.reg[13].loc.offset = (long)&sf->REG_NAME(r13) - new_cfa; + fs->regs.reg[14].how = REG_SAVED_OFFSET; + fs->regs.reg[14].loc.offset = (long)&sf->REG_NAME(r14) - new_cfa; + fs->regs.reg[15].how = REG_SAVED_OFFSET; + fs->regs.reg[15].loc.offset = (long)&sf->REG_NAME(r15) - new_cfa; + fs->regs.reg[16].how = REG_SAVED_OFFSET; + fs->regs.reg[16].loc.offset = (long)&sf->REG_NAME(rip) - new_cfa; + fs->retaddr_column = 16; + fs->signal_frame = 1; + return _URC_NO_REASON; +} + +#else /* Next section is for i386 */ + +#define MD_FALLBACK_FRAME_STATE_FOR x86_dragonfly_fallback_frame_state + + +static void +x86_sigtramp_range (unsigned char **start, unsigned char **end) +{ + unsigned long ps_strings; + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_PS_STRINGS; + len = sizeof (ps_strings); + sysctl (mib, 2, &ps_strings, &len, NULL, 0); + + *start = (unsigned char *)ps_strings - 128; + *end = (unsigned char *)ps_strings; +} + + +static _Unwind_Reason_Code +x86_dragonfly_fallback_frame_state +(struct _Unwind_Context *context, _Unwind_FrameState *fs) +{ + unsigned char *pc = context->ra; + unsigned char *sigtramp_start, *sigtramp_end; + struct sigframe *sf; + long new_cfa; + + x86_sigtramp_range(&sigtramp_start, &sigtramp_end); + + if (pc >= sigtramp_end || pc < sigtramp_start) + return _URC_END_OF_STACK; + + sf = (struct sigframe *) context->cfa; + new_cfa = sf->REG_NAME(esp); + fs->regs.cfa_how = CFA_REG_OFFSET; + fs->regs.cfa_reg = 4; + fs->regs.cfa_offset = new_cfa - (long) context->cfa; + + /* The SVR4 register numbering macros aren't usable in libgcc. */ + fs->regs.reg[0].how = REG_SAVED_OFFSET; + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(eax) - new_cfa; + fs->regs.reg[3].how = REG_SAVED_OFFSET; + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(ebx) - new_cfa; + fs->regs.reg[1].how = REG_SAVED_OFFSET; + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(ecx) - new_cfa; + fs->regs.reg[2].how = REG_SAVED_OFFSET; + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(edx) - new_cfa; + fs->regs.reg[6].how = REG_SAVED_OFFSET; + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(esi) - new_cfa; + fs->regs.reg[7].how = REG_SAVED_OFFSET; + fs->regs.reg[7].loc.offset = (long)&sf->REG_NAME(edi) - new_cfa; + fs->regs.reg[5].how = REG_SAVED_OFFSET; + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(ebp) - new_cfa; + fs->regs.reg[8].how = REG_SAVED_OFFSET; + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(eip) - new_cfa; + fs->retaddr_column = 8; + fs->signal_frame = 1; + return _URC_NO_REASON; +} +#endif /* ifdef __x86_64__ */ diff --git a/contrib/gcc-4.4/gcc/config/i386/dragonfly.h b/contrib/gcc-4.4/gcc/config/i386/dragonfly.h index 52eeea3203..bbe79e3d7a 100644 --- a/contrib/gcc-4.4/gcc/config/i386/dragonfly.h +++ b/contrib/gcc-4.4/gcc/config/i386/dragonfly.h @@ -94,4 +94,4 @@ along with GCC; see the file COPYING3. If not see /*#define STACK_CHECK_STATIC_BUILTIN 1 */ /* Define location of OS-specific unwind support configuration. */ -/* #define MD_UNWIND_SUPPORT "config/i386/dragonfly-unwind.h" */ +#define MD_UNWIND_SUPPORT "config/i386/dragonfly-unwind.h" diff --git a/contrib/gcc-4.4/gcc/crtstuff.c b/contrib/gcc-4.4/gcc/crtstuff.c index 884a2a5e6e..575f1558b1 100644 --- a/contrib/gcc-4.4/gcc/crtstuff.c +++ b/contrib/gcc-4.4/gcc/crtstuff.c @@ -81,20 +81,11 @@ call_ ## FUNC (void) \ } #endif -#if defined(OBJECT_FORMAT_ELF) \ - && !defined(OBJECT_FORMAT_FLAT) \ - && defined(HAVE_LD_EH_FRAME_HDR) \ - && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \ - && defined(__GLIBC__) && __GLIBC__ >= 2 +#if defined(__DragonFly__) /* implement dl_iterate_phdr EH */ #include -/* uClibc pretends to be glibc 2.2 and DT_CONFIG is defined in its link.h. - But it doesn't use PT_GNU_EH_FRAME ELF segment currently. */ -# if !defined(__UCLIBC__) \ - && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) -# define USE_PT_GNU_EH_FRAME -# endif +#define USE_PT_GNU_EH_FRAME #endif + #if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME) # define USE_EH_FRAME_REGISTRY #endif diff --git a/contrib/gcc-4.4/gcc/unwind-dw2-fde-glibc.c b/contrib/gcc-4.4/gcc/unwind-dw2-fde-glibc.c index d246ae1249..220afc0f99 100644 --- a/contrib/gcc-4.4/gcc/unwind-dw2-fde-glibc.c +++ b/contrib/gcc-4.4/gcc/unwind-dw2-fde-glibc.c @@ -32,9 +32,7 @@ #include "tconfig.h" #include "tsystem.h" -#ifndef inhibit_libc #include -#endif #include "coretypes.h" #include "tm.h" #include "dwarf2.h" @@ -45,9 +43,9 @@ #include "unwind-compat.h" #include "gthr.h" -#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))) +#if defined(__DragonFly__) + +#define ElfW __ElfN #ifndef __RELOC_POINTER # define __RELOC_POINTER(ptr, base) ((ptr) + (base)) diff --git a/gnu/lib/gcc44/libgcc/Makefile b/gnu/lib/gcc44/libgcc/Makefile index 32c200b03c..4091918e9c 100644 --- a/gnu/lib/gcc44/libgcc/Makefile +++ b/gnu/lib/gcc44/libgcc/Makefile @@ -38,7 +38,7 @@ SRCS+= ${FUNCS:S/$/.c/g} CLEANFILES+= ${FUNCS:S/$/.c/g} # LIB2ADDEH, gcc/Makefile -SRCS+= unwind-dw2.c unwind-dw2-fde.c unwind-sjlj.c +SRCS+= unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c SRCS+= gthr-gnat.c unwind-c.c SRCS+= unwind.h diff --git a/gnu/usr.bin/cc44/Makefile.inc b/gnu/usr.bin/cc44/Makefile.inc index c3fcafcc06..0e619a88d0 100644 --- a/gnu/usr.bin/cc44/Makefile.inc +++ b/gnu/usr.bin/cc44/Makefile.inc @@ -1,7 +1,7 @@ .if !target(____) ____: -GCCCOMPLETEVER= 4.4.5 +GCCCOMPLETEVER= 4.4.6 GCCPOINTVER= ${GCCCOMPLETEVER:R} GCCSHORTVER= ${GCCPOINTVER:S/.//} diff --git a/gnu/usr.bin/cc44/cc_prep/auto-host.h b/gnu/usr.bin/cc44/cc_prep/auto-host.h index 4c4ae5a323..25fb996ef8 100644 --- a/gnu/usr.bin/cc44/cc_prep/auto-host.h +++ b/gnu/usr.bin/cc44/cc_prep/auto-host.h @@ -197,7 +197,7 @@ /* Define if your assembler supports the --debug-prefix-map option. */ #ifndef USED_FOR_TARGET -/* #undef HAVE_AS_DEBUG_PREFIX_MAP */ +#define HAVE_AS_DEBUG_PREFIX_MAP 1 #endif @@ -852,13 +852,13 @@ /* Define 0/1 if your assembler supports .cfi_personality. */ #ifndef USED_FOR_TARGET -#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 0 +#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 1 #endif /* Define 0/1 if your assembler supports .cfi_sections. */ #ifndef USED_FOR_TARGET -#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0 +#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 1 #endif -- 2.41.0