public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RE: Accumulation of similar size data items to reduce ROM space.
@ 2004-11-04  6:06 Nitin.Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Nitin.Gupta @ 2004-11-04  6:06 UTC (permalink / raw)
  To: NitinY; +Cc: binutils



>-----Original Message-----
>From: binutils-owner@sources.redhat.com 
>[mailto:binutils-owner@sources.redhat.com] On Behalf Of Alan Modra
>Sent: Wednesday, November 03, 2004 7:05 PM
>To: Nitin Yewale
>Cc: binutils@sources.redhat.com
>Subject: Re: Accumulation of similar size data items to reduce 
>ROM space.
>
>
>On Wed, Nov 03, 2004 at 01:57:19PM +0530, Nitin Yewale wrote:
>> Even if compiler does the job of accumulating similar size 
>data items 
>> but it will be file wise. So it will be better if linker 
>reads all the 
>> object files and does the accumulation of similar size data items on 
>> the data type basis.
>
>No, doing this sort of thing in the compiler is by far the 
>easiest way to accomplish what you want.  Have the compiler 
>emit 1 byte variables to .data.s1, two byte variables to 
>.data.s2 and so on.  Then the linker can easily combine like 
>sized data items.

The compiler can also do clubbing of similar data types in one group and
then do the padding work.
A patch to gcc about stack slot analysis that could accomplish this sort
of work was posted sometime back.
http://gcc.gnu.org/ml/gcc-patches/2003-01/msg00019.html

>
>If you really must do this in the linker alone, then you'll need to
>a) determine data item boundaries
>b) rearrange section contents
>c) adjust all relocs pointing into the rearranged sections.
>d) adjust all relocs in the rearranged sections.
>e) adjust all symbols defined in those sections too.
>
>(a) is non-trivial.  How will you handle aggregates?
>
>-- 
>Alan Modra
>IBM OzLabs - Linux Technology Centre
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accumulation of similar size data items to reduce ROM space.
  2004-11-09  8:45 Nitin Yewale
@ 2004-11-09  9:24 ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2004-11-09  9:24 UTC (permalink / raw)
  To: Nitin Yewale; +Cc: binutils

On Tue, Nov 09, 2004 at 02:07:27PM +0530, Nitin Yewale wrote:
> We would like to put all similar size variables into one section. How can we 
> automate this in compiler?

By providing a suitable select_section function in gcc.  See
TARGET_ASM_SELECT_SECTION and varasm.c

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Accumulation of similar size data items to reduce ROM space.
@ 2004-11-09  8:45 Nitin Yewale
  2004-11-09  9:24 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Nitin Yewale @ 2004-11-09  8:45 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Hi,
Thank you for the informative reply.

>No, doing this sort of thing in the compiler is by far the easiest way
>to accomplish what you want.  Have the compiler emit 1 byte variables
>to .data.s1, two byte variables to .data.s2 and so on.  Then the linker
>can easily combine like sized data items.

We have tried to put all similar size variables into one sections by specifying
attribute for each variable like 
	char ch1a __attribute__ ((section ("charSect"))) = { 23 };

With above approach user will have to put each and every variable into the 
specific section by specifying the attribute. 
We would like to put all similar size variables into one section. How can we 
automate this in compiler?

Regards,
Nitin Yewale,
KPIT Cummins InfoSystems Ltd.
Pune, India

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH and H8 Series.
The following site also offers free technical support to its users. 
Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools were released on October 1, 2004.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

-----Original Message-----
From: Alan Modra [mailto:amodra@bigpond.net.au]
Sent: Wednesday, November 03, 2004 7:05 PM
To: Nitin Yewale
Cc: binutils@sources.redhat.com
Subject: Re: Accumulation of similar size data items to reduce ROM
space.


On Wed, Nov 03, 2004 at 01:57:19PM +0530, Nitin Yewale wrote:
> Even if compiler does the job of accumulating similar size data items
> but it will be file wise. So it will be better if linker reads all the
> object files and does the accumulation of similar size data items on the
> data type basis. 

No, doing this sort of thing in the compiler is by far the easiest way
to accomplish what you want.  Have the compiler emit 1 byte variables
to .data.s1, two byte variables to .data.s2 and so on.  Then the linker
can easily combine like sized data items.

If you really must do this in the linker alone, then you'll need to
a) determine data item boundaries
b) rearrange section contents
c) adjust all relocs pointing into the rearranged sections.
d) adjust all relocs in the rearranged sections.
e) adjust all symbols defined in those sections too.

(a) is non-trivial.  How will you handle aggregates?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Accumulation of similar size data items to reduce ROM space.
  2004-11-03  8:34 Nitin Yewale
@ 2004-11-03 13:35 ` Alan Modra
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Modra @ 2004-11-03 13:35 UTC (permalink / raw)
  To: Nitin Yewale; +Cc: binutils

On Wed, Nov 03, 2004 at 01:57:19PM +0530, Nitin Yewale wrote:
> Even if compiler does the job of accumulating similar size data items
> but it will be file wise. So it will be better if linker reads all the
> object files and does the accumulation of similar size data items on the
> data type basis. 

No, doing this sort of thing in the compiler is by far the easiest way
to accomplish what you want.  Have the compiler emit 1 byte variables
to .data.s1, two byte variables to .data.s2 and so on.  Then the linker
can easily combine like sized data items.

If you really must do this in the linker alone, then you'll need to
a) determine data item boundaries
b) rearrange section contents
c) adjust all relocs pointing into the rearranged sections.
d) adjust all relocs in the rearranged sections.
e) adjust all symbols defined in those sections too.

(a) is non-trivial.  How will you handle aggregates?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Accumulation of similar size data items to reduce ROM space.
@ 2004-11-03  8:34 Nitin Yewale
  2004-11-03 13:35 ` Alan Modra
  0 siblings, 1 reply; 5+ messages in thread
From: Nitin Yewale @ 2004-11-03  8:34 UTC (permalink / raw)
  To: binutils

Hi,
I would like to arrange similar types of initialized data items together to reduce the ROM space. The obvious prerequisite is that the linker should have information regarding the data type of the variables.

After analyzing the sources, I have found that the object files which the linker uses for final linking have information about the sizes of variables but not the data type. It will not be proper if we rearrange variables based on the sizes of the variables as the compiler may have added extra bytes for padding.

For e.g
char c = 23;
long x = 23213;
char gg = 21;
If you have declaration like above, then the object file contains are as follows.
			0x0000000000002450                c
			0x0000000000002454                x
                	0x0000000000002458                gg
              
The object file has the allocation information (i.e. size) of variables and linker will do the final assignment to them. In above case though variable "c" is of char data type and object file shows 4 bytes because compiler has added 3 bytes padding to the same due to alignment. 

Even if compiler does the job of accumulating similar size data items but it will be file wise. So it will be better if linker reads all the object files and does the accumulation of similar size data items on the data type basis.

Any help regarding this will be appreciated. Thanks in advance. 

Regards,
Nitin Yewale,
KPIT Cummins InfoSystems Ltd.
Pune, India

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH and H8 Series.
The following site also offers free technical support to its users. 
Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools were released on October 1, 2004.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-11-09  9:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-04  6:06 Accumulation of similar size data items to reduce ROM space Nitin.Gupta
  -- strict thread matches above, loose matches on Subject: below --
2004-11-09  8:45 Nitin Yewale
2004-11-09  9:24 ` Alan Modra
2004-11-03  8:34 Nitin Yewale
2004-11-03 13:35 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).