summaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-21 11:08:58 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-21 11:08:58 +0000
commit463553dbd6573d1fd41d24aa1aac8e83bc95e3d6 (patch)
tree03facded16790b6c727201147904c9c4862b73cc /libgcc
parentc51f754b281732cea699c7cc2595a0d0c8cc6300 (diff)
downloadgcc-463553dbd6573d1fd41d24aa1aac8e83bc95e3d6.tar.gz
2014-05-21 John Marino <gnugcc@marino.st>
gcc: * config.gcc (*-*-dragonfly*): New target. * configure.ac: Detect dl_iterate_phdr (*freebsd*, *dragonfly*). * configure: Regenerate. * config/dragonfly-stdint.h: New. * config/dragonfly.h: New. * config/dragonfly.opt: New. * config/i386/dragonfly.h: New. * ginclude/stddef.h: Detect _PTRDIFF_T_DECLARED for DragonFly. include: * liberty.h: Use basename function on DragonFly. libcilkrts: * runtime/os-unix.c (__DragonFly__): New target. libgcc: * config.host (*-*-dragonfly*): New target. * crtstuff.c: Make dl_iterate_support generic on *bsd. * enable-execute-stack-mprotect.c: Always mprotect on FreeBSD. * unwind-dw2-fde-dip.c: Add dl_iterate_phr support for DragonFly. * config/i386/dragonfly-unwind.h: New. libitm: * configure.tgt (*-*-dragonfly*): New target. libstdc++-v3: * acinclude.m4 (*-*-dragonfly*): New target. * configure: Regenerate. * configure.host (*-*-dragonfly*): New target. * config/locale/dragonfly/c_locale.cc: New. * config/locale/dragonfly/ctype_members.cc: New. * config/os/bsd/dragonfly/ctype_base.h: New. * config/os/bsd/dragonfly/ctype_configure_char.cc: New. * config/os/bsd/dragonfly/ctype_inline.h: New. * config/os/bsd/dragonfly/os_defines.h: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/ChangeLog8
-rw-r--r--libgcc/config.host17
-rw-r--r--libgcc/config/i386/dragonfly-unwind.h180
-rw-r--r--libgcc/crtstuff.c7
-rw-r--r--libgcc/enable-execute-stack-mprotect.c15
-rw-r--r--libgcc/unwind-dw2-fde-dip.c3
6 files changed, 213 insertions, 17 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index c912c8c7b8a..d7b93e8215b 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,11 @@
+2014-05-20 John Marino <gnugcc@marino.st>
+
+ * config.host (*-*-dragonfly*): New target.
+ * crtstuff.c: Make dl_iterate_support generic on *bsd.
+ * enable-execute-stack-mprotect.c: Always mprotect on FreeBSD.
+ * unwind-dw2-fde-dip.c: Add dl_iterate_phr support for DragonFly.
+ * config/i386/dragonfly-unwind.h: New.
+
2014-05-21 Maciej W. Rozycki <macro@codesourcery.com>
PR libgcc/60166
diff --git a/libgcc/config.host b/libgcc/config.host
index f4a74287293..5f13a9f18bf 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -207,6 +207,11 @@ case ${host} in
tmake_file="$tmake_file t-darwin ${cpu_type}/t-darwin t-libgcc-pic t-slibgcc-darwin"
extra_parts="crt3.o crttms.o crttme.o"
;;
+*-*-dragonfly*)
+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
+ tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
+ ;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
@@ -302,7 +307,8 @@ case ${host} in
esac
case ${host} in
-*-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-openbsd* | *-*-solaris2*)
+*-*-darwin* | *-*-dragonfly* | *-*-freebsd* | *-*-netbsd* | *-*-openbsd* | \
+ *-*-solaris2*)
enable_execute_stack=enable-execute-stack-mprotect.c
;;
i[34567]86-*-mingw* | x86_64-*-mingw*)
@@ -545,6 +551,14 @@ i[34567]86-*-elf*)
x86_64-*-elf*)
tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
;;
+i[34567]86-*-dragonfly*)
+ tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
+ md_unwind_header=i386/dragonfly-unwind.h
+ ;;
+x86_64-*-dragonfly*)
+ tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
+ md_unwind_header=i386/dragonfly-unwind.h
+ ;;
i[34567]86-*-freebsd*)
tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
;;
@@ -1262,6 +1276,7 @@ i[34567]86-*-darwin* | x86_64-*-darwin* | \
i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]* | \
i[34567]86-*-cygwin* | x86_64-*-cygwin* | \
i[34567]86-*-mingw* | x86_64-*-mingw* | \
+ i[34567]86-*-dragonfly* | x86_64-*-dragonfly* | \
i[34567]86-*-freebsd* | x86_64-*-freebsd* | \
i[34567]86-*-openbsd* | x86_64-*-openbsd*)
tmake_file="${tmake_file} t-softfp-tf"
diff --git a/libgcc/config/i386/dragonfly-unwind.h b/libgcc/config/i386/dragonfly-unwind.h
new file mode 100644
index 00000000000..cfea5e313e7
--- /dev/null
+++ b/libgcc/config/i386/dragonfly-unwind.h
@@ -0,0 +1,180 @@
+/* DWARF2 EH unwinding support for DragonFly BSD: AMD x86-64 and x86.
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Contributed by John Marino <gnugcc@marino.st>
+
+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 3, or (at your option)
+any later version.
+
+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.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+/* Do code reading to identify a signal frame, and set the frame
+ state data appropriately. See unwind-dw2.c for the structs. */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <signal.h>
+#include <sys/ucontext.h>
+#include <machine/sigframe.h>
+
+
+#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/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 12bed4b351d..2c56af32d60 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -79,11 +79,16 @@ call_ ## FUNC (void) \
}
#endif
+#if defined(TARGET_DL_ITERATE_PHDR) && \
+ (defined(__DragonFly__) || defined(__FreeBSD__))
+#define BSD_DL_ITERATE_PHDR_AVAILABLE
+#endif
+
#if defined(OBJECT_FORMAT_ELF) \
&& !defined(OBJECT_FORMAT_FLAT) \
&& defined(HAVE_LD_EH_FRAME_HDR) \
&& !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
- && defined(__FreeBSD__) && __FreeBSD__ >= 7
+ && defined(BSD_DL_ITERATE_PHDR_AVAILABLE)
#include <link.h>
# define USE_PT_GNU_EH_FRAME
#endif
diff --git a/libgcc/enable-execute-stack-mprotect.c b/libgcc/enable-execute-stack-mprotect.c
index 096abea2192..e3fb3b60afc 100644
--- a/libgcc/enable-execute-stack-mprotect.c
+++ b/libgcc/enable-execute-stack-mprotect.c
@@ -33,20 +33,7 @@ static int need_enable_exec_stack;
static void check_enabling (void) __attribute__ ((unused));
extern void __enable_execute_stack (void *);
-#if defined __FreeBSD__
-#include <sys/sysctl.h>
-
-static void __attribute__ ((constructor))
-check_enabling (void)
-{
- int prot = 0;
- size_t len = sizeof (prot);
-
- sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0);
- if (prot != STACK_PROT_RWX)
- need_enable_exec_stack = 1;
-}
-#elif defined __sun__ && defined __svr4__
+#if defined __sun__ && defined __svr4__
static void __attribute__ ((constructor))
check_enabling (void)
{
diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index d6c05216587..b7b9f9192f1 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -58,7 +58,8 @@
#endif
#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
- && defined(__FreeBSD__) && __FreeBSD__ >= 7
+ && defined(TARGET_DL_ITERATE_PHDR) \
+ && (defined(__DragonFly__) || defined(__FreeBSD__))
# define ElfW __ElfN
# define USE_PT_GNU_EH_FRAME
#endif