public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] objtool: More -ffunction-sections fixes
@ 2025-11-20 20:14 Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections Josh Poimboeuf
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

For tip/objtool/core.

- Patches 1-4: Rename functions

- Patches 5-6: Move the check out of objtool

Josh Poimboeuf (6):
  serial: icom: Fix namespace collision and startup() section placement
    with -ffunction-sections
  media: atomisp: gc2235: Fix namespace collision and startup() section
    placement with -ffunction-sections
  tty: amiserial: Fix namespace collision and startup() section
    placement with -ffunction-sections
  tty: synclink_gt: Fix namespace collision and startup() section
    placement with -ffunction-sections
  kbuild: Check for functions with ambiguous -ffunction-sections section
    names
  Revert "objtool: Warn on functions with ambiguous -ffunction-sections
    section names"

 .../media/atomisp/i2c/atomisp-gc2235.c        |  4 +--
 drivers/tty/amiserial.c                       | 14 ++++----
 drivers/tty/serial/icom.c                     |  8 ++---
 drivers/tty/synclink_gt.c                     | 20 +++++------
 include/asm-generic/vmlinux.lds.h             |  2 +-
 scripts/Makefile.vmlinux_o                    |  4 +++
 scripts/check-function-names.sh               | 25 ++++++++++++++
 tools/objtool/Documentation/objtool.txt       |  7 ----
 tools/objtool/check.c                         | 33 -------------------
 9 files changed, 53 insertions(+), 64 deletions(-)
 create mode 100755 scripts/check-function-names.sh

-- 
2.51.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 2/6] media: atomisp: gc2235: " Josh Poimboeuf
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

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 icom_startup().  For consistency, also rename its
shutdown() counterpart to icom_shutdown().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 drivers/tty/serial/icom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index 7fb995a8490e..d00903cfa841 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -760,7 +760,7 @@ static void load_code(struct icom_port *icom_port)
 		dma_free_coherent(&dev->dev, 4096, new_page, temp_pci);
 }
 
-static int startup(struct icom_port *icom_port)
+static int icom_startup(struct icom_port *icom_port)
 {
 	unsigned long temp;
 	unsigned char cable_id, raw_cable_id;
@@ -832,7 +832,7 @@ static int startup(struct icom_port *icom_port)
 	return 0;
 }
 
-static void shutdown(struct icom_port *icom_port)
+static void icom_shutdown(struct icom_port *icom_port)
 {
 	unsigned long temp;
 	unsigned char cmdReg;
@@ -1311,7 +1311,7 @@ static int icom_open(struct uart_port *port)
 	int retval;
 
 	kref_get(&icom_port->adapter->kref);
-	retval = startup(icom_port);
+	retval = icom_startup(icom_port);
 
 	if (retval) {
 		kref_put(&icom_port->adapter->kref, icom_kref_release);
@@ -1333,7 +1333,7 @@ static void icom_close(struct uart_port *port)
 	cmdReg = readb(&icom_port->dram->CmdReg);
 	writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg);
 
-	shutdown(icom_port);
+	icom_shutdown(icom_port);
 
 	kref_put(&icom_port->adapter->kref, icom_kref_release);
 }
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/6] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-21 13:28   ` [PATCH 2/6] " Hans de Goede
  2025-11-20 20:14 ` [PATCH 3/6] tty: amiserial: " Josh Poimboeuf
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/6] tty: amiserial: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 2/6] media: atomisp: gc2235: " Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 4/6] tty: synclink_gt: " Josh Poimboeuf
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

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 rs_startup().  For consistency, also rename its
shutdown() counterpart to rs_shutdown().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 drivers/tty/amiserial.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5af46442a792..81eaca751541 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -438,7 +438,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
  * ---------------------------------------------------------------
  */
 
-static int startup(struct tty_struct *tty, struct serial_state *info)
+static int rs_startup(struct tty_struct *tty, struct serial_state *info)
 {
 	struct tty_port *port = &info->tport;
 	unsigned long flags;
@@ -513,7 +513,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
  * This routine will shutdown a serial port; interrupts are disabled, and
  * DTR is dropped if the hangup on close termio flag is on.
  */
-static void shutdown(struct tty_struct *tty, struct serial_state *info)
+static void rs_shutdown(struct tty_struct *tty, struct serial_state *info)
 {
 	unsigned long	flags;
 
@@ -975,7 +975,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
 			change_speed(tty, state, NULL);
 		}
 	} else
