This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Accumulation of similar size data items to reduce ROM space.

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. 

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 for details. 
Latest versions of KPIT GNU tools were released on October 1, 2004.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]