From patchwork Sat Feb 24 03:33:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 86318 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BF0A93858287 for ; Sat, 24 Feb 2024 03:34:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by sourceware.org (Postfix) with ESMTPS id 10D8B3858425 for ; Sat, 24 Feb 2024 03:33:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10D8B3858425 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=flex--maskray.bounces.google.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10D8B3858425 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::114a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708745642; cv=none; b=tROEokfnFUI92LMJC9ONRUAAUbOABNrF08thtAaieJm5VE4bgBmNDmX0sbm6vdCUVSBvHZGp27lRXFg2Qepc5ZbnEL9jjrhsaJtd1zIrY06P5hlceK0ottGeGgEfxxhj1419aTtj8yYlugstp6XAgg66tofk1ZbCsd/1+nTbUV8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708745642; c=relaxed/simple; bh=uUUuOZNmQNyl/v9pJ4S4alDicFhDT18f3pbVTin8P8c=; h=DKIM-Signature:Date:Mime-Version:Message-ID:Subject:From:To; b=Qcg4hJMvLb0iyfzWqM7yV/7jduIzhg4Db+5K+vS+C7jqKq+kFPQlJDO4T/uLautiF6mdCLUWJJkiQo4TuuuUCO8ozXEwfcl/AvqJBTXcOPYuISFnYwGRvNhAwb4fCV12miE7ZE/Ud4Tbn7l0Q5lMaUImSio5b/4Jh0K201+rG3I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-608d6e7314bso22037b3.3 for ; Fri, 23 Feb 2024 19:33:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708745637; x=1709350437; darn=gcc.gnu.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=t1FI3j6aaBARzrrwF/OYnqqsv0+S4WE3pP8Pgp2CLl0=; b=UkHXZqo+oB7Sbj3b3c79sYrm6M1zWpfZkmUqr5kflT96zUIXbWV803Vn0BjlEkpQmK OXt4BnuE4wI5BxYNKSJlu72UqS7N5pkaKx0ARilrARRgzOkmXFgAOreN6NansOl+kaVi QVmeFiIH+Q9hQozfTKnMpKWMvEizigguPfsUSKvjMSZTSD6kGbfdwdQfZskd/v5Zvh06 qEBGYPziz9N69tVywpqWWMsiWhYHUVOrMhUkDd2hc5Ar4YvNjPJ/oBUItUUin7tQhNqT gNDb8mY51wJRqR19mPBXC3aaGYZT5F6TMH++5E365jtCWWETzvkd/xSeF9kyg9oa0Fue O5Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708745637; x=1709350437; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=t1FI3j6aaBARzrrwF/OYnqqsv0+S4WE3pP8Pgp2CLl0=; b=OT8xSK+DU0TYnVCjhu81EhRWmWHbIKtx1zsVpavm5Uw9t++smecusgZnt2ppXn2T1/ k5e2fohKPbNIF61yFUG85s0Yt6vKFTxAdxCaKu3sh2GrjWiy2ByZ60JnBtswBhNSbOuQ zFLItXrdZF6YaHYAS1Yvb7B5iS0VhIxEsSmfAiubf2w/YDXTSu6SiDa3RjYpMpTko85s k9Xuo0Cai0YPsxEEaLUSSjKLSBIgwTfOMJXC8SUKrqVj9xMrLmpQFdMVdWfU4TlyA0to 7R0fVJDYXPkIEa84y/N0PRFOoEJXVTHefU8C98aZebWUlEG/U1CPp2uc87GW36G9Rrax koaQ== X-Gm-Message-State: AOJu0YzsOs/K3/HMtTQKpmxeh6FBxsu0GkEFmd6L2o8GplutLM1uejKK K6GK/ARl4Q2eCYlzr8E7ZBvcjoxzWVgT7WoBBSZnQm+DnNbP7Eeo8rZghkQvqI78mbvwPwT3pQK UT8VuIlWnyp8YIVZ1A+oTd/yfJhQjPwxjNkWTs4PZK1EHBk/WpOIj9TypQcekiPB4yceSY9Q+X+ b+lEcnYQixOQZLhnZ9VwZrTLA6q1hYXIxBh6tI5iY= X-Google-Smtp-Source: AGHT+IFWHF9GtmXn2TFH8GXeu1Ioy4Wavpiu0U8MB0cMK/kFLHsBJbMfiwH2IV8vTJ+61XZwInbHp/AB21as X-Received: from maskray.svl.corp.google.com ([2620:15c:2d3:205:472:653f:d0c7:471]) (user=maskray job=sendgmr) by 2002:a05:690c:3612:b0:607:a30d:8cf with SMTP id ft18-20020a05690c361200b00607a30d08cfmr313938ywb.4.1708745637369; Fri, 23 Feb 2024 19:33:57 -0800 (PST) Date: Fri, 23 Feb 2024 19:33:54 -0800 Mime-Version: 1.0 Message-ID: <20240224033354.3767291-1-maskray@google.com> Subject: [PATCH] arm: Support -mfdpic for more targets From: Fangrui Song To: gcc-patches@gcc.gnu.org Cc: Christophe Lyon , Szabolcs Nagy , richard.earnshaw@arm.com, Fangrui Song X-Spam-Status: No, score=-19.6 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org From: Fangrui Song Targets that are not arm*-*-uclinuxfdpiceabi can use -S -mfdpic, but -c -mfdpic does not pass --fdpic to gas. This is an unnecessary restriction. Just define the ASM_SPEC in bpabi.h. Additionally, use armelf[b]_linux_fdpiceabi emulations for -mfdpic in linux-eabi.h. This will allow a future musl fdpic port to use the desired BFD emulation. gcc/ChangeLog: * config/arm/bpabi.h (TARGET_FDPIC_ASM_SPEC): Transform -mfdpic. * config/arm/linux-eabi.h (TARGET_FDPIC_LINKER_EMULATION): Define. (SUBTARGET_EXTRA_LINK_SPEC): Use TARGET_FDPIC_LINKER_EMULATION if -mfdpic. --- gcc/config/arm/bpabi.h | 2 +- gcc/config/arm/linux-eabi.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 7a279f3ed3c..6778be1a8bf 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -55,7 +55,7 @@ #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 TARGET_FDPIC_ASM_SPEC "%{mfdpic: --fdpic}" #define BE8_LINK_SPEC \ "%{!r:%{!mbe32:%:be8_linkopt(%{mlittle-endian:little}" \ diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index eef791f6a02..0c5c58e4928 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -46,12 +46,15 @@ #undef TARGET_LINKER_EMULATION #if TARGET_BIG_ENDIAN_DEFAULT #define TARGET_LINKER_EMULATION "armelfb_linux_eabi" +#define TARGET_FDPIC_LINKER_EMULATION "armelfb_linux_fdpiceabi" #else #define TARGET_LINKER_EMULATION "armelf_linux_eabi" +#define TARGET_FDPIC_LINKER_EMULATION "armelf_linux_fdpiceabi" #endif #undef SUBTARGET_EXTRA_LINK_SPEC -#define SUBTARGET_EXTRA_LINK_SPEC " -m " TARGET_LINKER_EMULATION +#define SUBTARGET_EXTRA_LINK_SPEC " -m %{mfdpic: " \ + TARGET_FDPIC_LINKER_EMULATION ";:" TARGET_LINKER_EMULATION "}" /* GNU/Linux on ARM currently supports three dynamic linkers: - ld-linux.so.2 - for the legacy ABI