This is the mail archive of the mailing list for the GCC 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]

Re: Minimal GCC/Linux shared lib + EH bug example

From: "Martin v. Loewis" <>

> "David Abrahams" <> writes:
> > I attempted to take C++ out of the picture in "weak.tgz" by using
> > __attribute__((weak)), but the assembler doesn't like what the compiler
> > outputs.
> Please be always as specific you can in such reports.

...of course you're right...

> I assume the
> assembler expressed its dislike by saying
>  Error: symbol `x' can not be both weak and common


> That may be a bug in gcc - it should not export a symbol as "common"
> when it also declares it as weak.
> > DOes g++ add some additional attribute to the template static data
> > members to make the assembler happy?
> No. For template static data, it *only* emits them as .comm, not as
> .weak. For initialized data that need to be merged at run-time (such
> as vtables), it emits them as weak. In your C example, you can achieve
> the same effect by saying
>   int x __attribute__((weak)) = 1;
> I ran your example, but could not see any problems with it.

When I added the initializer as you suggest, the "C" language example
produces the same results as the C++ one.

> > Each archive contains a script which attempts to build and run
> > example (well, "weak.tgz" doesn't attempt to run, since the build
fails). I
> > am using GCC 3.1 installed in /usr/local, which explains why
> > appears in the LD_LIBRARY_PATH in the scripts.
> Could it be that you've attached the same example twice? I could not
> find anything involving template static members (or C++, for that
> matter).

Hmm, yes, you're right; I tar'ed the wrong directory. Please see the

> For a minimal example, it would help if the directory structure where
> simpler...

Indeed; the title of the thread is slightly misleading ;-)


Attachment: weak.tgz
Description: application/compressed

Attachment: template.tgz
Description: application/compressed

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