Issue 63885
Summary [AIX] Invalid value written for relocation target for local-exec TLS access
Labels miscompilation, platform:aix
Assignees amy-kwan
Reporter hubert-reinterpretcast
    In the following, the value written at relocation's target in the object out of the compiler is supposed to be the value of the symbol, which is 4:
```
0000000000000004 l     O *COM*  0000000000000004 (idx: 15) y[UL]
```
however, we get 0 (and not 4):
```
0000000000000078 (idx: 11) y[TC]:
      78: 00 00 00 00   <unknown>
 0000000000000078:  R_TLS_LE     (idx: 15) y[UL]
      7c: 00 00 00 00 <unknown>
```

As a result, the program does the wrong thing (access to `y` instead accesses `x`).

### Source (`<stdin>`):
```c
static __thread int x, y;
int main(void) {
  x = 1;
  return x + y;
}
```

### Compiler invocation:
```
clang -ftls-model=local-exec -m64 -pthreads -xc -
```

### Run invocation and result:
```
$ ./a.out; echo $?
2
```

### Expected result:
```
1
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to