On Fri, Nov 21, 2008 at 11:19:32AM +0100, Joel Porquet wrote: > I agree that wether the code is pic or not and the tls model are quite > independent. > According to the manual, the default policy for TLS is affected by the > pic model though: > > -ftls-model=model > ... > The default without -fpic is "initial-exec"; with -fpic the > default is "global-dynamic".
Which is exactly what happens. Using -fpie does not cound as "with -fpic". > > It's a difference between linking an executable versus linking a > > shared library; this is one of the distinctions between -fpie and > > -fpic. > > Yes for the linking stage but for the object compilation, -fpie should > be almost the same. No, it shouldn't. `-fpie' `-fPIE' These options are similar to `-fpic' and `-fPIC', but generated position independent code can be only linked into executables. This is one of the reasons that the generated code can only be used in executables. > It could be but firstly when the global-dynamic model is specified one > should expect to get global-dynamic and not local-dynamic, and anyway > it is not local-dynamic. I don't remember what the deal is with the command line option, but I've run into that before. The answer was, I think, that it is behaving as designed - but not intuitively. As for the model, you're right, it's not local dynamic. It's global dynamic linked into an executable. The linker has performed some optimization on your output file because it can determine the symbol binding at static link time. There's no need for a dynamic relocation to calculate DTPREL when it's a link-time constant. This is all very interesting, but you didn't answer my question: is this causing some problem, or just confusing? These are all intended optimizations. -- Daniel Jacobowitz CodeSourcery