From c897ff7c96ea76810e4d9d429b73c68a46f63d5e Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 21 Apr 2024 15:29:29 +1000 Subject: [PATCH 1/2] Added support for diffing specific symbols in .o files --- diff.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/diff.py b/diff.py index e75169e..626b8fc 100755 --- a/diff.py +++ b/diff.py @@ -139,6 +139,12 @@ def complete_symbol( help="""Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)""", ) + parser.add_argument( + "-os", + dest="diff_obj_symbol", + metavar="SYMBOL", + help="""Diff a specific function in two .o files, both non-stripped.""", + ) parser.add_argument( "-f", "--file", @@ -1522,7 +1528,7 @@ def dump_elf( def dump_objfile( - start: str, end: Optional[str], config: Config, project: ProjectSettings + start: str, end: Optional[str], diff_obj_symbol: str, config: Config, project: ProjectSettings ) -> Tuple[str, ObjdumpCommand, ObjdumpCommand]: if config.base_shift: fail("--base-shift not compatible with -o") @@ -1550,6 +1556,8 @@ def dump_objfile( if project.disassemble_all: disassemble_flag = "-D" + elif diff_obj_symbol: + disassemble_flag = f"--disassemble={diff_obj_symbol}" else: disassemble_flag = "-d" @@ -3772,7 +3780,7 @@ def main() -> None: ) elif config.diff_obj: make_target, basecmd, mycmd = dump_objfile( - args.start, args.end, config, project + args.start, args.end, args.diff_obj_symbol, config, project ) else: make_target, basecmd, mycmd = dump_binary(args.start, args.end, config, project) From 25ff60f04cc9369cae92bb1a73ebeb097e647033 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 21 Apr 2024 23:22:50 +1000 Subject: [PATCH 2/2] =?UTF-8?q?Adjust=20name=20to=20=E2=80=94objsym?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff.py b/diff.py index 626b8fc..f679faa 100755 --- a/diff.py +++ b/diff.py @@ -140,7 +140,7 @@ def complete_symbol( see symbol names. (Recommended)""", ) parser.add_argument( - "-os", + "--objsym", dest="diff_obj_symbol", metavar="SYMBOL", help="""Diff a specific function in two .o files, both non-stripped.""",