Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Object Loading #25

Open
InfoHunter opened this issue Mar 15, 2023 · 3 comments
Open

Dynamic Object Loading #25

InfoHunter opened this issue Mar 15, 2023 · 3 comments
Milestone

Comments

@InfoHunter
Copy link
Member

类似于DSO那种,即每个feature都编译成so,然后启动的时候只加载base.so,此为体积最小。然后在比如进行TLS握手的同时,临时加载所需的so,比如SM4-GCM的so。这样属于时间换空间,即性能下降但体积可以做到极小

@InfoHunter
Copy link
Member Author

此功能需要从一开始设计的时候考虑进去,比如对各种算法调用的同时,需要判断是否so已经加载

@InfoHunter InfoHunter added this to the 1.0.0 milestone Mar 15, 2023
@chainsaid
Copy link
Collaborator

chainsaid commented Mar 15, 2023

DSO实现大概有两种方式,一种借助OS提供的系统调用直接加载链接库(如Linux中的,dlopen/dlsym/dlclose,Windows中的LoadLibraryExW等接口),一种类似于apache自己实现一套接口(apr_dso_load/apr_dso_unload/apr_dso_sym/apr_dso_error,共四个接口),对不同的OS环境进行解耦。
需要划定一下目标OS环境,是否只是Linux系统,如果要支持其他嵌入式OS,则需要添加如apache的中间层。
但为后续扩展性计,此处宜直接做好解耦工作,建议采用Apache的中间层方式,只是一层对系统调用的封装,对性能几乎无影响。接口的语义上可直接参考Apache的四个接口,相关的预检工作也可在这层抽象中做文章。

关于Apache的具体做法参考:
接口定义:https://apr.apache.org/docs/apr/trunk/group__apr__dso.html
具体实现:https://github.com/apache/apr/tree/trunk/dso 在不同的目标OS中,对四个接口分别进行了syscall的映射。
应用实例:https://github.com/apache/apr/blob/trunk/test/testdso.c

@InfoHunter
Copy link
Member Author

目前看来还是加一层比较合理

@InfoHunter InfoHunter changed the title 支持lazy加载二进制能力 Dynamic Object Loading Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants