This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: variables order(arrange)
- From: Jeff Law <law at redhat dot com>
- To: Man Glory <glory_man at tut dot by>, gcc-help at gcc dot gnu dot org
- Date: Tue, 08 Apr 2014 09:43:15 -0600
- Subject: Re: variables order(arrange)
- Authentication-results: sourceware.org; auth=none
- References: <CAG44KjCtoos-PhzqYaGzjSUo8vNfZgadjxUZM7G=tbeftEjbJw at mail dot gmail dot com> <533EAEAF dot 40807 at redhat dot com> <CAG44KjDruFAxu6ok_JD7knpqCq9rzw0myCKgZvVy_MVGoAFKow at mail dot gmail dot com>
On 04/08/14 07:40, Man Glory wrote:
Is there no easier way? Generally, it is very strange. In most
compilers I used earlier variables placed in memory one after another,
in the order they are declared in the program. Or you had to use some
flag when compiling application. Applied to these solutions.
As far I understand, in order to place a section in the script I need
to know their names. How to find the names of the sections?
Not really. The compiler and linker are free to rearrange variable
locations relative to each other. Depending on two variables to land
physically in memory next to each other is, umm, bad practice.
If you absolutely must do that, then the way to go is to get those
variables into their own sections then use a linker script to ensure
those sections are adjacent.
Alternately, put them in a structure.
jeff