]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: amiserial: Fix namespace collision and startup() section placement with -ffuncti...
authorJosh Poimboeuf <jpoimboe@kernel.org>
Thu, 20 Nov 2025 20:14:18 +0000 (12:14 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 21 Nov 2025 09:04:09 +0000 (10:04 +0100)
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

index 5af46442a792d4fb1e1fbf5d9db6ea106e02cb1a..81eaca751541ab44b36d43e3c1b12f0b2e316923 100644 (file)
@@ -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;
        }