14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $# != 1 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncall: main livelib.so deadlib.so
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmain: main.o prov.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -o main main.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmain.o: main.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -c main.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynclivelib.so: livelib.o prov.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -z defs -G -o livelib.so livelib.o prov.o -lc
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynclivelib.o: livelib.c prov.h
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -c livelib.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncprov.o: livelib.o prov.d
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync $dtrace -G -s prov.d livelib.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncprov.h: prov.d
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync $dtrace -h -s prov.d
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdeadlib.so: deadlib.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -z defs -G -o deadlib.so deadlib.o -lc
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdeadlib.o: deadlib.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync cc -c deadlib.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rm -f main.o livelib.o prov.o prov.h deadlib.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncclobber: clean
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync rm -f main livelib.so deadlib.so
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncprovider test_prov {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync probe go();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "prov.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync TEST_PROV_GO();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dlfcn.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <unistd.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <stdio.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmain(int argc, char **argv)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void *live, *dead;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("dlopen of livelib.so failed: %s\n", dlerror());
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) dlclose(live);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((dead = dlopen("./deadlib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("dlopen of deadlib.so failed: %s\n", dlerror());
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("dlopen of livelib.so failed: %s\n", dlerror());
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((go = dlsym(live, "go")) == NULL) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("failed to lookup 'go' in livelib.so\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ((void (*)(void))go)();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync test_prov*:::
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("%s:%s:%s\n", probemod, probefunc, probename);