From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3A3D33858D32; Wed, 19 Jul 2023 06:20:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A3D33858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689747640; bh=y08v6Jxzaj5HXZgBET85mO5UUh/5Nu6Nb9Ncg0zPXkU=; h=From:To:Subject:Date:From; b=CW3c/Nat6r7QfyaN1HZdDVPfHKgXQk/0AgdtY9UI2nVNJH9cykBo+5gSvSCOP11EO AVxoPsaNukvytAIIN497ALEGxbgtPbWqiwpZ74xE4Q3hLeX1QOMM2OdIWX6XKBCokV ctkG/04dRso5efSdNKalK5TEOlqpn93bo/SuVDEo= From: "i at maskray dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110729] New: -fpatchable-function-entries: __patchable_function_entries has wrong sh_link Date: Wed, 19 Jul 2023 06:20:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110729 Bug ID: 110729 Summary: -fpatchable-function-entries: __patchable_function_entries has wrong sh_link Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- Noticed by Ziwei Mao. % cat a.c void f() {} void g() {} void h() {} % gcc -ffunction-sections -fpatchable-function-entry=3D2 -c a.c % gcc -ffunction-sections -fpatchable-function-entry=3D2 -S a.c a.o has .text.f, .text.g, and .text.h, but just one __patchable_function_entries section. % grep __patchable_function_entries a.s .section __patchable_function_entries,"awo",@progbits,f .section __patchable_function_entries,"awo",@progbits,f .section __patchable_function_entries,"awo",@progbits,f I think the second and the third __patchable_function_entries should refere= nce g and h, respectively. Otherwise, if f is discarded by ld --gc-sections, the whole __patchable_function_entries (also used by g and h) will be discarded. (Also, if g is discarded, its __patchable_function_entries fragment may be retained if f is retained.)=