r218141 - In the Itanium ABI, move stuff to the comdat of variables with static init.

Richard Smith richard at metafoo.co.uk
Sat Nov 1 11:29:38 PDT 2014


Thanks, that sounds ideal.
On 1 Nov 2014 11:06, "Rafael EspĂ­ndola" <rafael.espindola at gmail.com> wrote:

> > and I can't get it to produce invalid code. The main difference is
> > that without a static constructor there is never an always run piece
> > of code that assumes that it has to write to y. We also put y in a rw
> > section even when S::x is defined, but I think that is a bug (and will
> > report it in a sec).
>
> Never mind, a better testcase is
>
> struct S {
>   static const int x;
> };
> //const int S::x = 42;
> inline const int* f() {
>   static const int y = S::x;
>   return &y;
> }
> const int *g() { return f(); }
>
>
> With the S::x definition comment we put _ZZ1fvE1y in .bss. With the
> definition present, it is placed in .rodata._ZZ1fvE1y. I guess it is
> theoretically possible for a linker to pick _ZZ1fvE1y from one file
> and _Z1fv from another, producing an invalid result.
>
> I will try to write a patch putting the variable and gv in the same
> comdat as the inline function.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141101/00d96665/attachment.html>


More information about the cfe-commits mailing list