Skip to content

Commit

Permalink
do not remove struct fields omg
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Jun 15, 2022
1 parent 807dfbf commit 2a0d8a8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cle/backends/elf/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def parse_structure_type(self, die, flags=None):
continue

field = self.parse_member(child)

print(field)
# Our default is import but Matt wants struct param fields to be exports
if "direction" not in field or field["direction"] != "both":
field["direction"] = "export"
Expand Down
5 changes: 3 additions & 2 deletions cle/backends/elf/parser/AMD64/classifier.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .register_class import RegisterClass
from .allocators import RegisterAllocator
from ...types import ClassType
import copy


class Classification:
Expand Down Expand Up @@ -268,7 +269,7 @@ def classify_aggregate(
ebs = []
cur = Eightbyte()
added = False
fields = typ.get("fields", [])
fields = copy.deepcopy(typ.get("fields", []))
while fields:
f = fields.pop(0)
field = types.get(f.get("type"))
Expand All @@ -277,7 +278,7 @@ def classify_aggregate(

# If we have another aggregate (I'm not sure this is correct)
if field.get("class") in ["Union", "Struct", "Class"]:
fields = field.get("fields", []) + fields
fields = copy.deepcopy(field.get("fields", [])) + fields
continue

added = False
Expand Down
13 changes: 12 additions & 1 deletion examples/array/facts.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,18 @@
"name": "Foo",
"size": 36,
"class": "Struct",
"fields": []
"fields": [
{
"name": "x",
"type": "1fd8c01bdca094933f920b41375cfed0",
"direction": "export"
},
{
"name": "c",
"type": "a577ccf4dfcba55c299a5e6b401951d1",
"direction": "export"
}
]
}
}
}
5 changes: 5 additions & 0 deletions examples/class-inheritance/facts.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
"size": 16,
"class": "Struct",
"fields": [
{
"name": "unknown",
"type": "308e7c0c4ed84449b2850937c1b6329e",
"direction": "export"
},
{
"name": "unknown",
"type": "3b92f99410a6dae32be62e61c114908a",
Expand Down
7 changes: 6 additions & 1 deletion examples/function-as-parameter/facts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3439,7 +3439,12 @@
"name": "exception_ptr",
"size": 8,
"class": "Class",
"fields": []
"fields": [
{
"name": "_M_exception_object",
"type": "bd0f95a6606dcd8b66497841cf8daa03"
}
]
},
"f35c8460d65ceaaadef5f007642685f2": {
"class": "Pointer",
Expand Down
1 change: 1 addition & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# TODO we will want to look at lib name if they auto load and not add to corpus
# OR we will want to generate separate corpora
# TODO debug why struct fields removed from array...
import cle

# TODOs slow to build: omega-h, strumpack (openblas) fortrilinos
Expand Down

0 comments on commit 2a0d8a8

Please sign in to comment.