In Android 8.0, My App's targetSdkVersion=22, I received the following warning log when debug:
W/linker: "/data/app/my_package_name-ndPicG9hxEo009BA_zqNQw==/lib/arm/libxxx.so": W + E load segments are not allowed
I have resolved "text relocation" for .so file before, if the targetSdkVersion is 26, then the app will receive an error.I know the reason for the question above,but I don't know how to fix this bug.
The source code(bionic/linker/linker_phdr.cpp) for the log:
if ((prot & (PROT_EXEC | PROT_WRITE)) == (PROT_EXEC | PROT_WRITE)) {
// W + E PT_LOAD segments are not allowed in O.
if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
DL_ERR_AND_LOG("\"%s\": W + E load segments are not allowed", name_.c_str());
return false;
}
DL_WARN("\"%s\": W + E load segments are not allowed", name_.c_str());
add_dlwarning(name_.c_str(), "W+E load segments");
}
so the key is the PROT_EXEC and PROT_WRITE permission. But how to forbid these permission? I need your help, Thank you!