#!/bin/sh# program## dlopen():# libd.so (local)# liba.so# <- libb.so## Expected: Undefined symbol in liba.so resolves to symbol in libb.so,# not to symbol in libd.so, since it's loaded RTLD_LOCAL.. ./test_setup# create libb.socat > libb.c << EOIint b() { return 1; }EOI# buildcompile_lib -o libb.so libb.c# create liba.socat > liba.c << EOIextern int b();int a() { return b(); }EOI# buildcompile_lib -o liba.so liba.c ./libb.so# create libd.socat > libd.c << EOIint b() { return 2; }EOI# buildcompile_lib -o libd.so libd.c# create programcat > program.c << EOI#include <dlfcn.h>#include <stdio.h>#include <stdlib.h>intmain(){void* liba;void* libd;int (*a)();libd = dlopen("./libd.so", RTLD_NOW | RTLD_LOCAL);if (libd == NULL) {fprintf(stderr, "Error opening libd.so: %s\n", dlerror());exit(117);}liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);if (liba == NULL) {fprintf(stderr, "Error opening liba.so: %s\n", dlerror());exit(117);}a = (int (*)())dlsym(liba, "a");if (a == NULL) {fprintf(stderr, "Error getting symbol a: %s\n", dlerror());exit(116);}return a();}EOI# buildcompile_program_dl -o program program.c# runtest_run_ok ./program 1