This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Minimal GCC/Linux shared lib + EH bug example
"David Abrahams" <david.abrahams@rcn.com> 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. 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.
> Each archive contains a script build.sh which attempts to build and run the
> 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 /usr/local/lib
> 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).
For a minimal example, it would help if the directory structure where
simpler...
Regards,
Martin