This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Alignment of .rodata symbols wasting space
- From: Ian Lance Taylor <ian at airs dot com>
- To: John Carter <john dot carter at tait dot co dot nz>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 12 May 2005 20:36:23 -0400
- Subject: Re: Alignment of .rodata symbols wasting space
- References: <Pine.LNX.4.61.0505131200590.9718@parore.tait.co.nz>
John Carter <john.carter@tait.co.nz> writes:
> I am linking an executable for an embedded target with very limited
> rom/ram resources.
>
> While analysing our space requirements I noted a fairly large
> discrepancy between the amount of rodata reported by readelf vs adding
> up the individual symbols reported by objdump --syms. (About a factor
> 1.5)
This would seem to be a linker issue rather than a gcc issue, and as
such is better directed to a binutils list. See
http://sourceware.org/binutils/
> As far as I can see, there are two sources for this discrepancy...
> 1) Alignment. (1 byte symbol followed by a 4 byte aligned symbol)
> 2) Some large mysterious other thing between the last symbol and the end
> of the rodata segment..
>
> Question 1)
> Any ld flags / linking script options / ... that I can use to pack all
> byte aligned objects together?
No. The linker can sort common symbols (--sort-common) but not
symbols in the .rodata section.
> Question 2)
> Any guesses as to what are the mystery rodata items that are not showing
> up in objdump --syms?
Use a linker map (linker -M option) to find out what is going there.
> Question 3)
> Are these problems perhaps an artifact of the somewhat elderly version
> of the toolchain we are using? ie. Would upgrading solve this problem?
> sparc-rtems-gcc 2.95.2
> sparc-rtems-objdump 2.11
Hard to be sure, but it doesn't seem especially likely.
Ian