From patchwork Mon Sep 9 15:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 173392 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp4534971ilq; Mon, 9 Sep 2019 08:46:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4S16+tE0khglrmAP8dTzFF1qb3w8nzOT6V/CthOVbUBqF3YZ9WYYZ9qLH4uqOdKqjtMhX X-Received: by 2002:aa7:da8b:: with SMTP id q11mr24950870eds.19.1568044019889; Mon, 09 Sep 2019 08:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568044019; cv=none; d=google.com; s=arc-20160816; b=NoJboMUL9olN/Ja/Ko02GoPBmoQMHtGrIxz1L+NhvSp7B4JTOwWnFeQ7W9v5C82Jct 1F/RkkeHrQF+HmUwFp6+FAxirHmkwnvMQ4vYVcF6a7K/sGMYAb1rOwMCs94x8GA5F5Lj zF8Xu+kcHAI4PB/Ml/qEx0qGClVakmGlIGIpdd4Uddcqqhu8EMUOidnH4FdId/M4VmIc l5Y1i53RKXR0wLrT3DDdcPmvCgS766KWNxVAgPBoC3uxzIiWGBUGRtel/yz23UFuUkWp QcjMITR8q8rpBztBXs4C4khq09maAUsxEA4EEqCmcYO0hdXD9rd082gOCbMWAnXcvTqx EBDw== 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:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature; bh=msFjZApsUqI6yomSYB7PGt0ODu+kVLdK3ralH3/PEoU=; b=RmdgRBPegztp7yWSP0WeR93z6eV3cnOrHuUsMpFYeWmq4S0LW0ZWW/qOdTesPYbI+e qHi/XvIQkqZX4BHtcNcLrtztSefh2CDPlaMkiKKMreMiV9jwQBJOLP59ctlo1Ugi20Fp APtqxtSwXelnK5+GC+0HAeTAjX5FFz/ZAsNvsouK0smE2TALBeRsW8bDXQFo+UgLdq9a zc/EO8kTivdtAwZ+1VAFnHJVUsLjaVvl3P32lkPJDmkbYe8n/TBx2fEEFCxqpZAQCtPD Kg+bovb3Yg+jO45JSOnhITCMy8m0lRcAqWxlCqVYQ3x7KfFZHV0HM9qcXOXx0EGMdmZ8 lWUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XkWuWmkk; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=OzziAZpb; spf=pass (google.com: domain of gcc-patches-return-508645-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-508645-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 b2si7901517ejv.318.2019.09.09.08.46.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Sep 2019 08:46:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-508645-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=XkWuWmkk; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=OzziAZpb; spf=pass (google.com: domain of gcc-patches-return-508645-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-508645-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=ruN tLotjQVaiXaX+J6MA2ccaQAYqlV7xVjjYfCMD74E/6Q1C2AIPEGJKrpoB7YCm/PL NaZoDG20RgwRDhjVJ8/U+vHZbOGy+XYzWSBfjmrhbJEkzKhMQOaOutRQwcf7tAOF L3zrfKX/oN3xKN7/sAPPmT1yYNzhJbtdh0qu+6Es= 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=t4pckgjU/ t/cZyTniuEIk1NW3MI=; b=XkWuWmkk31OMpV+okGz16P0Rqdpx47lJssaK4XCIL VcFRGx1LHys6JHHDJ7dql7v7/UotR4qH2c5VNdkXpjaERNxxpqUmtasr5QkI/h18 vfmcukSc8NtXvAPV/vSZzE3XYVJGtjeTderSGFeemZEYxSi5M51dJ5N4DxY7nIhM LQ= Received: (qmail 113411 invoked by alias); 9 Sep 2019 15:46:46 -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 113403 invoked by uid 89); 9 Sep 2019 15:46:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, 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.1 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Sep 2019 15:46:45 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x89FkgaM027615 for ; Mon, 9 Sep 2019 17:46:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=STMicroelectronics; bh=msFjZApsUqI6yomSYB7PGt0ODu+kVLdK3ralH3/PEoU=; b=OzziAZpbVopeGo9aeouoUEjsRqAw7529YSo1OYtNH7YPRC/9Mipi8yAZlz8TzpVTOVLL 2fyTn30T+lh8QI5DRM4mvOtmCiN0ayq4HYxNIkozKpTmh+jvFRDmNXpuRWA1/38l3nCI vOg7SJmvbacLTvS2kXzmr7YOTpefxPQjwDrj/fbfnJvdUANTbGsbNfWle5xmvSmUpq3e zSloR+sN0RWLyUVNNkfCREgKVaiyoalHXvBWI0XXscJfD7SY2OusPBAUCYvDxpPY5oiY C5pKxDNRy2wa6AZfIPsD5dMkdoTmmuwXUMuJOQlHV4qZ3x8settNh4gD1oyYswQmAbN1 KQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx08-00178001.pphosted.com with ESMTP id 2uv3ehpjb5-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 09 Sep 2019 17:46:42 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 41AAB4C for ; Mon, 9 Sep 2019 15:46:34 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id A2DB32B9BCE for ; Mon, 9 Sep 2019 17:46:33 +0200 (CEST) Received: from gnb.st.com (10.75.127.46) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 9 Sep 2019 17:46:33 +0200 From: Christophe Lyon To: Subject: [ARM/FDPIC v6 03/24] [ARM] FDPIC: Force FDPIC related options unless -mno-fdpic is provided Date: Mon, 9 Sep 2019 17:44:45 +0200 Message-ID: <20190909154526.11630-4-christophe.lyon@st.com> In-Reply-To: <20190909154526.11630-1-christophe.lyon@st.com> References: <20190909154526.11630-1-christophe.lyon@st.com> MIME-Version: 1.0 X-IsSubscribed: yes From: Christophe Lyon 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 static link is not supported as it requires specifying 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. 2019-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. (MUSL_DYNAMIC_LINKER): Add -fdpic suffix when needed. * config/arm/uclinuxfdpiceabi.h: New file. libsanitizer/ * configure.tgt (arm*-*-*fdpiceabi): Sanitizers are unsupported in this configuration. Change-Id: I74ac1fbb2e809e864d2b0acce66b173e76bcf92b -- 2.6.3 diff --git a/gcc/config.gcc b/gcc/config.gcc index 69904fd..2a6a8f0 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1208,6 +1208,11 @@ arm*-*-linux-* | arm*-*-uclinuxfdpiceabi) 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 e1bacf4..75d9a99 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,8 @@ /* 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 66ec0ea..b348971 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -89,7 +89,7 @@ #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}" #endif #define MUSL_DYNAMIC_LINKER \ - "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1" + "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to use the GNU/Linux version, not the generic BPABI version. */ @@ -101,9 +101,12 @@ #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) diff --git a/gcc/config/arm/uclinuxfdpiceabi.h b/gcc/config/arm/uclinuxfdpiceabi.h new file mode 100644 index 0000000..328adcb --- /dev/null +++ b/gcc/config/arm/uclinuxfdpiceabi.h @@ -0,0 +1,54 @@ +/* Configuration file for ARM GNU/Linux FDPIC EABI targets. + Copyright (C) 2018,2019 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 %{!fno-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. */ +/* -static is not supported, because we have to define the + dynamic-linker, as we have some relocations to resolve at load + time. We do not generate an error in case the user explictly passes + the -dynamic-linker option to the linker. */ +#undef SUBTARGET_EXTRA_LINK_SPEC +#define SUBTARGET_EXTRA_LINK_SPEC \ + "%{!mno-fdpic: -m " TARGET_FDPIC_LINKER_EMULATION \ + "%{!shared:%{!r: -pie}} }" \ + "%{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 3fb90ea..714f292 100644 --- a/libsanitizer/configure.tgt +++ b/libsanitizer/configure.tgt @@ -42,6 +42,9 @@ case "${target}" in ;; sparc*-*-solaris2.11*) ;; + arm*-*-*fdpiceabi) + UNSUPPORTED=1 + ;; arm*-*-linux*) ;; mips*64*-*-linux*)