From dc0f7d8f9652ba4fb18096e93fd50bd63ec35ad7 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Mon, 7 Aug 2023 15:41:21 +0200 Subject: [PATCH] initPlugins: run nix_plugin_entry() on dlopen'd plugins Only when it exists. --- src/libstore/globals.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index b9ad8ac18..afb6039f3 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -346,6 +346,12 @@ void initPlugins() dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL); if (!handle) throw Error("could not dynamically open plugin file '%s': %s", file, dlerror()); + + /* Older plugins use a statically initialized object to run their code. + Newer plugins can also export nix_plugin_entry() */ + void (*nix_plugin_entry)() = (void (*)())dlsym(handle, "nix_plugin_entry"); + if (nix_plugin_entry) + nix_plugin_entry(); } }