X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust-dl%2Flttng-ust-dl.c;h=e38eaf1e7d8f5cda4011d887940519111f61163f;hb=HEAD;hp=d366f64f8f46c2195bd0bc3a1ba8af69b3ec28ec;hpb=03db42ded43e5aa04ce5e6ca1bd72496b689e608;p=lttng-ust.git diff --git a/liblttng-ust-dl/lttng-ust-dl.c b/liblttng-ust-dl/lttng-ust-dl.c deleted file mode 100644 index d366f64f..00000000 --- a/liblttng-ust-dl/lttng-ust-dl.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2013 Paul Woegerer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; version 2.1 of - * the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#define _LGPL_SOURCE -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "usterr-signal-safe.h" - -#include -#include - -#define TRACEPOINT_DEFINE -#include "ust_dl.h" - -static void *(*__lttng_ust_plibc_dlopen)(const char *filename, int flag); -static int (*__lttng_ust_plibc_dlclose)(void *handle); - -static -void *_lttng_ust_dl_libc_dlopen(const char *filename, int flag) -{ - if (!__lttng_ust_plibc_dlopen) { - __lttng_ust_plibc_dlopen = dlsym(RTLD_NEXT, "dlopen"); - if (__lttng_ust_plibc_dlopen == NULL) { - fprintf(stderr, "%s\n", dlerror()); - return NULL; - } - } - return __lttng_ust_plibc_dlopen(filename, flag); -} - -static -int _lttng_ust_dl_libc_dlclose(void *handle) -{ - if (!__lttng_ust_plibc_dlclose) { - __lttng_ust_plibc_dlclose = dlsym(RTLD_NEXT, "dlclose"); - if (__lttng_ust_plibc_dlclose == NULL) { - fprintf(stderr, "%s\n", dlerror()); - return -1; - } - } - return __lttng_ust_plibc_dlclose(handle); -} - -static -void lttng_ust_dl_dlopen(void *so_base, const char *so_name, void *ip) -{ - char resolved_path[PATH_MAX]; - struct stat sostat; - - if (!realpath(so_name, resolved_path)) { - ERR("could not resolve path '%s'", so_name); - return; - } - - if (stat(resolved_path, &sostat)) { - ERR("could not access file status for %s", resolved_path); - return; - } - - tracepoint(lttng_ust_dl, dlopen, - so_base, resolved_path, sostat.st_size, sostat.st_mtime, ip); - return; -} - -void *dlopen(const char *filename, int flag) -{ - void *handle = _lttng_ust_dl_libc_dlopen(filename, flag); - if (__tracepoint_ptrs_registered && handle) { - struct link_map *p = NULL; - if (dlinfo(handle, RTLD_DI_LINKMAP, &p) != -1 && p != NULL - && p->l_addr != 0) - lttng_ust_dl_dlopen((void *) p->l_addr, p->l_name, - __builtin_return_address(0)); - } - return handle; -} - -int dlclose(void *handle) -{ - if (__tracepoint_ptrs_registered && handle) { - struct link_map *p = NULL; - if (dlinfo(handle, RTLD_DI_LINKMAP, &p) != -1 && p != NULL - && p->l_addr != 0) - tracepoint(lttng_ust_dl, dlclose, (void *) p->l_addr, - __builtin_return_address(0)); - } - return _lttng_ust_dl_libc_dlclose(handle); -}