diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/functionalities/load_unload | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/load_unload')
14 files changed, 547 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile new file mode 100644 index 00000000000..cbac629c7b5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile @@ -0,0 +1,24 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +LD_EXTRAS := -L. -l$(LIB_PREFIX)d -ldl +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules + +.PHONY: +a.out: lib_a lib_b lib_c lib_d hidden_lib_d + +lib_%: + $(MAKE) -f $*.mk + +hidden_lib_d: + $(MAKE) -C hidden + +clean:: + $(MAKE) -f a.mk clean + $(MAKE) -f b.mk clean + $(MAKE) -f c.mk clean + $(MAKE) -f d.mk clean + $(MAKE) -C hidden clean diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py new file mode 100644 index 00000000000..29f6effeeff --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -0,0 +1,315 @@ +""" +Test that breakpoint by symbol name works correctly with dynamic libs. +""" + +from __future__ import print_function + +import use_lldb_suite + +import os, time +import re +import lldb +from lldbtest import * +import lldbutil + +@skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently +class LoadUnloadTestCase(TestBase): + + def getCategories (self): + return ['basic_process'] + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.cpp. + self.line = line_number('main.c', + '// Set break point at this line for test_lldb_process_load_and_unload_commands().') + self.line_d_function = line_number('d.c', + '// Find this line number within d_dunction().') + if not self.platformIsDarwin(): + if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ: + self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + os.environ["LD_LIBRARY_PATH"] + ":" + os.getcwd()) + else: + if lldb.remote_platform: + wd = lldb.remote_platform.GetWorkingDirectory() + else: + wd = os.getcwd() + self.runCmd("settings set target.env-vars " + self.dylibPath + "=" + wd) + + def copy_shlibs_to_remote(self, hidden_dir=False): + """ Copies the shared libs required by this test suite to remote. + Does nothing in case of non-remote platforms. + """ + if lldb.remote_platform: + cwd = os.getcwd() + shlibs = ['libloadunload_a.so', 'libloadunload_b.so', + 'libloadunload_c.so', 'libloadunload_d.so'] + wd = lldb.remote_platform.GetWorkingDirectory() + for f in shlibs: + err = lldb.remote_platform.Put( + lldb.SBFileSpec(os.path.join(cwd, f)), + lldb.SBFileSpec(os.path.join(wd, f))) + if err.Fail(): + raise RuntimeError( + "Unable copy '%s' to '%s'.\n>>> %s" % + (f, wd, err.GetCString())) + if hidden_dir: + shlib = 'libloadunload_d.so' + hidden_dir = os.path.join(wd, 'hidden') + hidden_file = os.path.join(hidden_dir, shlib) + err = lldb.remote_platform.MakeDirectory(hidden_dir) + if err.Fail(): + raise RuntimeError( + "Unable to create a directory '%s'." % hidden_dir) + err = lldb.remote_platform.Put( + lldb.SBFileSpec(os.path.join(cwd, 'hidden', shlib)), + lldb.SBFileSpec(hidden_file)) + if err.Fail(): + raise RuntimeError( + "Unable copy 'libloadunload_d.so' to '%s'.\n>>> %s" % + (wd, err.GetCString())) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @not_remote_testsuite_ready + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_modules_search_paths(self): + """Test target modules list after loading a different copy of the library libd.dylib, and verifies that it works with 'target modules search-paths add'.""" + + # Invoke the default build rule. + self.build() + + if self.platformIsDarwin(): + dylibName = 'libloadunload_d.dylib' + else: + dylibName = 'libloadunload_d.so' + + # The directory with the dynamic library we did not link to. + new_dir = os.path.join(os.getcwd(), "hidden") + + old_dylib = os.path.join(os.getcwd(), dylibName) + new_dylib = os.path.join(new_dir, dylibName) + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.expect("target modules list", + substrs = [old_dylib]) + #self.expect("target modules list -t 3", + # patterns = ["%s-[^-]*-[^-]*" % self.getArchitecture()]) + # Add an image search path substitution pair. + self.runCmd("target modules search-paths add %s %s" % (os.getcwd(), new_dir)) + + self.expect("target modules search-paths list", + substrs = [os.getcwd(), new_dir]) + + self.expect("target modules search-paths query %s" % os.getcwd(), "Image search path successfully transformed", + substrs = [new_dir]) + + # Obliterate traces of libd from the old location. + os.remove(old_dylib) + # Inform (DY)LD_LIBRARY_PATH of the new path, too. + env_cmd_string = "settings set target.env-vars " + self.dylibPath + "=" + new_dir + if self.TraceOn(): + print("Set environment to: ", env_cmd_string) + self.runCmd(env_cmd_string) + self.runCmd("settings show target.env-vars") + + remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath + self.addTearDownHook(lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) + + self.runCmd("run") + + self.expect("target modules list", "LLDB successfully locates the relocated dynamic library", + substrs = [new_dylib]) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipUnlessListedRemote(['android']) + @expectedFailureAndroid # wrong source file shows up for hidden library + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_dyld_library_path(self): + """Test (DY)LD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else.""" + + # Invoke the default build rule. + self.build() + self.copy_shlibs_to_remote(hidden_dir=True) + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + if self.platformIsDarwin(): + dylibName = 'libloadunload_d.dylib' + dsymName = 'libloadunload_d.dylib.dSYM' + else: + dylibName = 'libloadunload_d.so' + + # The directory to relocate the dynamic library and its debugging info. + special_dir = "hidden" + if lldb.remote_platform: + wd = lldb.remote_platform.GetWorkingDirectory() + else: + wd = os.getcwd() + + old_dir = wd + new_dir = os.path.join(wd, special_dir) + old_dylib = os.path.join(old_dir, dylibName) + + remove_dyld_path_cmd = "settings remove target.env-vars " + self.dylibPath + self.addTearDownHook(lambda: self.dbg.HandleCommand(remove_dyld_path_cmd)) + + # For now we don't track (DY)LD_LIBRARY_PATH, so the old library will be in + # the modules list. + self.expect("target modules list", + substrs = [os.path.basename(old_dylib)], + matching=True) + + lldbutil.run_break_set_by_file_and_line (self, "d.c", self.line_d_function, num_expected_locations=1) + # After run, make sure the non-hidden library is picked up. + self.expect("run", substrs=["return", "700"]) + + self.runCmd("continue") + + # Add the hidden directory first in the search path. + env_cmd_string = ("settings set target.env-vars %s=%s" % + (self.dylibPath, new_dir)) + if not self.platformIsDarwin(): + env_cmd_string += ":" + wd + self.runCmd(env_cmd_string) + + # This time, the hidden library should be picked up. + self.expect("run", substrs=["return", "12345"]) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipUnlessListedRemote(['android']) + @expectedFailureAndroid # dlopen and dlclose prefixed with "__dl_" on android causing JIT compilation issues + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_lldb_process_load_and_unload_commands(self): + """Test that lldb process load/unload command work correctly.""" + + # Invoke the default build rule. + self.build() + self.copy_shlibs_to_remote() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break at main.c before the call to dlopen(). + # Use lldb's process load command to load the dylib, instead. + + lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + if lldb.remote_platform: + shlib_dir = lldb.remote_platform.GetWorkingDirectory() + else: + shlib_dir = self.mydir + # Make sure that a_function does not exist at this point. + self.expect("image lookup -n a_function", "a_function should not exist yet", + error=True, matching=False, + patterns = ["1 match found .* %s" % shlib_dir]) + + if lldb.remote_platform: + dylibName = os.path.join(shlib_dir, 'libloadunload_a.so') + elif self.platformIsDarwin(): + dylibName = 'libloadunload_a.dylib' + else: + dylibName = 'libloadunload_a.so' + + # Use lldb 'process load' to load the dylib. + self.expect("process load %s" % dylibName, "%s loaded correctly" % dylibName, + patterns = ['Loading "%s".*ok' % dylibName, + 'Image [0-9]+ loaded']) + + # Search for and match the "Image ([0-9]+) loaded" pattern. + output = self.res.GetOutput() + pattern = re.compile("Image ([0-9]+) loaded") + for l in output.split(os.linesep): + #print("l:", l) + match = pattern.search(l) + if match: + break + index = match.group(1) + + # Now we should have an entry for a_function. + self.expect("image lookup -n a_function", "a_function should now exist", + patterns = ["1 match found .*%s" % shlib_dir]) + + # Use lldb 'process unload' to unload the dylib. + self.expect("process unload %s" % index, "%s unloaded correctly" % dylibName, + patterns = ["Unloading .* with index %s.*ok" % index]) + + self.runCmd("process continue") + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipUnlessListedRemote(['android']) + def test_load_unload(self): + """Test breakpoint by name works correctly with dlopen'ing.""" + + # Invoke the default build rule. + self.build() + self.copy_shlibs_to_remote() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break by function name a_function (not yet loaded). + lldbutil.run_break_set_by_symbol (self, "a_function", num_expected_locations=0) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint and at a_function. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'a_function', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 1. + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 1']) + + # Issue the 'contnue' command. We should stop agaian at a_function. + # The stop reason of the thread should be breakpoint and at a_function. + self.runCmd("continue") + + # rdar://problem/8508987 + # The a_function breakpoint should be encountered twice. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'a_function', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 2. + self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 2']) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipUnlessListedRemote(['android']) + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + def test_step_over_load (self): + """Test stepping over code that loads a shared library works correctly.""" + + # Invoke the default build rule. + self.build() + self.copy_shlibs_to_remote() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break by function name a_function (not yet loaded). + lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint and at a_function. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + self.runCmd("thread step-over", "Stepping over function that loads library") + + # The stop reason should be step end. + self.expect("thread list", "step over succeeded.", + substrs = ['stopped', + 'stop reason = step over']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.c new file mode 100644 index 00000000000..9d4711772dd --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.c @@ -0,0 +1,15 @@ +//===-- a.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +extern int b_function (); + +int +a_function () +{ + return b_function (); +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk new file mode 100644 index 00000000000..a5c37561daa --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk @@ -0,0 +1,21 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +CFLAGS_EXTRAS := -fPIC +LD_EXTRAS := -L. -l$(LIB_PREFIX)b + +DYLIB_NAME := $(LIB_PREFIX)a +DYLIB_C_SOURCES := a.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules + +.PHONY: +$(DYLIB_FILENAME): lib_b + +lib_b: + $(MAKE) -f b.mk + +clean:: + $(MAKE) -f b.mk clean diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.c new file mode 100644 index 00000000000..6c629323655 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.c @@ -0,0 +1,13 @@ +//===-- b.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +b_function () +{ + return 500; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk new file mode 100644 index 00000000000..956dc37cb3f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk @@ -0,0 +1,9 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)b +DYLIB_C_SOURCES := b.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.c new file mode 100644 index 00000000000..b1778b462d0 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.c @@ -0,0 +1,13 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +c_function () +{ + return 600; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk new file mode 100644 index 00000000000..ebb5ce15787 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk @@ -0,0 +1,9 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)c +DYLIB_C_SOURCES := c.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/cmds.txt b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/cmds.txt new file mode 100644 index 00000000000..1e4b198dc0d --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/cmds.txt @@ -0,0 +1,2 @@ +breakpoint set -n a_function +run diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.c new file mode 100644 index 00000000000..6e5f0623101 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.c @@ -0,0 +1,13 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +d_function () +{ // Find this line number within d_dunction(). + return 700; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk new file mode 100644 index 00000000000..437c1507e20 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk @@ -0,0 +1,11 @@ +LEVEL := ../../make + +LIB_PREFIX := loadunload_ + +DYLIB_EXECUTABLE_PATH := $(CURDIR) + +DYLIB_NAME := $(LIB_PREFIX)d +DYLIB_C_SOURCES := d.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile new file mode 100644 index 00000000000..09aa39b378e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile @@ -0,0 +1,9 @@ +LEVEL := ../../../make + +LIB_PREFIX := loadunload_ + +DYLIB_NAME := $(LIB_PREFIX)d +DYLIB_C_SOURCES := d.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c new file mode 100644 index 00000000000..f20aa095f2f --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c @@ -0,0 +1,13 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +d_function () +{ // Find this line number within d_dunction(). + return 12345; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.c new file mode 100644 index 00000000000..bff9a317606 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.c @@ -0,0 +1,80 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <stdio.h> +#include <dlfcn.h> +#include <limits.h> +#include <string.h> +#include <unistd.h> +#include <libgen.h> +#include <stdlib.h> + +int +main (int argc, char const *argv[]) +{ +#if defined (__APPLE__) + const char *a_name = "@executable_path/libloadunload_a.dylib"; + const char *c_name = "@executable_path/libloadunload_c.dylib"; +#else + const char *a_name = "libloadunload_a.so"; + const char *c_name = "libloadunload_c.so"; +#endif + void *a_dylib_handle = NULL; + void *c_dylib_handle = NULL; + int (*a_function) (void); + + a_dylib_handle = dlopen (a_name, RTLD_NOW); // Set break point at this line for test_lldb_process_load_and_unload_commands(). + if (a_dylib_handle == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (1); + } + + a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function"); + if (a_function == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (2); + } + printf ("First time around, got: %d\n", a_function ()); + dlclose (a_dylib_handle); + + c_dylib_handle = dlopen (c_name, RTLD_NOW); + if (c_dylib_handle == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (3); + } + a_function = (int (*) ()) dlsym (c_dylib_handle, "c_function"); + if (a_function == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (4); + } + + a_dylib_handle = dlopen (a_name, RTLD_NOW); + if (a_dylib_handle == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (5); + } + + a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function"); + if (a_function == NULL) + { + fprintf (stderr, "%s\n", dlerror()); + exit (6); + } + printf ("Second time around, got: %d\n", a_function ()); + dlclose (a_dylib_handle); + + int d_function(void); + printf ("d_function returns: %d\n", d_function()); + + return 0; +} |