Re: Order of variables in specific sections when enabling optimization in gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Segher!

On Thu, 2019-03-07 at 06:08 -0600, Segher Boessenkool wrote:
> You probably should use a linker script for this.

You think of anything better than placing each variable in its own
section and placing them manually in the linker script in the order I
like? I would like to avoid any messing with linker script if that's
possible... If there's nothing better I may end up using suffixes
("section.1", "section.2", "section.3", ...) and sort the sections in
the linker script (`*(SORT(.section.*));`), but I would still prefer to
solve that in the source file only.

> The compiler can optimise away (some of) those variables even, or not
> always keep them in memory, etc., unless you use volatile on the
> vars.

No worries, it won't optimize them away, there's also a header where
these variables are declared with `extern ...` (omitted that in the
example, as this doesn't change anything) and all of them will be used
in the project. I'm just concerned about their order.

Regards,
FCh




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux