feat(nid): add nid_no_patch rule
This commit is contained in:
parent
e9f03cbf07
commit
58aef08fe1
|
|
@ -13,9 +13,16 @@ namespace Internal {
|
|||
|
||||
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 kNidDisambigMarker[] = "_nid_disambig";
|
||||
constexpr std::size_t kNidDisambigMarkerLen = sizeof(kNidDisambigMarker) - 1u;
|
||||
|
||||
inline bool IsNidNoPatch(const std::string& name) {
|
||||
return name.size() >= kNidNoPatchLen &&
|
||||
name.compare(name.size() - kNidNoPatchLen, kNidNoPatchLen, kNidNoPatch) == 0;
|
||||
}
|
||||
|
||||
inline std::string StripNidPostfix(const std::string& name) {
|
||||
std::string result = name;
|
||||
if (result.size() >= kNidPostfixLen &&
|
||||
|
|
|
|||
|
|
@ -485,12 +485,12 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
|
|||
|
||||
if (sym.st_name == 0u) continue;
|
||||
|
||||
const std::uint8_t binding = sym.st_info >> 4u;
|
||||
const bool isPatchable = binding != kStbLocal && sym.st_shndx != kShnUndef;
|
||||
|
||||
const std::string symName = ReadCStr(origDynStr, sym.st_name);
|
||||
if (symName.empty()) continue;
|
||||
|
||||
const std::uint8_t binding = sym.st_info >> 4u;
|
||||
const bool isPatchable = binding != kStbLocal && sym.st_shndx != kShnUndef && !IsNidNoPatch(symName);
|
||||
|
||||
std::string newValue = symName;
|
||||
if (isPatchable) {
|
||||
const std::string stripped = StripNidPostfix(symName);
|
||||
|
|
|
|||
Loading…
Reference in New Issue