Jakub Jelinek wrote:
I'm pretty sure all implementations of OpenGL are not compiled as PIC at this point in time.
AFAIK on x86 only, but it is wrong everywhere.
Can you elaborate?
On x86, ld supports Local Exec model in shared libraries (while for most other targets it does not). R_386_TLS_LE relocation is simply during -shared linking changed into R_386_TLS_TPOFF dynamic relocation (the same as is used for IE model, but there this reloc is against .got section while for LE it is against text section).
To be clear, are you saying that even if you declare a variable as LE, once you link the relevant code into a shared library it is changed to IE?
So, if you don't use -fpic anyway, you can just use LE model on IA-32, if you finally change it so that -fpic is used for the whole library, then those functions (or assembly stubs) can be put into some SHF_ALLOC|SHF_WRITE|SHF_EXECINSTR section.
If we don't use PIC, do we always get LE if we declare a variable as LE?
Which means you should use the default -ftls-model and use __attribute__((tls_model("initial-exec"))) or __attribute__((tls_model("local-exec"))) for the variables which are really performance critical.
Yes, that would be the plan.
On IA-32, you can use __asm ("jmp 1f; .section writetext, "awx"; 1: movl $foo@ntpoff, %0; jmp 2f; .previous; 2:" : "=r" (foo_offset)); to query some variable's offset which you can later on use with: __asm ("movl %gs:0(%1), %0" : "=r" (foo_value) : "r" (foo_offset)); Please do something like this only for runtime generated code, not for anything else.
Of course, silly me.