data type & sections

Daniel Lohmann daniel.lohmann@informatik.uni-erlangen.de
Tue Mar 20 10:59:00 GMT 2007


stefano carucci wrote:
> 
> Hello all,
> 
> my question is:
> Is it possible to set a data type (for example, the type
> "Matrix",customized by means of a struct, or a standard type, as "int")
> in a certain section (defined in the linker script, as ".data") in order
> for every Matrix-items (for example) to be placed in a dedicated memory?
> maybe, by means of a #pragma...?

Gcc supports various attributes to assign linker sections (such as
__attribute__((section, ".mysection")), take a look in the manuals),
which is in general a more flexible mechanism than #pragmas.

Unfortunately, the section attribute can be applied only to
variable/function definitions, not to type definition. Hence, it is not
possible to define a "default section" for all (static) variable
instances of a particular type, even though such feature would be *very*
useful.

If you have full control over the source code you may use a
pre-processor macro as workaround, which instantiates Matrix-items with
  the proper attributes.


Daniel



More information about the Gcc-help mailing list