Created
November 2, 2024 16:36
-
-
Save enh/d7538e32aca8b68ed3541dd803594b9d to your computer and use it in GitHub Desktop.
file(1) support for Android ELF notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/readelf.c b/src/readelf.c | |
index a79906f5..6fd877ec 100644 | |
--- a/src/readelf.c | |
+++ b/src/readelf.c | |
@@ -686,6 +686,27 @@ do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, | |
return -1; | |
return 1; | |
} | |
+ | |
+ if (NAMEEQUALS(name, "Android") && type == 1 && descsz >= 4) { | |
+ uint32_t api_level; | |
+ *flags |= FLAGS_DID_OS_NOTE; | |
+ memcpy(&api_level, &nbuf[doff], sizeof(api_level)); | |
+ api_level = elf_getu32(swap, api_level); | |
+ if (file_printf(ms, ", for Android %d", api_level) == -1) | |
+ return -1; | |
+ /* | |
+ * NDK r14 and later also include details of the NDK that | |
+ * built the binary. OS binaries (or binaries built by older | |
+ * NDKs) don't have this. The NDK release and build number | |
+ * are both 64-byte strings. | |
+ */ | |
+ if (descsz >= 4+64+64) { | |
+ if (file_printf(ms, ", built by NDK %.64s (%.64s)", | |
+ &nbuf[doff+4], &nbuf[doff+4+64]) == -1) | |
+ return -1; | |
+ } | |
+ } | |
+ | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment