Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Josh Poimboeuf and committed by
Peter Zijlstra
845c09e4 2c715c9d

+7 -7
+7 -7
drivers/tty/amiserial.c
··· 438 438 * --------------------------------------------------------------- 439 439 */ 440 440 441 - static int startup(struct tty_struct *tty, struct serial_state *info) 441 + static int rs_startup(struct tty_struct *tty, struct serial_state *info) 442 442 { 443 443 struct tty_port *port = &info->tport; 444 444 unsigned long flags; ··· 513 513 * This routine will shutdown a serial port; interrupts are disabled, and 514 514 * DTR is dropped if the hangup on close termio flag is on. 515 515 */ 516 - static void shutdown(struct tty_struct *tty, struct serial_state *info) 516 + static void rs_shutdown(struct tty_struct *tty, struct serial_state *info) 517 517 { 518 518 unsigned long flags; 519 519 ··· 975 975 change_speed(tty, state, NULL); 976 976 } 977 977 } else 978 - retval = startup(tty, state); 978 + retval = rs_startup(tty, state); 979 979 tty_unlock(tty); 980 980 return retval; 981 981 } ··· 1251 1251 */ 1252 1252 rs_wait_until_sent(tty, state->timeout); 1253 1253 } 1254 - shutdown(tty, state); 1254 + rs_shutdown(tty, state); 1255 1255 rs_flush_buffer(tty); 1256 - 1256 + 1257 1257 tty_ldisc_flush(tty); 1258 1258 port->tty = NULL; 1259 1259 ··· 1325 1325 struct serial_state *info = tty->driver_data; 1326 1326 1327 1327 rs_flush_buffer(tty); 1328 - shutdown(tty, info); 1328 + rs_shutdown(tty, info); 1329 1329 info->tport.count = 0; 1330 1330 tty_port_set_active(&info->tport, false); 1331 1331 info->tport.tty = NULL; ··· 1349 1349 port->tty = tty; 1350 1350 tty->driver_data = info; 1351 1351 1352 - retval = startup(tty, info); 1352 + retval = rs_startup(tty, info); 1353 1353 if (retval) { 1354 1354 return retval; 1355 1355 }