10b57cec5SDimitry Andric //===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // A tool can #include this file to get a -load option that allows the user to 100b57cec5SDimitry Andric // load arbitrary shared objects into the tool's address space. Note that this 110b57cec5SDimitry Andric // header can only be included by a program ONCE, so it should never to used by 120b57cec5SDimitry Andric // library authors. 130b57cec5SDimitry Andric // 140b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #ifndef LLVM_SUPPORT_PLUGINLOADER_H 170b57cec5SDimitry Andric #define LLVM_SUPPORT_PLUGINLOADER_H 180b57cec5SDimitry Andric 19e8d8bef9SDimitry Andric #ifndef DONT_GET_PLUGIN_LOADER_OPTION 200b57cec5SDimitry Andric #include "llvm/Support/CommandLine.h" 21e8d8bef9SDimitry Andric #endif 22e8d8bef9SDimitry Andric 23e8d8bef9SDimitry Andric #include <string> 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric namespace llvm { 260b57cec5SDimitry Andric struct PluginLoader { 270b57cec5SDimitry Andric void operator=(const std::string &Filename); 280b57cec5SDimitry Andric static unsigned getNumPlugins(); 290b57cec5SDimitry Andric static std::string& getPlugin(unsigned num); 300b57cec5SDimitry Andric }; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric #ifndef DONT_GET_PLUGIN_LOADER_OPTION 330b57cec5SDimitry Andric // This causes operator= above to be invoked for every -load option. 340b57cec5SDimitry Andric static cl::opt<PluginLoader, false, cl::parser<std::string>> 35*81ad6265SDimitry Andric LoadOpt("load", cl::value_desc("pluginfilename"), 360b57cec5SDimitry Andric cl::desc("Load the specified plugin")); 370b57cec5SDimitry Andric #endif 380b57cec5SDimitry Andric } 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric #endif 41