/usr/src/blcr-0.8.5/tests/dlopen_aux.c is in blcr-dkms 0.8.5-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #define _GNU_SOURCE 1 // For RTLD_DEFAULT
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <features.h>
#include <string.h>
#include "libcr.h"
#ifndef STRINGIFY
#define STRINGIFY_HELPER(x) #x
#define STRINGIFY(x) STRINGIFY_HELPER(x)
#endif
#define THE_LIBRARY "libcr.so." STRINGIFY(LIBCR_MAJOR)
int main(void)
{
cr_client_id_t (*my_cr_init)(void);
void *self_handle = dlopen(NULL, RTLD_LAZY);
void *libcr_handle;
cr_client_id_t client_id;
my_cr_init = dlsym(self_handle, "cr_init");
if (my_cr_init != NULL) {
fprintf(stderr, "cr_init found unexpectedly in 'self', before dlopen()\n");
exit(1);
}
my_cr_init = dlsym(RTLD_DEFAULT, "cr_init");
if (my_cr_init != NULL) {
fprintf(stderr, "cr_init found unexpectedly in default search, before dlopen()\n");
exit(1);
}
libcr_handle = dlopen(THE_LIBRARY, RTLD_NOW);
if (libcr_handle == NULL) {
fprintf(stderr, "dlopen(" THE_LIBRARY ") failed unexpectedly. Bad LD_LIBRARY_PATH?\n");
exit(1);
}
my_cr_init = dlsym(self_handle, "cr_init");
if (my_cr_init != NULL) {
fprintf(stderr, "cr_init found unexpectedly in 'self', after dlopen()\n");
exit(1);
}
my_cr_init = dlsym(RTLD_DEFAULT, "cr_init");
if (my_cr_init != NULL) {
fprintf(stderr, "cr_init found unexpectedly in default search, after dlopen()\n");
exit(1);
}
my_cr_init = dlsym(libcr_handle, "cr_init");
if (my_cr_init == NULL) {
fprintf(stderr, "cr_init not in dlopen()ed library\n");
exit(1);
}
client_id = my_cr_init();
if (client_id < 0) {
fprintf(stderr, "cr_init() call failed\n");
exit(1);
}
return 0;
}
|