lttng/ust-getcpu.h \
lttng/ust-elf.h \
lttng/counter-config.h \
+ lttng/ust-libc-wrapper.h \
lttng/urcu/pointer.h \
lttng/urcu/urcu-ust.h \
lttng/urcu/static/pointer.h \
--- /dev/null
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Public symbols of liblttng-ust-libc-wrapper.so
+ */
+
+#ifndef _LTTNG_UST_LIBC_WRAPPER_H
+#define _LTTNG_UST_LIBC_WRAPPER_H
+
+/*
+ * This is the constructor for the malloc part of the libc wrapper. It is
+ * publicly exposed because the malloc override needs to be initialized before
+ * the process becomes multithreaded and thus must happen before the main
+ * constructor of liblttng-ust starts threads. Since there is no reliable way
+ * to guarantee the execution order of constructors across shared library, the
+ * liblttng-ust constructor has to call the malloc constructor before starting
+ * any thread. This is achieved by having a weak public version of this
+ * function in liblttng-ust that is overridden by the one in
+ * liblttng-ust-wrapper-libc when it's preloaded.
+ */
+void lttng_ust_libc_wrapper_malloc_init(void);
+
+#endif
}
__attribute__((constructor))
-void lttng_ust_malloc_wrapper_init(void)
+void lttng_ust_libc_wrapper_malloc_init(void)
{
/* Initialization already done */
if (cur_alloc.calloc) {
void lttng_ust_sockinfo_session_enabled(void *owner);
-void lttng_ust_malloc_wrapper_init(void);
-
ssize_t lttng_ust_read(int fd, void *buf, size_t len);
size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset);
#include <lttng/ust.h>
#include <lttng/ust-error.h>
#include <lttng/ust-ctl.h>
+#include <lttng/ust-libc-wrapper.h>
#include <urcu/tls-compat.h>
#include <ust-comm.h>
#include <ust-fd.h>
* Weak symbol to call when the ust malloc wrapper is not loaded.
*/
__attribute__((weak))
-void lttng_ust_malloc_wrapper_init(void)
+void lttng_ust_libc_wrapper_malloc_init(void)
{
}
/*
* Invoke ust malloc wrapper init before starting other threads.
*/
- lttng_ust_malloc_wrapper_init();
+ lttng_ust_libc_wrapper_malloc_init();
timeout_mode = get_constructor_timeout(&constructor_timeout);