fix(libs): add _nid_no_patch_cut postfix and global cxa/unwind exports

This commit is contained in:
boykopovar committed 2026-09-07 10:56:34 +03:00
1 parent 1e0fc3f33a
commit 14f8c16ac4
4 files changed
+25 -7

No files matched your search

@@ -15,6 +15,8 @@ constexpr char kNidPostfix[] = "_nid_postfix";
constexpr std::size_t kNidPostfixLen = sizeof(kNidPostfix) - 1u;
constexpr char kNidNoPatch[] = "_nid_no_patch";
constexpr std::size_t kNidNoPatchLen = sizeof(kNidNoPatch) - 1u;
constexpr char kNidNoPatchCut[] = "_nid_no_patch_cut";
constexpr std::size_t kNidNoPatchCutLen = sizeof(kNidNoPatchCut) - 1u;
constexpr char kNidDisambigMarker[] = "_nid_disambig";
constexpr std::size_t kNidDisambigMarkerLen = sizeof(kNidDisambigMarker) - 1u;
@@ -23,6 +25,15 @@ inline bool IsNidNoPatch(const std::string& name) {
name.compare(name.size() - kNidNoPatchLen, kNidNoPatchLen, kNidNoPatch) == 0;
}
inline bool IsNidNoPatchCut(const std::string& name) {
return name.size() >= kNidNoPatchCutLen &&
name.compare(name.size() - kNidNoPatchCutLen, kNidNoPatchCutLen, kNidNoPatchCut) == 0;
}
inline std::string StripNidNoPatchCut(const std::string& name) {
return name.substr(0u, name.size() - kNidNoPatchCutLen);
}
inline std::string StripNidPostfix(const std::string& name) {
std::string result = name;
if (result.size() >= kNidPostfixLen &&
+4
View File
@@ -25,6 +25,10 @@ std::unordered_map<std::string, std::string> ResolveNids(const std::vector<std::
result.reserve(exportedNames.size());
for (const std::string& name : exportedNames) {
if (IsNidNoPatchCut(name)) {
result[name] = StripNidNoPatchCut(name);
continue;
}
if (IsNidNoPatch(name)) {
result[name] = name;
continue;
@@ -4,6 +4,9 @@
#define GCC_LOCAL_ALIAS(alias, target) \
asm(".local " #alias "\n.set " #alias "," #target "\n")
#define GCC_GLOBAL_ALIAS(alias, target) \
asm(".globl " #alias "\n.set " #alias "," #target "\n")
#define GCC_HIDDEN_FN
#endif
+7 -7
View File
@@ -10,13 +10,13 @@
extern "C" [[noreturn]] GCC_HIDDEN_FN void LibcRuntimeAssertion(const char*, int, const char*, const char*) { std::abort(); }
GCC_LOCAL_ALIAS(_ZSt21__glibcxx_assert_failPKciS0_S0_, LibcRuntimeAssertion);
GCC_LOCAL_ALIAS(__cxa_allocate_exception, __cxa_allocate_exception_nid_postfix);
GCC_GLOBAL_ALIAS(__cxa_allocate_exception_nid_no_patch_cut, __cxa_allocate_exception_nid_postfix);
GCC_GLOBAL_ALIAS(__cxa_throw_nid_no_patch_cut, __cxa_throw_nid_postfix);
GCC_GLOBAL_ALIAS(__cxa_begin_catch_nid_no_patch_cut, __cxa_begin_catch_nid_postfix);
GCC_GLOBAL_ALIAS(__cxa_end_catch_nid_no_patch_cut, __cxa_end_catch_nid_postfix);
GCC_GLOBAL_ALIAS(__cxa_rethrow_nid_no_patch_cut, __cxa_rethrow_nid_postfix);
GCC_GLOBAL_ALIAS(__gxx_personality_v0_nid_no_patch_cut, __gxx_personality_v0_nid_postfix);
GCC_GLOBAL_ALIAS(_Unwind_Resume_nid_no_patch_cut, _Unwind_Resume_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_free_exception, __cxa_free_exception_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_throw, __cxa_throw_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_begin_catch, __cxa_begin_catch_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_end_catch, __cxa_end_catch_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_rethrow, __cxa_rethrow_nid_postfix);
GCC_LOCAL_ALIAS(__gxx_personality_v0, __gxx_personality_v0_nid_postfix);
GCC_LOCAL_ALIAS(_Unwind_Resume, _Unwind_Resume_nid_postfix);
GCC_LOCAL_ALIAS(_ZSt9terminatev, _ZSt9terminatev_nid_postfix);
GCC_LOCAL_ALIAS(__cxa_call_terminate, __cxa_call_terminate_nid_postfix);