Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lizhangqu/dlfcn_compat
兼容Android 7.0 dlfcn(dlopen、dlsym、dlclose、dlerror)
https://github.com/lizhangqu/dlfcn_compat
dlfcn dlopen dlsym nougat
Last synced: about 2 months ago
JSON representation
兼容Android 7.0 dlfcn(dlopen、dlsym、dlclose、dlerror)
- Host: GitHub
- URL: https://github.com/lizhangqu/dlfcn_compat
- Owner: lizhangqu
- Created: 2019-01-31T06:29:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-23T07:47:37.000Z (about 5 years ago)
- Last Synced: 2024-04-16T11:21:22.429Z (9 months ago)
- Topics: dlfcn, dlopen, dlsym, nougat
- Language: C++
- Size: 71.3 KB
- Stars: 160
- Watchers: 6
- Forks: 38
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Thanks
Android N的实现来自 https://github.com/avs333/Nougat_dlfunctions
做了一点优化处理
- 支持除arm之外的CPU架构以支持模拟器,x86,x86_64经过验证没问题,mips和mips64可编译但没经过验证。
- 支持传递文件名而非绝对路径
- 不需要进行版本特判,统一使用compat函数,内部进行逻辑分发
### 技术原理见美团的《Android远程调试的探索与实现》相关文章中"符号化"和"突破7.0动态链接的限制"两部分
[Android远程调试的探索与实现](https://tech.meituan.com/2017/07/20/android-remote-debug.html)
### 使用方式
引入cmake
```
set(dlfcn_compat_root_dir /path/to/dlfcn)
add_subdirectory(${dlfcn_compat_root_dir} dlfcn)
include_directories(
${dlfcn_compat_root_dir}/include/
)
```链接静态库
```
target_link_libraries(yourSharedLibrary
dlfcn_compat_static
)
```引入头文件
```
#include "dlfcn_compat.h"
```相关函数
```
extern "C" {void *dlopen_compat(const char *filename, int flags);
void *dlsym_compat(void *handle, const char *symbol);
int dlclose_compat(void *handle);
const char *dlerror_compat();
int get_sdk_level();
}
```sample 见 app/src/main/cpp/sample.cpp