* Re: [PATCH 2/4] media: atomisp: Fix startup() section placement with -ffunction-sections [not found] ` <bf8cd823a3f11f64cc82167913be5013c72afa57.1762991150.git.jpoimboe@kernel.org> @ 2025-11-14 8:56 ` Peter Zijlstra 2025-11-14 20:43 ` Josh Poimboeuf 0 siblings, 1 reply; 3+ messages in thread From: Peter Zijlstra @ 2025-11-14 8:56 UTC (permalink / raw) To: Josh Poimboeuf Cc: x86, linux-kernel, live-patching, Hans de Goede, Mauro Carvalho Chehab, linux-toolchains On Wed, Nov 12, 2025 at 03:47:49PM -0800, Josh Poimboeuf wrote: > When compiling the kernel with -ffunction-sections (e.g., for LTO, > livepatch, dead code elimination, AutoFDO, or Propeller), the startup() > function gets compiled into the .text.startup section. In some cases it > can even be cloned into .text.startup.constprop.0 or > .text.startup.isra.0. > > However, the .text.startup and .text.startup.* section names are already > reserved for use by the compiler for __attribute__((constructor)) code. > Urgh, that's a 'fun' one. Is this not a -ffunction-sections bug? I mean, the compiler should never put regular non-reserved user symbols in a section it has reserved for itself, right? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/4] media: atomisp: Fix startup() section placement with -ffunction-sections 2025-11-14 8:56 ` [PATCH 2/4] media: atomisp: Fix startup() section placement with -ffunction-sections Peter Zijlstra @ 2025-11-14 20:43 ` Josh Poimboeuf 2025-11-18 8:57 ` Peter Zijlstra 0 siblings, 1 reply; 3+ messages in thread From: Josh Poimboeuf @ 2025-11-14 20:43 UTC (permalink / raw) To: Peter Zijlstra Cc: x86, linux-kernel, live-patching, Hans de Goede, Mauro Carvalho Chehab, linux-toolchains On Fri, Nov 14, 2025 at 09:56:57AM +0100, Peter Zijlstra wrote: > On Wed, Nov 12, 2025 at 03:47:49PM -0800, Josh Poimboeuf wrote: > > When compiling the kernel with -ffunction-sections (e.g., for LTO, > > livepatch, dead code elimination, AutoFDO, or Propeller), the startup() > > function gets compiled into the .text.startup section. In some cases it > > can even be cloned into .text.startup.constprop.0 or > > .text.startup.isra.0. > > > > However, the .text.startup and .text.startup.* section names are already > > reserved for use by the compiler for __attribute__((constructor)) code. > > > > Urgh, that's a 'fun' one. Is this not a -ffunction-sections bug? I mean, > the compiler should never put regular non-reserved user symbols in a > section it has reserved for itself, right? Right, so there's no ambiguity *IF* we know in advance whether it was compiled with -ffunction-sections. If so, constructor code goes in .text.startup.*, and startup() goes in .text.startup or .text.startup.constprop.0 or .text.startup.isra.0. So it's not really a compiler bug because it's possible to disambiguate those. Problem is, we can have some objects compiled with -ffunction-sections, and some compiled without, in the same kernel. So the disambiguation isn't possible at link time, since for example .text.startup could be startup() with -ffunction-sections, or it could be __attribute__((constructor)) without -ffunction-sections. I attempted to describe all that in patch 4. -- Josh ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/4] media: atomisp: Fix startup() section placement with -ffunction-sections 2025-11-14 20:43 ` Josh Poimboeuf @ 2025-11-18 8:57 ` Peter Zijlstra 0 siblings, 0 replies; 3+ messages in thread From: Peter Zijlstra @ 2025-11-18 8:57 UTC (permalink / raw) To: Josh Poimboeuf Cc: x86, linux-kernel, live-patching, Hans de Goede, Mauro Carvalho Chehab, linux-toolchains On Fri, Nov 14, 2025 at 12:43:10PM -0800, Josh Poimboeuf wrote: > On Fri, Nov 14, 2025 at 09:56:57AM +0100, Peter Zijlstra wrote: > > On Wed, Nov 12, 2025 at 03:47:49PM -0800, Josh Poimboeuf wrote: > > > When compiling the kernel with -ffunction-sections (e.g., for LTO, > > > livepatch, dead code elimination, AutoFDO, or Propeller), the startup() > > > function gets compiled into the .text.startup section. In some cases it > > > can even be cloned into .text.startup.constprop.0 or > > > .text.startup.isra.0. > > > > > > However, the .text.startup and .text.startup.* section names are already > > > reserved for use by the compiler for __attribute__((constructor)) code. > > > > > > > Urgh, that's a 'fun' one. Is this not a -ffunction-sections bug? I mean, > > the compiler should never put regular non-reserved user symbols in a > > section it has reserved for itself, right? > > Right, so there's no ambiguity *IF* we know in advance whether it was > compiled with -ffunction-sections. If so, constructor code goes in > .text.startup.*, and startup() goes in .text.startup or > .text.startup.constprop.0 or .text.startup.isra.0. > > So it's not really a compiler bug because it's possible to disambiguate > those. > > Problem is, we can have some objects compiled with -ffunction-sections, > and some compiled without, in the same kernel. So the disambiguation > isn't possible at link time, since for example .text.startup could be > startup() with -ffunction-sections, or it could be > __attribute__((constructor)) without -ffunction-sections. > > I attempted to describe all that in patch 4. Egads, what a mess :-( ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-18 8:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1762991150.git.jpoimboe@kernel.org>
[not found] ` <bf8cd823a3f11f64cc82167913be5013c72afa57.1762991150.git.jpoimboe@kernel.org>
2025-11-14 8:56 ` [PATCH 2/4] media: atomisp: Fix startup() section placement with -ffunction-sections Peter Zijlstra
2025-11-14 20:43 ` Josh Poimboeuf
2025-11-18 8:57 ` Peter Zijlstra
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox