/* Definitions for AMD x86-64 running Linux-based GNU systems with ELF format.
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
+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 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
-GNU CC is distributed in the hope that it will be useful,
+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.
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+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.
-#define LINUX_DEFAULT_ELF
+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/>. */
-#undef TARGET_VERSION
+#if TARGET_64BIT_DEFAULT
#define TARGET_VERSION fprintf (stderr, " (x86-64 Linux/ELF)");
+#else
+#define TARGET_VERSION fprintf (stderr, " (i386 Linux/ELF)");
+#endif
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -Asystem(posix)"
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ LINUX_TARGET_OS_CPP_BUILTINS(); \
+ } \
+ while (0)
#undef CPP_SPEC
-#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} \
- %{!m32:-D__LONG_MAX__=9223372036854775807L -D__LP64__ -D_LP64}"
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
/* The svr4 ABI for the i386 says that records and unions are returned
in memory. In the 64bit compilation we will turn this flag off in
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1
+/* We arrange for the whole %fs segment to map the tls area. */
+#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
+#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
+
/* Provide a LINK_SPEC. Here we provide support for the special GCC
options -static and -shared, which allow us to link things in one
of these three modes by applying the appropriate combinations of
When the -shared link option is used a final link is not being
done. */
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+
+#undef ASM_SPEC
+#define ASM_SPEC "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} \
+ %{Wa,*:%*} %{m32:--32} %{m64:--64} \
+ %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
+
+#if TARGET_64BIT_DEFAULT
+#define SPEC_32 "m32"
+#define SPEC_64 "!m32"
+#else
+#define SPEC_32 "!m64"
+#define SPEC_64 "m64"
+#endif
+
#undef LINK_SPEC
-#define LINK_SPEC "%{!m32:-m elf_x86_64 -Y P,/usr/lib64} %{m32:-m elf_i386} \
+#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
%{shared:-shared} \
%{!shared: \
%{!static: \
%{rdynamic:-export-dynamic} \
- %{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
- %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
+ %{" SPEC_32 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "}} \
+ %{" SPEC_64 ":%{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}}} \
%{static:-static}}"
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
- %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} \
- crti.o%s %{static:crtbeginT.o%s} \
- %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
-
+/* Similar to standard Linux, but adding -ffast-math support. */
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
-
+#define ENDFILE_SPEC \
+ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+ %{mpc32:crtprec32.o%s} \
+ %{mpc64:crtprec64.o%s} \
+ %{mpc80:crtprec80.o%s} \
+ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+
+#if TARGET_64BIT_DEFAULT
#define MULTILIB_DEFAULTS { "m64" }
+#else
+#define MULTILIB_DEFAULTS { "m32" }
+#endif
-/* Do code reading to identify a signal frame, and set the frame
- state data appropriately. See unwind-dw2.c for the structs.
- Don't use this at all if inhibit_libc is used. */
+/* Put all *tf routines in libgcc. */
+#undef LIBGCC2_HAS_TF_MODE
+#define LIBGCC2_HAS_TF_MODE 1
+#define LIBGCC2_TF_CEXT q
+#define TF_SIZE 113
-#ifndef inhibit_libc
-#ifdef IN_LIBGCC2
-#include <signal.h>
-#include <sys/ucontext.h>
-#endif
+#undef NEED_INDICATE_EXEC_STACK
+#define NEED_INDICATE_EXEC_STACK 1
-#ifdef __x86_64__
-#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
- do { \
- unsigned char *pc_ = (CONTEXT)->ra; \
- struct sigcontext *sc_; \
- long new_cfa_; \
- \
- /* movq __NR_rt_sigreturn, %rax ; syscall */ \
- if (*(unsigned char *)(pc_+0) == 0x48 \
- && *(unsigned long *)(pc_+1) == 0x050f0000000fc0c7) \
- { \
- struct ucontext *uc_ = (CONTEXT)->cfa; \
- sc_ = (struct sigcontext *) &uc_->uc_mcontext; \
- } \
- else \
- break; \
- \
- new_cfa_ = sc_->rsp; \
- (FS)->cfa_how = CFA_REG_OFFSET; \
- /* Register 7 is rsp */ \
- (FS)->cfa_reg = 7; \
- (FS)->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)&sc_->rax - new_cfa_; \
- (FS)->regs.reg[1].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[1].loc.offset = (long)&sc_->rbx - new_cfa_; \
- (FS)->regs.reg[2].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[2].loc.offset = (long)&sc_->rcx - new_cfa_; \
- (FS)->regs.reg[3].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[3].loc.offset = (long)&sc_->rdx - new_cfa_; \
- (FS)->regs.reg[4].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[4].loc.offset = (long)&sc_->rbp - new_cfa_; \
- (FS)->regs.reg[5].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[5].loc.offset = (long)&sc_->rsi - new_cfa_; \
- (FS)->regs.reg[6].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[6].loc.offset = (long)&sc_->rdi - new_cfa_; \
- (FS)->regs.reg[8].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[8].loc.offset = (long)&sc_->r8 - new_cfa_; \
- (FS)->regs.reg[9].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[9].loc.offset = (long)&sc_->r9 - new_cfa_; \
- (FS)->regs.reg[10].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[10].loc.offset = (long)&sc_->r10 - new_cfa_; \
- (FS)->regs.reg[11].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[11].loc.offset = (long)&sc_->r11 - new_cfa_; \
- (FS)->regs.reg[12].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[12].loc.offset = (long)&sc_->r12 - new_cfa_; \
- (FS)->regs.reg[13].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[13].loc.offset = (long)&sc_->r13 - new_cfa_; \
- (FS)->regs.reg[14].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[14].loc.offset = (long)&sc_->r14 - new_cfa_; \
- (FS)->regs.reg[15].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[15].loc.offset = (long)&sc_->r15 - new_cfa_; \
- (FS)->retaddr_column = 16; \
- goto SUCCESS; \
- } while (0)
-#else /* ifdef __x86_64__ */
-#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
- do { \
- unsigned char *pc_ = (CONTEXT)->ra; \
- struct sigcontext *sc_; \
- long new_cfa_; \
- \
- /* popl %eax ; movl $__NR_sigreturn,%eax ; int $0x80 */ \
- if (*(unsigned short *)(pc_+0) == 0xb858 \
- && *(unsigned int *)(pc_+2) == 119 \
- && *(unsigned short *)(pc_+6) == 0x80cd) \
- sc_ = (CONTEXT)->cfa + 4; \
- /* movl $__NR_rt_sigreturn,%eax ; int $0x80 */ \
- else if (*(unsigned char *)(pc_+0) == 0xb8 \
- && *(unsigned int *)(pc_+1) == 173 \
- && *(unsigned short *)(pc_+5) == 0x80cd) \
- { \
- struct rt_sigframe { \
- int sig; \
- struct siginfo *pinfo; \
- void *puc; \
- struct siginfo info; \
- struct ucontext uc; \
- } *rt_ = (CONTEXT)->cfa; \
- sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext; \
- } \
- else \
- break; \
- \
- new_cfa_ = sc_->esp; \
- (FS)->cfa_how = CFA_REG_OFFSET; \
- (FS)->cfa_reg = 4; \
- (FS)->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)&sc_->eax - new_cfa_; \
- (FS)->regs.reg[3].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[3].loc.offset = (long)&sc_->ebx - new_cfa_; \
- (FS)->regs.reg[1].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[1].loc.offset = (long)&sc_->ecx - new_cfa_; \
- (FS)->regs.reg[2].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[2].loc.offset = (long)&sc_->edx - new_cfa_; \
- (FS)->regs.reg[6].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[6].loc.offset = (long)&sc_->esi - new_cfa_; \
- (FS)->regs.reg[7].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[7].loc.offset = (long)&sc_->edi - new_cfa_; \
- (FS)->regs.reg[5].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[5].loc.offset = (long)&sc_->ebp - new_cfa_; \
- (FS)->regs.reg[8].how = REG_SAVED_OFFSET; \
- (FS)->regs.reg[8].loc.offset = (long)&sc_->eip - new_cfa_; \
- (FS)->retaddr_column = 8; \
- goto SUCCESS; \
- } while (0)
-#endif /* ifdef __x86_64__ */
-#endif /* ifdef inhibit_libc */
+#define MD_UNWIND_SUPPORT "config/i386/linux-unwind.h"
+
+/* This macro may be overridden in i386/k*bsd-gnu.h. */
+#define REG_NAME(reg) reg
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* i386 glibc provides __stack_chk_guard in %gs:0x14,
+ x86_64 glibc provides it in %fs:0x28. */
+#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14)
+#endif