-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding smeagle. Would be good to have others look at what we should do for callsites, and if it is okay to do the same thing for variables as functions * just run libabigail and spack tests * only include linked deps in experiment * add traceback print exceptions in spack experiment * ensuring we install deprecated and skip libabigail / predictions * dont disable libabigail, etc * adding example smeagle facts generator for Matt; * config command borked the config, tell user to do it manually * do not alter spack config it gets borked * start of work to update facts * pair programming with tim to fix locations, etc. Will add automated tests next * Add/asp tests (#14) * adding atoms and tests * add workflow dispatch * missing Makefile * ensure we install spliced * ensure we test truth facts if they exist * fixing bug with fact parsing structs with pointer * fixing recursive types fact generation * fixing double indirections (pointers and references w/ typedefs * fixing struc w/ struct * adding more support for arrays * adding offsets to var * add spliced using cle * prepare to run cle in spliced * refactor of smeagle to use elfcall and new algorithm! I still need to refactor the other predictors, likely tomorrow. * preparing to test libabigail since my local spack is entirely borked. Because. * re-enable smeagle * updating spliced to have compatible model for elfcall idea * account for spack ld library paths * set different_libs given mock splice * change cle location Signed-off-by: vsoch <[email protected]>
- Loading branch information
Showing
33 changed files
with
2,582 additions
and
425 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Atoms (ASP) Generation Tests | ||
on: | ||
workflow_dispatch: | ||
pull_request: [] | ||
|
||
jobs: | ||
test-basic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: Install Library | ||
run: | | ||
# archinfo, pyvex, pyelftools, then cle | ||
pip install git+https://github.com/angr/archinfo | ||
pip install git+https://github.com/angr/pyvex | ||
pip install git+https://github.com/eliben/pyelftools | ||
pip install git+https://github.com/vsoch/cle | ||
pip install pytest deepdiff | ||
pip install -e . | ||
- name: Run Examples | ||
run: | | ||
docker run -t -v $PWD:/code gcc:12.1 bash -c "cd /code && make" | ||
pytest -xs tests.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "examples/smeagle"] | ||
path = examples/smeagle | ||
url = https://github.com/buildsi/smeagle-examples |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
LIBS = ./examples/smeagle | ||
|
||
all: compile | ||
|
||
compile: $(LIBS)/* | ||
for dir in $^ ; do \ | ||
echo "Building" $${dir} ; \ | ||
$(MAKE) -C $${dir}; \ | ||
done | ||
|
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
%============================================================================ | ||
% Library Facts | ||
%============================================================================ | ||
|
||
%---------------------------------------------------------------------------- | ||
% Library: /home/vanessa/Desktop/Code/compspec/compspec-python/examples/dwarf/lib/libmath/v2/lib.v2.so | ||
%---------------------------------------------------------------------------- | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic3AddEii","Import","Integer32","%rdi"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic3AddEii","Import","Integer32","%rsi"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic3AddEii","Export","Integer32","%rax"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8SubtractEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8SubtractEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8SubtractEdd","Export","Float64","%xmm0"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Export","Float64","%xmm0"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic6DivideEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic6DivideEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("a","_ZN11MathLibrary10Arithmetic6DivideEdd","Export","Float64","%xmm0"). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
%============================================================================ | ||
% Library Facts | ||
%============================================================================ | ||
|
||
%---------------------------------------------------------------------------- | ||
% Library: /home/vanessa/Desktop/Code/compspec/compspec-python/examples/dwarf/lib/libmath/v1/lib.v1.so | ||
%---------------------------------------------------------------------------- | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic3AddEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic3AddEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic3AddEdd","Export","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8SubtractEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8SubtractEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8SubtractEdd","Export","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic8MultiplyEdd","Export","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic6DivideEdd","Import","Float64","%xmm0"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic6DivideEdd","Import","Float64","%xmm1"). | ||
abi_typelocation("b","_ZN11MathLibrary10Arithmetic6DivideEdd","Export","Float64","%xmm0"). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Spliced to print Asp | ||
|
||
## Single Facts | ||
|
||
This is an example of using spliced just to print asp facts to the terminal, | ||
which is an easy thing it can do! We start with [smeagle-output.json](smeagle-output.json), | ||
load it, and then use the same SmeagleRunner to print facts to the terminal. | ||
|
||
```python | ||
import spliced.utils as utils | ||
import spliced.predict.smeagle as smeagle | ||
|
||
cli = smeagle.SmeagleRunner() | ||
data = utils.read_json("smeagle-output.json") | ||
|
||
# We can accept a path (will run smeagle) or the raw data, so | ||
# it is important to provide a kwarg here! | ||
cli.generate_facts(data=data) | ||
``` | ||
```bash | ||
%============================================================================ | ||
% Library Facts | ||
%============================================================================ | ||
|
||
%---------------------------------------------------------------------------- | ||
% Library: libtest.so | ||
%---------------------------------------------------------------------------- | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","a","Integer","%rdi","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","b","Integer","%rsi","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","c","Integer","%rdx","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","d","Integer","%rcx","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","e","Integer","%r8","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","f","Integer","framebase+8","import","0"). | ||
``` | ||
|
||
This is provided in a little [generate-facts.py](generate-facts.py) courtesy script. | ||
|
||
```bash | ||
$ python generate-facts.py smeagle-output.json | ||
``` | ||
```bash | ||
%============================================================================ | ||
% Library Facts | ||
%============================================================================ | ||
|
||
%---------------------------------------------------------------------------- | ||
% Library: libtest.so | ||
%---------------------------------------------------------------------------- | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","a","Integer","%rdi","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","b","Integer","%rsi","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","c","Integer","%rdx","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","d","Integer","%rcx","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","e","Integer","%r8","import","0"). | ||
abi_typelocation("libtest.so","_Z7bigcallllllln","f","Integer","framebase+8","import","0"). | ||
``` | ||
|
||
|
||
## Simulating a Solve | ||
|
||
### Stability Test | ||
If you want to simulate a stability test, first run the script, providing two libs as "A" (original) | ||
and "B" (comparison). Here are examples (both ways) with our math library: | ||
|
||
```bash | ||
$ python stability-test.py ../../../compspec/compspec-python/examples/dwarf/lib/libmath/v1/lib.v1.so ../../../compspec/compspec-python/examples/dwarf/lib/libmath/v2/lib.v2.so | ||
|
||
Missing Imports | ||
--------------- | ||
_ZN11MathLibrary10Arithmetic3AddEdd Float64 %xmm0 | ||
_ZN11MathLibrary10Arithmetic3AddEdd Float64 %xmm1 | ||
|
||
Missing Exports | ||
--------------- | ||
_ZN11MathLibrary10Arithmetic3AddEdd Float64 %xmm0 | ||
``` | ||
```bash | ||
$ python stability-test.py ../../../compspec/compspec-python/examples/dwarf/lib/libmath/v2/lib.v2.so ../../../compspec/compspec-python/examples/dwarf/lib/libmath/v1/lib.v1.so | ||
|
||
Missing Imports | ||
--------------- | ||
_ZN11MathLibrary10Arithmetic3AddEii Integer32 %rdi | ||
_ZN11MathLibrary10Arithmetic3AddEii Integer32 %rsi | ||
|
||
Missing Exports | ||
--------------- | ||
_ZN11MathLibrary10Arithmetic3AddEii Integer32 %rax | ||
``` | ||
|
||
This will generate A.asp and B.asp. To run this more manually with clingo, you can copy your stability model here: | ||
|
||
```bash | ||
$ cp ../../spliced/predict/smeagle/lp/stability.lp . | ||
``` | ||
and run these in a clingo container (or via a local clingo install) like: | ||
|
||
```bash | ||
$ docker run -v $PWD:/data --rm -it ghcr.io/autamus/clingo bash | ||
$ cd /data | ||
$ clingo --out-ifs=\\n A.asp B.asp stability.lp | ||
``` | ||
And you'll get the same answer: | ||
|
||
```bash | ||
clingo version 5.5.1 | ||
Reading from A.asp ... | ||
Solving... | ||
Answer: 1 | ||
missing_exports("_ZN11MathLibrary10Arithmetic3AddEii","Integer32","%rax") | ||
missing_imports("_ZN11MathLibrary10Arithmetic3AddEii","Integer32","%rdi") | ||
missing_imports("_ZN11MathLibrary10Arithmetic3AddEii","Integer32","%rsi") | ||
SATISFIABLE | ||
|
||
Models : 1 | ||
Calls : 1 | ||
Time : 0.003s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) | ||
CPU Time : 0.003s | ||
``` | ||
|
||
### Compatible Test | ||
|
||
This is the test that smeagle is doing for our experiment, since we are loading | ||
all symbols within a space for a library A and dependencies (B) (to the scoped set we | ||
can find). | ||
|
||
|
||
```bash | ||
$ docker run -v $PWD:/data --rm -it ghcr.io/autamus/clingo bash | ||
$ cd /data | ||
$ clingo --out-ifs=\\n ccache-swig.asp compatible.lp | ||
``` | ||
|
Oops, something went wrong.