From patchwork Wed Sep 14 18:09:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: linted X-Patchwork-Id: 1220 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2302:b0:79:6ae5:3758 with SMTP id gv2csp838822dyb; Wed, 14 Sep 2022 11:11:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7BDZsUZ++dbHSLdhuHoh36cSQRJpK8yut0lvZSmTZaWBdXdV6F22oafr7JS3lAy2wvgTSv X-Received: by 2002:a17:906:8477:b0:77d:185a:b443 with SMTP id hx23-20020a170906847700b0077d185ab443mr11763161ejc.311.1663179063023; Wed, 14 Sep 2022 11:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663179063; cv=none; d=google.com; s=arc-20160816; b=cRZOQnW4O16HDGVtkHnNYDIOm8zXDAD3lTb7lq4mqOGY3ReRaM2Z7izuIkeHjL+j+R 858gsA7Z5ftUJGzsxDza/Y8Mwu/U+7GtRZAlfXYq9ry0EtTj0GUwv/HVA7ctTbU2RYkV eIOOJuRB7apP6L99n0JW1jEYYaGBjejdncBBl9seG3vwbu0ohuDpKlTbPO8ulYvTU+2/ 0jwX+paM/Bk4FXJLJKLceTcDkC0e3xaYYmpxobhkrTwpPAIEWcbwsmXZ8RbLGuxY2uBv bY/RffnCE/RAB4jYNNV5/bNYdaaEgReySPZbRDzqfo5x7p7qCQJntSeTmDwt+eEkyqde 4HWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=2aTqwTifmQ0HChBQbIHAUR9JCqe45qWaYvzF0mM+6wQ=; b=B2m3zQWLa/aL4EhhvUxrMTHZA+GxgZm8+7CV8sCSNp6kPdkTAISpf8lL2eZeL53jGg XOw/Mgl5CZQXTB0u9HWnWSy84zkOT6hOJNnV3kfLDwLBbtkGASIUI115eWmryXcsENlV boU9FZ1y8OekdkjG7xD4xhT/Ml9CrBfPjMfJkZWu8/8hvyER4e2wRWlkuNzn8b4wPwIW wDKzm7yrqwTcGaJoU4GbiFDqY3D2axt+lsUQjcf1JfzWDxN32fpYBbEze/Ta6nZd5yfw AZzAaW5QKf5IRm4VktEOS9/IZ9yhaLJL9UuoOWe/4Q0AqcJNjqNC2YanijsU36/6TTh9 w+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JyaVUqiL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jr20-20020a170906515400b0073d2fa02149si10967409ejc.553.2022.09.14.11.11.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 11:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JyaVUqiL; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A6403857831 for ; Wed, 14 Sep 2022 18:11:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A6403857831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663179061; bh=2aTqwTifmQ0HChBQbIHAUR9JCqe45qWaYvzF0mM+6wQ=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JyaVUqiLjg3tB7kxVL1BOhIEqTX/CACOa3hNMWxjvvVFiwjhD4sEEFihvWHlm9R1S ValbZGON3x9E9x6F7c4qV8TZ0RBWTUNtTjw7yFCRAhqmrS2wuRSn6X7pu82xlYGNbq YumoE/Ds3wn6BhQUcAVhbg3U61x87BufmyIxuw5E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id D598D3856DC2 for ; Wed, 14 Sep 2022 18:10:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D598D3856DC2 Received: by mail-pg1-x52b.google.com with SMTP id g4so15082012pgc.0 for ; Wed, 14 Sep 2022 11:10:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date; bh=N0MOOwksLY4jVvNjlZP3lsHVp8f3DbOGTClUWMIwRIg=; b=1YU4jRnSjCBDJaJLRSerXRCAwHiLC6cKEzwqF2GGTX5Cl14SZwESPIN569/pXQcna7 6h3nwH9qLq4AiidKQOk2UmnaFig0MObgraJxsTIfjTL88SF/vseVcbuzPO0EXjL1Qrwh Bwz0VWLjPdHKEv9bHp2vueyxhnV3NmXy0fErE5RH/THN/mtdoSIh0kUQL+T4/Fv8mmso fj7Qa8MCxvnET6ohi1pBj0+3mzqDT4niG5LKsg83DnvUoyTbnOq6oYK0Js0A2P/JcQxB 4rzG/aj0BJeIA81TNTPrEix735ljNdi/+p7O2dIV8qKj3C9OX7jk39H4Dm459frdno9A GpmA== X-Gm-Message-State: ACgBeo1PFIm6pwGrPcnu7imx3DfAF8sDoi5s+7wCjaTJdZ56KZ9/U2MQ 4BmlV82GMgXQCLAuMXOhQCGCW7Q+uhor22i6WT8ltIqHUsU= X-Received: by 2002:a05:6a00:c91:b0:540:f165:b049 with SMTP id a17-20020a056a000c9100b00540f165b049mr26515865pfv.76.1663179017499; Wed, 14 Sep 2022 11:10:17 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 14 Sep 2022 14:09:56 -0400 Message-ID: Subject: [PATCH] mips: Add appropriate linker flags when compiling with -static-pie To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: linted via Gcc-patches From: linted Reply-To: linted Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743969649070593351?= X-GMAIL-MSGID: =?utf-8?q?1743969649070593351?= Hello, This patch fixes missing flags when compiling with -static-pie on mips. I made these modifications based on the previously submitted static pie patch for arm as well as the working code for aarch64. I tested with a host of mips-elf and checked with mips-sim. This patch was also tested and used with uclibc-ng to generate static pie elfs. This is my first patch for gcc, so please let me know if there is anything I missed. Signed-off-by: linted --- gcc/config/mips/gnu-user.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h index 6aad7192e69..b1c665b7f37 100644 --- a/gcc/config/mips/gnu-user.h +++ b/gcc/config/mips/gnu-user.h @@ -56,11 +56,12 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_TARGET_LINK_SPEC "\ %{G*} %{EB} %{EL} %{mips*} %{shared} \ %{!shared: \ - %{!static: \ + %{!static:%{!static-pie: \ %{rdynamic:-export-dynamic} \ %{mabi=n32: -dynamic-linker " GNU_USER_DYNAMIC_LINKERN32 "} \ %{mabi=64: -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \ - %{mabi=32: -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \ + %{mabi=32: -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \ + %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \ %{static}} \ %{mabi=n32:-m" GNU_USER_LINK_EMULATIONN32 "} \ %{mabi=64:-m" GNU_USER_LINK_EMULATION64 "} \