forked from fkie-cad/cwe_checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/ir/project: propagate control flow for call returns
This patch does two things: 1. It allows the re-targeting of jumps for which no known true condition is available. Without a known condition, only blocks that consist of a single, unconditional jump can be skipped. 2. It allows the re-targeting of call returns in the same way that we already do it for unconditional jumps. For calls we never have a known condition as side-effects may invalidate any knowledge we have after the execution of all DEFs in the block. Example: Before the optimization we might have code like this: BLK [blk_0040a9c4] DEF [instr_0040a9c4_0] ra:4 = 0x40a9cc:4 JMP [instr_0040a9c4_1] call sub_00403f80 ret blk_0040a9cc BLK [blk_0040a9cc] JMP [instr_0040a9cc_1] Jump to blk_0040a9d0 BLK [blk_0040a9d0] DEF [instr_0040a9d0_0] a0:4 = ((0x43:4 << 0x10:4) + 0xffffb730:4) JMP [instr_0040a9d0_1] Jump to blk_0040a9d4 whereas after the optimization it becomes: BLK [blk_0040a9c4] DEF [instr_0040a9c4_0] ra:4 = 0x40a9cc:4 JMP [instr_0040a9c4_1] call sub_00403f80 ret blk_0040a9d0 BLK [blk_0040a9d0] DEF [instr_0040a9d0_0] a0:4 = ((0x43:4 << 0x10:4) + 0xffffb730:4) JMP [instr_0040a9d0_1] Jump to blk_0040a9d4 Fixes: 2487aac ("remove dead code originating from control flow propagation (fkie-cad#384)") Closes: fkie-cad#461 Reported-by: https://github.com/ElDavoo Signed-off-by: Valentin Obst <[email protected]>
- Loading branch information
Valentin Obst
committed
May 14, 2024
1 parent
2e08fb7
commit 33cfdb6
Showing
1 changed file
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters