Variable order and location within the section - optimization level dependent
Janáček Jiří
jiri.janacek@skoda.cz
Thu Oct 17 07:46:00 GMT 2013
-----Original Message-----
From: Ian Lance Taylor [mailto:iant@google.com]
Sent: Wednesday, October 16, 2013 4:30 PM
To: Janáček Jiří
Cc: gcc-help@gcc.gnu.org
Subject: Re: Variable order and location within the section - optimization level dependent
On Wed, Oct 16, 2013 at 7:06 AM, Janáček Jiří <jiri.janacek@skoda.cz> wrote:
>
> I do know this approach. I have created sections with the appropriate address ranges and located the variables into those sections by the below mentioned attribute.
> If no optimization is turned on, then the order (means also the address offset of the variable) is correct.
> If -O1 is turned on, the variables order within the section is exactly opposite.
> If -O1 is turned on and the flag -fno-toplevel-reorder is turned on as well, then the order is equal to the requested one. But I would like to apply such a behavior (no reorder) just for some variables in some modules. Other modules should be optimized by -O1 level.
> So I am curious which attributes can define this behavior.
Please don't top-post. Thanks.
It sounds like you are saying that you want to have your global variables appear in a specific order in a specific section.
There is no attribute that will make that happen. Sorry. The obvious workaround would be to use a struct.
Ian
------------------
Hello Ian,
Right, the obvious solution is to apply a struct - originally I intended to avoid this way (there are some internal reasons for that).
IMHO the description of the "-fno-toplevel-reorder" flag (http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Optimize-Options) is a bit confusing - I mean especially this section: "For new code, it is better to use attributes.”
Thanks for your support,
JiriJ
More information about the Gcc-help
mailing list