RE: [PATCH] /dev/mem gcc weak function workaround

From: Pallipadi, Venkatesh
Date: Wed Apr 30 2008 - 08:54:20 EST

>-----Original Message-----
>From: David Miller [mailto:davem@xxxxxxxxxxxxx]
>Sent: Tuesday, April 29, 2008 9:29 PM
>To: Pallipadi, Venkatesh
>Cc: mingo@xxxxxxx; tglx@xxxxxxxxxxxxx; hpa@xxxxxxxxx;
>akpm@xxxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
>Subject: Re: [PATCH] /dev/mem gcc weak function workaround
>From: Venki Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
>Date: Tue, 29 Apr 2008 18:31:09 -0700
>> Some flavors of gcc 4.1.0 and 4.1.1 seems to have trouble
>> weak function definitions. Calls to function from the same
>file where it is
>> defined as weak _may_ get inlined, even when there is a
>non-weak definition of
>> the function elsewhere. I tried using attribute 'noinline'
>which does not
>> seem to help either.
>> One workaround for this is to have weak functions defined in
>> file as below. Other possible way is to not use weak
>functions and go back
>> to ifdef logic.
>> There are few other usages in kernel that seem to depend on
>weak (and noinline)
>> working correctly, which can also potentially break and
>needs such workarounds.
>> Example -
>> mach_reboot_fixups() in arch/x86/kernel/reboot.c is one such
>call which
>> is getting inlined with a flavor of gcc 4.1.1.
>> Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
>> Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
>This sounds like a bug. And if gcc does multi-file compilation it
>can in theory do the same mistake even if you move it to another
>We need something more bulletproof here.

The references here

seem to suggest that the bug is only with weak definition in the same
So, having them in a different file should be good enough workaround

Tom: Comments?

>Also, we have a macro for marking things weak "__weak" which should
>be used here.

Yes. Will change that.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at