Skip to content

Add helper function claripy.replace_slice - #689

Open
unexondev wants to merge 11 commits into
angr:masterfrom
unexondev:master
Open

unexondev wants to merge 11 commits into
angr:masterfrom
unexondev:master

Conversation

@unexondev

Copy link
Copy Markdown

It will save lots of developers' time since it's really hard to perform replacements for sliced old expressions without using this algorithm.

@rhelmot

rhelmot commented Jan 2, 2026

Copy link
Copy Markdown
Member

The thing that this needs in order to be merged is tests and a better docstring, as I struggled for about 15min to understand the intended purpose of this function. Of course, please also fix the failing CI passes.

As an aside, I will admit I have never found need of anything like this in my decade of working with angr and claripy - we have found that this sort of approach for constructing a memory model (I assume this is what you're doing?) is prohibitively slow and instead we use MemoryObjects in angr to denote which bytes of memory are sourced from which slices (lazily computed) of the stored data.

@rhelmot

rhelmot commented Jan 2, 2026

Copy link
Copy Markdown
Member

The easiest way to get the pre-commit check to pass is to pip install pre-commit && pre-commit install to add the pre-commit hooks to the repository. They will handle formatting automatically.

@unexondev

unexondev commented Jan 2, 2026 •

Copy link
Copy Markdown
Author

Actually you're right and the reason that I need this function is to create my own backwards slicing algorithm which does not rely on emulated CFGs.
I was doing symbolic execution backwards and replacing the variables of each symbol with its value on previous line's state so it was allowing me to resolve dependencies.
The main problem I've encountered on this algorithm is memory read/writes, which is not kept completely 'symbolic' on memory (ie. mem_FF00000... -> unable to parse its memory address on this form); so I've created a different memory model for this.
Yes, just as you said, I've used this function on my memory model. I don't know where else it can be used but I thought it can be commonly used, I may be wrong.
Sorry for taking your time, waiting for your reply :)

@rhelmot

rhelmot commented Jan 2, 2026

Copy link
Copy Markdown
Member

I'm fine with taking this PR since not every implementation of a memory model needs to be optimized for speed.

@unexondev

unexondev commented Jan 2, 2026 •

Copy link
Copy Markdown
Author

is_true_under_csts
Do you think that I should open a pull request for this function as well? I think it's not quite obvious to figure out at first look, can be helpful.

I added some tests by the way.

…hat if size after replacement changes, slices before replacement dislocates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants