aix: 64 bit AIX TLS libpthread dependency.
commit34ce7f7a9a64dd69dd6a77dfd4a77406c3c71014
authorClément Chigot <clement.chigot@atos.net>
Thu, 12 Aug 2021 17:17:15 +0000 (12 13:17 -0400)
committerDavid Edelsohn <dje.gcc@gmail.com>
Sun, 15 Aug 2021 17:26:27 +0000 (15 13:26 -0400)
tree693b86639899af4c92e6b5c28062f734a47e23a8
parent882f1d58bfa56737ff2de84c3cd1e0acfc318b86
aix: 64 bit AIX TLS libpthread dependency.

64bit XCOFF files will generated TLS access, with local-exec or
global-exec models, by an access to R13. Thus, there isn't
any reference to a TLS symbol.

The problem is that it allows programs with TLS to be compiled and
linked even without -pthread. Most of the time, it will result in
a segfault when trying to access a TLS variable. But sometimes, it
might create a memory corruption.

This patch forces a reference to __tls_get_addr() to ensure link
will fail without -pthread.

gcc/ChangeLog:
2021-08-11  Clément Chigot  <clement.chigot@atos.net>

* config/rs6000/rs6000.c (xcoff_tls_exec_model_detected): New.
(rs6000_legitimize_tls_address_aix): Use it.
(rs6000_xcoff_file_end): Add ".ref __tls_get_addr" when
xcoff_tls_exec_model_detected is true.
gcc/config/rs6000/rs6000.c