bionic: ReadPadSegmentNote: Skip empty PT_NOTEs

Some obfuscated ELFs may containe "empty" PT_NOTEs (p_memsz == 0).
Attempting to mmap these will cause a EINVAL failure since the requested
mapping size is zero.

Skip these phrogram headers when parsing notes.

Also improve the failure log with arguments to the mmap syscall.

Test: Platinum Tests
Bug: 324468126
Change-Id: I7de4e55c6d221d555faabfcc33bb6997921dd022
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 8925e62..60f8868 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -717,13 +717,20 @@
       continue;
     }
 
+    // Some obfuscated ELFs may contain "empty" PT_NOTE program headers that don't
+    // point to any part of the ELF (p_memsz == 0). Skip these since there is
+    // nothing to decode. See: b/324468126
+    if (phdr->p_memsz == 0) {
+      continue;
+    }
+
     // note_fragment is scoped to within the loop so that there is
     // at most 1 PT_NOTE mapped at anytime during this search.
     MappedFileFragment note_fragment;
     if (!note_fragment.Map(fd_, file_offset_, phdr->p_offset, phdr->p_memsz)) {
-      DL_WARN("\"%s\" note mmap failed: %s", name_.c_str(), strerror(errno));
-      // If mmap failed, skip the optimization but don't block ELF loading
-      return true;
+      DL_ERR("\"%s\": PT_NOTE mmap(nullptr, %zu, PROT_READ, MAP_PRIVATE, %d, %p) failed: %m",
+             name_.c_str(), phdr->p_memsz, fd_, page_start(file_offset_ + phdr->p_offset));
+      return false;
     }
 
     const ElfW(Nhdr)* note_hdr = nullptr;