From 3a17f73727e2716b1b2031055bbafc331f513248 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Tue, 23 May 2017 16:38:10 +0000 Subject: [PATCH] Bring some rough support for FreeBSD S/390 to the GNU toolchain. This is no-op and only for reference: the S/390 port seems to be elusive in the BSDs so it is convenient to keep some trace from past efforts. It is likely newer attempts will focus on a newer toolchain using clang instead. Obtained from: Perforce depot/projects/s390 --- contrib/binutils/bfd/config.bfd | 4 +- contrib/binutils/ld/configure.tgt | 9 ++ .../binutils/ld/emulparams/elf64_s390_fbsd.sh | 2 + .../binutils/ld/emulparams/elf_s390_fbsd.sh | 2 + contrib/gcc/config.gcc | 9 ++ contrib/gcc/config/s390/freebsd.h | 105 ++++++++++++++++++ 6 files changed, 129 insertions(+), 2 deletions(-) create mode 100755 contrib/binutils/ld/emulparams/elf64_s390_fbsd.sh create mode 100755 contrib/binutils/ld/emulparams/elf_s390_fbsd.sh create mode 100644 contrib/gcc/config/s390/freebsd.h diff --git a/contrib/binutils/bfd/config.bfd b/contrib/binutils/bfd/config.bfd index 1365ac12f8a5..879c3a32ce13 100755 --- a/contrib/binutils/bfd/config.bfd +++ b/contrib/binutils/bfd/config.bfd @@ -1156,13 +1156,13 @@ case "${targ}" in targ_selvecs="bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec" ;; - s390-*-linux*) + s390-*-freebsd* | s390-*-linux*) targ_defvec=bfd_elf32_s390_vec targ64_selvecs=bfd_elf64_s390_vec want64=true ;; #ifdef BFD64 - s390x-*-linux*) + s390x-*-freebsd* | s390x-*-linux*) targ_defvec=bfd_elf64_s390_vec targ_selvecs=bfd_elf32_s390_vec want64=true diff --git a/contrib/binutils/ld/configure.tgt b/contrib/binutils/ld/configure.tgt index 46e05d33a8ab..2ed7d4a19702 100644 --- a/contrib/binutils/ld/configure.tgt +++ b/contrib/binutils/ld/configure.tgt @@ -480,12 +480,21 @@ powerpc-*-lynxos*) targ_emul=ppclynx ;; rs6000-*-aix5*) targ_emul=aix5rs6 ;; rs6000-*-aix*) targ_emul=aixrs6 ;; +s390x-*-freebsd*) targ_emul=elf64_s390 + targ_extra_emuls=elf_s390 + targ_extra_libpath=$targ_extra_emuls + tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;; s390x-*-linux*) targ_emul=elf64_s390 targ_extra_emuls=elf_s390 targ_extra_libpath=$targ_extra_emuls tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;; s390x-*-tpf*) targ_emul=elf64_s390 tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;; +s390-*-freebsd*) targ_emul=elf_s390 + targ64_extra_emuls=elf64_s390 + targ64_extra_libpath=elf64_s390 + tdir_elf64_s390=`echo ${targ_alias} | sed -e 's/s390/s390x/'` + ;; s390-*-linux*) targ_emul=elf_s390 targ64_extra_emuls=elf64_s390 targ64_extra_libpath=elf64_s390 diff --git a/contrib/binutils/ld/emulparams/elf64_s390_fbsd.sh b/contrib/binutils/ld/emulparams/elf64_s390_fbsd.sh new file mode 100755 index 000000000000..c0191ebc9eba --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf64_s390_fbsd.sh @@ -0,0 +1,2 @@ +. ${srcdir}/emulparams/elf64_s390.sh +. ${srcdir}/emulparams/elf_fbsd.sh diff --git a/contrib/binutils/ld/emulparams/elf_s390_fbsd.sh b/contrib/binutils/ld/emulparams/elf_s390_fbsd.sh new file mode 100755 index 000000000000..89662a0c7515 --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf_s390_fbsd.sh @@ -0,0 +1,2 @@ +. ${srcdir}/emulparams/elf_s390.sh +. ${srcdir}/emulparams/elf_fbsd.sh diff --git a/contrib/gcc/config.gcc b/contrib/gcc/config.gcc index ec05466a0eb0..e452dfed6fd3 100644 --- a/contrib/gcc/config.gcc +++ b/contrib/gcc/config.gcc @@ -1942,10 +1942,19 @@ rs6000-ibm-aix[56789].* | powerpc-ibm-aix[56789].*) thread_file='aix' extra_headers= ;; +s390-*-freebsd*) + tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file} s390/freebsd.h" + ;; s390-*-linux*) tm_file="s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h" tmake_file="${tmake_file} t-dfprules s390/t-crtstuff s390/t-linux" ;; +s390x-*-freebsd*) + tm_file="s390/s390.h s390/s390x.h dbxelf.h elfos.h ${fbsd_tm_file} s390/freebsd.h" + tm_p_file=s390/s390-protos.h + md_file=s390/s390.md + out_file=s390/s390.c + ;; s390x-*-linux*) tm_file="s390/s390x.h s390/s390.h dbxelf.h elfos.h svr4.h linux.h s390/linux.h" tm_p_file=s390/s390-protos.h diff --git a/contrib/gcc/config/s390/freebsd.h b/contrib/gcc/config/s390/freebsd.h new file mode 100644 index 000000000000..ad88072903bb --- /dev/null +++ b/contrib/gcc/config/s390/freebsd.h @@ -0,0 +1,105 @@ +/* Definitions for FreeBSD for S/390. + Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006 + Free Software Foundation, Inc. + Contributed by Hartmut Penner (hpenner@de.ibm.com) and + Ulrich Weigand (uweigand@de.ibm.com). + +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 2, 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 COPYING. If not, write to the Free +Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301, USA. */ + +#ifndef _CONFIG_S390_FREEBSD_H +#define _CONFIG_S390_FREEBSD_H + +/* Target specific version string. */ + +#ifdef DEFAULT_TARGET_64BIT +#undef TARGET_VERSION +#define TARGET_VERSION fprintf (stderr, " (FreeBSD for zSeries)"); +#else +#undef TARGET_VERSION +#define TARGET_VERSION fprintf (stderr, " (FreeBSD for S/390)"); +#endif + + +/* Target specific type definitions. */ + +/* ??? Do we really want long as size_t on 31-bit? */ +/* Answer is yes for FreeBSD. */ +#undef SIZE_TYPE +#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE 32 + +#undef DEFAULT_SIGNED_CHAR +#define DEFAULT_SIGNED_CHAR 1 + +/* Target specific assembler settings. */ + +#undef ASM_SPEC +#define ASM_SPEC "%{m31&m64}%{mesa&mzarch}%{march=*}" + + +/* Target specific linker settings. */ + +#ifdef DEFAULT_TARGET_64BIT +#define MULTILIB_DEFAULTS { "m64" } +#else +#define MULTILIB_DEFAULTS { "m31" } +#endif + +#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" +#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1" + +#undef LINK_SPEC +#define LINK_SPEC \ + "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ + %{shared:-shared} \ + %{!shared: \ + %{static:-static} \ + %{!static: \ + %{rdynamic:-export-dynamic} \ + %{!dynamic-linker: \ + %{m31:-dynamic-linker " LINUX_DYNAMIC_LINKER32 "} \ + %{m64:-dynamic-linker " LINUX_DYNAMIC_LINKER64 "}}}}" + +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" + +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack + +#define MD_UNWIND_SUPPORT "config/s390/freebsd-unwind.h" + +#ifdef TARGET_LIBC_PROVIDES_SSP +/* s390 glibc provides __stack_chk_guard in 0x14(tp), + s390x glibc provides it at 0x28(tp). */ +#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14) +#endif + +/* Define if long doubles should be mangled as 'g'. */ +#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING + +/* Override the default comment-starter of "/APP" from unix.h. */ +#undef ASM_APP_ON +#define ASM_APP_ON "#APP\n" +#undef ASM_APP_OFF +#define ASM_APP_OFF "#NO_APP\n" + +#endif