Giter Site home page Giter Site logo

Comments (5)

caikelun avatar caikelun commented on August 11, 2024

这个函数是用来查询导入符号的,.gnu_hash中不包含导入符号。你可以仔细看下这个函数中每种查找的注释,约靠前的查找方式查找到的概率越大,如果概率相同,则速度快的放在前面。

from bhook.

Mr-JingShi avatar Mr-JingShi commented on August 11, 2024

大佬,不好意思,这个文件相似符号名字的函数太多了,我标记错位置了。
应该是这个位置:

static ElfW(Sym) *bh_elf_find_export_func_symbol_by_symbol_name_unsafe(bh_elf_t *self, const char *sym_name)

个人觉得xhook的写法更好:

static int xh_elf_gnu_hash_lookup(xh_elf_t *self, const char *symbol, uint32_t *symidx)
{
    if(0 == xh_elf_gnu_hash_lookup_def(self, symbol, symidx)) return 0;
    // 当然对于export符号查找,这个import符号查找需要屏蔽掉
    // if(0 == xh_elf_gnu_hash_lookup_undef(self, symbol, symidx)) return 0;
    return XH_ERRNO_NOTFND;
}

static int xh_elf_find_symidx_by_name(xh_elf_t *self, const char *symbol, uint32_t *symidx)
{
    if(self->is_use_gnu_hash)
        return xh_elf_gnu_hash_lookup(self, symbol, symidx);
    else
        return xh_elf_hash_lookup(self, symbol, symidx);
}

存在gnu_hash段、sym_name确实不存在于gnu_hash布隆过滤器中时,不应该继续到sysv-hash中查找,而是提前退出。

from bhook.

Mr-JingShi avatar Mr-JingShi commented on August 11, 2024

查询一个不存在的数据,容易造成白嫖,布隆过滤器可以快速识别白嫖,识别到白嫖之后就应该快速制止。

from bhook.

caikelun avatar caikelun commented on August 11, 2024

我理解你说的意思。在实际的线上环境中,我们遇到过一些不太正常的so,有符号信息仅存在于.hash但是不存在于.gnu_hash中。

另外,请不要太相信xhook,这真的是一份很老的代码了,很多年前我就已经放弃维护了,xhook的很多细节也没有在线上做过大规模的验证。

from bhook.

Mr-JingShi avatar Mr-JingShi commented on August 11, 2024

谢谢老师的细心回答。

from bhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.