[PATCH v4 2/2] ARM: ftrace: Add MODULE_PLTS support

Ard Biesheuvel ard.biesheuvel at linaro.org
Tue Mar 13 11:29:01 PDT 2018


On 13 March 2018 at 18:24, Alexander Sverdlin
<alexander.sverdlin at nokia.com> wrote:
> Hi!
>
> On 13/03/18 18:51, Ard Biesheuvel wrote:
>>>> if (IS_ENABLED(CONFIG_ARM_MODULE_PLTS))
>>>>     module_plt_alloc_fixed();
>>> Do you consider this a legal C code if without module-plts.o the function would not exist at all?
>>> That's too much relying on optimizer I think...
>>>
>> Yes, we rely on that in many different places in the kernel.
>
> https://www.kernel.org/doc/Documentation/process/coding-style.rst:
> "However, this approach still allows the C compiler to see the code
> inside the block, and check it for correctness (syntax, types, symbol
> references, etc).  Thus, you still have to use an #ifdef if the code inside the
> block references symbols that will not exist if the condition is not met."
>

"will not exist" is ambiguous here. It is rather common to declare
symbols, but only define them conditionally, and use IS_ENABLED() to
refer to them. As the documentation says, this gets rid of #ifdefs,
making the code always visible to the compiler which is a good thing.



More information about the linux-arm-kernel mailing list