From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id F0E033858D29 for ; Mon, 15 Mar 2021 07:45:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F0E033858D29 Received: by mail-pj1-x1029.google.com with SMTP id cl21-20020a17090af695b02900c61ac0f0e9so1544197pjb.1 for ; Mon, 15 Mar 2021 00:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9u5yeb9IvBRmVu4KdNRQOt0r4quDfRPv1NqJC49WIHI=; b=JnKlMhYfRaIej0CJCssXfVXKxIpf76Uq3uVCpR+aJm6IY4Zum4kLXvj3Nxfiop3o0m wUNj8jCPnpZ41WmCrrFwT4Dp7hoegxh8MqEW9ZI9/2gJ5kAXftto/tDWpHuegQYjgYU4 /vGuiFjm2NzZ1AvcsZMgmrEajZClBBQlMYYjHXN0TWaFX4BCa1/WNnZNhZtlFuz3K9bX VrgCD7ITS8iYIouEtBg6gCNyNcfjB3Dttfz3S3LZpuRyGvuShnZk+tA4iYHeUEUyJ8S4 9AcfoMK4lPsM+KqtSG5Vqf0uMFbdouhLHLlLigYVgqgTMaaT6EOg9+Rk88RtCfATnplM Tl/g== X-Gm-Message-State: AOAM53237Yv924/QWNkF2fsZ4jfZBuXk11f0EvBs9mRAfKzUbyVAz1C3 vSHRREuKTdNjGoO8npvL2VKhQg9Jr8Tz83VNptLTikvLMDHBlQ== X-Google-Smtp-Source: ABdhPJwHPIEwsUuLzXDMbiVTS7cVj/bRlmukejSqVHML/xsTrIrhorkbG14d/Ojb7b3OnhMaXL3nUj2HVp5GTztyuYI= X-Received: by 2002:a17:902:b28b:b029:e6:375:69b0 with SMTP id u11-20020a170902b28bb02900e6037569b0mr10434610plr.25.1615794335044; Mon, 15 Mar 2021 00:45:35 -0700 (PDT) MIME-Version: 1.0 References: <20210315011050.309228-1-maskray@google.com> <878s6ozxil.fsf@oldenburg.str.redhat.com> In-Reply-To: <878s6ozxil.fsf@oldenburg.str.redhat.com> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Mon, 15 Mar 2021 00:45:23 -0700 Message-ID: Subject: Re: [PATCH] Set the retain attribute on _elf_set_element if CC supports [BZ #27492] To: Florian Weimer Cc: Fangrui Song via Libc-alpha Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.6 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_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Mar 2021 07:45:37 -0000 On Mon, Mar 15, 2021 at 12:28 AM Florian Weimer wrote: > > * Fangrui Song via Libc-alpha: > > > So that text_set_element/data_set_element/bss_set_element defined > > variables will be retained by the linker. > > > > Note: 'used' and 'retain' are orthogonal: 'used' makes sure the variable > > will not be optimized out; 'retain' prevents section garbage collection > > if the linker support SHF_GNU_RETAIN. > > This needs recent-ish GCC 11, see commit 6347f4a0904fce17e ("Add retain > attribute to place symbols in SHF_GNU_RETAIN section). > > > +#ifdef __has_attribute > > +#if __has_attribute (retain) > > +# ifdef SHARED > > Indentation is off there. OK. I can increase the level of indentation... > It's probably simpler to define a new macro, like > ELEMENT_SECTION_ATTRIBUTES, and use that unconditionally, perhaps like > this? > > #ifndef __ASSEMBLER__ > # if defined (__has_attribute) && __has_attribute (retain) > # define ELEMENT_SECTION_ATTRIBUTES used, retain > # else > # define ELEMENT_SECTION_ATTRIBUTES used > # endif > #endif `#ifdef __has_attribute` should be fine without #ifndef __ASSEMBLER__ ? > Have you checked that __has_attribute (retain) is only true on GCC if > the underlying linker has retain support and the attribute does not > produce a warning? There is a GCC bug. I've reported https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587 > > Thanks, > Florian >