------- Comment #42 from hjl at lucon dot org 2007-11-05 14:18 ------- (In reply to comment #39) > Subject: Re: [4.3 Regression] typeinfo name referenced in ... defined in > discarded section > > > On 04/11/2007, at 7:01 PM, hjl at lucon dot org wrote: > > >> - Won't this cause the global variable to be discarded if anyone > >> defines a different global variable which also references the same > >> string? > > > > The comdat group should have both global variables defined. > > I'm talking about > > static char * some_variable = "hi there"; > > and in some other file > > static char * some_variable = "hi there"; > > the compiler does not know that there are two files containing > 'some_variable', and they have to be different variables (someone > might change one of them and the other should not change if that > happens), but the two "hi there" strings should be shared. > > How should the compiler represent this in ELF? >
1. Put "hi there" in a comdat group. 2. Mark "hi there" global and hidden. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33871