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
300d08e996
commit
1c2761c4f9
@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <pthread.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
#include "reentrant.h"
|
||||
|
||||
static char sorry[] = "Service unavailable";
|
||||
|
||||
@ -164,6 +165,7 @@ _rtld_thread_init(void *li __unused)
|
||||
#ifndef IN_LIBDL
|
||||
static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
|
||||
static struct dl_phdr_info phdr_info;
|
||||
static mutex_t dl_phdr_info_lock = MUTEX_INITIALIZER;
|
||||
|
||||
static void
|
||||
dl_init_phdr_info(void)
|
||||
@ -204,13 +206,17 @@ int
|
||||
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
|
||||
void *data __unused)
|
||||
{
|
||||
|
||||
#ifndef IN_LIBDL
|
||||
int ret;
|
||||
|
||||
__init_elf_aux_vector();
|
||||
if (__elf_aux_vector == NULL)
|
||||
return (1);
|
||||
_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
|
||||
return (0);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user