Date: Fri, 23 Apr 2021 11:14:57 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 127849157ab9 - stable/13 - rtld: style tls_get_addr_slow Message-ID: <202104231114.13NBEvCN013031@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=127849157ab94c630533fdd7201422b36d3cf96f commit 127849157ab94c630533fdd7201422b36d3cf96f Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-04-06 18:55:10 +0000 Commit: Konstantin Belousov <kib@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 *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104231114.13NBEvCN013031>