2

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!

Fred
  • 21
  • 2
  • Don't have write-and-execute segments in your application or library. – user253751 Oct 11 '17 at 01:30
  • 1
    Yes, I know that. But the library code is written by someone else and I don't familiar with C++. How to find the write-and-execute code snippet? Can I resolve it when build .so file use NDK? Can you give me an simple example? THX – Fred Oct 11 '17 at 01:54
  • Hi, did you fix this issue? – shadowfire Jan 30 '18 at 09:13

0 Answers0