Repository navigation
feat(native): decode Android .note.android.ident ELF notes - #9502
Merged
morluto merged 8 commits intoNov 9, 2026
Merged
Conversation
Decode Android NDK NT_ANDROID_TYPE_IDENT (.note.android.ident, owner Android, type 1) notes in inspect_elf_notes across legacy 4-byte and modern >=132-byte descriptors with bounded TextBudget accounting.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The reviewed changes appear safe to merge; no new actionable issue was found. SummaryAdds structured Android ELF note facts to
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ELF note] --> B{Android owner and type 1?}
B -->|No| C[android is null]
B -->|Yes| D{Descriptor length}
D -->|4 bytes| E[Decode API using ELF byte order]
D -->|132 bytes or more| F[Check two fixed string slots]
D -->|Other| C
F -->|Invalid| C
F -->|Valid| G[Charge retained text and decode fields]
E --> H[Return entry with raw descriptor facts]
G --> H
C --> H
Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile |
…port, and add feature spec
…-ident-elf-note # Conflicts: # docs/specs/README.md
# Conflicts: # docs/elf-notes.md # src/native/elf/ElfNoteParser.ts
…-ident-elf-note # Conflicts: # docs/specs/README.md
3 tasks done
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decode Android NDK
.note.android.ident(owner === "Android",n_type === 1,NT_ANDROID_TYPE_IDENT) ELF notes ininspect_elf_notes/rea inspect-elf-notesso callers receive structuredandroid_api,ndk_version, andndk_build_numberfacts instead of falling back totype_name: "unknown"and manual hex slicing. No existing upstream issue is linked; this extends the built-in static ELF note reader alongsideGNUandCOREnotes.Problem and expected behavior
Android NDK shared libraries and executables linked with Bionic
crtbegin_so.o/crtbrand.Sembed a.note.android.identnote (owner: "Android",type: 1):< r14) and unbranded platform builds emit a 4-byte descriptor storinguint32_t android_apiin the ELF image's byte order.r14+) emits a 132-byte (or extended>= 132-byte) descriptor containinguint32_t android_apiat0..4,char ndk_version[64]at4..68, andchar ndk_build_number[64]at68..132.Previously,
inspect_elf_notesonly mappedGNUandCOREnote owners, leavingAndroidtype1entries astype_name: "unknown"withdescriptor.hex: nullon 132-byte notes (above the 64-byte preview threshold). Callers inspecting Android native libraries now receivetype_name: "android_ident"and a structuredandroidobject while truncated or non-ASCII vendor payloads safely degradeandroidtonulland preserve raw descriptor provenance.Change and scope
Follow the contribution scope.
ELF_NOTE_TYPE_NAMESwith"android_ident", addandroidNoteTypeName(type)forowner === "Android", and add nullableandroid: { android_api, ndk_version, ndk_build_number }to each note entry insrc/domain/native/elfNotes.ts.decodeAndroidinsrc/native/elf/ElfNoteParser.tsfollowing the same endianness andTextBudget(scanned+used) accounting asdecodeGnuanddecodeCore:descriptor.length === 4: decodes{ android_api, ndk_version: null, ndk_build_number: null }.descriptor.length >= 132: caches the 128-byte fixed-slot scan per descriptor slice inTextBudget.scans, validates printable ASCII (0x20..0x7e) before NUL and clean NUL padding across both 64-byte slots (4..68and68..132), charges retained string bytes toTextBudget.used, and returns{ android_api, ndk_version, ndk_build_number }.0..3or5..131bytes), unterminated, control-byte, or non-zero-padded slots returnandroid: nullwithout rejecting valid ELF images.inspect_elf_notestool contract description,docs/elf-notes.md, anddocs/specs/native/android-elf-ident-note/{spec.md,plan.md,tasks.md}(indexed indocs/specs/README.md).NT_ANDROID_TYPE_MEMTAG/NT_ANDROID_TYPE_KUSER), which remaintype_name: "unknown"withandroid: null.Contract and boundary impact
src/domain/native/elfNotes.ts(note entry schema and Android type-name mapping) andsrc/native/elf/ElfNoteParser.ts(static note-entry projection consumed byElfNotesProvider,ElfNotesService,inspect-elf-notes, andinspect_elf_notes).inspect_elf_notesboundary; no target execution, attachment, or external tool invocation).inspect_elf_notes/inspect-elf-notesoutput entries add"android_ident"totype_nameandandroid: { android_api: number, ndk_version: string | null, ndk_build_number: string | null } | nullalongsidegnuandcore.<= 64-byte hex previews remain unchanged; unparsed Android descriptors setandroid: nullrather than fabricating fields.docs/public/product-catalog.json), package, or installation impact: CI regenerates ignored catalogs; no build outputs committed.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/domain/native/elfNotes.test.ts: verifiesandroidNoteTypeNamemappings (1 -> "android_ident", other types ->"unknown").src/native/elf/ElfNoteParser.test.ts: covers little-endian (aarch64,x86_64) and big-endian (ELF32,ELF64).note.android.identsections with 132-byte, 152-byte extended, and legacy 4-byte descriptors;owner === "Android"with unknowntype: 2;0-,2-, and68-byte truncated descriptors; unterminated, control-byte, and non-zero-padded 64-byte slots; andTextBudgetscan caching and retained-text limits.tests/boundary/mcp/elfNotesMcp.test.ts: verifiesinspect_elf_notesover MCP decodes.note.android.identand preservesdescriptor.hexon short truncated notes without starting a deep provider.tests/acceptance/elfNotesAndroid.test.ts: verifies CLI (inspect-elf-notes --json) and stdio MCP (inspect_elf_notes) parity across little-endian ELF64 and big-endian ELF32 targets.ElfNoteParser.toEntryonly checkedGNUandCOREowners, emittingtype_name: "unknown"with noandroidfield forowner === "Android", type === 1.entries[]item fromrea inspect-elf-notes libtarget.so --json/inspect_elf_notes):{ "index": 0, "table_kind": "section", "table_index": 1, "namesz": 8, "descsz": 132, "type": 1, "type_name": "android_ident", "owner": "Android", "owner_bytes_hex": "416e64726f696400", "descriptor": { "bytes": 132, "sha256": "...", "hex": null }, "gnu": null, "core": null, "android": { "android_api": 24, "ndk_version": "r27c", "ndk_build_number": "12297006" } }.note.android.ident; otherNT_ANDROID_*note types remain rawunknownentries by design.For evidence-bearing changes:
Validation performed
npx oxfmt . && npx oxfmt --check .— passed (All matched files use the correct format).npm run build:cached— passed (3 successful, 3 total).npm run check:fast— passed (typecheckandlint/ module boundaries clean).npx vitest run --project domain src/domain/native/elfNotes.test.ts src/domain/native/elfNoteLayout.test.ts— passed (2 files, 6 tests).npx vitest run --project services src/application/binaryDiagnostics/ElfNotesService.test.ts— passed (1 file, 6 tests).npx vitest run --project adapters src/native/elf/ElfNoteParser.test.ts src/native/elf/ElfNotesProvider.test.ts— passed (2 files, 72 passed, 1 skipped).npx vitest run --project boundary tests/boundary/filesystem/elfNotes.test.ts tests/boundary/filesystem/flutterElfNotes.test.ts— passed (2 files, 15 tests).npx vitest run --project mcp-boundary tests/boundary/mcp/elfNotesMcp.test.ts— passed (1 file, 7 tests).npx vitest run --project acceptance tests/acceptance/elfNotesCli.test.ts tests/acceptance/elfNotesCore.test.ts tests/acceptance/elfNotesAbiEndian.test.ts— passed (3 files, 11 tests).npx vitest run --project acceptance tests/acceptance/elfNotesAndroid.test.ts— passed (1 file, 2 tests).npm run verify:architecture-guards— passed (Architecture guards passed across 2548 source files).npm run verify:test-discovery— passed (Discovered all 3197 test files exactly once).npm run scan:todos— passed (No tech-debt markers found).npm run jscpd— passed (3.46% duplicated lines).npm run knip && npm run knip:production— passed (Knip found no issues).npm run metadata:check && npm run mcp-catalog:check && npm run docs:check && npm run verify:docs:routes— passed (9/9docs checks and341built HTML documentation routes clean).npm run lint:typed— passed (6,676 files, 0 errors).v22.23.4,v24.22.1,v26.13.0) across all 12 ELF note suites above — passed (12files,119passed,1skipped on each runtime).Compatibility, safety, and release
androidproperty oninspect_elf_notesentries and"android_ident"enum member ontype_name.inspect_elf_notesis a portable built-in static ELF reader that does not invoke external disassemblers or debuggers.inspect_elf_notestool contract schema updates automatically).Bufferwith fixed 128-byte slot scanning andTextBudgetaccounting; no filesystem mutation, process execution, or unbounded string allocation.Author readiness
Human owner: @saariuslystoned
Before merge
type(scope): outcome.