Issue 109087
Summary TLS segment offsets different for target i386 and i386-unknown-linux
Labels new issue
Assignees
Reporter prabhjotsingh3
    Hi,

The tls offsets used is different for target i386 and i386-unknonwn-linux for local-exec model.

Example code :-


```
#include <stdio.h>
__thread int myvar;
int main(void)
{
        myvar = 0;
        return 0;
}
```

For target i386 it uses offsets from the beginning of tls segment :-
Command - `clang -ftls-model=local-exec --target=i386 -v thread.c`
```
080484a0 <main>:
 80484a3:       50 push   %eax
 80484a4:       c7 45 fc 00 00 00 00    movl $0x0,-0x4(%ebp)
 80484ab:       65 a1 00 00 00 00       mov %gs:0x0,%eax
 80484b1:       c7 80 fc ff ff ff 00    movl $0x0,-0x4(%eax)
 80484b8:       00 00 00 
 80484bb:       31 c0 xor    %eax,%eax
 80484bd:       83 c4 04                add $0x4,%esp
 80484c0:       5d                      pop    %ebp
 80484c1: c3                      ret

```

For target i386-unknown-linux it uses offsets from the end of tls segment :-
Command - `clang -ftls-model=local-exec --target=i386-unknown-linux  -v thread.c`
```
000011a0 <main>:
    11a0:       55 push   %ebp
    11a1:       89 e5                   mov    %esp,%ebp
 11a3:       50                      push   %eax
    11a4:       c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%ebp)
    11ab:       65 c7 05 fc ff ff ff    movl   $0x0,%gs:0xfffffffc
    11b2:       00 00 00 00 
    11b6: 31 c0                   xor    %eax,%eax
    11b8:       83 c4 04 add    $0x4,%esp
    11bb:       5d                      pop %ebp
    11bc:       c3                      ret
    11bd:       66 90 xchg   %ax,%ax
    11bf:       90 nop
```
Would be grateful if anyway could please let me know the reason for this and is there anyway to control this via clang arguments?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to