[PATCH 2/6] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections

Josh Poimboeuf posted 6 patches 1 week, 4 days ago
[PATCH 2/6] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections
Posted by Josh Poimboeuf 1 week, 4 days ago
When compiled with -ffunction-sections (e.g., for LTO, livepatch, dead
code elimination, AutoFDO, or Propeller), the startup() function gets
compiled into the .text.startup section (or in some cases
.text.startup.constprop.0 or .text.startup.isra.0).

However, the .text.startup and .text.startup.* sections are also used by
the compiler for __attribute__((constructor)) code.

This naming conflict causes the vmlinux linker script to wrongly place
startup() function code in .init.text, which gets freed during boot.

Some builds have a mix of objects, both with and without
-ffunctions-sections, so it's not possible for the linker script to
disambiguate with #ifdef CONFIG_FUNCTION_SECTIONS or similar.  This
means that "startup" unfortunately needs to be prohibited as a function
name.

Rename startup() to gc2235_startup().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 drivers/staging/media/atomisp/i2c/atomisp-gc2235.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
index 6fc39ab95e46..6050637a0def 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
@@ -491,7 +491,7 @@ static int gc2235_s_power(struct v4l2_subdev *sd, int on)
 	return ret;
 }
 
-static int startup(struct v4l2_subdev *sd)
+static int gc2235_startup(struct v4l2_subdev *sd)
 {
 	struct gc2235_device *dev = to_gc2235_sensor(sd);
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -556,7 +556,7 @@ static int gc2235_set_fmt(struct v4l2_subdev *sd,
 		return 0;
 	}
 
-	ret = startup(sd);
+	ret = gc2235_startup(sd);
 	if (ret) {
 		dev_err(&client->dev, "gc2235 startup err\n");
 		goto err;
-- 
2.51.1
Re: [PATCH 2/6] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections
Posted by Hans de Goede 1 week, 3 days ago
Hi,

On 20-Nov-25 9:14 PM, Josh Poimboeuf wrote:
> When compiled with -ffunction-sections (e.g., for LTO, livepatch, dead
> code elimination, AutoFDO, or Propeller), the startup() function gets
> compiled into the .text.startup section (or in some cases
> .text.startup.constprop.0 or .text.startup.isra.0).
> 
> However, the .text.startup and .text.startup.* sections are also used by
> the compiler for __attribute__((constructor)) code.
> 
> This naming conflict causes the vmlinux linker script to wrongly place
> startup() function code in .init.text, which gets freed during boot.
> 
> Some builds have a mix of objects, both with and without
> -ffunctions-sections, so it's not possible for the linker script to
> disambiguate with #ifdef CONFIG_FUNCTION_SECTIONS or similar.  This
> means that "startup" unfortunately needs to be prohibited as a function
> name.
> 
> Rename startup() to gc2235_startup().
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Feel free to merge through the x86/tip tree together with the
rest of the series.

Regards,

Hans




> ---
>  drivers/staging/media/atomisp/i2c/atomisp-gc2235.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
> index 6fc39ab95e46..6050637a0def 100644
> --- a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
> +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
> @@ -491,7 +491,7 @@ static int gc2235_s_power(struct v4l2_subdev *sd, int on)
>  	return ret;
>  }
>  
> -static int startup(struct v4l2_subdev *sd)
> +static int gc2235_startup(struct v4l2_subdev *sd)
>  {
>  	struct gc2235_device *dev = to_gc2235_sensor(sd);
>  	struct i2c_client *client = v4l2_get_subdevdata(sd);
> @@ -556,7 +556,7 @@ static int gc2235_set_fmt(struct v4l2_subdev *sd,
>  		return 0;
>  	}
>  
> -	ret = startup(sd);
> +	ret = gc2235_startup(sd);
>  	if (ret) {
>  		dev_err(&client->dev, "gc2235 startup err\n");
>  		goto err;