summaryrefslogtreecommitdiff
path: root/linker/linker_phdr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linker/linker_phdr.cpp')
-rw-r--r--linker/linker_phdr.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 5b0ee491a..973fcf5a2 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -248,14 +248,26 @@ bool ElfReader::VerifyElfHeader() {
}
if (header_.e_shentsize != sizeof(ElfW(Shdr))) {
- DL_ERR("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
- name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
- return false;
+ // Fail if app is targeting Android O or above
+ if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ DL_ERR_AND_LOG("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
+ name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
+ return false;
+ }
+ DL_WARN("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
+ name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
+ add_dlwarning(name_.c_str(), "has invalid ELF header");
}
if (header_.e_shstrndx == 0) {
- DL_ERR("\"%s\" has invalid e_shstrndx", name_.c_str());
- return false;
+ // Fail if app is targeting Android O or above
+ if (get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ DL_ERR_AND_LOG("\"%s\" has invalid e_shstrndx", name_.c_str());
+ return false;
+ }
+
+ DL_WARN("\"%s\" has invalid e_shstrndx", name_.c_str());
+ add_dlwarning(name_.c_str(), "has invalid ELF header");
}
return true;
@@ -608,7 +620,7 @@ bool ElfReader::LoadSegments() {
int prot = PFLAGS_TO_PROT(phdr->p_flags);
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() > 25) {
+ 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;
}