[gPXE-devel] Weak pxe_menu_boot()

Stefan Hajnoczi stefanha at gmail.com
Tue Jul 13 11:36:13 EDT 2010


On Fri, Jul 9, 2010 at 5:24 PM, Joshua Oreman <oremanj at rwcr.net> wrote:
> On Fri, Jul 9, 2010 at 3:29 AM, Stefan Hajnoczi <stefanha at gmail.com> wrote:
>> Richard Sandiford identified the issue: the compiler inlines
>> pxe_menu_boot() because the symbol has visibility "hidden".  From
>> include/compiler.h:
>>
>> /* Force visibility of all symbols to "hidden", i.e. inform gcc that
>>  * all symbol references resolve strictly within our final binary.
>>  * This avoids unnecessary PLT/GOT entries on x86_64.
>>  *
>>  * This is a stronger claim than specifying "-fvisibility=hidden",
>>  * since it also affects symbols marked with "extern".
>>  */
>> #ifndef ASSEMBLY
>> #if __GNUC__ >= 4
>> #pragma GCC visibility push(hidden)
>> #endif
>> #endif /* ASSEMBLY */
>>
>> So although the function is extern, the pxe_menu_boot symbol has
>> visibility "hidden" and the compiler decides inlining is okay, despite
>> it being a weak symbol.  Add __attribute__((visibility("default"))) to
>> pxe_menu_boot() to test this.
>>
>> It seems to me that gcc interprets "hidden" as "all symbol references
>> resolve strictly within the compilation unit" rather than "all symbols
>> references resolve strictly within our final binary".  Whether or not
>> gcc changes its behavior, we need to solve this for gPXE so that it
>> works on existing compilers.
>
> Excellent job tracking this down. I wonder if
> __attribute__((noinline)) would work as well?

That would be a nice fix.  I'll test it and see if we can add it to
__weak.  Otherwise we may have to add
__attibute__((visbility("default))) to __weak.

Stefan


More information about the gPXE-devel mailing list