dl_iterate_phdr(3): provide exclusive locking for callback when statically linked.
Apparently llvm unwinder depends on the external locking for callback. Reviewed by: cem, emaste Tested by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D26109
This commit is contained in:
parent
9060f2c392
commit
22517af2c1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=364423
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "un-namespace.h"
|
#include "un-namespace.h"
|
||||||
#include "libc_private.h"
|
#include "libc_private.h"
|
||||||
|
#include "reentrant.h"
|
||||||
|
|
||||||
static char sorry[] = "Service unavailable";
|
static char sorry[] = "Service unavailable";
|
||||||
|
|
||||||
@ -164,6 +165,7 @@ _rtld_thread_init(void *li __unused)
|
|||||||
#ifndef IN_LIBDL
|
#ifndef IN_LIBDL
|
||||||
static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
|
static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
|
||||||
static struct dl_phdr_info phdr_info;
|
static struct dl_phdr_info phdr_info;
|
||||||
|
static mutex_t dl_phdr_info_lock = MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dl_init_phdr_info(void)
|
dl_init_phdr_info(void)
|
||||||
@ -204,13 +206,17 @@ int
|
|||||||
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
|
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
|
||||||
void *data __unused)
|
void *data __unused)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef IN_LIBDL
|
#ifndef IN_LIBDL
|
||||||
|
int ret;
|
||||||
|
|
||||||
__init_elf_aux_vector();
|
__init_elf_aux_vector();
|
||||||
if (__elf_aux_vector == NULL)
|
if (__elf_aux_vector == NULL)
|
||||||
return (1);
|
return (1);
|
||||||
_once(&dl_phdr_info_once, dl_init_phdr_info);
|
_once(&dl_phdr_info_once, dl_init_phdr_info);
|
||||||
return (callback(&phdr_info, sizeof(phdr_info), data));
|
mutex_lock(&dl_phdr_info_lock);
|
||||||
|
ret = callback(&phdr_info, sizeof(phdr_info), data);
|
||||||
|
mutex_unlock(&dl_phdr_info_lock);
|
||||||
|
return (ret);
|
||||||
#else
|
#else
|
||||||
return (0);
|
return (0);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user