Skip to content

Commit 3186333

Browse files
jpoimboePeter Zijlstra
authored andcommitted
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
1 parent 845c09e commit 3186333

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/tty/synclink_gt.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ static void wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value);
407407

408408
static void msc_set_vcr(struct slgt_info *info);
409409

410-
static int startup(struct slgt_info *info);
410+
static int startup_hw(struct slgt_info *info);
411411
static int block_til_ready(struct tty_struct *tty, struct file * filp,struct slgt_info *info);
412-
static void shutdown(struct slgt_info *info);
412+
static void shutdown_hw(struct slgt_info *info);
413413
static void program_hw(struct slgt_info *info);
414414
static void change_params(struct slgt_info *info);
415415

@@ -622,7 +622,7 @@ static int open(struct tty_struct *tty, struct file *filp)
622622

623623
if (info->port.count == 1) {
624624
/* 1st open on this device, init hardware */
625-
retval = startup(info);
625+
retval = startup_hw(info);
626626
if (retval < 0) {
627627
mutex_unlock(&info->port.mutex);
628628
goto cleanup;
@@ -666,7 +666,7 @@ static void close(struct tty_struct *tty, struct file *filp)
666666
flush_buffer(tty);
667667
tty_ldisc_flush(tty);
668668

669-
shutdown(info);
669+
shutdown_hw(info);
670670
mutex_unlock(&info->port.mutex);
671671

672672
tty_port_close_end(&info->port, tty);
@@ -687,7 +687,7 @@ static void hangup(struct tty_struct *tty)
687687
flush_buffer(tty);
688688

689689
mutex_lock(&info->port.mutex);
690-
shutdown(info);
690+
shutdown_hw(info);
691691

692692
spin_lock_irqsave(&info->port.lock, flags);
693693
info->port.count = 0;
@@ -1445,7 +1445,7 @@ static int hdlcdev_open(struct net_device *dev)
14451445
spin_unlock_irqrestore(&info->netlock, flags);
14461446

14471447
/* claim resources and init adapter */
1448-
if ((rc = startup(info)) != 0) {
1448+
if ((rc = startup_hw(info)) != 0) {
14491449
spin_lock_irqsave(&info->netlock, flags);
14501450
info->netcount=0;
14511451
spin_unlock_irqrestore(&info->netlock, flags);
@@ -1455,7 +1455,7 @@ static int hdlcdev_open(struct net_device *dev)
14551455
/* generic HDLC layer open processing */
14561456
rc = hdlc_open(dev);
14571457
if (rc) {
1458-
shutdown(info);
1458+
shutdown_hw(info);
14591459
spin_lock_irqsave(&info->netlock, flags);
14601460
info->netcount = 0;
14611461
spin_unlock_irqrestore(&info->netlock, flags);
@@ -1499,7 +1499,7 @@ static int hdlcdev_close(struct net_device *dev)
14991499
netif_stop_queue(dev);
15001500

15011501
/* shutdown adapter and release resources */
1502-
shutdown(info);
1502+
shutdown_hw(info);
15031503

15041504
hdlc_close(dev);
15051505

@@ -2328,7 +2328,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
23282328
return IRQ_HANDLED;
23292329
}
23302330

2331-
static int startup(struct slgt_info *info)
2331+
static int startup_hw(struct slgt_info *info)
23322332
{
23332333
DBGINFO(("%s startup\n", info->device_name));
23342334

@@ -2361,7 +2361,7 @@ static int startup(struct slgt_info *info)
23612361
/*
23622362
* called by close() and hangup() to shutdown hardware
23632363
*/
2364-
static void shutdown(struct slgt_info *info)
2364+
static void shutdown_hw(struct slgt_info *info)
23652365
{
23662366
unsigned long flags;
23672367

0 commit comments

Comments
 (0)