From 486bb51167a11fbbe4d1fd9c5ab3decb8d6b3cf9 Mon Sep 17 00:00:00 2001 From: boykopovar Date: Fri, 21 Aug 2026 00:32:00 +0300 Subject: [PATCH] fix(nid): exclude undefined dynamic symbols from elf nid patching --- core/libs/nid/src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/libs/nid/src/main.cpp b/core/libs/nid/src/main.cpp index 05a97625f..dcaf13dc5 100644 --- a/core/libs/nid/src/main.cpp +++ b/core/libs/nid/src/main.cpp @@ -52,6 +52,7 @@ struct Elf64_Sym { constexpr std::uint32_t SHT_DYNSYM = 11u; constexpr std::uint8_t STB_LOCAL = 0u; +constexpr std::uint16_t SHN_UNDEF = 0u; constexpr char kNidPostfix[] = "_nid_postfix"; constexpr std::size_t kNidPostfixLen = sizeof(kNidPostfix) - 1u; @@ -198,6 +199,7 @@ void _patchNidsElf(std::vector& elf, const std::string& libraryNam const std::uint8_t binding = sym.st_info >> 4u; if (binding == STB_LOCAL) continue; if (sym.st_name == 0u) continue; + if (sym.st_shndx == SHN_UNDEF) continue; const std::string symName = _readCStr(newDynStr, sym.st_name); if (symName.empty()) continue;