git: 127849157ab9 - stable/13 - rtld: style tls_get_addr_slow
Konstantin Belousov
kib at FreeBSD.org
Fri Apr 23 11:14:58 UTC 2021
The branch stable/13 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=127849157ab94c630533fdd7201422b36d3cf96f
commit 127849157ab94c630533fdd7201422b36d3cf96f
Author: Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-04-06 18:55:10 +0000
Commit: Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-04-23 11:14:07 +0000
rtld: style tls_get_addr_slow
(cherry picked from commit 85d846b369f4d8c0033993d3d1307779d3b9aa62)
---
libexec/rtld-elf/rtld.c | 54 ++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 4749e3a50d72..134c2566b4cd 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -4855,35 +4855,35 @@ static void *tls_get_addr_slow(Elf_Addr **, int, size_t) __noinline;
static void *
tls_get_addr_slow(Elf_Addr **dtvp, int index, size_t offset)
{
- Elf_Addr *newdtv, *dtv;
- RtldLockState lockstate;
- int to_copy;
+ Elf_Addr *newdtv, *dtv;
+ RtldLockState lockstate;
+ int to_copy;
- dtv = *dtvp;
- /* Check dtv generation in case new modules have arrived */
- if (dtv[0] != tls_dtv_generation) {
- wlock_acquire(rtld_bind_lock, &lockstate);
- newdtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr));
- to_copy = dtv[1];
- if (to_copy > tls_max_index)
- to_copy = tls_max_index;
- memcpy(&newdtv[2], &dtv[2], to_copy * sizeof(Elf_Addr));
- newdtv[0] = tls_dtv_generation;
- newdtv[1] = tls_max_index;
- free(dtv);
- lock_release(rtld_bind_lock, &lockstate);
- dtv = *dtvp = newdtv;
- }
+ dtv = *dtvp;
+ /* Check dtv generation in case new modules have arrived */
+ if (dtv[0] != tls_dtv_generation) {
+ wlock_acquire(rtld_bind_lock, &lockstate);
+ newdtv = xcalloc(tls_max_index + 2, sizeof(Elf_Addr));
+ to_copy = dtv[1];
+ if (to_copy > tls_max_index)
+ to_copy = tls_max_index;
+ memcpy(&newdtv[2], &dtv[2], to_copy * sizeof(Elf_Addr));
+ newdtv[0] = tls_dtv_generation;
+ newdtv[1] = tls_max_index;
+ free(dtv);
+ lock_release(rtld_bind_lock, &lockstate);
+ dtv = *dtvp = newdtv;
+ }
- /* Dynamically allocate module TLS if necessary */
- if (dtv[index + 1] == 0) {
- /* Signal safe, wlock will block out signals. */
- wlock_acquire(rtld_bind_lock, &lockstate);
- if (!dtv[index + 1])
- dtv[index + 1] = (Elf_Addr)allocate_module_tls(index);
- lock_release(rtld_bind_lock, &lockstate);
- }
- return ((void *)(dtv[index + 1] + offset));
+ /* Dynamically allocate module TLS if necessary */
+ if (dtv[index + 1] == 0) {
+ /* Signal safe, wlock will block out signals. */
+ wlock_acquire(rtld_bind_lock, &lockstate);
+ if (!dtv[index + 1])
+ dtv[index + 1] = (Elf_Addr)allocate_module_tls(index);
+ lock_release(rtld_bind_lock, &lockstate);
+ }
+ return ((void *)(dtv[index + 1] + offset));
}
void *
More information about the dev-commits-src-all
mailing list