From patchwork Fri May 25 08:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 136807 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3291134lji; Fri, 25 May 2018 01:33:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHgGeLsDfuhzrayUJ6sGyIT8JM5xMSGr2CoXOJHyQRmiNXGZZuuYz5z/+bj3Qzqqkn3BFd X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr1625660plo.325.1527237229706; Fri, 25 May 2018 01:33:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527237229; cv=none; d=google.com; s=arc-20160816; b=MVYoK9SlnIjRr+5rJSrQclDTWuNe23vXraOO9vkZjhI1kHR0zp4eDg/EPoeT4pmEdC KS0FcLu2l1BvUXhEP99coF0hVF5cyCvKORlLFuCOrs1poldCRXQhRqH7cIyk53MSYLKC vO/Y9ubK//pA6Ev+KL+9HW0jedx3eQmNLmKSlk1HTVKqV92sINikITEn+bM4HPiNGslb rmv9yACpseDQNcEH3htZTkxLzypeacbgNfHCKEYBDXdtSpyKA0ZruASeIBcBnod3KkI3 FqBXLyfYTPllOEl4k2hhY4hNM1Nm9a8hhTGZREbgdtTdO1Cv9QD45af/gx53AT9C3v5O gWCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=ehMP2h7Y79FY8PG+z5p6HrVwzD3c16nFMbHF3kRxABY=; b=lDqnmt9dB7GAsNUttuGrd7Y1sSXv5BQiWntOhae5WDlalN9CEhYf0MWbbbcyiTU0bx VstpzshR0/4uJvmAMi6+w+vAivFWvGzZ1IjXC6ic0JLuBZC+piubEYCD+Li6Q1edtMNO JpcW1faA383xR/T23alKmxRvXwzK9pZYNj5xXAXwgAjkenvDwguT7hNWaIZE1hZ0vkzj BtTjWCBssWX4LSLmnDxRxb5+YW4BF3fMKqM5EguMEGmNfYd37Y8MxuhSJd7PG5k9IUr8 kPxAG4ozBTqq5TH5lH7Lx6yjHUfT0kOJgeKtzqDqL14k/EPxDiwp5WIVx6KZ+MtMl7Gy qsgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ntHcgVeV; spf=pass (google.com: domain of gcc-patches-return-478474-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478474-patch=linaro.org@gcc.gnu.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f26-v6si3113448pgn.247.2018.05.25.01.33.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 01:33:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-478474-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ntHcgVeV; spf=pass (google.com: domain of gcc-patches-return-478474-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478474-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=MN3 aoxhoo93LW/ZnzplnU+f90hXdW8v9bfnI2qkkdVvlAo10O6hfd7OO/zMtLMCgBaz 38DWLXW/P29LRcLmQ2ZauXFd+L4qHRZYPCDeTeB//ZA2d7g5lSxa6WRKigJsM8mS g5SKxuwMxdo+CfCts8xzegYAveSkEyPuvPtbVySg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=XZF3EN8Z3 1GQcax47Ye8HwGs4+I=; b=ntHcgVeVTFQXMBcgjdSTLfwUBCogF6ZCMIQu/lxBJ TMAw2NdYOUy/eVYFTw+JFIDkA68ywqDflqjXkM/HU0qxD2PTVqzZgDmEyAofVnCI a7boJkbxHOlfvEPfysXlbwDl30Kuwuhl6ulkrvotFHiKeX4VM5JlcXP3xrOVXTc9 20= Received: (qmail 74245 invoked by alias); 25 May 2018 08:09:38 -0000 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 Received: (qmail 42841 invoked by uid 89); 25 May 2018 08:05:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=fnopie, fno-pie, fnoPIE, fno-PIE X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 08:05:13 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w4P7xBwI003910; Fri, 25 May 2018 10:05:10 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2j59prjvm2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 25 May 2018 10:05:10 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2807B38; Fri, 25 May 2018 08:05:10 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E9F491B22; Fri, 25 May 2018 08:05:09 +0000 (GMT) Received: from gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 25 May 2018 10:05:09 +0200 From: Christophe Lyon To: , Subject: [ARM/FDPIC 03/21] [ARM] FDPIC: Force FDPIC related options unless -mno-fdpic is provided Date: Fri, 25 May 2018 10:03:16 +0200 Message-ID: <20180525080354.13295-4-christophe.lyon@st.com> In-Reply-To: <20180525080354.13295-1-christophe.lyon@st.com> References: <20180525080354.13295-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-25_03:, , signatures=0 X-IsSubscribed: yes In FDPIC mode, we set -fPIE unless the user provides -fno-PIE, -fpie, -fPIC or -fpic: indeed FDPIC code is PIC, but we want to generate code for executables rather than shared libraries by default. We also make sure to use the --fdpic assembler option, and select the appropriate linker emulation. At link time, we also default to -pie, unless we are generating a shared library or a relocatable file (-r). Note that even for static link, we must specify the dynamic linker because the executable still has to relocate itself at startup. We also force 'now' binding since lazy binding is not supported. We should also apply the same behavior for -Wl,-Ur as for -r, but I couldn't find how to describe that in the specs fragment. 2018-XX-XX Christophe Lyon Mickaël Guêné gcc/ * config.gcc: Handle arm*-*-uclinuxfdpiceabi. * config/arm/bpabi.h (TARGET_FDPIC_ASM_SPEC): New. (SUBTARGET_EXTRA_ASM_SPEC): Use TARGET_FDPIC_ASM_SPEC. * config/arm/linux-eabi.h (FDPIC_CC1_SPEC): New. (CC1_SPEC): Use FDPIC_CC1_SPEC. * config/arm/uclinuxfdpiceabi.h: New file. libsanitizer/ * configure.tgt (arm*-*-uclinuxfdpiceabi): Sanitizers are unsupported in this configuration. Change-Id: If369e0a10bb916fd72e38f71498d3c640fa85c4c -- 2.6.3 diff --git a/gcc/config.gcc b/gcc/config.gcc index f3fdbf8..01b81c6 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1140,6 +1140,11 @@ arm*-*-linux-* | arm*-*-uclinuxfdpiceabi) # ARM GNU/Linux with ELF esac tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi" tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h arm/aout.h vxworks-dummy.h arm/arm.h" + case $target in + arm*-*-uclinuxfdpiceabi) + tm_file="$tm_file arm/uclinuxfdpiceabi.h" + ;; + esac # Generation of floating-point instructions requires at least ARMv5te. if [ "$with_float" = "hard" -o "$with_float" = "softfp" ] ; then target_cpu_cname="arm10e" diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 1e3ecfb..5901154 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -55,6 +55,8 @@ #define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}" +#define TARGET_FDPIC_ASM_SPEC "" + #define BE8_LINK_SPEC \ "%{!r:%{!mbe32:%:be8_linkopt(%{mlittle-endian:little}" \ " %{mbig-endian:big}" \ @@ -64,7 +66,7 @@ /* Tell the assembler to build BPABI binaries. */ #undef SUBTARGET_EXTRA_ASM_SPEC #define SUBTARGET_EXTRA_ASM_SPEC \ - "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5}" TARGET_FIX_V4BX_SPEC + "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5}" TARGET_FIX_V4BX_SPEC TARGET_FDPIC_ASM_SPEC #ifndef SUBTARGET_EXTRA_LINK_SPEC #define SUBTARGET_EXTRA_LINK_SPEC "" diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index 8585fde..4cee958 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -98,11 +98,14 @@ #undef ASAN_CC1_SPEC #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}" +#define FDPIC_CC1_SPEC "" + #undef CC1_SPEC #define CC1_SPEC \ - LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC, \ + LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC " " \ + FDPIC_CC1_SPEC, \ GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC " " \ - ANDROID_CC1_SPEC) + ANDROID_CC1_SPEC "" FDPIC_CC1_SPEC) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) diff --git a/gcc/config/arm/uclinuxfdpiceabi.h b/gcc/config/arm/uclinuxfdpiceabi.h new file mode 100644 index 0000000..43a17de --- /dev/null +++ b/gcc/config/arm/uclinuxfdpiceabi.h @@ -0,0 +1,53 @@ +/* Configuration file for ARM GNU/Linux FDPIC EABI targets. + Copyright (C) 2018 Free Software Foundation, Inc. + Contributed by STMicroelectronics. + + 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 + . */ + +/* On uClibc EABI GNU/Linux, we want to force -mfdpic by default, + which also means we produce PIE code by default. */ +#undef FDPIC_CC1_SPEC +#define FDPIC_CC1_SPEC \ + "%{!mno-fdpic:-mfdpic %{!no-PIE:%{!fpie:%{!fPIC:%{!fpic: -fPIE}}}}}" + +/* Add --fdpic assembler flag by default. */ +#undef TARGET_FDPIC_ASM_SPEC +#define TARGET_FDPIC_ASM_SPEC "%{!mno-fdpic: --fdpic}" + +/* TARGET_BIG_ENDIAN_DEFAULT is set in + config.gcc for big endian configurations. */ +#if TARGET_BIG_ENDIAN_DEFAULT +#define TARGET_FDPIC_LINKER_EMULATION "armelfb_linux_fdpiceabi" +#else +#define TARGET_FDPIC_LINKER_EMULATION "armelf_linux_fdpiceabi" +#endif + +/* Unless we generate a shared library or a relocatable object, we + force -pie. */ +/* Even with -static, we have to define the dynamic-linker, as we + have some relocations to resolve at load time. */ +#undef SUBTARGET_EXTRA_LINK_SPEC +#define SUBTARGET_EXTRA_LINK_SPEC \ + "%{!mno-fdpic: -m " TARGET_FDPIC_LINKER_EMULATION \ + "%{!shared:%{!r: -pie}} \ + %{static:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" \ + "%{mno-fdpic: -m " TARGET_LINKER_EMULATION "}" \ + "%{!r:%{!mno-fdpic: -z now}}" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "%{!mno-fdpic:%{!shared:crtreloc.o%s}} " \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt index 1dce1e6..dff34cd 100644 --- a/libsanitizer/configure.tgt +++ b/libsanitizer/configure.tgt @@ -43,6 +43,9 @@ case "${target}" in ;; s390*-*-linux*) ;; + arm*-*-uclinuxfdpiceabi) + UNSUPPORTED=1 + ;; arm*-*-linux*) ;; mips*64*-*-linux*)