From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C805238708B2; Mon, 15 Feb 2021 18:54:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C805238708B2 From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99113] SHF_GNU_RETAIN doesn't work with Linux kernel Date: Mon, 15 Feb 2021 18:54:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2021 18:54:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99113 Sergei Trofimovich changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |slyfox at gcc dot gnu.org --- Comment #2 from Sergei Trofimovich --- I have a few notes: 1. GCC should put SHF_GNU_RETAIN section into a different section from .data anyway, right? I think that means linux kernel would need to adapt in any case to merge new .data.${SHF_GNU_RETAIN_name} section into appropriate place in it's linker script. Proposal: rename a section in an easily distinguishable prefix, like: NEW: .data.retain.event_initcall_finish OLD: .data.event_initcall_finish That would simplify tweaking linux ldscript. For -fno-function-sections cas= e it could be just. .data.retain Do we still have time for such a rename? Is it safe? 2. Linux kernel does support -ffunction-sections with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. But it relies even more on naming conventions: #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text #define DATA_MAIN .data #define SDATA_MAIN .sdata #define RODATA_MAIN .rodata #define BSS_MAIN .bss #define SBSS_MAIN .sbss #endif A variant of [1.] would allow for easier section ganthering in the script. 3. I tried to add '.data.event*' (and similar) to linux ldscript and it was= not enough for me to built a kernel that does not crash. Which might hint at binutils bug or linux loader bug (or at my bad attempt at adding sections).=