Copying binary code?

Jeff Garzik (jgarzik@mandrakesoft.com)
Thu, 16 Dec 1999 13:25:12 +0000


A good trick with __initdata is to have a bunch of data, and then copy
only what you need into dynamic kernel memory. PCI names does this.

I want to do the same thing with code: copy the code I want into
dynamic memory on a function-by-function basis. Is there a preferred
method?

Presuming function dependencies are correct, a possible solution might
be to compile any code which might be dynamic copied with -fPIC, and
then set up the copy and call on that basis. That is somewhat messy, I
am almost surely missing a more elegant solution.

If you are wondering "why", I want to drop all support code for chipsets
which are not detected by drive probe (which is substantial in some
cases). Or in other words, have drivers re-link themselves at runtime,
freeing unwanted code :)

Though I guess __init and this sort of hackery becomes less important in
a hot-plug device world.

Thanks much,

Jeff

-- 
Jeff Garzik              | Just once, I wish we would encounter
Building 1024            | an alien menace that wasn't immune to
MandrakeSoft, Inc.       | bullets.   -- The Brigadier, "Dr. Who"

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/