aboutsummaryrefslogtreecommitdiff
path: root/disassembler_dex.h
AgeCommit message (Collapse)Author
2021-07-23[Zucchini]: Support DEX AnnotationsDirectoryItemCalder Kitagawa
Adds support for AnnotationsDirectoryItem references. These take a similar form to variable length reference lists; however, the header for the list is not just the size of one list but rather three sublists and also contains a reference to class annotations within the header. The CL adds a parser for these items and a few types. The ReferenceReader is reused from the CachedItemListReferenceReader. There isn't a noticeable change in generation or apply time but the memory footprint can potentially be much larger as each annotation can produce on average a few offsets and there can be thousands of instances. Bug: 847571 Change-Id: I04afe4c6e35c66c0c9157ed3ac3e5bf338931f03 Reviewed-on: https://chromium-review.googlesource.com/1095645 Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: agrieve <agrieve@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#566420} NOKEYCHECK=True GitOrigin-RevId: 966646525b939a8fd52a993894bbb3822d9cb674
2021-07-23[Zucchini]: Support reference lists in DEXCalder Kitagawa
Adds support for types which contain variable length lists of references in DEX. These lists take the form: |NTTTTT|NTT|N|NTT|... where N is the header containing the length and T is a reference body. There are three types which utilize this format. AnnotationsDirectoryItem also uses a variant of this format with multiple lists per item (to be added in a separate CL). Method: We pre-cache the offsets of each T within the list using the parser and iterate over it in the ReferenceReader. This is faster than implicitly parsing each list and avoids having to handle all the accounting for the number of lists, items per list, map size, etc. in the ReferenceReader. The tradeoff is memory which varies by number of types and annotations but could exceed 1 MB in a very large DEX file. This is an acceptable cost for the time and simplicity gained. Explicitly parsing beforehand is also safer as it delegates the validation of DEX structure to the parser early before any references are read. This is also inkeeping with the style of the other ReferenceReaders in the file. Bug: 847571 Change-Id: I853905b10ab7003e87895cc50c5ebf6b9fb4a424 Reviewed-on: https://chromium-review.googlesource.com/1087409 Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: agrieve <agrieve@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#565989} NOKEYCHECK=True GitOrigin-RevId: 55a60dd9ab731cb569e49ae3600bc42c716d4756
2021-07-23[Zucchini]: Finish Simple DEX Type SupportCalder Kitagawa
This finishes support for simple DEX types including absolute offsets, indexes into lists and code items. It is mostly just pattern matching to add the new types to the already existing types. The exception to pattern matching is cases with sentinel values. This requires slight refactoring to existing code to account for empty/sentinel fields which should be skipped. Bug: 847571 Change-Id: Ia83a9d9adee2967bfcc10644ea134063865929f9 Reviewed-on: https://chromium-review.googlesource.com/1076901 Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#564479} NOKEYCHECK=True GitOrigin-RevId: b87359eb909433d97367382b5982baab5352124e
2021-07-23[Zucchini] Add DEX Reference read / write for basic types.Samuel Huang
(Committing on behalf of etiennep@). This CL adds DEX References read / write for 11 basic types. Details: - Add InstructionParser to visit DEX instructions in the insns member of a CodeItem, taking care to skip non-instruction "payloads". - Add InstructionReferenceReader to visit CodeItem References found in |[lo, hi)|, using provided callbacks to apply type filters and extract targets. - Add ItemReferenceReader to visit fixed-sized items to extract Referenes from a "member variable of interest", using a callback to extract targets. - DisassemblerDex: Add MakeRead*() and MakeWrite*() to return a visitor to read / write supported DEX References. - Add DEX unit test to audit the error-prone look-up table from DisassemblerDex::MakeReferenceGroups(). Change-Id: Ice12a867aab4fdcb4a152bb1946ea7515ad426ef Reviewed-on: https://chromium-review.googlesource.com/994066 Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Commit-Queue: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#549178} NOKEYCHECK=True GitOrigin-RevId: 7b249ec48aa0f1058496a1b7f095b0f126011bf6
2021-07-23[Zucchini] Create dex disassembler.Etienne Pierre-Doray
Creates Disassembler that recognises and parses DEX format. For now, it doesn't extract any type reference, so it is equivalent to DisassemblerNoOp. Extraction of various types of reference will be added in a follow-up CL. BufferView::covers_array() and unittests were also added. Change-Id: I08756244e9af899cf0f40dabd2b0059e1749328e Reviewed-on: https://chromium-review.googlesource.com/967603 Reviewed-by: Samuel Huang <huangs@chromium.org> Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/master@{#546807} NOKEYCHECK=True GitOrigin-RevId: d214e2cf9e23bf055f0e0655e9564761d50206ad