From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 99B76389ECA5 for ; Thu, 15 Sep 2022 21:45:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99B76389ECA5 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-pf1-x429.google.com with SMTP id e68so19370886pfe.1 for ; Thu, 15 Sep 2022 14:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=6TIes/xNw+2NLGLRlR0LhHHSFcCTFhJBZAmrHVw+xiM=; b=Kres5u6sYNbn2dHMHYN5SR02YkrPth8iT4vREOqDBVVU3SdqJRtscsv+XMMrUNIrz7 cHbglWcBWBWqD32h1Tj98OBf9hvB5kVcVmwrX8aCJWmXlfVSATC4aCNKhvgS1XyKqLg4 n1Aa1aEW8yN9cv44kXc3Qvg9Shtwb0xhgGjHG/f8c1Dsqcg7Nxzg1rk2lmnb5Degb3XK GPTUAQJzLy85iqJsxqlO5Ifyckz2mPbRjJCcyXGYS9YsWkzSlcZrpfSX6/duG4WSLmE4 tZL6NtEzJgds4X1GXV63eJea8dSUReX2ybm04yHXu+oI6kPHDK9qQua1WpPGDudj1Xa2 HVTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=6TIes/xNw+2NLGLRlR0LhHHSFcCTFhJBZAmrHVw+xiM=; b=Di5xbzn66rrn2x9fHUruAFLsHXQWZ9GZy3uj2TKAkhyPNRw1keeAe9vnV5TSHWCrgZ kpqcbtxji4XJrH7xld9yWHjeSAgV5IUNWMZfF+QDe5uogcvrqD+ed47xT5PHYUsvybOW 9rBl5IPw3E18+NH9LCYFXvDQ+G3nD9xCvbkbENkEbw/elOOjx2lF1so54yzrQBWuZwpI fZMLeHR4tJ8swhAn00u85RRHwHxkGp94672DyVpFNpVvNEey9ZMSjcHmur9cMxCh8eZM zLZ4vQNT46EodxiRjeqnG6zGxuTaoRkOxjzbe2ASKysMlN9jk+8rbGRTNcbTJt/WWqF3 sPjA== X-Gm-Message-State: ACrzQf2nxVkPeqWc63VXYR5Qe2E9h94YqobfZT71JrLGqFFuu4S8YuZG WnJEi/i1uXgv/JOeSGR/dWsBvg== X-Google-Smtp-Source: AMsMyM4m0F2BEuuxkxHuxw4oWGmkTJsu+OlSu3BePPIU4H7/pOsLZ7Oj9DwguRPxxtb+pc0C4nHi0Q== X-Received: by 2002:a05:6a00:b8d:b0:545:e7de:78e5 with SMTP id g13-20020a056a000b8d00b00545e7de78e5mr1534080pfj.72.1663278318270; Thu, 15 Sep 2022 14:45:18 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:8494:8dcf:dba5:8283]) by smtp.gmail.com with ESMTPSA id q6-20020a17090311c600b00177ef3246absm13682311plh.103.2022.09.15.14.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 14:45:17 -0700 (PDT) Date: Thu, 15 Sep 2022 14:45:13 -0700 From: Fangrui Song To: Wilco Dijkstra Cc: "H.J. Lu" , Florian Weimer , Wilco Dijkstra via Libc-alpha Subject: Re: [RESEND PATCH] Makeconfig: Set pie-ccflag to -fPIE by default Message-ID: <20220915214513.s6uzsy2zvcnevolx@google.com> References: <10cbed26-dc3c-3a55-8e39-95916c614dbb@linaro.org> <87pmgj2o1d.fsf@oldenburg.str.redhat.com> <20220829195703.tvrqhe7ggnaks3oo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-19.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,KAM_INFOUSMEBIZ,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-09-05, Wilco Dijkstra wrote: >Hi, > >>>> Right, so it should be safe then to mark all symbols as hidden. >>>> >>>> We could also teach GCC to never emit GOT indirections with -fPIE -static >>>> (the only reason to use a GOT indirection is to avoid copy relocations in >>>> dynamically linked binaries). >>>> >>> >>>But -static isn't passed to cc1. > >The driver could just pass it or change -fPIE into a new -fstatic-PIE. > >> With Clang, -fPIE -fno-direct-access-external-data can be used. >> See https://maskray.me/blog/2021-01-09-copy-relocations-canonical-plt-entries-and-protected >> >> GCC's x86 port went with -mdirect-extern-access. > >Well ideally we'd have the same option that works in both compilers - it's likely easy to >support in GCC. > >It would be great to also have something like -ffast-PIC that implies -fno-semantic-interposition >since 99% of the time you don't need semantic interposition. > >Cheers, >Wilco In Clang, -fpic/-fPIC without -fno-semantic-interposition still allows interprocedural optimizations of default visibility external linkage definitions. It is unfortunate that GCC doesn't allow it and --enable-default-semantic-interposition is rejected (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100937) So if such an option -ffast-PIC is made, it will only benefit GCC. I have a long write-up in https://maskray.me/blog/2021-05-09-fno-semantic-interposition#in-action