From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3AAE33835416; Sat, 17 Apr 2021 03:09:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AAE33835416 From: "i at maskray dot me" To: glibc-bugs@sourceware.org Subject: [Bug libc/27492] Make static linking friendly with {ld.bfd,ld.lld} -z start-stop-gc: removing unused section '__libc_atexit' Date: Sat, 17 Apr 2021 03:09:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.33 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: version bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Apr 2021 03:09:11 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27492 Fangrui Song changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |2.33 Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #3 from Fangrui Song --- Fixed by https://sourceware.org/git/?p=3Dglibc.git;a=3Dcommit;h=3Dcd6ae7ea5431c2b8f1= 6201fb0e2c413bf8d2df06 commit cd6ae7ea5431c2b8f16201fb0e2c413bf8d2df06 Author: Fangrui Song Date: Fri Apr 16 11:26:39 2021 Set the retain attribute on _elf_set_element if CC supports [BZ #27492] 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. GNU ld 2.37 and LLD 13 will support -z start-stop-gc which allow C identifier name sections to be GCed even if there are live __start_/__stop_ references. Without the change, there are some static linking problems, e.g. _IO_cleanup (libio/genops.c) may be discarded by ld --gc-sections, so stdout is not flushed on exit. Note: GCC may warning 'retain' attribute ignored while __has_attribute(retain) is 1 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99587). Reviewed-by: H.J. Lu --=20 You are receiving this mail because: You are on the CC list for the bug.=