1e30bbad2SIngo Weinhold#!/bin/sh 2e30bbad2SIngo Weinhold 3e30bbad2SIngo Weinhold# program 4e30bbad2SIngo Weinhold# <- liba.so 5e30bbad2SIngo Weinhold# <- libb.so 6e30bbad2SIngo Weinhold# <- libd.so 7e30bbad2SIngo Weinhold# 8e30bbad2SIngo Weinhold# Expected: dlsym(RTLD_NEXT) finds symbol in order liba.so, libb.so, libd.so 9e30bbad2SIngo Weinhold 10e30bbad2SIngo Weinhold 11*09bd92c5SIngo Weinhold. ./test_setup 12e30bbad2SIngo Weinhold 13e30bbad2SIngo Weinhold 14e30bbad2SIngo Weinhold# create libd.so 15e30bbad2SIngo Weinholdcat > libd.c << EOI 16e30bbad2SIngo Weinholdint a() { return 1; } 17e30bbad2SIngo WeinholdEOI 18e30bbad2SIngo Weinhold 19e30bbad2SIngo Weinhold# build 20*09bd92c5SIngo Weinholdcompile_lib -o libd.so libd.c 21e30bbad2SIngo Weinhold 22e30bbad2SIngo Weinhold 23e30bbad2SIngo Weinhold# create libb.so 24e30bbad2SIngo Weinholdcat > libb.c << EOI 25e30bbad2SIngo Weinhold#define __USE_GNU 26e30bbad2SIngo Weinhold#include <dlfcn.h> 27e30bbad2SIngo Weinholdint 28e30bbad2SIngo Weinholda() 29e30bbad2SIngo Weinhold{ 30e30bbad2SIngo Weinhold int (*nextA)(); 31e30bbad2SIngo Weinhold *(void**)&nextA = dlsym(RTLD_NEXT, "a"); 32e30bbad2SIngo Weinhold return (nextA != 0 ? nextA() : 0) + 2; 33e30bbad2SIngo Weinhold} 34e30bbad2SIngo WeinholdEOI 35e30bbad2SIngo Weinhold 36e30bbad2SIngo Weinhold# build 37*09bd92c5SIngo Weinholdcompile_lib_dl -o libb.so libb.c ./libd.so 38e30bbad2SIngo Weinhold 39e30bbad2SIngo Weinhold 40e30bbad2SIngo Weinhold# create liba.so 41e30bbad2SIngo Weinholdcat > liba.c << EOI 42e30bbad2SIngo Weinhold#include <dlfcn.h> 43e30bbad2SIngo Weinholdint 44e30bbad2SIngo Weinholda() 45e30bbad2SIngo Weinhold{ 46e30bbad2SIngo Weinhold int (*nextA)(); 47e30bbad2SIngo Weinhold *(void**)&nextA = dlsym(RTLD_NEXT, "a"); 48e30bbad2SIngo Weinhold return (nextA != 0 ? nextA() : 0) + 4; 49e30bbad2SIngo Weinhold} 50e30bbad2SIngo WeinholdEOI 51e30bbad2SIngo Weinhold 52e30bbad2SIngo Weinhold# build 53*09bd92c5SIngo Weinholdcompile_lib_dl -o liba.so liba.c ./libb.so 54e30bbad2SIngo Weinhold 55e30bbad2SIngo Weinhold 56e30bbad2SIngo Weinhold# create program 57e30bbad2SIngo Weinholdcat > program.c << EOI 58e30bbad2SIngo Weinhold 59e30bbad2SIngo Weinhold#include <dlfcn.h> 60e30bbad2SIngo Weinholdint 61e30bbad2SIngo Weinholda() 62e30bbad2SIngo Weinhold{ 63e30bbad2SIngo Weinhold int (*nextA)(); 64e30bbad2SIngo Weinhold *(void**)&nextA = dlsym(RTLD_NEXT, "a"); 65e30bbad2SIngo Weinhold return (nextA != 0 ? nextA() : 0) + 8; 66e30bbad2SIngo Weinhold} 67e30bbad2SIngo Weinhold 68e30bbad2SIngo Weinholdint 69e30bbad2SIngo Weinholdmain() 70e30bbad2SIngo Weinhold{ 71e30bbad2SIngo Weinhold return a(); 72e30bbad2SIngo Weinhold} 73e30bbad2SIngo WeinholdEOI 74e30bbad2SIngo Weinhold 75e30bbad2SIngo Weinhold# build 76*09bd92c5SIngo Weinholdcompile_program_dl -o program program.c ./liba.so 77e30bbad2SIngo Weinhold 78e30bbad2SIngo Weinhold# run 79e30bbad2SIngo Weinholdtest_run_ok ./program 15 80e30bbad2SIngo Weinhold 81