Alignment of .rodata symbols wasting space
John Carter
john.carter@tait.co.nz
Fri May 13 01:34:00 GMT 2005
On Thu, 12 May 2005, Ishwar Rattan wrote:
> If I recall correctly the data has to be properly aligned
> for correct access under SPARC else you might see bus-error
> run time errors..
Correct, a 4 byte int has to be align on a 4 byte boundary.
However, a 1 byte int can (I believe) be aligned on a byte boundary, but
there is a performance penalty in accessing it if it is not 4 byte
aligned.
Thus if you sorted the rodata items by size, you could pack all the 1 byte
items together, then all the two byte items align on a two byte boundary,
etc.
Unfortunately the only thing I can find in ld is a script option to
*(SORT(.rodata.*)) the item names. No quite what I want, and
--sort-common, which seems to do nothing to either the rodata or bss
segments.
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand
Somewhere on the edge of a Galaxy, one of literally billions of such
galaxies, is a sun, one of literally billions of suns in that
galaxy.
Orbiting that sun is a small rock 330000 times smaller than that
sun.
This rock is covered by a very very thin scum of life. (Think 6000km
of rock followed by a meter or so of biomass.)
Amongst the millions of species in that scum are many hundreds of
thousands of types beetle and a mere handful of primates.
Surprisingly enough, this email does not originate from a beetle.
It originates from just one of the 6 billion vastly outnumbered humans.
I trust you will keep this perspective and context in mind when
reacting to this email.
More information about the Gcc-help
mailing list