Re: Fwd: binutils in debian unstable is broken.

Andrew Morton (akpm@zip.com.au)
Tue, 04 Dec 2001 21:42:46 -0800


Josh McKinney wrote:
>
> This seems to be a kernel bug which is shown with the new version of ld. Thought I would
> forward this along so maybe it can get fixed.
>
> ...
> drivers/char/char.o(.data+0x46b4): undefined reference to `local symbols
> in discarded section .text.exit'

It is a kernel bug, and it's going to break a truckload
of PCI drivers, along with uhci_pci_remove().

What is happening is this: a typical driver has:

static void __devexit remove_foo(...)
{}

static struct pci_driver foo_driver = {
...
remove: remove_foo;
};

The problem is that if foo.c is statically linked into the
kernel, and if CONFIG_HOTPLUG is not set, __devexit evaluates
to __exit. And in vmlinux.lds we've asked the linker to
discard all the contents of section .text.exit.

The problem appears to be that the linker is now actually doing what
we asked it to do, so the `remove_foo' entry in that table now points
at a function which isn't going to be linked into the kernel. Oh dear.

Workarounds are:

1) Enable CONFIG_HOTPLUG

2) Change vmlinux.lds so we don't drop the .text.exit section (this
is effectively the same as 1)

3) Something else. HJ's #ifdef MODULE works OK. It has a rather
internecine relationship with the workings of __devexit though.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/