Re: [Q] ld: Does LTO reorder ro variables in two files?

From: Jeff Law
Date: Thu Dec 19 2019 - 10:22:11 EST


On Thu, 2019-12-19 at 17:04 +0300, Kirill Tkhai wrote:
> CC: gcc-help@xxxxxxxxxxx
>
> Hi, gcc guys,
>
> this thread starts here: https://lkml.org/lkml/2019/12/19/403
>
> There are two const variables:
>
> struct sched_class idle_sched_class
> and
> struct sched_class fair_sched_class,
>
> which are declared in two files idle.c and fair.c.
>
> 1)In Makefile the order is: idle.o fair.o
> 2)the variables go to the same ro section
> 3)there is no SORT(.*) keyword in linker script.
>
> Is it always true, that after linkage &idle_sched_class < &fair_sched_class?
I certainly wouldn't depend on it. The first and most obvious problem
is symbol sorting by the linker. Longer term I'd be worried about LTO
reordering things.

In the end I'm pretty sure it'd be well outside what I'd be comfortable
depending on.

jeff
>