llvm.org GIT mirror llvm / 13a253a
Implicitly getting a new option by linking to support.o instead of support.a is a bad idea. Make tools that want the option #include PluginSupport.h explicitly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14738 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
1 changed file(s) with 8 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file implements the -load command line option processor. When
10 // linked into a program, this new command line option is available that allows
11 // users to load shared objects into the running program.
12 //
13 // Note that there are no symbols exported by the .o file generated for this
14 // .cpp file. Because of this, a program must link against support.o instead of
15 // support.a: otherwise this translation unit will not be included.
9 // This file implements the -load command line option handler.
1610 //
1711 //===----------------------------------------------------------------------===//
1812
13 #define DONT_GET_PLUGIN_LOADER_OPTION
14 #include "Support/PluginLoader.h"
1915 #include "Support/DynamicLinker.h"
20 #include "Support/CommandLine.h"
21 #include "Config/config.h"
2216 #include
2317 using namespace llvm;
2418
25 namespace {
26 struct PluginLoader {
27 void operator=(const std::string &Filename) {
28 std::string ErrorMessage;
29 if (LinkDynamicObject (Filename.c_str (), &ErrorMessage))
30 std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
31 << "\n -load request ignored.\n";
32 }
33 };
19 void PluginLoader::operator=(const std::string &Filename) {
20 std::string ErrorMessage;
21 if (LinkDynamicObject(Filename.c_str(), &ErrorMessage))
22 std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
23 << "\n -load request ignored.\n";
3424 }
35
36 // This causes operator= above to be invoked for every -load option.
37 static cl::opt >
38 LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin" SHLIBEXT),
39 cl::desc("Load the specified plugin"));