mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 10:08:56 +02:00
ircd::mods: Support code and data demangled export sections.
This commit is contained in:
parent
94ed73a60e
commit
59b0b633cb
|
@ -11,10 +11,18 @@
|
|||
#pragma once
|
||||
#define HAVE_IRCD_MAPI_H
|
||||
|
||||
#define IRCD_MODULE_EXPORT_SECTION "ircd"
|
||||
#define IRCD_MODULE_EXPORT_CODE_SECTION "ircd.code"
|
||||
#define IRCD_MODULE_EXPORT_DATA_SECTION "ircd.data"
|
||||
|
||||
#define IRCD_MODULE_EXPORT_CODE \
|
||||
__attribute__((section(IRCD_MODULE_EXPORT_CODE_SECTION)))
|
||||
|
||||
#define IRCD_MODULE_EXPORT_DATA \
|
||||
__attribute__((section(IRCD_MODULE_EXPORT_DATA_SECTION)))
|
||||
|
||||
// Common convenience
|
||||
#define IRCD_MODULE_EXPORT \
|
||||
__attribute__((section(IRCD_MODULE_EXPORT_SECTION)))
|
||||
IRCD_MODULE_EXPORT_CODE
|
||||
|
||||
/// Module API: Interface for module developers.
|
||||
namespace ircd::mapi
|
||||
|
@ -37,11 +45,8 @@ namespace ircd::mapi
|
|||
"IRCD_MODULE"
|
||||
};
|
||||
|
||||
/// Symbols in this section are automatically demangle-mapped on load.
|
||||
const char *const import_section_name
|
||||
{
|
||||
IRCD_MODULE_EXPORT_SECTION
|
||||
};
|
||||
/// Symbols in these sections are automatically demangle-mapped on load.
|
||||
extern const char *const import_section_names[];
|
||||
}
|
||||
|
||||
/// The magic number at the front of the header
|
||||
|
|
23
ircd/mods.cc
23
ircd/mods.cc
|
@ -62,6 +62,14 @@ ircd::mods::mod::loaded
|
|||
bool
|
||||
ircd::mapi::static_destruction;
|
||||
|
||||
const char *const
|
||||
ircd::mapi::import_section_names[]
|
||||
{
|
||||
IRCD_MODULE_EXPORT_CODE_SECTION,
|
||||
IRCD_MODULE_EXPORT_DATA_SECTION,
|
||||
nullptr
|
||||
};
|
||||
|
||||
//
|
||||
// mods::mod::mod
|
||||
//
|
||||
|
@ -79,10 +87,14 @@ try
|
|||
{
|
||||
mode
|
||||
}
|
||||
,exports
|
||||
,exports{[this]
|
||||
{
|
||||
mods::mangles(this->path, mapi::import_section_name)
|
||||
}
|
||||
std::map<std::string, std::string> ret;
|
||||
for(auto section(mapi::import_section_names); *section; ++section)
|
||||
ret.merge(mods::mangles(this->path, *section));
|
||||
|
||||
return ret;
|
||||
}()}
|
||||
,handle{[this]
|
||||
{
|
||||
// Can't interrupt this ctx during the dlopen() as long as exceptions
|
||||
|
@ -747,7 +759,10 @@ ircd::mods::make_target_name(const string_view &name,
|
|||
|
||||
auto ret{fmt::snstringf
|
||||
{
|
||||
4096, "%s(%s", name, prototype
|
||||
4096, "%s%s%s",
|
||||
name,
|
||||
prototype? "(" : "",
|
||||
prototype
|
||||
}};
|
||||
|
||||
ret.shrink_to_fit();
|
||||
|
|
Loading…
Reference in a new issue