New issue
Advanced search Search tips

Issue 918867 link

Starred by 1 user

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature



Sign in to add a comment

Zucchini: Add ARM Support

Project Member Reported by hua...@chromium.org, Jan 3

Issue description

There are two main parts to this task:

(1) Add ARM support (ARM32 and AArch64) for ELF. This makes Zucchini more useful for mobile usage. This is already implemented "Trunk" Zucchini, and is the final step needed for Zucchini's Chromium repo to catch up with "Trunk". 
 
(2) Add ARM support for PE (EXE and DLL): This involves some new code, but should be relatively simple.

 
Project Member

Comment 1 by bugdroid1@chromium.org, Jan 11

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/398b188eab96c3b198b6a4eb8788bba77202aef8

commit 398b188eab96c3b198b6a4eb8788bba77202aef8
Author: Samuel Huang <huangs@chromium.org>
Date: Fri Jan 11 20:00:13 2019

[Zucchini] ARM Support: Add arm_utils.* with tests.

This CL adds new files for ARM support. The code is not yet integrated
into Zucchini, but are only used by the added tests. The high-level
goal is to support rel32 reference read / write via:

    (data bytes) <-> |code| <-> |disp| <-> |target_rva|,

where |code| is ARM machine code value (read-write), and |disp| is a
PC-relative displacement. Details:
* Add template class ArmAddrTraits as API to process rel32 references.
  It is specialized for each rel32 address type, and aggregates
  selected low-level static functions from an ARM *Translator class.
* Add class Arm32Rel32Translator for 32-bit ARM (ARM32)
  * ArmAddrTraits is specialized to {A24} encoding for ARM mode, and
    {T8, T11, T21, T24} encodings for THUMB2 mode.
  * Complication: |code| can affect |disp| <-> |target_rva|, since the
    the BLX instruction dictates whether |target_rva| should be 2-byte
    or 4-byte aligned!
* The BLX special case makes |disp| <-> |target_rva| unsuitable for
  ArmAddrTraits. This led to the API to be defined as:
  * Fetch() for (data bytes) -> |code|.
  * Store() for |code| -> (data bytes).
  * Decode() for |code| -> |disp| & alignment spec (ArmAlign).
  * Encode() for |disp| -> |code|: Modifies existing |code|.
  * Read() for |code| -> |target_rva|: Needs |instr_rva|.
  * Write() for |target_rva| -> |code|.
    * Needs |instr_rva|; modifies existing |code|.
* Add class AArch64Rel32Translator for 64-bit ARM (AArch64).
  * ArmAddrTraits is specialized to {Immd14, Immd19, Immd26} encodings.

Bug: 918867
Change-Id: Ie20935e391ed0ac85c408aa9c8959305dc8bba42
Reviewed-on: https://chromium-review.googlesource.com/c/1394397
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622115}
[modify] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/BUILD.gn
[add] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/arm_utils.cc
[add] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/arm_utils.h
[add] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/arm_utils_unittest.cc
[modify] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/reference_bytes_mixer.cc
[modify] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/reference_bytes_mixer.h
[modify] https://crrev.com/398b188eab96c3b198b6a4eb8788bba77202aef8/components/zucchini/zucchini_gen.cc

Project Member

Comment 2 by bugdroid1@chromium.org, Jan 16 (6 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/64b76696cded1502e1f9dd055dd3e2a51fa70f80

commit 64b76696cded1502e1f9dd055dd3e2a51fa70f80
Author: Samuel Huang <huangs@chromium.org>
Date: Wed Jan 16 15:31:06 2019

[Zucchini] ARM code: Fix counting mistake; rename T21 to T20.

ARM instruction B encoding T3 specifies:
  |code|: 11110Scc cciiiiii 10(J1)0(J2)jjj jjjjjjjj
  |disp|: SSSSSSSS SSSS(J2)(J1)ii iiiijjjj jjjjjjj0

There are 20 bits in |code| dedicated for |disp|:
  S iiiiii (J1)(J2)jjj jjjjjjjj

Previously this was miscounted as 21! This CL corrects the mistake, and
renames "T21" to "T20". There's no change in behavior.

Bug: 918867
Change-Id: Ie571bc1a413c4b77f2017cfd2ffe8bf99975ef7a
Reviewed-on: https://chromium-review.googlesource.com/c/1413352
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623243}
[modify] https://crrev.com/64b76696cded1502e1f9dd055dd3e2a51fa70f80/components/zucchini/arm_utils.cc
[modify] https://crrev.com/64b76696cded1502e1f9dd055dd3e2a51fa70f80/components/zucchini/arm_utils.h
[modify] https://crrev.com/64b76696cded1502e1f9dd055dd3e2a51fa70f80/components/zucchini/arm_utils_unittest.cc

Project Member

Comment 3 by bugdroid1@chromium.org, Jan 18 (4 days ago)

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/88de28e56330d97fe046755fee972495d5e5749d

commit 88de28e56330d97fe046755fee972495d5e5749d
Author: Samuel Huang <huangs@chromium.org>
Date: Fri Jan 18 19:36:50 2019

[Zucchini] ARM code: Add alignment checks for Read*() / Write*(); add tests.

Read*() / Write*() functions for ARM code take |instr_rva|, and
translate |code| <-> |target_rva|. Both |instr_rva| and |target_rva|
must be properly aligned (2-bytes or 4-bytes), but previously such
checks were only done on |target_rva - PC(instr_rva)|. This CL adds:
* Alignment checks for input params of Read*() / Write*().
* Unit tests for Read*() / Write*().

Also update high-level comments in arm_utils.h.

Bug: 918867
Change-Id: Ie37d2df621411920b54ef699edaed1d90eacba88
Reviewed-on: https://chromium-review.googlesource.com/c/1415753
Reviewed-by: Samuel Huang <huangs@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#624236}
[modify] https://crrev.com/88de28e56330d97fe046755fee972495d5e5749d/components/zucchini/arm_utils.cc
[modify] https://crrev.com/88de28e56330d97fe046755fee972495d5e5749d/components/zucchini/arm_utils.h
[modify] https://crrev.com/88de28e56330d97fe046755fee972495d5e5749d/components/zucchini/arm_utils_unittest.cc

Sign in to add a comment