Incorrect local-dynamic TLS linker optimization with clang-generated code on PowerPC

Alan Modra amodra at
Wed Jan 28 18:50:58 PST 2015

On Thu, Jan 29, 2015 at 08:28:17AM +1030, Alan Modra wrote:
> On Wed, Jan 28, 2015 at 05:02:06PM +0100, Ulrich Weigand wrote:
> > Note how the original instruction marked with R_PPC64_GOT_TLSLD16_LO sets
> > register r29, while the linker-generated replacement sets r3.  Looking at
> > the linker code, the addis "r3, r13, ..." seems to be simply hard-coded,
> > which works only if the original instruction sets register r3.
> Ouch.  Will fix.

Fixed with

> > There is also a linker optimination for the general-dynamic case, but
> > from reading the BFD sources this seems to work correctly for any
> > target register and doesn't just assume r3.  Alan, is that right?
> No, I think that is also broken.

Actually, looking at it again after I'd woken up properly, the general
dynamic case is good.

> BTW, -Wl,--no-tls-optimize is another workaround for this problem.

Alan Modra
Australia Development Lab, IBM

More information about the llvm-commits mailing list