Date: Sat, 11 Nov 2017 22:04:15 +0000 (UTC) From: Gerald Pfeifer <gerald@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r454006 - in head/lang/gcc7: . files Message-ID: <201711112204.vABM4FA0041227@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gerald Date: Sat Nov 11 22:04:15 2017 New Revision: 454006 URL: https://svnweb.freebsd.org/changeset/ports/454006 Log: Add a patch that we just pulled into gcc7-devel via upstream that addresses a real-world issue around threading and unwinding as files/patch-freebsd-unwind.h . This will become obsolete with the next release of GCC 7, GCC 7.3. Bump PORTREVISION since this is a functional change. Added: head/lang/gcc7/files/patch-freebsd-unwind.h (contents, props changed) Modified: head/lang/gcc7/Makefile Modified: head/lang/gcc7/Makefile ============================================================================== --- head/lang/gcc7/Makefile Sat Nov 11 21:55:19 2017 (r454005) +++ head/lang/gcc7/Makefile Sat Nov 11 22:04:15 2017 (r454006) @@ -3,7 +3,7 @@ PORTNAME= gcc PORTVERSION= 7.2.0 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= lang MASTER_SITES= GCC/releases/gcc-${DISTVERSION} PKGNAMESUFFIX= ${SUFFIX} Added: head/lang/gcc7/files/patch-freebsd-unwind.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lang/gcc7/files/patch-freebsd-unwind.h Sat Nov 11 22:04:15 2017 (r454006) @@ -0,0 +1,90 @@ +2017-11-05 Andreas Tobler <andreast@gcc.gnu.org> + + Backport from mainline + 2017-11-04 Andreas Tobler <andreast@gcc.gnu.org> + + PR libgcc/82635 + * config/i386/freebsd-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Use a + sysctl to determine whether we're in a trampoline. + Keep the pattern matching method for systems without + KERN_PROC_SIGTRAMP sysctl. + +--- UTC +--- libgcc/config/i386/freebsd-unwind.h 2017/11/05 17:24:37 254430 ++++ libgcc/config/i386/freebsd-unwind.h 2017/11/05 19:30:41 254431 +@@ -28,7 +28,10 @@ + + #include <sys/types.h> + #include <signal.h> ++#include <unistd.h> ++#include <sys/sysctl.h> + #include <sys/ucontext.h> ++#include <sys/user.h> + #include <machine/sigframe.h> + + #define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg +@@ -36,6 +39,38 @@ + #ifdef __x86_64__ + #define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state + ++#ifdef KERN_PROC_SIGTRAMP ++/* FreeBSD past 9.3 provides a kern.proc.sigtramp.<pid> sysctl that ++ returns the location of the signal trampoline. Use this to find ++ out whether we're in a trampoline. ++*/ ++static int ++x86_64_outside_sigtramp_range (unsigned char *pc) ++{ ++ static int sigtramp_range_determined = 0; ++ static unsigned char *sigtramp_start, *sigtramp_end; ++ ++ if (sigtramp_range_determined == 0) ++ { ++ struct kinfo_sigtramp kst = {0}; ++ size_t len = sizeof (kst); ++ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_SIGTRAMP, getpid() }; ++ ++ sigtramp_range_determined = 1; ++ if (sysctl (mib, 4, &kst, &len, NULL, 0) == 0) ++ { ++ sigtramp_range_determined = 2; ++ sigtramp_start = kst.ksigtramp_start; ++ sigtramp_end = kst.ksigtramp_end; ++ } ++ } ++ if (sigtramp_range_determined < 2) /* sysctl failed if < 2 */ ++ return 1; ++ ++ return (pc < sigtramp_start || pc >= sigtramp_end); ++} ++#endif ++ + static _Unwind_Reason_Code + x86_64_freebsd_fallback_frame_state + (struct _Unwind_Context *context, _Unwind_FrameState *fs) +@@ -43,6 +78,7 @@ + struct sigframe *sf; + long new_cfa; + ++#ifndef KERN_PROC_SIGTRAMP + /* Prior to FreeBSD 9, the signal trampoline was located immediately + before the ps_strings. To support non-executable stacks on AMD64, + the sigtramp was moved to a shared page for FreeBSD 9. Unfortunately +@@ -62,12 +98,15 @@ + && *(unsigned int *)(context->ra + 8) == 0x01a1c0c7 + && *(unsigned int *)(context->ra + 12) == 0x050f0000 )) + return _URC_END_OF_STACK; ++#else ++ if (x86_64_outside_sigtramp_range(context->ra)) ++ return _URC_END_OF_STACK; ++#endif + + 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_reg = __LIBGCC_STACK_POINTER_REGNUM__; + fs->regs.cfa_offset = new_cfa - (long) context->cfa; + + /* The SVR4 register numbering macros aren't usable in libgcc. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711112204.vABM4FA0041227>