-
Notifications
You must be signed in to change notification settings - Fork 3
Dealing with function pointers
Hermann Loose edited this page Aug 26, 2013
·
3 revisions
Function::hasAddressTaken() is true for a lot of functions in my example code, a single bitcode module comprising all of libgit2.
When recursively iterating over the uses of each function (Value::use_begin and Value::use_end) and terminating at call instructions (does that make sense?) I find fewer occurrences of indirect calls than by simply iterating over all instructions in the module and looking for these calls. This is likely due to the following facts rendering the search incomplete:
- a
StoreInstitself does not have any further uses and it seems that the value stored in the pointer operand does not reflect in the pointer operand appearing in the uses of the value either- simply including the pointer operand and its uses in the search
made it prohibitively slow during testing, this can probably be made more feasible (or just more complicated …)gotcha: the original store is of course a use of the pointer operand, thus infinite looping was enjoyed … the next point is still valid though: by tracking which part of e.g. an LLVMstructcontains the function pointer and discarding any uses bygetelementptrreferring to other indices etc.
- simply including the pointer operand and its uses in the search
- TBD (just taking notes so far)
- is arithmetic involving function pointers allowed / defined? (if yes, this whole thing is probably a dead end)
- apparently allowed (with warnings) in GCC using a size of 1