[llvm-commits] [llvm-gcc-4.2] r82152 - in /llvm-gcc-4.2/trunk/gcc: config.gcc config/exec-stack.h config/i386/openbsd.h config/i386/openbsd64.h config/i386/openbsdelf.h config/openbsd-libpthread.h config/openbsd.h
Duncan Sands
baldrick at free.fr
Thu Sep 17 11:14:38 PDT 2009
Author: baldrick
Date: Thu Sep 17 13:14:37 2009
New Revision: 82152
URL: http://llvm.org/viewvc/llvm-project?rev=82152&view=rev
Log:
Update OpenBSD target configurations for llvm-gcc based on the gcc 4.2 port,
and most importantly enable pic when building an llvm enabled configuration.
Patch by Jonathan Gray.
Added:
llvm-gcc-4.2/trunk/gcc/config/exec-stack.h
llvm-gcc-4.2/trunk/gcc/config/i386/openbsd64.h
llvm-gcc-4.2/trunk/gcc/config/openbsd-libpthread.h
Modified:
llvm-gcc-4.2/trunk/gcc/config.gcc
llvm-gcc-4.2/trunk/gcc/config/i386/openbsd.h
llvm-gcc-4.2/trunk/gcc/config/i386/openbsdelf.h
llvm-gcc-4.2/trunk/gcc/config/openbsd.h
Modified: llvm-gcc-4.2/trunk/gcc/config.gcc
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=82152&r1=82151&r2=82152&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config.gcc (original)
+++ llvm-gcc-4.2/trunk/gcc/config.gcc Thu Sep 17 13:14:37 2009
@@ -1152,10 +1152,15 @@
;;
i[34567]86-*-openbsd*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
- tm_file="${tm_file} openbsd.h i386/openbsdelf.h"
+ tm_file="${tm_file} openbsd.h openbsd-libpthread.h i386/openbsdelf.h"
gas=yes
gnu_ld=yes
;;
+x86_64-*-openbsd*)
+ tm_file="i386/biarch64.h i386/i386.h i386/unix.h i386/att.h dbxelf.h elfos.h openbsd.h openbsd-libpthread.h i386/x86-64.h i386/openbsd64.h"
+ tm_file="${tm_file} exec-stack.h"
+ tmake_file="t-libc-ok t-openbsd i386/t-openbsd"
+ ;;
i[34567]86-*-coff*)
tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h dbxcoff.h i386/i386-coff.h"
use_fixproto=yes
Added: llvm-gcc-4.2/trunk/gcc/config/exec-stack.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/exec-stack.h?rev=82152&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/exec-stack.h (added)
+++ llvm-gcc-4.2/trunk/gcc/config/exec-stack.h Thu Sep 17 13:14:37 2009
@@ -0,0 +1,40 @@
+/* Enable stack execute around trampoline address.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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)
+any later version.
+
+GNU CC 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. */
+
+#undef FINALIZE_TRAMPOLINE
+#define FINALIZE_TRAMPOLINE(TRAMP) \
+ emit_library_call(gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"), \
+ 0, VOIDmode, 1, memory_address (SImode, (TRAMP)), Pmode)
+
+#undef TRANSFER_FROM_TRAMPOLINE
+#define TRANSFER_FROM_TRAMPOLINE \
+extern void __enable_execute_stack (void *); \
+void \
+__enable_execute_stack (addr) \
+ void *addr; \
+{ \
+ long size = getpagesize (); \
+ long mask = ~(size-1); \
+ char *page = (char *) (((long) addr) & mask); \
+ char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
+ \
+ if (mprotect (page, end - page, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) \
+ perror ("mprotect of trampoline code"); \
+}
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/openbsd.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/openbsd.h?rev=82152&r1=82151&r2=82152&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/openbsd.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/openbsd.h Thu Sep 17 13:14:37 2009
@@ -41,10 +41,10 @@
/* This must agree with <machine/ansi.h> */
#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
#undef WCHAR_TYPE
#define WCHAR_TYPE "int"
@@ -52,6 +52,9 @@
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 32
+#undef WINT_TYPE
+#define WINT_TYPE "int"
+
/* Assembler format: overall framework. */
#undef ASM_APP_ON
Added: llvm-gcc-4.2/trunk/gcc/config/i386/openbsd64.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/openbsd64.h?rev=82152&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/openbsd64.h (added)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/openbsd64.h Thu Sep 17 13:14:37 2009
@@ -0,0 +1,121 @@
+/* Configuration for an OpenBSD x86-64 target.
+
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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)
+any later version.
+
+GNU CC 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. */
+
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (OpenBSD/x86-64 ELF)")
+
+/* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using
+ libraries compiled with the native cc, so undef it. */
+#undef NO_DOLLAR_IN_LABEL
+
+/* Override the default comment-starter of "/". */
+#undef ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
+
+/* Run-time target specifications */
+
+#define TARGET_OS_CPP_BUILTINS() \
+ do \
+ { \
+ OPENBSD_OS_CPP_BUILTINS_ELF(); \
+ if (TARGET_64BIT) \
+ OPENBSD_OS_CPP_BUILTINS_LP64(); \
+ } \
+ while (0)
+
+/* As an elf system, we need crtbegin/crtend stuff. */
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "\
+ %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \
+ crtbegin%O%s} %{shared:crtbeginS%O%s}"
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+
+/* Layout of source language data types. */
+
+/* This must agree with <machine/_types.h> */
+#undef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Assembler format: overall framework. */
+
+#undef ASM_APP_ON
+#define ASM_APP_ON "#APP\n"
+
+#undef ASM_APP_OFF
+#define ASM_APP_OFF "#NO_APP\n"
+
+#undef SET_ASM_OP
+#define SET_ASM_OP "\t.set\t"
+
+/* The following macros were originally stolen from i386v4.h.
+ These have to be defined to get PIC code correct. */
+
+/* Assembler format: dispatch tables. */
+
+/* Assembler format: sections. */
+
+/* Stack & calling: aggregate returns. */
+
+/* Don't default to pcc-struct-return, because gcc is the only compiler, and
+ we want to retain compatibility with older gcc versions. */
+#define DEFAULT_PCC_STRUCT_RETURN 0
+
+/* Assembler format: alignment output. */
+
+/* Stack & calling: profiling. */
+
+/* OpenBSD's profiler recovers all information from the stack pointer.
+ The icky part is not here, but in machine/profile.h. */
+#undef FUNCTION_PROFILER
+#define FUNCTION_PROFILER(FILE, LABELNO) \
+ fputs (flag_pic ? "\tcall __mcount at PLT\n": "\tcall __mcount\n", FILE);
+
+/* Assembler format: exception region output. */
+
+/* Assembler format: alignment output. */
+
+/* Note that we pick up ASM_OUTPUT_MAX_SKIP_ALIGN from i386/gas.h */
+
+/* Note that we pick up ASM_OUTPUT_MI_THUNK from unix.h. */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
+ %{assert*} \
+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
+
+#define OBSD_HAS_CORRECT_SPECS
+
+#undef JUMP_TABLES_IN_TEXT_SECTION
+#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/openbsdelf.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/openbsdelf.h?rev=82152&r1=82151&r2=82152&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/openbsdelf.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/openbsdelf.h Thu Sep 17 13:14:37 2009
@@ -56,10 +56,10 @@
/* This must agree with <machine/ansi.h> */
#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
+#define SIZE_TYPE "long unsigned int"
#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
+#define PTRDIFF_TYPE "long int"
#undef WCHAR_TYPE
#define WCHAR_TYPE "int"
@@ -111,9 +111,6 @@
/* Assembler format: exception region output. */
-/* our configuration still doesn't handle dwarf2 correctly */
-#define DWARF2_UNWIND_INFO 0
-
/* Assembler format: alignment output. */
/* Note that we pick up ASM_OUTPUT_MAX_SKIP_ALIGN from i386/gas.h */
Added: llvm-gcc-4.2/trunk/gcc/config/openbsd-libpthread.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/openbsd-libpthread.h?rev=82152&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/openbsd-libpthread.h (added)
+++ llvm-gcc-4.2/trunk/gcc/config/openbsd-libpthread.h Thu Sep 17 13:14:37 2009
@@ -0,0 +1,23 @@
+/* LIB_SPEC appropriate for OpenBSD. Include -lpthread if -pthread is
+ specified on the command line. */
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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)
+any later version.
+
+GNU CC 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. */
+
+#define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread} -lc}"
+
Modified: llvm-gcc-4.2/trunk/gcc/config/openbsd.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/openbsd.h?rev=82152&r1=82151&r2=82152&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/openbsd.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/openbsd.h Thu Sep 17 13:14:37 2009
@@ -73,6 +73,37 @@
/* Controlling the compilation driver. */
/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD targets. */
+#define OPENBSD_OS_CPP_BUILTINS_COMMON() \
+ do \
+ { \
+ builtin_define ("__OpenBSD__"); \
+ builtin_define ("__unix__"); \
+ builtin_define ("__ANSI_COMPAT"); \
+ builtin_assert ("system=unix"); \
+ builtin_assert ("system=bsd"); \
+ builtin_assert ("system=OpenBSD"); \
+ } \
+ while (0)
+
+/* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */
+#define OPENBSD_OS_CPP_BUILTINS_ELF() \
+ do \
+ { \
+ OPENBSD_OS_CPP_BUILTINS_COMMON(); \
+ builtin_define ("__ELF__"); \
+ } \
+ while (0)
+
+/* TARGET_OS_CPP_BUILTINS() common to all LP64 OpenBSD targets. */
+#define OPENBSD_OS_CPP_BUILTINS_LP64() \
+ do \
+ { \
+ builtin_define ("_LP64"); \
+ builtin_define ("__LP64__"); \
+ } \
+ while (0)
+
+/* XXX old stuff TARGET_OS_CPP_BUILTINS() common to all OpenBSD targets. */
#define OPENBSD_OS_CPP_BUILTINS() \
do \
{ \
@@ -96,15 +127,8 @@
#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
#endif
-/* LIB_SPEC appropriate for OpenBSD. */
-#ifdef HAS_LIBC_R
-/* -lc(_r)?(_p)?, select _r for threads, and _p for p or pg. */
-# define OBSD_LIB_SPEC "%{!shared:-lc%{pthread:_r}%{p:_p}%{!p:%{pg:_p}}}"
-#else
-/* Include -lpthread if -pthread is specified on the command line. */
-# define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}"
-#endif
-
+#undef LIB_SPEC
+#define LIB_SPEC OBSD_LIB_SPEC
#ifndef OBSD_HAS_CORRECT_SPECS
@@ -140,6 +164,10 @@
"%{g:%{!nostdlib:-L/usr/lib/debug}} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}}} %{shared:-Bshareable -x} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
#endif
+#if defined(HAVE_LD_EH_FRAME_HDR)
+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+#endif
+
#undef LIB_SPEC
#define LIB_SPEC OBSD_LIB_SPEC
#endif
@@ -282,10 +310,6 @@
/* Storage layout. */
-/* Otherwise, since we support weak, gthr.h erroneously tries to use
- #pragma weak. */
-#define GTHREAD_USE_WEAK 0
-
/* bug work around: we don't want to support #pragma weak, but the current
code layout needs HANDLE_PRAGMA_WEAK asserted for __attribute((weak)) to
work. On the other hand, we don't define HANDLE_PRAGMA_WEAK directly,
@@ -307,5 +331,18 @@
perror ("mprotect of trampoline code"); \
}
+/* LLVM LOCAL begin */
+#ifdef ENABLE_LLVM
+
+/* Yes, we're supporting PIC codegen for OpenBSD targets! */
+#define LLVM_SET_TARGET_OPTIONS(argvec) \
+ if (flag_pic) \
+ argvec.push_back ("--relocation-model=pic"); \
+ else \
+ argvec.push_back ("--relocation-model=static");
+
+#endif
+/* LLVM LOCAL end */
+
#include <sys/types.h>
#include <sys/mman.h>
More information about the llvm-commits
mailing list