Re: [PATCH 02/17] x86, lto: Mark all top level asm statements as .text

From: Thomas Gleixner
Date: Wed Mar 27 2019 - 11:08:48 EST


On Wed, 27 Mar 2019, Andi Kleen wrote:
> On Wed, Mar 27, 2019 at 03:20:08PM +0100, Thomas Gleixner wrote:
> > /* Simple instruction patching code. */
> > -#define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
> > +#define NATIVE_LABEL(a,x,b) "\n" a #x "_" #b ":\n\t"
> >
> > #define DEF_NATIVE(ops, name, code) \
> > - __visible extern const char start_##ops##_##name[], end_##ops##_##name[]; \
> > - asm(NATIVE_LABEL("start_", ops, name) code NATIVE_LABEL("end_", ops, name))
> > + static const char start_##ops##_##name[], end_##ops##_##name[]; \
>
> Please don't apply the static/__visible removal hunk, I will just need to
> revert it again for LTO.

Why on earth is this needed for LTO?

>From the GCC manual:

"This attribute, attached to a global variable or function, nullifies the
effect of the -fw hole-program command-line option, so the object remains
visible outside the current compilation unit."

Neither the variable nor the data generated are global anymore. This data
is only used inside this compilation unit and I don't see why LTO needs a
reference outside of it. If so, then I really want to understand WHY
exactly.

Thanks,

tglx