Skip to content

Commit

Permalink
tweaks to corpora, started working on asp.py and rules.md (not added …
Browse files Browse the repository at this point in the history
…yet)

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Mar 15, 2021
1 parent b9dea39 commit da5e02a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion abi-python/Dockerfile.clingo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN /bin/bash -c "conda install -y -c conda-forge mamba && \
source activate clingo-env && \
conda clean --all -y && \
pip install pyelftools && \
conda install clingo ipython"
conda install clingo ipython six"
RUN echo "source activate clingo-env" > ~/.bashrc
ENV PATH /opt/conda/envs/clingo-env/bin:${PATH}
ENTRYPOINT /bin/bash
Expand Down
10 changes: 8 additions & 2 deletions abi-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This isn't hugely complicated, but it's a place to start!

## 3. Logic Program

We next want to be able to use the start of work from [read_elf_corpus.py](read_elf_corpus.py)
We next want to be able to use the start of work from [corpus.py](corpus.py)
to dump out the corpora for each into a set of facts. Once we have these facts, we can start to work
on rules that indicate ABI compatability (or actually, not, because we can theoretically stop as soon as we find a reason
something is not). For this purpose, we are going to want to use clingo and the
Expand All @@ -91,7 +91,7 @@ $ docker build -f Dockerfile.clingo -t clingo .
```

We are going to use a combination of spack's solver [asp.py](https://github.com/spack/spack/blob/develop/lib/spack/spack/solver/asp.py)
and [read_elf_corpus.py](read_elf_corpus.py) to try and accomplish the same.
and [corpus.py](corpus.py) to try and accomplish the same.

```bash
$ docker run -it --rm -v $PWD/:/code clingo bash
Expand All @@ -109,3 +109,9 @@ result = is_compatible("simple-example/math-client", "simple-example/libmath-v1.
```

**under development**

## 4. Rules

I'm going to start out by writing out a list of rules that determine ABI compatibility,
and we will want to have these represented in actual rules for the solver.
See [rules.md](rules.md) for this development.
11 changes: 7 additions & 4 deletions abi-python/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Corpus:
variables, and nested Dwarf Information Entries
"""

def __init__(self, filename=None):
def __init__(self, filename=None, include_dwarf_entries=False):
self.elfheader = {}

# This could be split into variables / symbols
Expand All @@ -162,14 +162,17 @@ def __init__(self, filename=None):
self.dynamic_tags = {}
self.architecture = None
self._soname = None
self.read_elf_corpus(filename)
self.read_elf_corpus(filename, include_dwarf_entries)

def __str__(self):
return "[Corpus:%s]" % self.path

def __repr__(self):
return str(self)

def exists(self):
return self.path is not None and os.path.exists(self.path)

@property
def soname():
return self.dynamic_tags.get("soname")
Expand Down Expand Up @@ -220,7 +223,7 @@ def __str__(self):
def __repr__(self):
return str(self)

def get_corpus_from_elf(self, filename):
def get_corpus_from_elf(self, filename, include_dwarf_entries=False):
"""Given an elf binary, read it in with elfutils ELFFile and then
iterate through dwarf info to generate a tree.
"""
Expand All @@ -229,7 +232,7 @@ def get_corpus_from_elf(self, filename):
sys.exit("%s does not exist." % filename)

# Create a new corpus to interact with
return Corpus(filename)
return Corpus(filename, include_dwarf_entries)


def get_die_filepath(die):
Expand Down

0 comments on commit da5e02a

Please sign in to comment.