This is the mail archive of the
mailing list for the GCC project.
Re: [Patch] SH : Add target specific option -msort-data for SH-ELF target
- From: Richard Sandiford <richard at codesourcery dot com>
- To: "Anil Paranjape" <AnilP1 at KPITCummins dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 20 Jun 2005 21:26:37 +0100
- Subject: Re: [Patch] SH : Add target specific option -msort-data for SH-ELF target
- References: <4A1BE23A7B777442B60F4B4916AE0F13061308A0@sohm.kpit.com>
"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