<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63885>63885</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AIX] Invalid value written for relocation target for local-exec TLS access
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            miscompilation,
            platform:aix
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            amy-kwan
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hubert-reinterpretcast
      </td>
    </tr>
</table>

<pre>
    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
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlEuP4ygQxz9N5VJyZIOdx8GHPCZSS70aabpX2lsL44rNDgYLcB7ffoXjzGR7ejRtoUQURf2qoPgL71VjiEootsCY6K7J97MwwBgU-5kYQmtd2Q4VuZA4UiaQ6x0FKXyYVba-lk8GQ0t4tFrbszINsN1oOAk9EJ6dCoEMioCOtJUiKGuALT0G4RoKqG7bbfUvyYB2CGiPo0XarleaHCqPfuh766nGYLGih_CTr792ldWRfG6VbOOWHPgG0j2kG1ik0xin6f-_HDXG7ysC2-y-_gVsg_iLD7CVqi_AN5gVwNZ4hWL79zMU-w8RrT3TidyYD2GsMo0RhKnR2IA5sPXnsluuHsnZnfy6i-R7hDF9XK6iT5r-HIjAd4P5buzZAP8yOb8HxF347e31-eXt-csY6Q-1Tjj5HvcB7F1tt9-NR4GO_KDDvVV6ZxsnOqwt-dFwdtY0GFplmvHgpCTv4-XDIr3CIkVlfCBR422FfFy4RBBbzx9hwPht4IsdnKQYLbrxnQ-1GjMdN_16HfI290EEJfHtLbQuApUJeIl5X4Fvby7R1AllgK1OVtXxyGC5vR_WBYHvMfvhjegoDM7EBbZ9CAPLj5vpfSG7H-_CnO7v6TfNJLUwDSbHoH3S2Zo08H18gzqhC0lMukWOSX-rzGNykZh8KoVvg3mgY-zr6UJ_kwiwHOfADmJuhwB8iyRbi8By4IebB_sU-MulJxnoT7jsQ-usLnm95msxozJbrNZ5XiwX-awtF7wSaXGktC6YEDyri2opqK7SY35M6VjNVMlSxtNlVmQrtmb5vCiIZazKVjIt-JpLyFPqhNJzrU_d3LpmprwfqFzw1aqYaVGR9pPAdsrflG1SQgZsB4z1WoSjdR3wjVCXSX1dGeMl1dB4yFOtfPA_CUEFPar25ukfKPb4ZE5Cq_qd7h6texDeu-hG60MjvD6_TC9pNjhdtiH0Pp4tOwA7NCq0QzWXtgN2iPTpL-mdjZoN7DAW64Edxnr_CwAA__8OJ8LB">