[Patch] SH : Add target specific option -msort-data for SH-ELF target
Richard Sandiford
richard@codesourcery.com
Mon Jun 20 21:27:00 GMT 2005
"Anil Paranjape" <AnilP1@KPITCummins.com> writes:
> Please find below a patch for SH (ELF) target, which generate separate
> sections for variables with different data types. Arrays are also
> treated same way. This is done for initialized global variables and read
> only (const) data.
>
> This patch will reduce padding (memory gaps) between variables with
> different data types. Since characters will be 1 byte aligned, short
> integers will be 2 byte aligned and long integers will be 4 byte aligned
> and all will be placed in different sections. This will help in reducing
> RAM as well as ROM size.
>
> All characters will go in .d_char section, short integers in .d_short
> section, long integers in .d_long section, read only characters will go
> in .rod_char section, read only short integers will go in .rod_short
> section and read only long integers will go in .rod_long section.
Just a comment from a random reader: why did you restrict the new
behaviour to these types? Why not generalise it to all types of a
particular alignment? E.g. 1-byte-aligned structures could go in
.d_char, 2-byte-aligned structures in .d_short, etc.
Also, how about naming the sections something like ".data.align%d",
in a similar vein to the .rodata.cst%d and .rodata.str%d sections
that we use for merging? At first glance, it looks like the patch
could be much simpler if written that way. It also means that any
existing linker scripts that use "*(.data*)", etc., will work without
modification.
Richard
More information about the Gcc-patches
mailing list