This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Variable order and location within the section - optimization level dependent
- From: JanÃÄek JiÅÃ <jiri dot janacek at skoda dot cz>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 17 Oct 2013 07:46:33 +0000
- Subject: RE: Variable order and location within the section - optimization level dependent
- Authentication-results: sourceware.org; auth=none
- References: <65513286F68AA34992CFC96B7C77DF397697A7FF at srv-exch-mbx2 dot skoda dot cz> <CAKOQZ8wh4sJGYxRVGtYiHCfsHxi6Jgqf7EATNtzVTjw+DfcLZg at mail dot gmail dot com> <65513286F68AA34992CFC96B7C77DF397697A867 at srv-exch-mbx2 dot skoda dot cz> <CAKOQZ8wXbrujV5ciG059SYe9eEMTS2s_fs151nWd_9Q2dpgasw at mail dot gmail dot com>
-----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