BTIGhidra icon indicating copy to clipboard operation
BTIGhidra copied to clipboard

No types on a simple example

Open jaybosamiya opened this issue 1 year ago • 0 comments

When testing BTIGhidra on a simple example (below), the types in Ghidra are not updated. It does work fine on the file in DEMO.md, so my setup is correct and I'm following the correct steps, but nonetheless there is no output on the following simple example (which is similar to the one in the DEMO.md, but simplified):

I compiled this file (gcc -o test-linked-list-with-main test-linked-list-with-main.c):

struct Node {
	struct Node* next;
	int data;
};

int getlast(struct Node* n) {
	struct Node* nxt = n->next;
	while(nxt != 0) {
		n = nxt;
		nxt = n->next;
	}
	return n->data;
}

int main() {}

(Sidenote: I needed to add the trivial main to prevent it from crashing immediately. See https://github.com/trailofbits/binary_type_inference/issues/67 for the issue I opened on it crashing on .o files)

I also used "Save to debug directory" to get all the files produced in /tmp, and executed binary_to_types to get:

$ binary_to_types ./test-linked-list-with-main /tmp/ir.json /tmp/lattice.json /tmp/additional_constraints.pb /tmp/interesting_tids.pb --out foo
Num generated recursive variables: 0

$ wc -c foo
1354 foo

Since the output foo is non-trivially sized, it appears that binary_to_types has actually done some analysis on it, which is why I'm opening this issue here, rather than opening it on the binary_type_inference repo. Nonetheless, it does say that it generated 0 recursive variables, which is also surprising, so it is unclear where the issue itself comes from.

All relevant files attached for debugging: test-linked-list-with-main-debug-files.zip

jaybosamiya avatar Aug 20 '24 21:08 jaybosamiya