[PATCH v2 2/2] [POWERPC] Use new machine_xxx_initcall hooks in platform code

Arnd Bergmann arnd at arndb.de
Wed Dec 5 09:05:56 EST 2007


On Tuesday 04 December 2007, Benjamin Herrenschmidt wrote:
> > 2. The call to firmware_has_feature() turns into a compile-time check
> > in
> > many cases, so if the kernel does not contain support for any firmware
> > with the given feature, all the code referenced it can get optimized
> > away by the compiler.
> 
> The machine init stuff will soon get rid of whatever test is in it too,
> as soon as I get to do the ELF magic.

Section magic is often painful and causes a number of problems. Moreover, it
won't do the same thing as what the compiler can do. Consider

static int x __attribute__((section("some_platform.data"))) = 1;
static int f(void) __attribute__((section("some_platform.text")));
{
	if (firmware_has_feature(FOO))
		return x;
	return 0;
}

When firmware_has_feature(FOO) statically evaluates to false, f becomes an
empty function and x is left out from the object file.
If you turn it into a platform_is() check and discard all "some_platform"
sections, you need to have both in the vmlinux file and can discard them
at run time, which is something completely different. You can also
discard them in the linker script, but that's a lot more work than having
the compiler do the right thing.

	Arnd <><



More information about the Linuxppc-dev mailing list