-		retval = startup(tty, state);
+		retval = rs_startup(tty, state);
 	tty_unlock(tty);
 	return retval;
 }
@@ -1251,9 +1251,9 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 		 */
 		rs_wait_until_sent(tty, state->timeout);
 	}
-	shutdown(tty, state);
+	rs_shutdown(tty, state);
 	rs_flush_buffer(tty);
-		
+
 	tty_ldisc_flush(tty);
 	port->tty = NULL;
 
@@ -1325,7 +1325,7 @@ static void rs_hangup(struct tty_struct *tty)
 	struct serial_state *info = tty->driver_data;
 
 	rs_flush_buffer(tty);
-	shutdown(tty, info);
+	rs_shutdown(tty, info);
 	info->tport.count = 0;
 	tty_port_set_active(&info->tport, false);
 	info->tport.tty = NULL;
@@ -1349,7 +1349,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
 	port->tty = tty;
 	tty->driver_data = info;
 
-	retval = startup(tty, info);
+	retval = rs_startup(tty, info);
 	if (retval) {
 		return retval;
 	}
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/6] tty: synclink_gt: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
                   ` (2 preceding siblings ...)
  2025-11-20 20:14 ` [PATCH 3/6] tty: amiserial: " Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names Josh Poimboeuf
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

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 startup_hw().  For consistency, also rename its
shutdown() counterpart to shutdown_hw().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 drivers/tty/synclink_gt.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 3865b10d2d43..9d591fb291fd 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -407,9 +407,9 @@ static void  wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value);
 
 static void  msc_set_vcr(struct slgt_info *info);
 
-static int  startup(struct slgt_info *info);
+static int  startup_hw(struct slgt_info *info);
 static int  block_til_ready(struct tty_struct *tty, struct file * filp,struct slgt_info *info);
-static void shutdown(struct slgt_info *info);
+static void shutdown_hw(struct slgt_info *info);
 static void program_hw(struct slgt_info *info);
 static void change_params(struct slgt_info *info);
 
