From patchwork Fri Nov 16 15:47:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 151351 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp586415ljp; Fri, 16 Nov 2018 07:49:32 -0800 (PST) X-Google-Smtp-Source: AJdET5cAPHTb5kgHkUYmr7wlb+l/QiKJkGjS5QRUmW86YHKhTiTXCvQ1EewXloz614J7q8Mjh9nv X-Received: by 2002:a17:902:6a8b:: with SMTP id n11-v6mr11530964plk.311.1542383372307; Fri, 16 Nov 2018 07:49:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542383372; cv=none; d=google.com; s=arc-20160816; b=Oa7pYZa2ZrW7y6KAGXK2zwY9keUMycUo6C4oji53HHqjtSnLjAMpG12YGfEt4ZDPYI OgLNRwBmlRfIgyYz/sJFAvMSfd1RE2gSLDBcd5ZUzA6YOS3rVwMyLZlJPE+lSox1SqZw 1oTY34uZj8W9ojJYsZLzKKFjImJBXEDcIk1YO7N5+EiWQ9XevHT6NLehNYy+73125yOy Thjxxst1rUoOzGDPBp6GvbGdu89iJdb1Z8gHxKCEt+L+5VFie1WzUafJGsFJk3qXltzH UrFijnPsn3zwYDS+KsQ1QT/t82Ao3MW6WZiLvaGmDjRGhJ/njEBA7VWkxsy6DhWJyQ0X zhkw== 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:cc:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature; bh=YrKjfxlY47OtrjPQg8Cvy8dSGMHEVKeAUTj9G5q5xrA=; b=lBW4NBu5xgemKBlAV3oGrSBVpAV5GC9YfXKfNkyd7MaumHXaZ9lm0SmutuF+K37dSw eyRKAjn++o1nz/nOJ0dz3ImIOVntNZLJF669+4JvdMAhxFR/IW654Q8jWSj5BxQgw0SB sNRDep+CtNB8cSAe/4tXQncJ8K2UgfSxKLP6SmKc6VBbKd7LiE/C03F/kTcjrveXkPo+ ZGrFepD0rCmE3q5szqV9ZRsHW5rMd6hKncad6qoZFDqfrpvVTx9v/mGz6SNbW/q/deLL UXSQ7RUoZQ/Ye+a8HLuUVsKRC6UrgAjSUXQ4vW+XqS8mpku9mim3pOCBBooEeXbQDIFp u4Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KouhnlDI; spf=pass (google.com: domain of gcc-patches-return-490265-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-490265-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 r196si24526132pgr.311.2018.11.16.07.49.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 07:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-490265-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=KouhnlDI; spf=pass (google.com: domain of gcc-patches-return-490265-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-490265-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:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=I910vekQHwKLrBRQ1ZdgXDHXMtVDm9F2Kgc7Id7XXp+RwiRlM4v+V NNyhvda+nzcYSUgwEl4807w2rH86ieK2MaIV1Udh1kIt6Vt+P94meRqUZ6EFnQm4 yQGb2OS9utwCxS/qqXJSfMXINvO8d9ZOjvMhb3iW2mpM85Qpw2WnsI= 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:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=rS6gWdoEL4HzBgF3w+csR/mF89c=; b=KouhnlDIEwrEBWZPQo1Vz/D27EVK zckVkF6WUVTAWlFtxflChUOhhQBy8vO7rM7CgS357KkBeJRIwantCbKyv+5J3YTL m9jg0jejAgzfwsub5x8sCdUZtVeyOh8cBkvA5tv2VMlZofIb2LFZ2lfLHaiHrkB/ uvoM4DfhcSRm6nw= Received: (qmail 68587 invoked by alias); 16 Nov 2018 15:49:20 -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 67514 invoked by uid 89); 16 Nov 2018 15:49:19 -0000 Authentication-Results: sourceware.org; auth=none 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=Tell 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, 16 Nov 2018 15:49:17 +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 wAGFio4v002163; Fri, 16 Nov 2018 16:49:14 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2nsx068vym-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Nov 2018 16:49:14 +0100 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 D7D993F; Fri, 16 Nov 2018 15:49:13 +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 BC21A5011; Fri, 16 Nov 2018 15:49:13 +0000 (GMT) Received: from gnb.st.com (10.75.127.45) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 16 Nov 2018 16:49:13 +0100 From: Christophe Lyon To: CC: Subject: [ARM/FDPIC v4 03/20] [ARM] FDPIC: Force FDPIC related options unless -mno-fdpic is provided Date: Fri, 16 Nov 2018 16:47:31 +0100 Message-ID: <20181116154808.25154-4-christophe.lyon@st.com> In-Reply-To: <20181116154808.25154-1-christophe.lyon@st.com> References: <20181116154808.25154-1-christophe.lyon@st.com> MIME-Version: 1.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 6bfa329..975e293 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1175,6 +1175,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 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 4254b19..af4b740 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -101,11 +101,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 b241ddb..c38b3f4 100644 --- a/libsanitizer/configure.tgt +++ b/libsanitizer/configure.tgt @@ -45,6 +45,9 @@ case "${target}" in ;; sparc*-*-solaris2.11*) ;; + arm*-*-uclinuxfdpiceabi) + UNSUPPORTED=1 + ;; arm*-*-linux*) ;; mips*64*-*-linux*)