From f513aece93f7b19bbe1ba01d97340d41468fcbbc Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 5 Jun 2024 16:39:54 +0100 Subject: 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 --- tools/check_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/check_cfi.py') 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"]: -- cgit v1.2.3-59-g8ed1b