[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: doubly created constants
From:       Michael Shalayeff <mickey () lucifier ! net>
Date:       2010-04-21 9:51:34
Message-ID: 20100421095134.GA30114 () lucifier ! net
[Download RAW message or body]

On Tue, Apr 20, 2010 at 09:53:47PM +0200, Anders Magnusson wrote:
> Thorsten Glaser wrote:
> >Anders Magnusson dixit:
> >
> >>That's true, and I would even say that it should not be the
> >>responsibility of the compiler to merge constants; the linker can do
> >>a much better job and merge constants between files.
> >
> >Does it do that then? Or is it the programmer's job?
> I assume most modern linkers do that.  It isnц╓t especially difficult.

i think the point being is that a one-liner like:
char s[] = "blah blah";

generates the following:
	.data
	.globl s
s:
	.byte 98
	.byte 108
	.byte 97
	.byte 104
	.byte 32
	.byte 98
	.byte 108
	.byte 97
	.byte 104
	.byte 0
	.section .rodata
.L11:
	.ascii "blah blah\0"

where you can see the same string is included twice.
i really doubt any linker would remove the second string.
plus to that it is not even using .asci[iz] initialiser for
the array (which needlessly creates much bigger asm).
this bothered me for a while but i never looked to fix it myself.
cu
--
    paranoic mickey       (my employers have changed but, the name has remained)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic