static and global variables allocation

Ian Lance Taylor iant@google.com
Wed Dec 16 01:10:00 GMT 2009


PhDUCSB <eng.hmohsen@gmail.com> writes:

> I want to know which files in the gcc compiler deals with static and global
> variable allocations because I would like to change the place they are
> allocated at in memory. Any help would be appreciated. Thanks, 

They are handled in gcc/varasm.c.  However, if what you care about is
where they wind up in memory, then you probably don't want to fiddle
with gcc.  It is the linker which lays variables out in memory.  One
approach is to group variables into sections using the section
attribute.  Then use a linker script to put the sections at the
addresses you want.

Ian



More information about the Gcc-help mailing list