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

From: Thomas Gleixner
Date: Wed Mar 27 2019 - 15:08:35 EST


On Wed, 27 Mar 2019, Andi Kleen wrote:
> > 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.
>
> The LTO code generation doesn't compile file by file, but reorders
> all the functions and other top level statements into "partitions".
> The partitions are ordered by call graph so that inlining and some
> other optimizations work efficiently
>
> Then it finally runs multiple copies of the gcc code generator that
> generate code from these partitions, each generating an own assembler file.
>
> The top level assembler is not part of the call graph that drives
> the partitioning.

There is no top level assembly anymore. It's static data in the .rodata
section which is completely uninteresting for a call graph. That data is
accessed by the C function.

It's static so it's scope is within the file and whatever GCC does with
that C function it has to respect that it accesses static data. If that's
not true then this really needs to be fixed at the compiler side and not in
the kernel.

Thanks,

tglx