Lines 290-295
Link Here
|
290 |
+#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? UINT64_TYPE : UINT32_TYPE) |
290 |
+#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? UINT64_TYPE : UINT32_TYPE) |
291 |
--- /dev/null |
291 |
--- /dev/null |
292 |
+++ gcc/config/dragonfly.h |
292 |
+++ gcc/config/dragonfly.h |
|
|
293 |
@@ -0,0 +1,141 @@ |
294 |
+/* Base configuration file for all DragonFly targets. |
295 |
+ Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc. |
296 |
+ Copyright (C) 2010-2012 John R. Marino <www.dragonlace.net> |
297 |
+ |
298 |
+This file is part of GCC. |
299 |
+ |
300 |
+GCC is free software; you can redistribute it and/or modify |
301 |
+it under the terms of the GNU General Public License as published by |
302 |
+the Free Software Foundation; either version 3, or (at your option) |
303 |
+any later version. |
304 |
+ |
305 |
+GCC is distributed in the hope that it will be useful, |
306 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
307 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
308 |
+GNU General Public License for more details. |
309 |
+ |
310 |
+You should have received a copy of the GNU General Public License |
311 |
+along with GCC; see the file COPYING3. If not see |
312 |
+<http://www.gnu.org/licenses/>. */ |
313 |
+ |
314 |
+/* Common DragonFly configuration. |
315 |
+ All DragonFly architectures should include this file, which will specify |
316 |
+ their commonalities. |
317 |
+ |
318 |
+ Adapted from gcc/config/freebsd.h by |
319 |
+ Joerg Sonnenberger <joerg@bec.de> |
320 |
+ |
321 |
+ Adapted from gcc/config/i386/freebsd-elf.h by |
322 |
+ David O'Brien <obrien@FreeBSD.org>. |
323 |
+ Further work by David O'Brien <obrien@FreeBSD.org> and |
324 |
+ Loren J. Rittle <ljrittle@acm.org>. */ |
325 |
+ |
326 |
+/* JRM: 15 Nov 2010 |
327 |
+ SWITCH_TAKES_ARG & WORD_SWITCH_TAKES_ARG removed due to poisoning. |
328 |
+ http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02102.html |
329 |
+ http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02373.html */ |
330 |
+ |
331 |
+#undef TARGET_OS_CPP_BUILTINS |
332 |
+#define TARGET_OS_CPP_BUILTINS() \ |
333 |
+ do \ |
334 |
+ { \ |
335 |
+ builtin_define_std ("unix"); \ |
336 |
+ builtin_define ("__DragonFly__"); \ |
337 |
+ builtin_assert ("system=unix"); \ |
338 |
+ builtin_assert ("system=bsd"); \ |
339 |
+ builtin_assert ("system=DragonFly"); \ |
340 |
+ } \ |
341 |
+ while (0) |
342 |
+ |
343 |
+#undef CPP_SPEC |
344 |
+#define CPP_SPEC \ |
345 |
+ "%(cpp_cpu) %(cpp_arch) %{posix:-D_POSIX_SOURCE}" |
346 |
+ |
347 |
+#undef STARTFILE_SPEC |
348 |
+#define STARTFILE_SPEC \ |
349 |
+ "%{!shared: \ |
350 |
+ %{pg:gcrt1.o%s} \ |
351 |
+ %{!pg: \ |
352 |
+ %{p:gcrt1.o%s} \ |
353 |
+ %{!p: \ |
354 |
+ %{profile: gcrt1.o%s} \ |
355 |
+ %{!profile: \ |
356 |
+ %{pie: Scrt1.o%s;:crt1.o%s}}}}} \ |
357 |
+ crti.o%s \ |
358 |
+ %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}" |
359 |
+ |
360 |
+#undef ENDFILE_SPEC |
361 |
+#define ENDFILE_SPEC \ |
362 |
+ "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" |
363 |
+ |
364 |
+#undef LIB_SPEC |
365 |
+#define LIB_SPEC \ |
366 |
+ "%{pthread:-lpthread} -lc" |
367 |
+ |
368 |
+/* Provide a LINK_SPEC appropriate for DragonFly. Here we provide support |
369 |
+ for the special GCC options -static and -shared, which allow us to |
370 |
+ link things in one of these three modes by applying the appropriate |
371 |
+ combinations of options at link-time. |
372 |
+ |
373 |
+ When the -shared link option is used a final link is not being |
374 |
+ done. */ |
375 |
+ |
376 |
+#define DFBSD_LINK_SPEC \ |
377 |
+ "%{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \ |
378 |
+ %{v:-V} \ |
379 |
+ %{assert*} %{R*} %{rpath*} %{defsym*} \ |
380 |
+ %{shared:-Bshareable %{h*} %{soname*}} \ |
381 |
+ %{!shared: \ |
382 |
+ %{!static: \ |
383 |
+ %{rdynamic:-export-dynamic} \ |
384 |
+ -dynamic-linker %(dfbsd_dynamic_linker) \ |
385 |
+ } \ |
386 |
+ %{static:-Bstatic}} \ |
387 |
+ %{!static:--hash-style=both} \ |
388 |
+ %{symbolic:-Bsymbolic}" |
389 |
+ |
390 |
+#undef LINK_SPEC |
391 |
+#define LINK_SPEC DFBSD_LINK_SPEC |
392 |
+ |
393 |
+#define DFBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.2" |
394 |
+ |
395 |
+#if defined(HAVE_LD_EH_FRAME_HDR) |
396 |
+#define LINK_EH_SPEC "--eh-frame-hdr" |
397 |
+#endif |
398 |
+ |
399 |
+/* Use --as-needed -lgcc_s for eh support. */ |
400 |
+#ifdef HAVE_LD_AS_NEEDED |
401 |
+#define USE_LD_AS_NEEDED 1 |
402 |
+#endif |
403 |
+ |
404 |
+/************************[ Target stuff ]***********************************/ |
405 |
+ |
406 |
+/* All DragonFly Architectures support the ELF object file format. */ |
407 |
+#undef OBJECT_FORMAT_ELF |
408 |
+#define OBJECT_FORMAT_ELF |
409 |
+ |
410 |
+/* Don't assume anything about the header files. */ |
411 |
+#undef NO_IMPLICIT_EXTERN_C |
412 |
+#define NO_IMPLICIT_EXTERN_C 1 |
413 |
+ |
414 |
+/* Follow DragonFly's standard headers (<machine/stdint.h>, etc...). */ |
415 |
+ |
416 |
+#undef WCHAR_TYPE |
417 |
+#define WCHAR_TYPE "int" |
418 |
+ |
419 |
+#undef WINT_TYPE |
420 |
+#define WINT_TYPE "int" |
421 |
+ |
422 |
+#define MATH_LIBRARY_PROFILE "m_p" |
423 |
+ |
424 |
+/* Code generation parameters. */ |
425 |
+ |
426 |
+/* Use periods rather than dollar signs in special g++ assembler names. |
427 |
+ This ensures the configuration knows our system correctly so we can link |
428 |
+ with libraries compiled with the native cc. */ |
429 |
+#undef NO_DOLLAR_IN_LABEL |
430 |
+ |
431 |
+/* Used by libgcc2.c. We support file locking with fcntl / F_SETLKW. |
432 |
+ This enables the test coverage code to use file locking when exiting a |
433 |
+ program, which avoids race conditions if the program has forked. */ |
434 |
+#define TARGET_POSIX_IO |
435 |
--- /dev/null |
436 |
+++ gcc/config/dragonfly.h.orig |
293 |
@@ -0,0 +1,139 @@ |
437 |
@@ -0,0 +1,139 @@ |
294 |
+/* Base configuration file for all DragonFly targets. |
438 |
+/* Base configuration file for all DragonFly targets. |
295 |
+ Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc. |
439 |
+ Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc. |
Lines 904-955
Link Here
|
904 |
+ |
1048 |
+ |
905 |
--- /dev/null |
1049 |
--- /dev/null |
906 |
+++ gcc/config/i386/freebsd-unwind.h |
1050 |
+++ gcc/config/i386/freebsd-unwind.h |
907 |
@@ -0,0 +1,184 @@ |
1051 |
@@ -0,0 +1,179 @@ |
908 |
+/* DWARF2 EH unwinding support for FreeBSD: AMD x86-64 and x86. |
1052 |
+/* DWARF2 EH unwinding support for FreeBSD: AMD x86-64 and x86. |
909 |
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. |
1053 |
+ Copyright (C) 2010, 2012 John Marino <draco@marino.st> |
910 |
+ Copyright (C) 2010 John Marino <draco@marino.st> |
|
|
911 |
+ |
912 |
+This file is part of GCC. |
913 |
+ |
914 |
+GCC is free software; you can redistribute it and/or modify |
915 |
+it under the terms of the GNU General Public License as published by |
916 |
+the Free Software Foundation; either version 2, or (at your option) |
917 |
+any later version. |
918 |
+ |
919 |
+In addition to the permissions in the GNU General Public License, the |
920 |
+Free Software Foundation gives you unlimited permission to link the |
921 |
+compiled version of this file with other programs, and to distribute |
922 |
+those programs without any restriction coming from the use of this |
923 |
+file. (The General Public License restrictions do apply in other |
924 |
+respects; for example, they cover modification of the file, and |
925 |
+distribution when not linked into another program.) |
926 |
+ |
927 |
+GCC is distributed in the hope that it will be useful, |
928 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of |
929 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
930 |
+GNU General Public License for more details. |
931 |
+ |
932 |
+You should have received a copy of the GNU General Public License |
933 |
+along with GCC; see the file COPYING. If not, write to |
934 |
+the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
935 |
+Boston, MA 02110-1301, USA. */ |
936 |
+ |
1054 |
+ |
937 |
+/* Do code reading to identify a signal frame, and set the frame |
1055 |
+/* Do code reading to identify a signal frame, and set the frame |
938 |
+ state data appropriately. See unwind-dw2.c for the structs. */ |
1056 |
+ state data appropriately. See unwind-dw2.c for the structs. */ |
939 |
+ |
1057 |
+ |
940 |
+#include <sys/types.h> |
1058 |
+#include <sys/types.h> |
941 |
+#include <sys/sysctl.h> |
|
|
942 |
+#include <signal.h> |
1059 |
+#include <signal.h> |
943 |
+#include <sys/ucontext.h> |
1060 |
+#include <sys/ucontext.h> |
944 |
+#include <machine/sigframe.h> |
1061 |
+#include <machine/sigframe.h> |
945 |
+ |
1062 |
+ |
946 |
+ |
|
|
947 |
+#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg |
1063 |
+#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg |
948 |
+ |
1064 |
+ |
949 |
+#ifdef __x86_64__ |
1065 |
+#ifdef __x86_64__ |
950 |
+#define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state |
1066 |
+#define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state |
951 |
+ |
1067 |
+ |
952 |
+ |
1068 |
+#if (__FreeBSD__ < 9) |
|
|
1069 |
+#include <sys/sysctl.h> |
953 |
+static void |
1070 |
+static void |
954 |
+x86_64_sigtramp_range (unsigned char **start, unsigned char **end) |
1071 |
+x86_64_sigtramp_range (unsigned char **start, unsigned char **end) |
955 |
+{ |
1072 |
+{ |
Lines 965-970
Link Here
|
965 |
+ *start = (unsigned char *)ps_strings - 32; |
1082 |
+ *start = (unsigned char *)ps_strings - 32; |
966 |
+ *end = (unsigned char *)ps_strings; |
1083 |
+ *end = (unsigned char *)ps_strings; |
967 |
+} |
1084 |
+} |
|
|
1085 |
+#endif |
968 |
+ |
1086 |
+ |
969 |
+ |
1087 |
+ |
970 |
+static _Unwind_Reason_Code |
1088 |
+static _Unwind_Reason_Code |
Lines 976-984
Link Here
|
976 |
+ struct sigframe *sf; |
1094 |
+ struct sigframe *sf; |
977 |
+ long new_cfa; |
1095 |
+ long new_cfa; |
978 |
+ |
1096 |
+ |
|
|
1097 |
+#if (__FreeBSD__ < 9) |
979 |
+ x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end); |
1098 |
+ x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end); |
980 |
+ if (pc >= sigtramp_end || pc < sigtramp_start) |
1099 |
+ if (pc >= sigtramp_end || pc < sigtramp_start) |
981 |
+ return _URC_END_OF_STACK; |
1100 |
+ return _URC_END_OF_STACK; |
|
|
1101 |
+#else |
1102 |
+ /* Prior to FreeBSD 9, the signal trampoline was located immediately |
1103 |
+ before the ps_strings. To support non-executable stacks on AMD64, |
1104 |
+ the sigtramp was moved to a shared page for FreeBSD 9. We are |
1105 |
+ stuck looking for frame patterns again (sys/amd64/amd64/sigtramp.S): |
1106 |
+ |
1107 |
+ <pc + 00>: lea 0x10(%rsp),%rdi |
1108 |
+ <pc + 05>: pushq $0x0 |
1109 |
+ <pc + 17>: mov $0x1a1,%rax |
1110 |
+ <pc + 14>: syscall |
1111 |
+ |
1112 |
+ If we can't find this pattern, we're at the end of the stack. |
1113 |
+ */ |
1114 |
+ |
1115 |
+ if (!( *(unsigned int *)(context->ra) == 0x247c8d48 |
1116 |
+ && *(unsigned int *)(context->ra + 4) == 0x48006a10 |
1117 |
+ && *(unsigned int *)(context->ra + 8) == 0x01a1c0c7 |
1118 |
+ && *(unsigned int *)(context->ra + 12) == 0x050f0000 )) |
1119 |
+ return _URC_END_OF_STACK; |
1120 |
+#endif |
982 |
+ |
1121 |
+ |
983 |
+ sf = (struct sigframe *) context->cfa; |
1122 |
+ sf = (struct sigframe *) context->cfa; |
984 |
+ new_cfa = sf->REG_NAME(rsp); |
1123 |
+ new_cfa = sf->REG_NAME(rsp); |
Lines 1029-1035
Link Here
|
1029 |
+ |
1168 |
+ |
1030 |
+#define MD_FALLBACK_FRAME_STATE_FOR x86_freebsd_fallback_frame_state |
1169 |
+#define MD_FALLBACK_FRAME_STATE_FOR x86_freebsd_fallback_frame_state |
1031 |
+ |
1170 |
+ |
1032 |
+ |
1171 |
+#include <sys/sysctl.h> |
1033 |
+static void |
1172 |
+static void |
1034 |
+x86_sigtramp_range (unsigned char **start, unsigned char **end) |
1173 |
+x86_sigtramp_range (unsigned char **start, unsigned char **end) |
1035 |
+{ |
1174 |
+{ |