5 --- gcc/config.gcc.orig
12 + # Let these non-posix thread selections fall through if requested
15 echo 'Unknown thread configuration for FreeBSD'
18 # need_64bit_hwint=yes # system compiler has this for all arch!
24 + tmake_file="t-slibgcc"
25 + case ${enable_threads} in
30 + # Let these non-posix thread selections fall through if requested
33 + echo 'Unknown thread configuration for DragonFly BSD'
37 + extra_options="$extra_options rpath.opt dragonfly.opt"
38 + default_use_cxa_atexit=yes
41 *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu)
42 extra_options="$extra_options gnu-user.opt"
49 tmake_file="t-slibgcc"
53 tm_file="dbxelf.h elfos.h newlib-stdint.h arm/unknown-elf.h arm/elf.h arm/aout.h arm/arm.h arm/ecos-elf.h"
54 tmake_file="arm/t-arm arm/t-arm-elf"
56 -arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtemseabi*)
60 + case ${enable_threads} in
61 + "" | yes | posix) thread_file='posix' ;;
63 + tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h"
64 + tm_file="$tm_file arm/elf.h arm/linux-gas.h arm/linux-elf.h arm/bpabi.h arm/linux-eabi.h"
65 + tm_file="$tm_file ../../libgcc/config/arm/bpabi-lib.h arm/aout.h arm/arm.h"
67 + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC ANDROID_DEFAULT=1"
70 + tm_defines="$tm_defines TARGET_BIG_ENDIAN_DEFAULT=1"
73 + extra_options="$extra_options linux.opt linux-android.opt"
74 + default_use_cxa_atexit=yes
78 + # The BPABI long long divmod functions return a 128-bit value in registers r0-r3.
79 + # Correctly modeling that requires the use of TImode.
80 + need_64bit_hwint=yes
82 +arm*-*-symbianelf* | arm*-*-rtemseabi*)
83 # The BPABI long long divmod functions return a 128-bit value in
84 # registers r0-r3. Correctly modeling that requires the use of
87 tm_file="dbxelf.h elfos.h arm/unknown-elf.h arm/elf.h arm/bpabi.h"
88 tmake_file="arm/t-arm arm/t-arm-elf"
91 - tm_file="$tm_file newlib-stdint.h"
92 - tmake_file="${tmake_file} arm/t-bpabi"
96 tm_file="${tm_file} rtems.h arm/rtems-eabi.h newlib-stdint.h"
97 tmake_file="${tmake_file} arm/t-bpabi t-rtems arm/t-rtems-eabi"
98 @@ -1196,19 +1240,31 @@
100 tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
102 +i[34567]86-*-dragonfly*)
103 + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h dragonfly.h dragonfly-stdint.h i386/dragonfly.h"
104 + tmake_file="${tmake_file} i386/t-crtstuff"
106 +x86_64-*-dragonfly*)
107 + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h dragonfly.h dragonfly-stdint.h i386/x86-64.h i386/dragonfly.h"
108 + tmake_file="${tmake_file} i386/t-crtstuff"
110 i[34567]86-*-freebsd*)
111 tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/freebsd.h"
112 + tmake_file="${tmake_file} i386/t-crtstuff"
115 tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h"
116 + tmake_file="${tmake_file} i386/t-crtstuff"
118 i[34567]86-*-netbsdelf*)
119 - tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h"
120 + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h netbsd-stdint.h"
121 extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
122 + tmake_file="${tmake_file} i386/t-crtstuff"
125 - tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h"
126 + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h netbsd-stdint.h"
127 extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
128 + tmake_file="${tmake_file} i386/t-crtstuff"
130 i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
131 tm_file="i386/i386.h i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h openbsd-oldgas.h openbsd.h i386/openbsd.h"
132 @@ -3530,6 +3586,8 @@
134 i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*)
136 + i[34567]86-*-dragonfly* | x86_64-*-dragonfly*)
138 i[34567]86-*-freebsd* | x86_64-*-freebsd*)
142 +++ gcc/config/dragonfly-stdint.h
144 +/* Definitions for <stdint.h> types for DragonFly systems.
145 + Copyright (C) 2009 Free Software Foundation, Inc.
146 + Contributed by Gerald Pfeifer <gerald@pfeifer.com>.
148 +This file is part of GCC.
150 +GCC is free software; you can redistribute it and/or modify
151 +it under the terms of the GNU General Public License as published by
152 +the Free Software Foundation; either version 3, or (at your option)
155 +GCC is distributed in the hope that it will be useful,
156 +but WITHOUT ANY WARRANTY; without even the implied warranty of
157 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
158 +GNU General Public License for more details.
160 +Under Section 7 of GPL version 3, you are granted additional
161 +permissions described in the GCC Runtime Library Exception, version
162 +3.1, as published by the Free Software Foundation.
164 +You should have received a copy of the GNU General Public License and
165 +a copy of the GCC Runtime Library Exception along with this program;
166 +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
167 +<http://www.gnu.org/licenses/>. */
169 +#define SIG_ATOMIC_TYPE "int"
171 +#define INT8_TYPE "signed char"
172 +#define INT16_TYPE "short int"
173 +#define INT32_TYPE "int"
174 +#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
175 +#define UINT8_TYPE "unsigned char"
176 +#define UINT16_TYPE "short unsigned int"
177 +#define UINT32_TYPE "unsigned int"
178 +#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
180 +#define INT_LEAST8_TYPE INT8_TYPE
181 +#define INT_LEAST16_TYPE INT16_TYPE
182 +#define INT_LEAST32_TYPE INT32_TYPE
183 +#define INT_LEAST64_TYPE INT64_TYPE
184 +#define UINT_LEAST8_TYPE UINT8_TYPE
185 +#define UINT_LEAST16_TYPE UINT16_TYPE
186 +#define UINT_LEAST32_TYPE UINT32_TYPE
187 +#define UINT_LEAST64_TYPE UINT64_TYPE
189 +#define INT_FAST8_TYPE INT32_TYPE
190 +#define INT_FAST16_TYPE INT32_TYPE
191 +#define INT_FAST32_TYPE INT32_TYPE
192 +#define INT_FAST64_TYPE INT64_TYPE
193 +#define UINT_FAST8_TYPE UINT32_TYPE
194 +#define UINT_FAST16_TYPE UINT32_TYPE
195 +#define UINT_FAST32_TYPE UINT32_TYPE
196 +#define UINT_FAST64_TYPE UINT64_TYPE
198 +#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? INT64_TYPE : INT32_TYPE)
199 +#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? UINT64_TYPE : UINT32_TYPE)
201 +++ gcc/config/dragonfly.h
203 +/* Base configuration file for all DragonFly targets.
204 + Copyright (C) 1999, 2000, 2001, 2007, 2008 Free Software Foundation, Inc.
206 +This file is part of GCC.
208 +GCC is free software; you can redistribute it and/or modify
209 +it under the terms of the GNU General Public License as published by
210 +the Free Software Foundation; either version 3, or (at your option)
213 +GCC is distributed in the hope that it will be useful,
214 +but WITHOUT ANY WARRANTY; without even the implied warranty of
215 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
216 +GNU General Public License for more details.
218 +You should have received a copy of the GNU General Public License
219 +along with GCC; see the file COPYING3. If not see
220 +<http://www.gnu.org/licenses/>. */
222 +/* Common DragonFly configuration.
223 + All DragonFly architectures should include this file, which will specify
224 + their commonalities.
225 + Adapted from gcc/config/i386/freebsd-elf.h by
226 + David O'Brien <obrien@FreeBSD.org>.
227 + Further work by David O'Brien <obrien@FreeBSD.org> and
228 + Loren J. Rittle <ljrittle@acm.org>. */
230 +#undef TARGET_OS_CPP_BUILTINS
231 +#define TARGET_OS_CPP_BUILTINS() \
234 + builtin_define_std ("unix"); \
235 + builtin_define ("__DragonFly__"); \
236 + builtin_assert ("system=unix"); \
237 + builtin_assert ("system=bsd"); \
238 + builtin_assert ("system=DragonFly"); \
244 + "%(cpp_cpu) %(cpp_arch) %{posix:-D_POSIX_SOURCE}"
246 +#undef STARTFILE_SPEC
247 +#define STARTFILE_SPEC \
253 + %{profile: gcrt1.o%s} \
255 + %{pie: Scrt1.o%s;:crt1.o%s}}}}} \
257 + %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
260 +#define ENDFILE_SPEC \
261 + "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
265 + "%{pthread:-lpthread} -lc"
267 +#if defined(HAVE_LD_EH_FRAME_HDR)
268 +#define LINK_EH_SPEC "--eh-frame-hdr"
271 +/* Provide a LINK_SPEC appropriate for DragonFly. Here we provide support
272 + for the special GCC options -static and -shared, which allow us to
273 + link things in one of these three modes by applying the appropriate
274 + combinations of options at link-time.
276 + When the -shared link option is used a final link is not being
279 +#define DFBSD_LINK_SPEC \
280 + "%{p:%nconsider using '-pg' instead of '-p' with gprof(1)} \
282 + %{assert*} %{R*} %{rpath*} %{defsym*} \
283 + %{shared:-Bshareable %{h*} %{soname*}} \
286 + %{rdynamic:-export-dynamic} \
287 + -dynamic-linker %(dfbsd_dynamic_linker) \
289 + %{static:-Bstatic} \
291 + %{!static:--hash-style=both -rpath @PREFIX@/gcc-aux/lib} \
292 + %{symbolic:-Bsymbolic}"
295 +#define LINK_SPEC DFBSD_LINK_SPEC
297 +#define DFBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.2"
300 +/* Use --as-needed -lgcc_s for eh support. */
301 +#ifdef HAVE_LD_AS_NEEDED
302 +#define USE_LD_AS_NEEDED 1
305 +/************************[ Target stuff ]***********************************/
307 +/* All DragonFly Architectures support the ELF object file format. */
308 +#undef OBJECT_FORMAT_ELF
309 +#define OBJECT_FORMAT_ELF
311 +/* Don't assume anything about the header files. */
312 +#undef NO_IMPLICIT_EXTERN_C
313 +#define NO_IMPLICIT_EXTERN_C 1
315 +/* Follow DragonFly's standard headers (<machine/stdint.h>, etc...). */
318 +#define WCHAR_TYPE "int"
321 +#define WINT_TYPE "int"
324 + * Profile libraries are found at /usr/lib/profile with standard names
325 + * #define MATH_LIBRARY_PROFILE "m_p"
328 +/* Code generation parameters. */
330 +/* Use periods rather than dollar signs in special g++ assembler names.
331 + This ensures the configuration knows our system correctly so we can link
332 + with libraries compiled with the native cc. */
333 +#undef NO_DOLLAR_IN_LABEL
335 +/* Used by libgcc2.c. We support file locking with fcntl / F_SETLKW.
336 + This enables the test coverage code to use file locking when exiting a
337 + program, which avoids race conditions if the program has forked. */
338 +#define TARGET_POSIX_IO
340 +++ gcc/config/dragonfly.opt
342 +; DragonFlyBSD options.
344 +; Copyright (C) 2010, 2011
345 +; Free Software Foundation, Inc.
347 +; This file is part of GCC.
349 +; GCC is free software; you can redistribute it and/or modify it under
350 +; the terms of the GNU General Public License as published by the Free
351 +; Software Foundation; either version 3, or (at your option) any later
354 +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
355 +; WARRANTY; without even the implied warranty of MERCHANTABILITY or
356 +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359 +; You should have received a copy of the GNU General Public License
360 +; along with GCC; see the file COPYING3. If not see
361 +; <http://www.gnu.org/licenses/>.
363 +; See the GCC internals manual (options.texi) for a description of this file's format.
365 +; Please try to keep this file in ASCII collating order.
371 +Driver JoinedOrMissing
377 +Driver JoinedOrMissing
395 +Driver JoinedOrMissing
398 +Driver JoinedOrMissing
404 +Driver JoinedOrMissing
406 +; This comment is to ensure we retain the blank line above.
408 +++ gcc/config/netbsd-stdint.h
410 +/* Definitions for <stdint.h> types for NetBSD systems.
411 + Copyright (C) 2009 Free Software Foundation, Inc.
412 + Contributed by Gerald Pfeifer <gerald@pfeifer.com>.
414 +This file is part of GCC.
416 +GCC is free software; you can redistribute it and/or modify
417 +it under the terms of the GNU General Public License as published by
418 +the Free Software Foundation; either version 3, or (at your option)
421 +GCC is distributed in the hope that it will be useful,
422 +but WITHOUT ANY WARRANTY; without even the implied warranty of
423 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424 +GNU General Public License for more details.
426 +Under Section 7 of GPL version 3, you are granted additional
427 +permissions described in the GCC Runtime Library Exception, version
428 +3.1, as published by the Free Software Foundation.
430 +You should have received a copy of the GNU General Public License and
431 +a copy of the GCC Runtime Library Exception along with this program;
432 +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
433 +<http://www.gnu.org/licenses/>. */
435 +#define SIG_ATOMIC_TYPE "int"
437 +#define INT8_TYPE "signed char"
438 +#define INT16_TYPE "short int"
439 +#define INT32_TYPE "int"
440 +#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
441 +#define UINT8_TYPE "unsigned char"
442 +#define UINT16_TYPE "short unsigned int"
443 +#define UINT32_TYPE "unsigned int"
444 +#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
446 +#define INT_LEAST8_TYPE "signed char"
447 +#define INT_LEAST16_TYPE "short int"
448 +#define INT_LEAST32_TYPE "int"
449 +#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
450 +#define UINT_LEAST8_TYPE "unsigned char"
451 +#define UINT_LEAST16_TYPE "short unsigned int"
452 +#define UINT_LEAST32_TYPE "unsigned int"
453 +#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
455 +#define INT_FAST8_TYPE "int"
456 +#define INT_FAST16_TYPE "int"
457 +#define INT_FAST32_TYPE "int"
458 +#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
459 +#define UINT_FAST8_TYPE "unsigned int"
460 +#define UINT_FAST16_TYPE "unsigned int"
461 +#define UINT_FAST32_TYPE "unsigned int"
462 +#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
464 +#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
465 +#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
467 +++ gcc/config/i386/dragonfly.h
469 +/* Definitions for Intel 386 running DragonFly with ELF format
470 + Copyright (C) 1996, 2000, 2002, 2004, 2007, 2010, 2011
471 + Free Software Foundation, Inc.
472 + Contributed by Eric Youngdale.
473 + Modified for stabs-in-ELF by H.J. Lu.
474 + Adapted from GNU/Linux version by John Polstra.
475 + Continued development by David O'Brien <obrien@freebsd.org>
477 +This file is part of GCC.
479 +GCC is free software; you can redistribute it and/or modify
480 +it under the terms of the GNU General Public License as published by
481 +the Free Software Foundation; either version 3, or (at your option)
484 +GCC is distributed in the hope that it will be useful,
485 +but WITHOUT ANY WARRANTY; without even the implied warranty of
486 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
487 +GNU General Public License for more details.
489 +You should have received a copy of the GNU General Public License
490 +along with GCC; see the file COPYING3. If not see
491 +<http://www.gnu.org/licenses/>. */
494 +/* Override the default comment-starter of "/". */
495 +#undef ASM_COMMENT_START
496 +#define ASM_COMMENT_START "#"
499 +#define ASM_APP_ON "#APP\n"
502 +#define ASM_APP_OFF "#NO_APP\n"
504 +#undef DBX_REGISTER_NUMBER
505 +#define DBX_REGISTER_NUMBER(n) \
506 + (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
508 +#undef NO_PROFILE_COUNTERS
509 +#define NO_PROFILE_COUNTERS 1
511 +/* Tell final.c that we don't need a label passed to mcount. */
514 +#define MCOUNT_NAME ".mcount"
516 +/* Make gcc agree with <machine/ansi.h>. */
519 +#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
522 +#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
524 +#undef WCHAR_TYPE_SIZE
525 +#define WCHAR_TYPE_SIZE (TARGET_64BIT ? 32 : BITS_PER_WORD)
527 +#undef SUBTARGET_EXTRA_SPECS /* i386.h bogusly defines it. */
528 +#define SUBTARGET_EXTRA_SPECS \
529 + { "dfbsd_dynamic_linker", DFBSD_DYNAMIC_LINKER }
532 +/* A C statement to output to the stdio stream FILE an assembler
533 + command to advance the location counter to a multiple of 1<<LOG
534 + bytes if it is within MAX_SKIP bytes.
536 + This is used to align code labels according to Intel recommendations. */
538 +#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
539 +#undef ASM_OUTPUT_MAX_SKIP_ALIGN
540 +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
541 + if ((LOG) != 0) { \
542 + if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
543 + else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
547 +/* Don't default to pcc-struct-return, we want to retain compatibility with
548 + older gcc versions AND pcc-struct-return is nonreentrant.
549 + (even though the SVR4 ABI for the i386 says that records and unions are
550 + returned in memory). */
552 +#undef DEFAULT_PCC_STRUCT_RETURN
553 +#define DEFAULT_PCC_STRUCT_RETURN 0
555 +/* DragonFly sets the rounding precision of the FPU to 53 bits. Let the
556 + compiler get the contents of <float.h> and std::numeric_limits correct. */
557 +#undef TARGET_96_ROUND_53_LONG_DOUBLE
558 +#define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
560 +/* Put all *tf routines in libgcc. */
561 +#undef LIBGCC2_HAS_TF_MODE
562 +#define LIBGCC2_HAS_TF_MODE 1
563 +#define LIBGCC2_TF_CEXT q
566 +/* Static stack checking is supported by means of probes. */
567 +#define STACK_CHECK_STATIC_BUILTIN 1
569 +/* Support for i386 has been removed from DragonFly for several releases */
570 +#define SUBTARGET32_DEFAULT_CPU "i486"
572 +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
574 --- gcc/config/i386/freebsd.h.orig
575 +++ gcc/config/i386/freebsd.h
577 %{rdynamic:-export-dynamic} \
578 -dynamic-linker %(fbsd_dynamic_linker) } \
579 %{static:-Bstatic}} \
580 + %{!static:--hash-style=both -rpath @PREFIX@/gcc-aux/lib} \
581 %{symbolic:-Bsymbolic}"
583 /* A C statement to output to the stdio stream FILE an assembler
586 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
588 +/* Compile in __enable_execute_stack (void *) (see config.host) */
589 +#define HAVE_ENABLE_EXECUTE_STACK
590 --- gcc/config/i386/netbsd-elf.h.orig
591 +++ gcc/config/i386/netbsd-elf.h
593 /* Provide a LINK_SPEC appropriate for a NetBSD/i386 ELF target. */
596 -#define LINK_SPEC NETBSD_LINK_SPEC_ELF
597 +#define LINK_SPEC NETBSD_LINK_SPEC_ELF \
598 +"%{!static:-rpath @PREFIX@/gcc-aux/lib}"
600 #define NETBSD_ENTRY_POINT "__start"
603 #define DEFAULT_PCC_STRUCT_RETURN 1
605 #define HAVE_ENABLE_EXECUTE_STACK
606 +/* Define this to be nonzero if static stack checking is supported. */
607 +#define STACK_CHECK_STATIC_BUILTIN 1
609 +#if defined(HAVE_LD_EH_FRAME_HDR)
610 +#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
612 --- gcc/config/i386/netbsd64.h.orig
613 +++ gcc/config/i386/netbsd64.h
617 #define HAVE_ENABLE_EXECUTE_STACK
619 +/* Define this to be nonzero if static stack checking is supported. */
620 +#define STACK_CHECK_STATIC_BUILTIN 1
622 +#if defined(HAVE_LD_EH_FRAME_HDR)
623 +#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
625 --- gcc/ginclude/stddef.h.orig
626 +++ gcc/ginclude/stddef.h
628 one less case to deal with in the following. */
629 #if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)
630 #include <machine/ansi.h>
631 +#if !defined(_MACHINE_ANSI_H_)
632 +#if defined(_I386_ANSI_H_) || defined(_X86_64_ANSI_H_)
633 +#define _MACHINE_ANSI_H_
637 /* On FreeBSD 5, machine/ansi.h does not exist anymore... */
638 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
639 #include <sys/_types.h>
642 +#if defined(__DragonFly__)
643 +#include <sys/types.h>
646 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
647 defined if the corresponding type is *not* defined.
648 FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.
650 #ifndef _BSD_PTRDIFF_T_
651 #ifndef ___int_ptrdiff_t_h
652 #ifndef _GCC_PTRDIFF_T
653 +#ifndef _PTRDIFF_T_DECLARED /* DragonFly */
657 @@ -144,10 +154,12 @@
658 #define _BSD_PTRDIFF_T_
659 #define ___int_ptrdiff_t_h
660 #define _GCC_PTRDIFF_T
661 +#define _PTRDIFF_T_DECLARED
662 #ifndef __PTRDIFF_TYPE__
663 #define __PTRDIFF_TYPE__ long int
665 typedef __PTRDIFF_TYPE__ ptrdiff_t;
666 +#endif /* _PTRDIFF_T_DECLARED */
667 #endif /* _GCC_PTRDIFF_T */
668 #endif /* ___int_ptrdiff_t_h */
669 #endif /* _BSD_PTRDIFF_T_ */
673 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
674 + || defined(__DragonFly__) \
675 || defined(__FreeBSD_kernel__)
676 /* __size_t is a typedef on FreeBSD 5, must not trash it. */
679 /* FreeBSD 5 can't be handled well using "traditional" logic above
680 since it no longer defines _BSD_RUNE_T_ yet still desires to export
681 rune_t in some cases... */
682 -#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
683 +#if defined (__DragonFly__) || (defined (__FreeBSD__) && (__FreeBSD__ >= 5))
684 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
686 #ifndef _RUNE_T_DECLARED
687 --- include/libiberty.h.orig
688 +++ include/libiberty.h
690 to find the declaration so provide a fully prototyped one. If it
691 is 1, we found it so don't provide any declaration at all. */
692 #if !HAVE_DECL_BASENAME
693 -#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME)
694 +#if defined (__GNU_LIBRARY__ ) \
695 + || defined (__linux__) \
696 + || defined (__DragonFly__) \
697 + || defined (__FreeBSD__) \
698 + || defined (__OpenBSD__) \
699 + || defined (__NetBSD__) \
700 + || defined (__CYGWIN__) \
701 + || defined (__CYGWIN32__) \
702 + || defined (__MINGW32__) \
703 + || defined (HAVE_DECL_BASENAME)
704 extern char *basename (const char *);
706 /* Do not allow basename to be used if there is no prototype seen. We
707 --- libgcc/config.host.orig
708 +++ libgcc/config.host
710 tmake_file="$tmake_file t-darwin ${cpu_type}/t-darwin t-libgcc-pic t-slibgcc-darwin"
711 extra_parts="crt3.o crttms.o crttme.o"
714 + tmake_file="t-slibgcc-elf-ver t-linux arm/t-arm"
715 + tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
716 + tmake_file="$tmake_file arm/t-linux-androideabi arm/t-arm-softfp soft-fp/t-softfp"
717 + extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
720 + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
721 + tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
722 + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
725 # This is the generic ELF configuration of FreeBSD. Later
726 # machine-specific sections may refine and add to this
728 extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
731 - tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
732 + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
733 + tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver"
734 # NetBSD 1.7 and later are set up to use GCC's crtstuff for
735 # ELF configurations. We will clear extra_parts in the
736 # a.out configurations.
741 -*-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-openbsd* | *-*-solaris2* | \
742 - alpha*-dec-osf5.1*)
743 +*-*-freebsd* | *-*-dragonfly* | *-*-netbsd* | *-*-openbsd*)
744 + enable_execute_stack=enable-execute-stack-freebsd.c
746 +*-*-darwin* | *-*-solaris2* | alpha*-dec-osf5.1*)
747 enable_execute_stack=enable-execute-stack-mprotect.c
749 i[34567]86-*-mingw* | x86_64-*-mingw*)
750 @@ -354,11 +368,11 @@
751 tmake_file="$tmake_file arm/t-arm arm/t-elf t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
752 extra_parts="$extra_parts crti.o crtn.o"
754 -arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtemseabi*)
755 +arm*-*-symbianelf* | arm*-*-rtemseabi*)
756 tmake_file="${tmake_file} arm/t-arm arm/t-elf t-fixedpoint-gnu-prefix"
757 tm_file="$tm_file arm/bpabi-lib.h"
759 - arm*-*-eabi* | arm*-*-rtemseabi*)
761 tmake_file="${tmake_file} arm/t-bpabi"
762 extra_parts="crtbegin.o crtend.o crti.o crtn.o"
764 @@ -523,16 +537,29 @@
766 tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
768 +i[34567]86-*-dragonfly*)
769 + tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
770 + md_unwind_header=i386/dragonfly-unwind.h
772 +x86_64-*-dragonfly*)
773 + tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
774 + md_unwind_header=i386/dragonfly-unwind.h
776 i[34567]86-*-freebsd*)
777 tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
778 + md_unwind_header=i386/freebsd-unwind.h
781 tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
782 + md_unwind_header=i386/freebsd-unwind.h
784 i[34567]86-*-netbsdelf*)
785 + tmake_file="${tmake_file} i386/t-crtstuff"
786 + md_unwind_header=i386/netbsd-unwind.h
789 tmake_file="${tmake_file} i386/t-crtstuff"
790 + md_unwind_header=i386/netbsd-unwind.h
792 i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
794 @@ -1160,6 +1187,7 @@
795 i[34567]86-*-gnu* | \
796 i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]* | \
797 i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw* | \
798 + i[34567]86-*-dragonfly* | x86_64-*-dragonfly* | \
799 i[34567]86-*-freebsd* | x86_64-*-freebsd*)
800 tmake_file="${tmake_file} t-softfp-tf"
801 if test "${host_address}" = 32; then
802 --- libgcc/crtstuff.c.orig
803 +++ libgcc/crtstuff.c
808 +#if defined(TARGET_DL_ITERATE_PHDR) && \
809 + ( defined(__FreeBSD__) \
810 + || defined(__OpenBSD__) \
811 + || defined(__NetBSD__) \
812 + || defined(__DragonFly__))
813 +#define BSD_DL_ITERATE_PHDR_AVAILABLE
816 #if defined(OBJECT_FORMAT_ELF) \
817 && !defined(OBJECT_FORMAT_FLAT) \
818 && defined(HAVE_LD_EH_FRAME_HDR) \
819 && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
820 - && defined(__FreeBSD__) && __FreeBSD__ >= 7
821 + && defined(BSD_DL_ITERATE_PHDR_AVAILABLE)
823 # define USE_PT_GNU_EH_FRAME
826 +++ libgcc/enable-execute-stack-freebsd.c
828 +/* Implement __enable_execute_stack using mprotect(2).
829 + Copyright (C) 2011, 2012 Free Software Foundation, Inc.
831 + This file is part of GCC.
833 + GCC is free software; you can redistribute it and/or modify it under
834 + the terms of the GNU General Public License as published by the Free
835 + Software Foundation; either version 3, or (at your option) any later
838 + GCC is distributed in the hope that it will be useful, but WITHOUT ANY
839 + WARRANTY; without even the implied warranty of MERCHANTABILITY or
840 + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
843 + Under Section 7 of GPL version 3, you are granted additional
844 + permissions described in the GCC Runtime Library Exception, version
845 + 3.1, as published by the Free Software Foundation.
847 + You should have received a copy of the GNU General Public License and
848 + a copy of the GCC Runtime Library Exception along with this program;
849 + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
850 + <http://www.gnu.org/licenses/>. */
852 +#include <sys/mman.h>
856 +#define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC)
858 +extern void __enable_execute_stack (void *);
861 +__enable_execute_stack (void *addr)
866 + long page_addr, ends_addr;
870 + size = getpagesize ();
871 + mask = ~((long) size - 1);
873 + page_addr = (long) addr;
874 + ends_addr = (long) (addr + __LIBGCC_TRAMPOLINE_SIZE__);
876 + page = (char *) (page_addr & mask);
877 + ends = (char *) ((ends_addr & mask) + size);
880 + * Note that no errors should be emitted by mprotect; it is considered
881 + * dangerous for library calls to send messages to stdout/stderr.
883 + if (mprotect (page, ends - page, STACK_PROT_RWX) < 0)
886 --- libgcc/unwind-dw2-fde-dip.c.orig
887 +++ libgcc/unwind-dw2-fde-dip.c
891 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
892 - && defined(__FreeBSD__) && __FreeBSD__ >= 7
893 + && defined(TARGET_DL_ITERATE_PHDR) \
894 + && (defined(__FreeBSD__) || defined(__DragonFly__))
896 # define USE_PT_GNU_EH_FRAME
899 +#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
900 + && defined(TARGET_DL_ITERATE_PHDR) \
901 + && (defined(__OpenBSD__) || defined(__NetBSD__))
902 +# define ElfW(n) Elf_##n
903 +# define USE_PT_GNU_EH_FRAME
906 #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
907 && defined(TARGET_DL_ITERATE_PHDR) \
908 && defined(__sun__) && defined(__svr4__)
910 +++ libgcc/config/i386/dragonfly-unwind.h
912 +/* DWARF2 EH unwinding support for DragonFly BSD: AMD x86-64 and x86.
913 + Copyright (C) 2010 John Marino <draco@marino.st> */
915 +/* Do code reading to identify a signal frame, and set the frame
916 + state data appropriately. See unwind-dw2.c for the structs. */
918 +#include <sys/types.h>
919 +#include <sys/sysctl.h>
921 +#include <sys/ucontext.h>
922 +#include <machine/sigframe.h>
925 +#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg
928 +#define MD_FALLBACK_FRAME_STATE_FOR x86_64_dragonfly_fallback_frame_state
932 +x86_64_sigtramp_range (unsigned char **start, unsigned char **end)
934 + unsigned long ps_strings;
939 + mib[1] = KERN_PS_STRINGS;
940 + len = sizeof (ps_strings);
941 + sysctl (mib, 2, &ps_strings, &len, NULL, 0);
943 + *start = (unsigned char *)ps_strings - 32;
944 + *end = (unsigned char *)ps_strings;
948 +static _Unwind_Reason_Code
949 +x86_64_dragonfly_fallback_frame_state
950 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
952 + unsigned char *pc = context->ra;
953 + unsigned char *sigtramp_start, *sigtramp_end;
954 + struct sigframe *sf;
957 + x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end);
958 + if (pc >= sigtramp_end || pc < sigtramp_start)
959 + return _URC_END_OF_STACK;
961 + sf = (struct sigframe *) context->cfa;
962 + new_cfa = sf->REG_NAME(rsp);
963 + fs->regs.cfa_how = CFA_REG_OFFSET;
964 + /* Register 7 is rsp */
965 + fs->regs.cfa_reg = 7;
966 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
968 + /* The SVR4 register numbering macros aren't usable in libgcc. */
969 + fs->regs.reg[0].how = REG_SAVED_OFFSET;
970 + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(rax) - new_cfa;
971 + fs->regs.reg[1].how = REG_SAVED_OFFSET;
972 + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(rdx) - new_cfa;
973 + fs->regs.reg[2].how = REG_SAVED_OFFSET;
974 + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(rcx) - new_cfa;
975 + fs->regs.reg[3].how = REG_SAVED_OFFSET;
976 + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(rbx) - new_cfa;
977 + fs->regs.reg[4].how = REG_SAVED_OFFSET;
978 + fs->regs.reg[4].loc.offset = (long)&sf->REG_NAME(rsi) - new_cfa;
979 + fs->regs.reg[5].how = REG_SAVED_OFFSET;
980 + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(rdi) - new_cfa;
981 + fs->regs.reg[6].how = REG_SAVED_OFFSET;
982 + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(rbp) - new_cfa;
983 + fs->regs.reg[8].how = REG_SAVED_OFFSET;
984 + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(r8) - new_cfa;
985 + fs->regs.reg[9].how = REG_SAVED_OFFSET;
986 + fs->regs.reg[9].loc.offset = (long)&sf->REG_NAME(r9) - new_cfa;
987 + fs->regs.reg[10].how = REG_SAVED_OFFSET;
988 + fs->regs.reg[10].loc.offset = (long)&sf->REG_NAME(r10) - new_cfa;
989 + fs->regs.reg[11].how = REG_SAVED_OFFSET;
990 + fs->regs.reg[11].loc.offset = (long)&sf->REG_NAME(r11) - new_cfa;
991 + fs->regs.reg[12].how = REG_SAVED_OFFSET;
992 + fs->regs.reg[12].loc.offset = (long)&sf->REG_NAME(r12) - new_cfa;
993 + fs->regs.reg[13].how = REG_SAVED_OFFSET;
994 + fs->regs.reg[13].loc.offset = (long)&sf->REG_NAME(r13) - new_cfa;
995 + fs->regs.reg[14].how = REG_SAVED_OFFSET;
996 + fs->regs.reg[14].loc.offset = (long)&sf->REG_NAME(r14) - new_cfa;
997 + fs->regs.reg[15].how = REG_SAVED_OFFSET;
998 + fs->regs.reg[15].loc.offset = (long)&sf->REG_NAME(r15) - new_cfa;
999 + fs->regs.reg[16].how = REG_SAVED_OFFSET;
1000 + fs->regs.reg[16].loc.offset = (long)&sf->REG_NAME(rip) - new_cfa;
1001 + fs->retaddr_column = 16;
1002 + fs->signal_frame = 1;
1003 + return _URC_NO_REASON;
1006 +#else /* Next section is for i386 */
1008 +#define MD_FALLBACK_FRAME_STATE_FOR x86_dragonfly_fallback_frame_state
1012 +x86_sigtramp_range (unsigned char **start, unsigned char **end)
1014 + unsigned long ps_strings;
1018 + mib[0] = CTL_KERN;
1019 + mib[1] = KERN_PS_STRINGS;
1020 + len = sizeof (ps_strings);
1021 + sysctl (mib, 2, &ps_strings, &len, NULL, 0);
1023 + *start = (unsigned char *)ps_strings - 128;
1024 + *end = (unsigned char *)ps_strings;
1028 +static _Unwind_Reason_Code
1029 +x86_dragonfly_fallback_frame_state
1030 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
1032 + unsigned char *pc = context->ra;
1033 + unsigned char *sigtramp_start, *sigtramp_end;
1034 + struct sigframe *sf;
1037 + x86_sigtramp_range(&sigtramp_start, &sigtramp_end);
1039 + if (pc >= sigtramp_end || pc < sigtramp_start)
1040 + return _URC_END_OF_STACK;
1042 + sf = (struct sigframe *) context->cfa;
1043 + new_cfa = sf->REG_NAME(esp);
1044 + fs->regs.cfa_how = CFA_REG_OFFSET;
1045 + fs->regs.cfa_reg = 4;
1046 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
1048 + /* The SVR4 register numbering macros aren't usable in libgcc. */
1049 + fs->regs.reg[0].how = REG_SAVED_OFFSET;
1050 + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(eax) - new_cfa;
1051 + fs->regs.reg[3].how = REG_SAVED_OFFSET;
1052 + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(ebx) - new_cfa;
1053 + fs->regs.reg[1].how = REG_SAVED_OFFSET;
1054 + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(ecx) - new_cfa;
1055 + fs->regs.reg[2].how = REG_SAVED_OFFSET;
1056 + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(edx) - new_cfa;
1057 + fs->regs.reg[6].how = REG_SAVED_OFFSET;
1058 + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(esi) - new_cfa;
1059 + fs->regs.reg[7].how = REG_SAVED_OFFSET;
1060 + fs->regs.reg[7].loc.offset = (long)&sf->REG_NAME(edi) - new_cfa;
1061 + fs->regs.reg[5].how = REG_SAVED_OFFSET;
1062 + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(ebp) - new_cfa;
1063 + fs->regs.reg[8].how = REG_SAVED_OFFSET;
1064 + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(eip) - new_cfa;
1065 + fs->retaddr_column = 8;
1066 + fs->signal_frame = 1;
1067 + return _URC_NO_REASON;
1069 +#endif /* ifdef __x86_64__ */
1071 +++ libgcc/config/i386/freebsd-unwind.h
1073 +/* DWARF2 EH unwinding support for FreeBSD: AMD x86-64 and x86.
1074 + Copyright (C) 2010, 2012 John Marino <draco@marino.st>
1076 +/* Do code reading to identify a signal frame, and set the frame
1077 + state data appropriately. See unwind-dw2.c for the structs. */
1079 +#include <sys/types.h>
1080 +#include <signal.h>
1081 +#include <sys/ucontext.h>
1082 +#include <machine/sigframe.h>
1084 +#define REG_NAME(reg) sf_uc.uc_mcontext.mc_## reg
1087 +#define MD_FALLBACK_FRAME_STATE_FOR x86_64_freebsd_fallback_frame_state
1089 +#if (__FreeBSD__ < 9)
1090 +#include <sys/sysctl.h>
1092 +x86_64_sigtramp_range (unsigned char **start, unsigned char **end)
1094 + unsigned long ps_strings;
1098 + mib[0] = CTL_KERN;
1099 + mib[1] = KERN_PS_STRINGS;
1100 + len = sizeof (ps_strings);
1101 + sysctl (mib, 2, &ps_strings, &len, NULL, 0);
1103 + *start = (unsigned char *)ps_strings - 32;
1104 + *end = (unsigned char *)ps_strings;
1109 +static _Unwind_Reason_Code
1110 +x86_64_freebsd_fallback_frame_state
1111 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
1113 + unsigned char *pc = context->ra;
1114 + unsigned char *sigtramp_start, *sigtramp_end;
1115 + struct sigframe *sf;
1118 +#if (__FreeBSD__ < 9)
1119 + x86_64_sigtramp_range(&sigtramp_start, &sigtramp_end);
1120 + if (pc >= sigtramp_end || pc < sigtramp_start)
1121 + return _URC_END_OF_STACK;
1123 + /* Prior to FreeBSD 9, the signal trampoline was located immediately
1124 + before the ps_strings. To support non-executable stacks on AMD64,
1125 + the sigtramp was moved to a shared page for FreeBSD 9. We are
1126 + stuck looking for frame patterns again (sys/amd64/amd64/sigtramp.S):
1128 + <pc + 00>: lea 0x10(%rsp),%rdi
1129 + <pc + 05>: pushq $0x0
1130 + <pc + 17>: mov $0x1a1,%rax
1131 + <pc + 14>: syscall
1133 + If we can't find this pattern, we're at the end of the stack.
1136 + if (!( *(unsigned int *)(context->ra) == 0x247c8d48
1137 + && *(unsigned int *)(context->ra + 4) == 0x48006a10
1138 + && *(unsigned int *)(context->ra + 8) == 0x01a1c0c7
1139 + && *(unsigned int *)(context->ra + 12) == 0x050f0000 ))
1140 + return _URC_END_OF_STACK;
1143 + sf = (struct sigframe *) context->cfa;
1144 + new_cfa = sf->REG_NAME(rsp);
1145 + fs->regs.cfa_how = CFA_REG_OFFSET;
1146 + /* Register 7 is rsp */
1147 + fs->regs.cfa_reg = 7;
1148 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
1150 + /* The SVR4 register numbering macros aren't usable in libgcc. */
1151 + fs->regs.reg[0].how = REG_SAVED_OFFSET;
1152 + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(rax) - new_cfa;
1153 + fs->regs.reg[1].how = REG_SAVED_OFFSET;
1154 + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(rdx) - new_cfa;
1155 + fs->regs.reg[2].how = REG_SAVED_OFFSET;
1156 + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(rcx) - new_cfa;
1157 + fs->regs.reg[3].how = REG_SAVED_OFFSET;
1158 + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(rbx) - new_cfa;
1159 + fs->regs.reg[4].how = REG_SAVED_OFFSET;
1160 + fs->regs.reg[4].loc.offset = (long)&sf->REG_NAME(rsi) - new_cfa;
1161 + fs->regs.reg[5].how = REG_SAVED_OFFSET;
1162 + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(rdi) - new_cfa;
1163 + fs->regs.reg[6].how = REG_SAVED_OFFSET;
1164 + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(rbp) - new_cfa;
1165 + fs->regs.reg[8].how = REG_SAVED_OFFSET;
1166 + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(r8) - new_cfa;
1167 + fs->regs.reg[9].how = REG_SAVED_OFFSET;
1168 + fs->regs.reg[9].loc.offset = (long)&sf->REG_NAME(r9) - new_cfa;
1169 + fs->regs.reg[10].how = REG_SAVED_OFFSET;
1170 + fs->regs.reg[10].loc.offset = (long)&sf->REG_NAME(r10) - new_cfa;
1171 + fs->regs.reg[11].how = REG_SAVED_OFFSET;
1172 + fs->regs.reg[11].loc.offset = (long)&sf->REG_NAME(r11) - new_cfa;
1173 + fs->regs.reg[12].how = REG_SAVED_OFFSET;
1174 + fs->regs.reg[12].loc.offset = (long)&sf->REG_NAME(r12) - new_cfa;
1175 + fs->regs.reg[13].how = REG_SAVED_OFFSET;
1176 + fs->regs.reg[13].loc.offset = (long)&sf->REG_NAME(r13) - new_cfa;
1177 + fs->regs.reg[14].how = REG_SAVED_OFFSET;
1178 + fs->regs.reg[14].loc.offset = (long)&sf->REG_NAME(r14) - new_cfa;
1179 + fs->regs.reg[15].how = REG_SAVED_OFFSET;
1180 + fs->regs.reg[15].loc.offset = (long)&sf->REG_NAME(r15) - new_cfa;
1181 + fs->regs.reg[16].how = REG_SAVED_OFFSET;
1182 + fs->regs.reg[16].loc.offset = (long)&sf->REG_NAME(rip) - new_cfa;
1183 + fs->retaddr_column = 16;
1184 + fs->signal_frame = 1;
1185 + return _URC_NO_REASON;
1188 +#else /* Next section is for i386 */
1190 +#define MD_FALLBACK_FRAME_STATE_FOR x86_freebsd_fallback_frame_state
1192 +#include <sys/sysctl.h>
1194 +x86_sigtramp_range (unsigned char **start, unsigned char **end)
1196 + unsigned long ps_strings;
1200 + mib[0] = CTL_KERN;
1201 + mib[1] = KERN_PS_STRINGS;
1202 + len = sizeof (ps_strings);
1203 + sysctl (mib, 2, &ps_strings, &len, NULL, 0);
1205 + *start = (unsigned char *)ps_strings - 128;
1206 + *end = (unsigned char *)ps_strings;
1210 +static _Unwind_Reason_Code
1211 +x86_freebsd_fallback_frame_state
1212 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
1214 + unsigned char *pc = context->ra;
1215 + unsigned char *sigtramp_start, *sigtramp_end;
1216 + struct sigframe *sf;
1219 + x86_sigtramp_range(&sigtramp_start, &sigtramp_end);
1221 + if (pc >= sigtramp_end || pc < sigtramp_start)
1222 + return _URC_END_OF_STACK;
1224 + sf = (struct sigframe *) context->cfa;
1225 + new_cfa = sf->REG_NAME(esp);
1226 + fs->regs.cfa_how = CFA_REG_OFFSET;
1227 + fs->regs.cfa_reg = 4;
1228 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
1230 + /* The SVR4 register numbering macros aren't usable in libgcc. */
1231 + fs->regs.reg[0].how = REG_SAVED_OFFSET;
1232 + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(eax) - new_cfa;
1233 + fs->regs.reg[3].how = REG_SAVED_OFFSET;
1234 + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(ebx) - new_cfa;
1235 + fs->regs.reg[1].how = REG_SAVED_OFFSET;
1236 + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(ecx) - new_cfa;
1237 + fs->regs.reg[2].how = REG_SAVED_OFFSET;
1238 + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(edx) - new_cfa;
1239 + fs->regs.reg[6].how = REG_SAVED_OFFSET;
1240 + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(esi) - new_cfa;
1241 + fs->regs.reg[7].how = REG_SAVED_OFFSET;
1242 + fs->regs.reg[7].loc.offset = (long)&sf->REG_NAME(edi) - new_cfa;
1243 + fs->regs.reg[5].how = REG_SAVED_OFFSET;
1244 + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(ebp) - new_cfa;
1245 + fs->regs.reg[8].how = REG_SAVED_OFFSET;
1246 + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(eip) - new_cfa;
1247 + fs->retaddr_column = 8;
1248 + fs->signal_frame = 1;
1249 + return _URC_NO_REASON;
1251 +#endif /* ifdef __x86_64__ */
1253 +++ libgcc/config/i386/netbsd-unwind.h
1255 +/* DWARF2 EH unwinding support for x86 NetBSD
1256 + Copyright (C) 2010 John Marino (www.dragonlace.net) */
1258 +/* Do code reading to identify a signal frame, and set the frame
1259 + state data appropriately. See unwind-dw2.c for the structs. */
1261 +#include <sys/ucontext.h>
1262 +#include <machine/frame.h>
1264 +#define REG_NAME(reg) sf_uc.uc_mcontext.__gregs[_REG_## reg]
1271 +#define MD_FALLBACK_FRAME_STATE_FOR x86_64_netbsd_fallback_frame_state
1273 +static _Unwind_Reason_Code
1274 +x86_64_netbsd_fallback_frame_state
1275 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
1277 + /* signal_frame is sigframe_siginfo minus sf_ra handler return address */
1278 + struct signal_frame {
1279 + siginfo_t sf_si; /* actual saved siginfo */
1280 + ucontext_t sf_uc; /* actual saved ucontext */
1282 + struct signal_frame *sf;
1285 + /* We are looking for the following signal trampoline pattern. If we don't
1286 + find it, we are at the end of the stack and can't unwind.
1288 + <__sigtramp_siginfo_2+12>: mov $0xffffffffffffffff,%rdi
1289 + <__sigtramp_siginfo_2+19>: mov $0x1,%rax
1290 + <__sigtramp_siginfo_2+26>: syscall
1293 + if ( *(unsigned int *) (context->ra + 12) == 0xffc7c748
1294 + && *(unsigned int *) (context->ra + 16) == 0x48ffffff
1295 + && *(unsigned int *) (context->ra + 20) == 0x0001c0c7
1296 + && *(unsigned int *) (context->ra + 24) == 0x050f0000 )
1298 + sf = (struct signal_frame *) context->cfa;
1299 + new_cfa = sf->REG_NAME(RSP);
1300 + fs->regs.cfa_how = CFA_REG_OFFSET;
1301 + fs->regs.cfa_reg = 7;
1302 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
1306 + return _URC_END_OF_STACK;
1309 + /* The SVR4 register numbering macros aren't usable in libgcc. */
1310 + fs->regs.reg[ 0].how = REG_SAVED_OFFSET;
1311 + fs->regs.reg[ 0].loc.offset = (long)&sf->REG_NAME(RAX) - new_cfa;
1312 + fs->regs.reg[ 1].how = REG_SAVED_OFFSET;
1313 + fs->regs.reg[ 1].loc.offset = (long)&sf->REG_NAME(RDX) - new_cfa;
1314 + fs->regs.reg[ 2].how = REG_SAVED_OFFSET;
1315 + fs->regs.reg[ 2].loc.offset = (long)&sf->REG_NAME(RCX) - new_cfa;
1316 + fs->regs.reg[ 3].how = REG_SAVED_OFFSET;
1317 + fs->regs.reg[ 3].loc.offset = (long)&sf->REG_NAME(RBX) - new_cfa;
1318 + fs->regs.reg[ 4].how = REG_SAVED_OFFSET;
1319 + fs->regs.reg[ 4].loc.offset = (long)&sf->REG_NAME(RSI) - new_cfa;
1320 + fs->regs.reg[ 5].how = REG_SAVED_OFFSET;
1321 + fs->regs.reg[ 5].loc.offset = (long)&sf->REG_NAME(RDI) - new_cfa;
1322 + fs->regs.reg[ 6].how = REG_SAVED_OFFSET;
1323 + fs->regs.reg[ 6].loc.offset = (long)&sf->REG_NAME(RBP) - new_cfa;
1324 + fs->regs.reg[ 8].how = REG_SAVED_OFFSET;
1325 + fs->regs.reg[ 8].loc.offset = (long)&sf->REG_NAME(R8) - new_cfa;
1326 + fs->regs.reg[ 9].how = REG_SAVED_OFFSET;
1327 + fs->regs.reg[ 9].loc.offset = (long)&sf->REG_NAME(R9) - new_cfa;
1328 + fs->regs.reg[10].how = REG_SAVED_OFFSET;
1329 + fs->regs.reg[10].loc.offset = (long)&sf->REG_NAME(R10) - new_cfa;
1330 + fs->regs.reg[11].how = REG_SAVED_OFFSET;
1331 + fs->regs.reg[11].loc.offset = (long)&sf->REG_NAME(R11) - new_cfa;
1332 + fs->regs.reg[12].how = REG_SAVED_OFFSET;
1333 + fs->regs.reg[12].loc.offset = (long)&sf->REG_NAME(R12) - new_cfa;
1334 + fs->regs.reg[13].how = REG_SAVED_OFFSET;
1335 + fs->regs.reg[13].loc.offset = (long)&sf->REG_NAME(R13) - new_cfa;
1336 + fs->regs.reg[14].how = REG_SAVED_OFFSET;
1337 + fs->regs.reg[14].loc.offset = (long)&sf->REG_NAME(R14) - new_cfa;
1338 + fs->regs.reg[15].how = REG_SAVED_OFFSET;
1339 + fs->regs.reg[15].loc.offset = (long)&sf->REG_NAME(R15) - new_cfa;
1340 + fs->regs.reg[16].how = REG_SAVED_OFFSET;
1341 + fs->regs.reg[16].loc.offset = (long)&sf->REG_NAME(RIP) - new_cfa;
1342 + fs->retaddr_column = 16;
1343 + fs->signal_frame = 1;
1344 + return _URC_NO_REASON;
1350 +#else /* Next section is for i386 */
1355 +#define MD_FALLBACK_FRAME_STATE_FOR x86_netbsd_fallback_frame_state
1357 +static _Unwind_Reason_Code
1358 +x86_netbsd_fallback_frame_state
1359 +(struct _Unwind_Context *context, _Unwind_FrameState *fs)
1361 + /* signal_frame is sigframe_siginfo minus sf_ra handler return address */
1362 + struct signal_frame {
1363 + int sf_signum; /* "signum" argument for handler" */
1364 + siginfo_t *sf_sip; /* "sip" argument for handler" */
1365 + ucontext_t *sf_ucp; /* "ucp" argument for handler" */
1366 + siginfo_t sf_si; /* actual saved siginfo */
1367 + ucontext_t sf_uc; /* actual saved ucontext */
1369 + struct signal_frame *sf;
1372 + /* We are looking for the following signal trampoline pattern. If we don't
1373 + find it, we are at the end of the stack and can't unwind.
1375 + <__sigtramp_siginfo_2+18>: movl $0xffffffff,0x4(%esp)
1376 + <__sigtramp_siginfo_2+26>: mov $0x1,%eax
1377 + <__sigtramp_siginfo_2+31>: int $0x80
1380 + if ( *(unsigned int *) (context->ra + 18) == 0x042444c7
1381 + && *(unsigned int *) (context->ra + 22) == 0xffffffff
1382 + && *(unsigned char *) (context->ra + 26) == 0xb8
1383 + && *(unsigned int *) (context->ra + 27) == 0x00000001
1384 + && *(unsigned short *) (context->ra + 31) == 0x80cd )
1386 + sf = (struct signal_frame *) context->cfa;
1387 + new_cfa = sf->REG_NAME(ESP);
1388 + fs->regs.cfa_how = CFA_REG_OFFSET;
1389 + fs->regs.cfa_reg = 4;
1390 + fs->regs.cfa_offset = new_cfa - (long) context->cfa;
1394 + return _URC_END_OF_STACK;
1397 + /* The SVR4 register numbering macros aren't usable in libgcc. */
1398 + fs->regs.reg[0].how = REG_SAVED_OFFSET;
1399 + fs->regs.reg[0].loc.offset = (long)&sf->REG_NAME(EAX) - new_cfa;
1400 + fs->regs.reg[3].how = REG_SAVED_OFFSET;
1401 + fs->regs.reg[3].loc.offset = (long)&sf->REG_NAME(EBX) - new_cfa;
1402 + fs->regs.reg[1].how = REG_SAVED_OFFSET;
1403 + fs->regs.reg[1].loc.offset = (long)&sf->REG_NAME(ECX) - new_cfa;
1404 + fs->regs.reg[2].how = REG_SAVED_OFFSET;
1405 + fs->regs.reg[2].loc.offset = (long)&sf->REG_NAME(EDX) - new_cfa;
1406 + fs->regs.reg[6].how = REG_SAVED_OFFSET;
1407 + fs->regs.reg[6].loc.offset = (long)&sf->REG_NAME(ESI) - new_cfa;
1408 + fs->regs.reg[7].how = REG_SAVED_OFFSET;
1409 + fs->regs.reg[7].loc.offset = (long)&sf->REG_NAME(EDI) - new_cfa;
1410 + fs->regs.reg[5].how = REG_SAVED_OFFSET;
1411 + fs->regs.reg[5].loc.offset = (long)&sf->REG_NAME(EBP) - new_cfa;
1412 + fs->regs.reg[8].how = REG_SAVED_OFFSET;
1413 + fs->regs.reg[8].loc.offset = (long)&sf->REG_NAME(EIP) - new_cfa;
1414 + fs->retaddr_column = 8;
1415 + fs->signal_frame = 1;
1416 + return _URC_NO_REASON;
1422 +#endif /* ifdef __x86_64__ */
1424 --- libiberty/getpagesize.c.orig
1425 +++ libiberty/getpagesize.c
1430 +#ifndef __ANDROID__
1438 +#endif /* __ANDROID__ */
1439 --- libiberty/setproctitle.c.orig
1440 +++ libiberty/setproctitle.c
1443 setproctitle (const char *name ATTRIBUTE_UNUSED, ...)
1445 +#ifndef __ANDROID__
1447 /* On GNU/Linux this sets the top visible "comm", but not
1448 necessarily the name visible in ps. */
1449 prctl (PR_SET_NAME, name);
1453 --- gcc/configure.orig
1455 @@ -26810,6 +26810,20 @@
1456 gcc_cv_target_dl_iterate_phdr=no
1459 + *-*-dragonfly* | *-*-freebsd*)
1460 + if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then
1461 + gcc_cv_target_dl_iterate_phdr=yes
1463 + gcc_cv_target_dl_iterate_phdr=no
1467 + if grep dl_iterate_phdr $target_header_dir/link_elf.h > /dev/null 2>&1; then
1468 + gcc_cv_target_dl_iterate_phdr=yes
1470 + gcc_cv_target_dl_iterate_phdr=no
1475 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
1476 --- gcc/Makefile.in.orig
1478 @@ -1150,7 +1150,6 @@
1486 @@ -1469,13 +1468,18 @@
1487 ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \
1488 $(OBJS-libcommon-target) @TREEBROWSER@ main.o gccspec.o cppspec.o \
1489 $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) mips-tfile.o mips-tdump.o \
1490 - $(GCOV_OBJS) $(GCOV_DUMP_OBJS)
1491 + $(GCOV_OBJS) $(GCOV_DUMP_OBJS) insn-modes.o insn-modes-ada.o
1493 # This lists all host object files, whether they are included in this
1494 # compilation or not.
1495 ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS)
1497 -BACKEND = main.o @TREEBROWSER@ libbackend.a libcommon-target.a libcommon.a \
1498 +BACKEND = main.o @TREEBROWSER@ insn-modes.o libbackend.a \
1499 + libcommon-target.a libcommon.a \
1500 + $(CPPLIB) $(LIBDECNUMBER)
1502 +BACKEND2 = main.o @TREEBROWSER@ insn-modes-ada.o libbackend.a \
1503 + libcommon-target.a libcommon.a \
1504 $(CPPLIB) $(LIBDECNUMBER)
1506 MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
1507 @@ -3506,6 +3510,8 @@
1508 $(TM_H) $(RTL_H) $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H)
1509 insn-modes.o : insn-modes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
1511 +insn-modes-ada.o : insn-modes-ada.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
1512 + $(TM_H) $(MACHMODE_H)
1513 insn-opinit.o : insn-opinit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
1514 $(TM_H) $(RTL_H) $(TM_P_H) insn-config.h $(FLAGS_H) $(RECOG_H) \
1515 $(EXPR_H) $(OPTABS_H) reload.h
1516 @@ -3599,6 +3605,7 @@
1518 insn-modes.c: s-modes; @true
1519 insn-modes.h: s-modes-h; @true
1520 +insn-modes-ada.c: s-modes-ada; @true
1521 min-insn-modes.c: s-modes-m; @true
1523 s-modes: build/genmodes$(build_exeext)
1524 @@ -3616,6 +3623,12 @@
1525 $(SHELL) $(srcdir)/../move-if-change tmp-min-modes.c min-insn-modes.c
1528 +s-modes-ada: s-modes
1529 + $(shell sed -e 's/: TARGET_96_ROUND_53_LONG_DOUBLE \? &ieee_extended_intel_96_round_53_format //' \
1530 + < insn-modes.c > tmp-modes-ada.c)
1531 + $(SHELL) $(srcdir)/../move-if-change tmp-modes-ada.c insn-modes-ada.c
1532 + $(STAMP) s-modes-ada
1534 insn-preds.c: s-preds; @true
1535 tm-preds.h: s-preds-h; @true
1536 tm-constrs.h: s-constrs-h; @true
1537 @@ -4378,7 +4391,7 @@
1539 $(SHELL) $(srcdir)/doc/install.texi2html
1541 -MANFILES = doc/gcov.1 doc/cpp.1 doc/gcc.1 doc/gfdl.7 doc/gpl.7 doc/fsf-funding.7
1542 +MANFILES = doc/gcov.1 doc/cpp.1 doc/gcc.1
1544 generated-manpages: man
1546 @@ -4530,7 +4543,7 @@
1547 # Install the driver last so that the window when things are
1549 install: install-common $(INSTALL_HEADERS) \
1550 - install-cpp install-man install-info install-@POSUB@ \
1551 + install-cpp install-man install-@POSUB@ \
1552 install-driver install-lto-wrapper install-gcc-ar
1554 ifeq ($(enable_plugin),yes)
1555 @@ -4655,6 +4668,9 @@
1556 -rm -f $(DESTDIR)$(bindir)/$(target_noncanonical)-gcc-$(version)$(exeext)
1557 -( cd $(DESTDIR)$(bindir) && \
1558 $(LN) $(GCC_INSTALL_NAME)$(exeext) $(target_noncanonical)-gcc-$(version)$(exeext) )
1559 + -if [ -f gnat1$(exeext) ] ; then \
1560 + ( cd $(DESTDIR)$(bindir) && $(LN) $(GCC_INSTALL_NAME)$(exeext) ada$(exeext) ) \
1562 -if [ -f gcc-cross$(exeext) ] ; then \
1563 if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
1564 rm -f $(DESTDIR)$(gcc_tooldir)/bin/gcc$(exeext); \
1565 @@ -4728,10 +4744,7 @@
1566 install-man: lang.install-man \
1567 $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext) \
1568 $(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext) \
1569 - $(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext) \
1570 - $(DESTDIR)$(man7dir)/fsf-funding$(man7ext) \
1571 - $(DESTDIR)$(man7dir)/gfdl$(man7ext) \
1572 - $(DESTDIR)$(man7dir)/gpl$(man7ext)
1573 + $(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext)
1575 $(DESTDIR)$(man7dir)/%$(man7ext): doc/%.7 installdirs
1579 @@ -14412,7 +14412,7 @@
1581 if ac_fn_c_try_compile "$LINENO"; then :
1582 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1583 -$as_echo "yes" >&6; }; stage1_cflags="$stage1_cflags -fkeep-inline-functions"
1584 +$as_echo "yes" >&6; };
1586 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1587 $as_echo "no" >&6; }