On 04/04/14 06:19, Man Glory wrote:
Is it possible to build such application using gcc to variables
arranged in order of their declared in source code?
For example, I have 2 variables in application declared one after
another, and then build the application, one of them is located at
0x20001330, another at 0x2000131C. In the range between these
addresses the compiler placed several other variables. And I would
like to see these variables were located in neighboring cells, ie one
after another.
I looked at the gcc description and found nothing suitable.
Use -fdata-sections and a linker script.
-fdata-sections will place each variable into its own section (assuming
your object format supports that, ELF does).
Once that's in place, you can use a linker script to explicitly place
the two sections next to each other.
Jeff