summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Jones <christopher.jones@arm.com> 2024-06-05 16:39:54 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-07-01 15:50:16 +0000
commitf513aece93f7b19bbe1ba01d97340d41468fcbbc (patch)
tree05bd51a7fb5c740df395d34524549aac5d855ae1
parent571e7b5ec1cbcd9ecb2b30ac67e69881f98e0767 (diff)
Accept immediate comments in x86(_64) assembly
Objdump can sometimes output comments after assembly instructions, which are then not recognised as an instruction that alters the stack, by check_cfi.py. For example objdump might output the following when increasing the frame size on x86_64: subq $0x108, %rsp # imm = 0x108 Fix this by recognising and accepting assembly comments in this form: "# imm = 0x..." which may be postfixed to stack altering instructions from objdump. Note: objdump does not currently output these comments however subsequent changes to quick entrypoint assembly could result in these comments being added. Test: ./art/tools/check_cfi.py (on x86 and x86_64 targets) Change-Id: I0195e82c0eb9f7409f3ec46eeafec05a4a8e3f41
-rwxr-xr-xtools/check_cfi.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/check_cfi.py b/tools/check_cfi.py
index 55b622d422..ac6f810f2b 100755
--- a/tools/check_cfi.py
+++ b/tools/check_cfi.py
@@ -57,8 +57,8 @@ def get_inst_semantics(arch: str) -> List[Any]:
ptr_size = {"i386": 4, "x86_64": 8}[arch]
add(r"push. .*", lambda m: ptr_size)
add(r"pop. .*", lambda m: -ptr_size)
- add(r"sub. \$(\w+), (?:%esp|%rsp)", lambda m: int(m[1], 0))
- add(r"add. \$(\w+), (?:%esp|%rsp)", lambda m: -int(m[1], 0))
+ add(r"sub. \$(\w+), (?:%esp|%rsp)( # imm = \w+)?", lambda m: int(m[1], 0))
+ add(r"add. \$(\w+), (?:%esp|%rsp)( # imm = \w+)?", lambda m: -int(m[1], 0))
add(r"call. (0x\w+) <.*", lambda m: ptr_size, adjust_pc=lambda m: int(m[1], 0))
add(r"j[a-z]* (0x\w+) <.*", adjust_pc=lambda m: int(m[1], 0))
if arch in ["arm", "aarch64"]: