Skip to content

Implement RTLD_NEXT for dlsym #6

@weizhiao

Description

@weizhiao

The current dlopen-rs does not implement RTLD_NEXT, which causes issues when loading certain shared libraries that rely on dlsym with the RTLD_NEXT parameter.

Reference implementation approach:

  1. Use the return address register to retrieve the caller's address.
  2. Use add2dso to locate the shared library corresponding to that address.
  3. Search subsequent shared libraries after that one to resolve the symbol.

This logic aligns with the implementation in musl libc.

If you're interested in implementing this, feel free to give it a try—just make sure to comment in this issue to let me know!😊

目前dlopen-rs还没有实现RTLD_NEXT,这会导致其加载某些动态库时出现问题,因为这些动态库会使用到带有RTLD_NEXT参数的dlsym。

实现方式:

  1. 使用保存返回地址的寄存器获得调用者的地址。
  2. 使用add2dso获得该地址对应的动态库。
  3. 从该动态库之后的动态库中获取符号。

可以参考musl中的实现。

如果你有兴趣实现它的话可以去尝试一下,不过需要在本issue中告诉我一下。😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions