File tree Expand file tree Collapse file tree 3 files changed +8
-13
lines changed Expand file tree Collapse file tree 3 files changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,6 @@ endif()
2121set (GNULTO_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for plugin-api.h" )
2222if (LLD_ENABLE_GNU_LTO)
2323 find_package (GNULTO REQUIRED)
24- include (CheckSymbolExists)
25- check_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
26- if (NOT HAVE_DLOPEN)
27- message (FATAL_ERROR "Could not find the definition of dlopen(). Is dlfcn.h available?" )
28- endif ()
2924endif ()
3025
3126configure_file (
Original file line number Diff line number Diff line change @@ -427,8 +427,6 @@ void BitcodeCompiler::addObject(IRFile &f,
427427}
428428
429429#if LLD_ENABLE_GNU_LTO
430- #include < dlfcn.h>
431-
432430GccIRCompiler *GccIRCompiler::singleton = nullptr ;
433431
434432GccIRCompiler *GccIRCompiler::getInstance () {
@@ -460,13 +458,14 @@ GccIRCompiler::~GccIRCompiler() {
460458}
461459
462460void GccIRCompiler::loadPlugin () {
463- plugin = dlopen (ctx.arg .plugin .data (), RTLD_NOW);
464- if (plugin == NULL ) {
465- error (dlerror ());
461+ std::string Error;
462+ plugin = llvm::sys::DynamicLibrary::getPermanentLibrary (ctx.arg .plugin .data (), &Error);
463+ if (!plugin.isValid ()) {
464+ error (Error);
466465 return ;
467466 }
468- void *tmp = dlsym ( plugin, " onload" );
469- if (tmp == NULL ) {
467+ void *tmp = plugin. getAddressOfSymbol ( " onload" );
468+ if (! tmp) {
470469 error (" Plugin does not provide onload()" );
471470 return ;
472471 }
Original file line number Diff line number Diff line change 2525#include " llvm/ADT/DenseSet.h"
2626#include " llvm/ADT/SmallString.h"
2727#include " llvm/Support/raw_ostream.h"
28+ #include " llvm/Support/DynamicLibrary.h"
2829#include < memory>
2930#include < vector>
3031
@@ -114,7 +115,7 @@ class GccIRCompiler : public IRCompiler {
114115#endif
115116 ld_plugin_all_symbols_read_handler allSymbolsReadHandler;
116117 // Handle for the shared library created via dlopen().
117- void * plugin;
118+ llvm::sys::DynamicLibrary plugin;
118119
119120 void initializeTv ();
120121};
You can’t perform that action at this time.
0 commit comments