Path: blob/main/libexec/rtld-elf/tests/dlopen_hash_test.c
288945 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2026 Alex S <[email protected]>4* Copyright 2026 The FreeBSD Foundation5*6* Portions of this software were developed by7* Konstantin Belousov <[email protected]> under sponsorship from8* the FreeBSD Foundation.9*/1011#include <atf-c.h>12#include <dlfcn.h>13#include <fcntl.h>14#include <link.h>15#include <stdio.h>1617ATF_TC_WITHOUT_HEAD(dlopen_hash);18ATF_TC_BODY(dlopen_hash, tc)19{20void *handle;21char *pathfds;22char *name;23int testdir;2425handle = dlopen("libpythagoras.so.0", RTLD_LAZY);26ATF_REQUIRE(handle == NULL);2728testdir = open(atf_tc_get_config_var(tc, "srcdir"),29O_RDONLY | O_DIRECTORY);30ATF_REQUIRE(testdir >= 0);3132ATF_REQUIRE(asprintf(&pathfds, "%d", testdir) > 0);33ATF_REQUIRE(rtld_set_var("LIBRARY_PATH_FDS", pathfds) == 0);3435ATF_REQUIRE(asprintf(&name, "#%d/libpythagoras.so.0", testdir) > 0);36handle = dlopen(name, RTLD_LAZY);37ATF_REQUIRE(handle != NULL);38}3940ATF_TP_ADD_TCS(tp)41{42ATF_TP_ADD_TC(tp, dlopen_hash);43return atf_no_error();44}454647