@@ -622,7 +622,7 @@ static int open(struct tty_struct *tty, struct file *filp)
 
 	if (info->port.count == 1) {
 		/* 1st open on this device, init hardware */
-		retval = startup(info);
+		retval = startup_hw(info);
 		if (retval < 0) {
 			mutex_unlock(&info->port.mutex);
 			goto cleanup;
@@ -666,7 +666,7 @@ static void close(struct tty_struct *tty, struct file *filp)
 	flush_buffer(tty);
 	tty_ldisc_flush(tty);
 
-	shutdown(info);
+	shutdown_hw(info);
 	mutex_unlock(&info->port.mutex);
 
 	tty_port_close_end(&info->port, tty);
@@ -687,7 +687,7 @@ static void hangup(struct tty_struct *tty)
 	flush_buffer(tty);
 
 	mutex_lock(&info->port.mutex);
-	shutdown(info);
+	shutdown_hw(info);
 
 	spin_lock_irqsave(&info->port.lock, flags);
 	info->port.count = 0;
@@ -1445,7 +1445,7 @@ static int hdlcdev_open(struct net_device *dev)
 	spin_unlock_irqrestore(&info->netlock, flags);
 
 	/* claim resources and init adapter */
-	if ((rc = startup(info)) != 0) {
+	if ((rc = startup_hw(info)) != 0) {
 		spin_lock_irqsave(&info->netlock, flags);
 		info->netcount=0;
 		spin_unlock_irqrestore(&info->netlock, flags);
@@ -1455,7 +1455,7 @@ static int hdlcdev_open(struct net_device *dev)
 	/* generic HDLC layer open processing */
 	rc = hdlc_open(dev);
 	if (rc) {
-		shutdown(info);
+		shutdown_hw(info);
 		spin_lock_irqsave(&info->netlock, flags);
 		info->netcount = 0;
 		spin_unlock_irqrestore(&info->netlock, flags);
@@ -1499,7 +1499,7 @@ static int hdlcdev_close(struct net_device *dev)
 	netif_stop_queue(dev);
 
 	/* shutdown adapter and release resources */
-	shutdown(info);
+	shutdown_hw(info);
 
 	hdlc_close(dev);
 
@@ -2328,7 +2328,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int startup(struct slgt_info *info)
+static int startup_hw(struct slgt_info *info)
 {
 	DBGINFO(("%s startup\n", info->device_name));
 
@@ -2361,7 +2361,7 @@ static int startup(struct slgt_info *info)
 /*
  *  called by close() and hangup() to shutdown hardware
  */
-static void shutdown(struct slgt_info *info)
+static void shutdown_hw(struct slgt_info *info)
 {
 	unsigned long flags;
 
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
                   ` (3 preceding siblings ...)
  2025-11-20 20:14 ` [PATCH 4/6] tty: synclink_gt: " Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-20 20:14 ` [PATCH 6/6] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" Josh Poimboeuf
  2025-11-21  7:00 ` [PATCH 0/6] objtool: More -ffunction-sections fixes Greg Kroah-Hartman
  6 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

Commit 9c7dc1dd897a ("objtool: Warn on functions with ambiguous
-ffunction-sections section names") only works for drivers which are
compiled on architectures supported by objtool.

Make a script to perform the same check for all architectures.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 include/asm-generic/vmlinux.lds.h |  2 +-
 scripts/Makefile.vmlinux_o        |  4 ++++
 scripts/check-function-names.sh   | 25 +++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100755 scripts/check-function-names.sh

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5efe1de2209b..0cdae6f809b5 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -110,7 +110,7 @@
  * .text.startup could be __attribute__((constructor)) code in a *non*
  * ffunction-sections object, which should be placed in .init.text; or it could
  * be an actual function named startup() in an ffunction-sections object, which
- * should be placed in .text.  Objtool will detect and complain about any such
+ * should be placed in .text.  The build will detect and complain about any such
  * ambiguously named functions.
  */
 #define TEXT_MAIN							\
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 20533cc0b1ee..527352c222ff 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -63,11 +63,15 @@ quiet_cmd_ld_vmlinux.o = LD      $@
 	--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
 	$(cmd_objtool)
 
+cmd_check_function_names = $(srctree)/scripts/check-function-names.sh $@
+
 define rule_ld_vmlinux.o
 	$(call cmd_and_savecmd,ld_vmlinux.o)
 	$(call cmd,gen_objtooldep)
+	$(call cmd,check_function_names)
 endef
 
+
 vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed_rule,ld_vmlinux.o)
 
diff --git a/scripts/check-function-names.sh b/scripts/check-function-names.sh
new file mode 100755
index 000000000000..410042591cfc
--- /dev/null
+++ b/scripts/check-function-names.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Certain function names are disallowed due to section name ambiguities
+# introduced by -ffunction-sections.
+#
+# See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
+
+objfile="$1"
+
+if [ ! -f "$objfile" ]; then
+	echo "usage: $0 <file.o>" >&2
+	exit 1
+fi
+
+bad_symbols=$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
+
+if [ -n "$bad_symbols" ]; then
+	echo "$bad_symbols" | while read -r sym; do
+		echo "$objfile: error: $sym() function name creates ambiguity with -ffunction-sections" >&2
+	done
+	exit 1
+fi
+
+exit 0
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/6] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names"
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
                   ` (4 preceding siblings ...)
  2025-11-20 20:14 ` [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names Josh Poimboeuf
@ 2025-11-20 20:14 ` Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
  2025-11-21  7:00 ` [PATCH 0/6] objtool: More -ffunction-sections fixes Greg Kroah-Hartman
  6 siblings, 1 reply; 15+ messages in thread
From: Josh Poimboeuf @ 2025-11-20 20:14 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

This reverts commit 9c7dc1dd897a1cdcade9566ea4664b03fbabf4a4.

The check-function-names.sh script now provides the function name
checking functionality for all architectures, making the objtool check
redundant.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/Documentation/objtool.txt |  7 ------
 tools/objtool/check.c                   | 33 -------------------------
 2 files changed, 40 deletions(-)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index f88f8d28513a..9e97fc25b2d8 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -456,13 +456,6 @@ the objtool maintainers.
     these special names and does not use module_init() / module_exit()
     macros to create them.
 
-13. file.o: warning: func() function name creates ambiguity with -ffunctions-sections
-
-    Functions named startup(), exit(), split(), unlikely(), hot(), and
-    unknown() are not allowed due to the ambiguity of their section
-    names when compiled with -ffunction-sections.  For more information,
-    see the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
-
 
 If the error doesn't seem to make sense, it could be a bug in objtool.
 Feel free to ask objtool maintainers for help.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 72c7f6f03350..57fac6ce3454 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2663,37 +2663,6 @@ static int decode_sections(struct objtool_file *file)
 	return 0;
 }
 
-/*
- * Certain function names are disallowed due to section name ambiguities
- * introduced by -ffunction-sections.
- *
- * See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
- */
-static int validate_function_names(struct objtool_file *file)
-{
-	struct symbol *func;
-	int warnings = 0;
-
-	for_each_sym(file->elf, func) {
-		if (!is_func_sym(func))
-			continue;
-
-		if (!strcmp(func->name, "startup")	|| strstarts(func->name, "startup.")	||
-		    !strcmp(func->name, "exit")		|| strstarts(func->name, "exit.")	||
-		    !strcmp(func->name, "split")	|| strstarts(func->name, "split.")	||
-		    !strcmp(func->name, "unlikely")	|| strstarts(func->name, "unlikely.")	||
-		    !strcmp(func->name, "hot")		|| strstarts(func->name, "hot.")	||
-		    !strcmp(func->name, "unknown")	|| strstarts(func->name, "unknown.")) {
-
-			WARN("%s() function name creates ambiguity with -ffunction-sections",
-			     func->name);
-			warnings++;
-		}
-	}
-
-	return warnings;
-}
-
 static bool is_special_call(struct instruction *insn)
 {
 	if (insn->type == INSN_CALL) {
@@ -4963,8 +4932,6 @@ int check(struct objtool_file *file)
 	if (!nr_insns)
 		goto out;
 
-	warnings += validate_function_names(file);
-
 	if (opts.retpoline)
 		warnings += validate_retpoline(file);
 
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/6] objtool: More -ffunction-sections fixes
  2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
                   ` (5 preceding siblings ...)
  2025-11-20 20:14 ` [PATCH 6/6] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" Josh Poimboeuf
@ 2025-11-21  7:00 ` Greg Kroah-Hartman
  6 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2025-11-21  7:00 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: x86, linux-kernel, Peter Zijlstra, Jiri Slaby,
	Mauro Carvalho Chehab, Hans de Goede

On Thu, Nov 20, 2025 at 12:14:15PM -0800, Josh Poimboeuf wrote:
> For tip/objtool/core.
> 
> - Patches 1-4: Rename functions
> 
> - Patches 5-6: Move the check out of objtool
> 
> Josh Poimboeuf (6):
>   serial: icom: Fix namespace collision and startup() section placement
>     with -ffunction-sections
>   media: atomisp: gc2235: Fix namespace collision and startup() section
>     placement with -ffunction-sections
>   tty: amiserial: Fix namespace collision and startup() section
>     placement with -ffunction-sections
>   tty: synclink_gt: Fix namespace collision and startup() section
>     placement with -ffunction-sections
>   kbuild: Check for functions with ambiguous -ffunction-sections section
>     names
>   Revert "objtool: Warn on functions with ambiguous -ffunction-sections
>     section names"

For the tty changes:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip: objtool/core] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names"
  2025-11-20 20:14 ` [PATCH 6/6] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     11991999a20145b7f8af21202d0cac6b1f90a6e4
Gitweb:        https://git.kernel.org/tip/11991999a20145b7f8af21202d0cac6b1f90a6e4
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:21 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:10 +01:00

Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names"

This reverts commit 9c7dc1dd897a1cdcade9566ea4664b03fbabf4a4.

The check-function-names.sh script now provides the function name
checking functionality for all architectures, making the objtool check
redundant.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/c7d549d4de8bd1490d106b99630eea5efc69a4dd.1763669451.git.jpoimboe@kernel.org
---
 tools/objtool/Documentation/objtool.txt |  7 +-----
 tools/objtool/check.c                   | 33 +------------------------
 2 files changed, 40 deletions(-)

diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt
index f88f8d2..9e97fc2 100644
--- a/tools/objtool/Documentation/objtool.txt
+++ b/tools/objtool/Documentation/objtool.txt
@@ -456,13 +456,6 @@ the objtool maintainers.
     these special names and does not use module_init() / module_exit()
     macros to create them.
 
-13. file.o: warning: func() function name creates ambiguity with -ffunctions-sections
-
-    Functions named startup(), exit(), split(), unlikely(), hot(), and
-    unknown() are not allowed due to the ambiguity of their section
-    names when compiled with -ffunction-sections.  For more information,
-    see the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
-
 
 If the error doesn't seem to make sense, it could be a bug in objtool.
 Feel free to ask objtool maintainers for help.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 1a20ff8..490cf78 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2642,37 +2642,6 @@ static int decode_sections(struct objtool_file *file)
 	return 0;
 }
 
-/*
- * Certain function names are disallowed due to section name ambiguities
- * introduced by -ffunction-sections.
- *
- * See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
- */
-static int validate_function_names(struct objtool_file *file)
-{
-	struct symbol *func;
-	int warnings = 0;
-
-	for_each_sym(file->elf, func) {
-		if (!is_func_sym(func))
-			continue;
-
-		if (!strcmp(func->name, "startup")	|| strstarts(func->name, "startup.")	||
-		    !strcmp(func->name, "exit")		|| strstarts(func->name, "exit.")	||
-		    !strcmp(func->name, "split")	|| strstarts(func->name, "split.")	||
-		    !strcmp(func->name, "unlikely")	|| strstarts(func->name, "unlikely.")	||
-		    !strcmp(func->name, "hot")		|| strstarts(func->name, "hot.")	||
-		    !strcmp(func->name, "unknown")	|| strstarts(func->name, "unknown.")) {
-
-			WARN("%s() function name creates ambiguity with -ffunction-sections",
-			     func->name);
-			warnings++;
-		}
-	}
-
-	return warnings;
-}
-
 static bool is_special_call(struct instruction *insn)
 {
 	if (insn->type == INSN_CALL) {
@@ -4942,8 +4911,6 @@ int check(struct objtool_file *file)
 	if (!nr_insns)
 		goto out;
 
-	warnings += validate_function_names(file);
-
 	if (opts.retpoline)
 		warnings += validate_retpoline(file);
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip: objtool/core] kbuild: Check for functions with ambiguous -ffunction-sections section names
  2025-11-20 20:14 ` [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     93863f3f859a626347ce2ec18947b11357b4ca14
Gitweb:        https://git.kernel.org/tip/93863f3f859a626347ce2ec18947b11357b4ca14
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:20 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:10 +01:00

kbuild: Check for functions with ambiguous -ffunction-sections section names

Commit 9c7dc1dd897a ("objtool: Warn on functions with ambiguous
-ffunction-sections section names") only works for drivers which are
compiled on architectures supported by objtool.

Make a script to perform the same check for all architectures.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/a6a49644a34964f7e02f3a8ce43af03e72817180.1763669451.git.jpoimboe@kernel.org
---
 include/asm-generic/vmlinux.lds.h |  2 +-
 scripts/Makefile.vmlinux_o        |  4 ++++
 scripts/check-function-names.sh   | 25 +++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100755 scripts/check-function-names.sh

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5efe1de..0cdae6f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -110,7 +110,7 @@
  * .text.startup could be __attribute__((constructor)) code in a *non*
  * ffunction-sections object, which should be placed in .init.text; or it could
  * be an actual function named startup() in an ffunction-sections object, which
- * should be placed in .text.  Objtool will detect and complain about any such
+ * should be placed in .text.  The build will detect and complain about any such
  * ambiguously named functions.
  */
 #define TEXT_MAIN							\
diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o
index 20533cc..527352c 100644
--- a/scripts/Makefile.vmlinux_o
+++ b/scripts/Makefile.vmlinux_o
@@ -63,11 +63,15 @@ quiet_cmd_ld_vmlinux.o = LD      $@
 	--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
 	$(cmd_objtool)
 
+cmd_check_function_names = $(srctree)/scripts/check-function-names.sh $@
+
 define rule_ld_vmlinux.o
 	$(call cmd_and_savecmd,ld_vmlinux.o)
 	$(call cmd,gen_objtooldep)
+	$(call cmd,check_function_names)
 endef
 
+
 vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 	$(call if_changed_rule,ld_vmlinux.o)
 
diff --git a/scripts/check-function-names.sh b/scripts/check-function-names.sh
new file mode 100755
index 0000000..4100425
--- /dev/null
+++ b/scripts/check-function-names.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Certain function names are disallowed due to section name ambiguities
+# introduced by -ffunction-sections.
+#
+# See the comment above TEXT_MAIN in include/asm-generic/vmlinux.lds.h.
+
+objfile="$1"
+
+if [ ! -f "$objfile" ]; then
+	echo "usage: $0 <file.o>" >&2
+	exit 1
+fi
+
+bad_symbols=$(nm "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' | grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')
+
+if [ -n "$bad_symbols" ]; then
+	echo "$bad_symbols" | while read -r sym; do
+		echo "$objfile: error: $sym() function name creates ambiguity with -ffunction-sections" >&2
+	done
+	exit 1
+fi
+
+exit 0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip: objtool/core] tty: synclink_gt: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 ` [PATCH 4/6] tty: synclink_gt: " Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     31863337138a0482d614f1090727dac87c936959
Gitweb:        https://git.kernel.org/tip/31863337138a0482d614f1090727dac87c936959
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:19 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:10 +01:00

tty: synclink_gt: Fix namespace collision and startup() section placement with -ffunction-sections

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 startup_hw().  For consistency, also rename its
shutdown() counterpart to shutdown_hw().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/f0ee750f35c878172cc09916a0724b74e62eadc2.1763669451.git.jpoimboe@kernel.org
---
 drivers/tty/synclink_gt.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 3865b10..9d591fb 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -407,9 +407,9 @@ static void  wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value);
 
 static void  msc_set_vcr(struct slgt_info *info);
 
-static int  startup(struct slgt_info *info);
+static int  startup_hw(struct slgt_info *info);
 static int  block_til_ready(struct tty_struct *tty, struct file * filp,struct slgt_info *info);
-static void shutdown(struct slgt_info *info);
+static void shutdown_hw(struct slgt_info *info);
 static void program_hw(struct slgt_info *info);
 static void change_params(struct slgt_info *info);
 
@@ -622,7 +622,7 @@ static int open(struct tty_struct *tty, struct file *filp)
 
 	if (info->port.count == 1) {
 		/* 1st open on this device, init hardware */
-		retval = startup(info);
+		retval = startup_hw(info);
 		if (retval < 0) {
 			mutex_unlock(&info->port.mutex);
 			goto cleanup;
@@ -666,7 +666,7 @@ static void close(struct tty_struct *tty, struct file *filp)
 	flush_buffer(tty);
 	tty_ldisc_flush(tty);
 
-	shutdown(info);
+	shutdown_hw(info);
 	mutex_unlock(&info->port.mutex);
 
 	tty_port_close_end(&info->port, tty);
@@ -687,7 +687,7 @@ static void hangup(struct tty_struct *tty)
 	flush_buffer(tty);
 
 	mutex_lock(&info->port.mutex);
-	shutdown(info);
+	shutdown_hw(info);
 
 	spin_lock_irqsave(&info->port.lock, flags);
 	info->port.count = 0;
@@ -1445,7 +1445,7 @@ static int hdlcdev_open(struct net_device *dev)
 	spin_unlock_irqrestore(&info->netlock, flags);
 
 	/* claim resources and init adapter */
-	if ((rc = startup(info)) != 0) {
+	if ((rc = startup_hw(info)) != 0) {
 		spin_lock_irqsave(&info->netlock, flags);
 		info->netcount=0;
 		spin_unlock_irqrestore(&info->netlock, flags);
@@ -1455,7 +1455,7 @@ static int hdlcdev_open(struct net_device *dev)
 	/* generic HDLC layer open processing */
 	rc = hdlc_open(dev);
 	if (rc) {
-		shutdown(info);
+		shutdown_hw(info);
 		spin_lock_irqsave(&info->netlock, flags);
 		info->netcount = 0;
 		spin_unlock_irqrestore(&info->netlock, flags);
@@ -1499,7 +1499,7 @@ static int hdlcdev_close(struct net_device *dev)
 	netif_stop_queue(dev);
 
 	/* shutdown adapter and release resources */
-	shutdown(info);
+	shutdown_hw(info);
 
 	hdlc_close(dev);
 
@@ -2328,7 +2328,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int startup(struct slgt_info *info)
+static int startup_hw(struct slgt_info *info)
 {
 	DBGINFO(("%s startup\n", info->device_name));
 
@@ -2361,7 +2361,7 @@ static int startup(struct slgt_info *info)
 /*
  *  called by close() and hangup() to shutdown hardware
  */
-static void shutdown(struct slgt_info *info)
+static void shutdown_hw(struct slgt_info *info)
 {
 	unsigned long flags;
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip: objtool/core] tty: amiserial: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 ` [PATCH 3/6] tty: amiserial: " Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     845c09e4744f111eae894ad3b67a369bb43d50fb
Gitweb:        https://git.kernel.org/tip/845c09e4744f111eae894ad3b67a369bb43d50fb
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:18 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:09 +01:00

tty: amiserial: Fix namespace collision and startup() section placement with -ffunction-sections

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 rs_startup().  For consistency, also rename its
shutdown() counterpart to rs_shutdown().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/9e56afff5268b0b12b99a8aa9bf244d6ebdcdf47.1763669451.git.jpoimboe@kernel.org
---
 drivers/tty/amiserial.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5af4644..81eaca7 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -438,7 +438,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
  * ---------------------------------------------------------------
  */
 
-static int startup(struct tty_struct *tty, struct serial_state *info)
+static int rs_startup(struct tty_struct *tty, struct serial_state *info)
 {
 	struct tty_port *port = &info->tport;
 	unsigned long flags;
@@ -513,7 +513,7 @@ errout:
  * This routine will shutdown a serial port; interrupts are disabled, and
  * DTR is dropped if the hangup on close termio flag is on.
  */
-static void shutdown(struct tty_struct *tty, struct serial_state *info)
+static void rs_shutdown(struct tty_struct *tty, struct serial_state *info)
 {
 	unsigned long	flags;
 
@@ -975,7 +975,7 @@ check_and_exit:
 			change_speed(tty, state, NULL);
 		}
 	} else
-		retval = startup(tty, state);
+		retval = rs_startup(tty, state);
 	tty_unlock(tty);
 	return retval;
 }
@@ -1251,9 +1251,9 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 		 */
 		rs_wait_until_sent(tty, state->timeout);
 	}
-	shutdown(tty, state);
+	rs_shutdown(tty, state);
 	rs_flush_buffer(tty);
-		
+
 	tty_ldisc_flush(tty);
 	port->tty = NULL;
 
@@ -1325,7 +1325,7 @@ static void rs_hangup(struct tty_struct *tty)
 	struct serial_state *info = tty->driver_data;
 
 	rs_flush_buffer(tty);
-	shutdown(tty, info);
+	rs_shutdown(tty, info);
 	info->tport.count = 0;
 	tty_port_set_active(&info->tport, false);
 	info->tport.tty = NULL;
@@ -1349,7 +1349,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
 	port->tty = tty;
 	tty->driver_data = info;
 
-	retval = startup(tty, info);
+	retval = rs_startup(tty, info);
 	if (retval) {
 		return retval;
 	}

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip: objtool/core] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 ` [PATCH 2/6] media: atomisp: gc2235: " Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  2025-11-21 13:28   ` [PATCH 2/6] " Hans de Goede
  1 sibling, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     2c715c9de293b6c05bcdff1c22a7626f3bb42492
Gitweb:        https://git.kernel.org/tip/2c715c9de293b6c05bcdff1c22a7626f3bb42492
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:17 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:09 +01:00

media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections

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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/d28103a6edf7beceb5e3c6fa24e49dbad1350389.1763669451.git.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 6fc39ab..6050637 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;

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [tip: objtool/core] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 ` [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections Josh Poimboeuf
@ 2025-11-21  9:57   ` tip-bot2 for Josh Poimboeuf
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot2 for Josh Poimboeuf @ 2025-11-21  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Josh Poimboeuf, Peter Zijlstra (Intel), Greg Kroah-Hartman, x86,
	linux-kernel

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     da6202139aef11c3c5881176e6e3184d88d8a0d9
Gitweb:        https://git.kernel.org/tip/da6202139aef11c3c5881176e6e3184d88d8a0d9
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Thu, 20 Nov 2025 12:14:16 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 21 Nov 2025 10:04:09 +01:00

serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections

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 icom_startup().  For consistency, also rename its
shutdown() counterpart to icom_shutdown().

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/1aee9ef69f9d40405676712b34f0c397706e7023.1763669451.git.jpoimboe@kernel.org
---
 drivers/tty/serial/icom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index 7fb995a..d00903c 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -760,7 +760,7 @@ static void load_code(struct icom_port *icom_port)
 		dma_free_coherent(&dev->dev, 4096, new_page, temp_pci);
 }
 
-static int startup(struct icom_port *icom_port)
+static int icom_startup(struct icom_port *icom_port)
 {
 	unsigned long temp;
 	unsigned char cable_id, raw_cable_id;
@@ -832,7 +832,7 @@ unlock:
 	return 0;
 }
 
-static void shutdown(struct icom_port *icom_port)
+static void icom_shutdown(struct icom_port *icom_port)
 {
 	unsigned long temp;
 	unsigned char cmdReg;
@@ -1311,7 +1311,7 @@ static int icom_open(struct uart_port *port)
 	int retval;
 
 	kref_get(&icom_port->adapter->kref);
-	retval = startup(icom_port);
+	retval = icom_startup(icom_port);
 
 	if (retval) {
 		kref_put(&icom_port->adapter->kref, icom_kref_release);
@@ -1333,7 +1333,7 @@ static void icom_close(struct uart_port *port)
 	cmdReg = readb(&icom_port->dram->CmdReg);
 	writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg);
 
-	shutdown(icom_port);
+	icom_shutdown(icom_port);
 
 	kref_put(&icom_port->adapter->kref, icom_kref_release);
 }

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/6] media: atomisp: gc2235: Fix namespace collision and startup() section placement with -ffunction-sections
  2025-11-20 20:14 ` [PATCH 2/6] media: atomisp: gc2235: " Josh Poimboeuf
  2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
@ 2025-11-21 13:28   ` Hans de Goede
  1 sibling, 0 replies; 15+ messages in thread
From: Hans de Goede @ 2025-11-21 13:28 UTC (permalink / raw)
  To: Josh Poimboeuf, x86
  Cc: linux-kernel, Peter Zijlstra, Greg Kroah-Hartman, Jiri Slaby,
	Mauro Carvalho Chehab

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;


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-11-21 13:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 20:14 [PATCH 0/6] objtool: More -ffunction-sections fixes Josh Poimboeuf
2025-11-20 20:14 ` [PATCH 1/6] serial: icom: Fix namespace collision and startup() section placement with -ffunction-sections Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-20 20:14 ` [PATCH 2/6] media: atomisp: gc2235: " Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-21 13:28   ` [PATCH 2/6] " Hans de Goede
2025-11-20 20:14 ` [PATCH 3/6] tty: amiserial: " Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-20 20:14 ` [PATCH 4/6] tty: synclink_gt: " Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-20 20:14 ` [PATCH 5/6] kbuild: Check for functions with ambiguous -ffunction-sections section names Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-20 20:14 ` [PATCH 6/6] Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" Josh Poimboeuf
2025-11-21  9:57   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-11-21  7:00 ` [PATCH 0/6] objtool: More -ffunction-sections fixes Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox