From patchwork Wed Sep 19 08:32:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kettenis X-Patchwork-Id: 184947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 121962C007C for ; Wed, 19 Sep 2012 18:32:53 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348648374; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:Message-Id:From:To:CC:In-reply-to:Subject:References: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=K3aioMChsH6B6ejMy1cN Y8FMAxU=; b=Sow9IL/8mbQdNClsxLTlEamJq0bd61XbOGYq4iIGbueDQEsbRXXp QhCOORZotp1WqLgpxN3O4SZ/F2J4lXRYi65y3QBpwsH8yVoYLjS5KQYlTOkogaWQ JL50K7LEZ2AhtcRBsBw1Ns8gg3wpBDimN+59QzBoq4SUnLNfFi5u5M8= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:Message-Id:From:To:CC:In-reply-to:Subject:References:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MpqYhz+2jPkOAXF7qX8M387Hyhj2s5Zii9X87eSJP4L47xSg/4AepiYnQtXVwf QiLndRza0Uy+Zud9WCwGe8PT8KVgwi752U9MNwcR3FyTD2LNwWvav1PqYEyzuVCR xYujFchRDwxIPL/jXVxFSoufhRyPdN9NXFUnrCjKDH/SE=; Received: (qmail 8494 invoked by alias); 19 Sep 2012 08:32:42 -0000 Received: (qmail 8476 invoked by uid 22791); 19 Sep 2012 08:32:37 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Sep 2012 08:32:22 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id q8J8WJ3v026601; Wed, 19 Sep 2012 10:32:19 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id q8J8WHe1021522; Wed, 19 Sep 2012 10:32:17 +0200 (CEST) Date: Wed, 19 Sep 2012 10:32:17 +0200 (CEST) Message-Id: <201209190832.q8J8WHe1021522@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: dave.anglin@nrc-cnrc.gc.ca CC: mark.kettenis@xs4all.nl, gcc-patches@gcc.gnu.org In-reply-to: <20120918184335.GA5236@hiauly1.hia.nrc.ca> (message from John David Anglin on Tue, 18 Sep 2012 14:43:35 -0400) Subject: Re: [PATCH] OpenBSD/hppa support References: <201209061833.q86IXNUa025235@glazunov.sibelius.xs4all.nl> <20120918184335.GA5236@hiauly1.hia.nrc.ca> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org > Date: Tue, 18 Sep 2012 14:43:35 -0400 > From: John David Anglin > > On Thu, 06 Sep 2012, Mark Kettenis wrote: > > > Most bits are stolen from Linux, but there are a few subtle > > differences since our assembler is configured to be slightly more > > HP-UX-ish. > > > > > > libgcc/: > > > > 2012-09-06 Mark Kettenis > > > > * config.host (hppa-*-openbsd*): New target. > > * config/pa/t-openbsd: New file. > > > > gcc/: > > > > 2012-09-06 Mark Kettenis > > > > * config.gcc (hppa*-*-openbsd*): New target. > > * config/pa/pa-openbsd.h: New file. > > * config/pa/pa32-openbsd.h: New file. > > * config/host-openbsd.c (TRY_EXCEPT_VM_SPACE): Define for > > OpenBSD/hppa. > > OK. Please add 2012 to files with copyrights. Thanks Dave! Here is an update diff with the copyright year updates. Would you be so kind to commit this for me? Thanks, Mark libgcc/: 2012-09-19 Mark Kettenis * config.host (hppa-*-openbsd*): New target. * config/pa/t-openbsd: New file. gcc:/ 2012-09-19 Mark Kettenis * config.gcc (hppa*-*-openbsd*): New target. * config/pa/pa-openbsd.h: New file. * config/pa/pa32-openbsd.h: New file. * config/host-openbsd.c: Update copyright year. (TRY_EXCEPT_VM_SPACE): Define for OpenBSD/hppa. Index: gcc/config/pa/pa32-openbsd.h =================================================================== --- gcc/config/pa/pa32-openbsd.h (revision 0) +++ gcc/config/pa/pa32-openbsd.h (working copy) @@ -0,0 +1,23 @@ +/* Definitions for PA_RISC with ELF-32 format + Copyright (C) 2000, 2002, 2004, 2006, 2007, 2010, 2011, 2012 + Free Software Foundation, Inc. + +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. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +/* Turn off various SOM crap we don't want. */ +#undef TARGET_ELF32 +#define TARGET_ELF32 1 Index: gcc/config/pa/pa-openbsd.h =================================================================== --- gcc/config/pa/pa-openbsd.h (revision 0) +++ gcc/config/pa/pa-openbsd.h (working copy) @@ -0,0 +1,162 @@ +/* Definitions for PA_RISC with ELF format + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, + 2011, 2012 + Free Software Foundation, Inc. + +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. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + + +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do \ + { \ + OPENBSD_OS_CPP_BUILTINS(); \ + builtin_assert ("machine=bigendian"); \ + } \ + while (0) + +/* Our profiling scheme doesn't LP labels and counter words. */ +#define NO_DEFERRED_PROFILE_COUNTERS 1 + +#undef STRING_ASM_OP +#define STRING_ASM_OP "\t.stringz\t" + +#define TEXT_SECTION_ASM_OP "\t.text" +#define DATA_SECTION_ASM_OP "\t.data" +#define BSS_SECTION_ASM_OP "\t.section\t.bss" + +/* We want local labels to start with period if made with asm_fprintf. */ +#undef LOCAL_LABEL_PREFIX +#define LOCAL_LABEL_PREFIX "." + +/* Define these to generate the Linux/ELF/SysV style of internal + labels all the time - i.e. to be compatible with + ASM_GENERATE_INTERNAL_LABEL in . Compare these with the + ones in pa.h and note the lack of dollar signs in these. FIXME: + shouldn't we fix pa.h to use ASM_GENERATE_INTERNAL_LABEL instead? */ + +#undef ASM_OUTPUT_ADDR_VEC_ELT +#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ + if (TARGET_BIG_SWITCH) \ + fprintf (FILE, "\t.word .L%d\n", VALUE); \ + else \ + fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE) + +#undef ASM_OUTPUT_ADDR_DIFF_ELT +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ + if (TARGET_BIG_SWITCH) \ + fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL); \ + else \ + fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE) + +/* Use the default. */ +#undef ASM_OUTPUT_LABEL + +/* NOTE: (*targetm.asm_out.internal_label)() is defined for us by elfos.h, and + does what we want (i.e. uses colons). It must be compatible with + ASM_GENERATE_INTERNAL_LABEL(), so do not define it here. */ + +/* Use the default. */ +#undef ASM_OUTPUT_INTERNAL_LABEL + +/* Use the default. */ +#undef TARGET_ASM_GLOBALIZE_LABEL + +/* FIXME: Hacked from the one so that we avoid multiple + labels in a function declaration (since pa.c seems determined to do + it differently) */ + +#undef ASM_DECLARE_FUNCTION_NAME +#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ + do \ + { \ + ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ + ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ + } \ + while (0) + +/* As well as globalizing the label, we need to encode the label + to ensure a plabel is generated in an indirect call. */ + +#undef ASM_OUTPUT_EXTERNAL_LIBCALL +#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ + do \ + { \ + if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \ + pa_encode_label (FUN); \ + (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0)); \ + } \ + while (0) + +/* This says how to output an assembler line to define a global common symbol + with size SIZE (in bytes) and alignment ALIGN (in bits). */ + +#undef ASM_OUTPUT_ALIGNED_COMMON +#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ + pa_asm_output_aligned_common (FILE, NAME, SIZE, ALIGN) + +/* This says how to output an assembler line to define a local common symbol + with size SIZE (in bytes) and alignment ALIGN (in bits). This macro + controls how the assembler definitions of uninitialized static variables + are output. */ + +#undef ASM_OUTPUT_ALIGNED_LOCAL +#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ + pa_asm_output_aligned_local (FILE, NAME, SIZE, ALIGN) + +/* OpenBSD always uses gas. */ +#undef TARGET_GAS +#define TARGET_GAS 1 + +/* Layout of source language data types. */ + +/* This must agree with */ +#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 + +#undef WINT_TYPE +#define WINT_TYPE "int" + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{!shared:%{!nostdlib:%{!r:%{!e*:-e __start}}}} \ + %{shared:-shared} %{R*} \ + %{static:-Bstatic} \ + %{!static:-Bdynamic} \ + %{assert*} \ + -dynamic-linker /usr/libexec/ld.so" + +#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}" + +#define OBSD_HAS_CORRECT_SPECS + +#define HAVE_ENABLE_EXECUTE_STACK Index: gcc/config/host-openbsd.c =================================================================== --- gcc/config/host-openbsd.c (revision 191150) +++ gcc/config/host-openbsd.c (working copy) @@ -1,5 +1,6 @@ /* OpenBSD host-specific hook definitions. - Copyright (C) 2004, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2004, 2007, 2008, 2010, 2011, 2012 + Free Software Foundation, Inc. This file is part of GCC. @@ -33,6 +34,8 @@ that's probably free. */ #if defined(__amd64__) # define TRY_EMPTY_VM_SPACE 0x400000000000 +#elif defined(__hppa__) +# define TRY_EMPTY_VM_SPACE 0xb0000000 #elif defined(__i386__) # define TRY_EMPTY_VM_SPACE 0xb0000000 #else Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 191150) +++ gcc/config.gcc (working copy) @@ -1016,10 +1016,15 @@ tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h pa/pa-linux.h \ pa/pa32-regs.h pa/pa32-linux.h" ;; -# port not yet contributed. -#hppa*-*-openbsd*) -# target_cpu_default="MASK_PA_11" -# ;; +hppa*-*-openbsd*) + target_cpu_default="MASK_PA_11" + tm_file="${tm_file} dbxelf.h elfos.h openbsd.h openbsd-stdint.h openbsd-libpthread.h \ + pa/pa-openbsd.h pa/pa32-regs.h pa/pa32-openbsd.h" + tmake_file="${tmake_file} pa/t-openbsd" + extra_options="${extra_options} openbsd.opt" + gas=yes + gnu_ld=yes + ;; hppa[12]*-*-hpux10*) case ${target} in hppa1.1-*-* | hppa2*-*-*) Index: libgcc/config/pa/t-openbsd =================================================================== --- libgcc/config/pa/t-openbsd (revision 0) +++ libgcc/config/pa/t-openbsd (working copy) @@ -0,0 +1,9 @@ +#Plug millicode routines into libgcc.a We want these on both native and +#cross compiles. We use the "64-bit" routines because the "32-bit" code +#is broken for certain corner cases. +LIB1ASMSRC = pa/milli64.S +LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI _dyncall + +HOST_LIBGCC2_CFLAGS += -DELF=1 -DLINUX=1 + +LIB2ADD = $(srcdir)/config/pa/fptr.c Index: libgcc/config.host =================================================================== --- libgcc/config.host (revision 191150) +++ libgcc/config.host (working copy) @@ -499,6 +499,9 @@ extra_parts="libgcc_stub.a" md_unwind_header=pa/hpux-unwind.h ;; +hppa*-*-openbsd*) + tmake_file="$tmake_file pa/t-openbsd" + ;; i[34567]86-*-darwin*) tmake_file="$tmake_file i386/t-crtpc i386/t-crtfm" tm_file="$tm_file i386/darwin-lib.h"