macaw/macaw-ppc/tests/ppc/test-indirect-calls.c
Tristan Ravitch 2092a0fd01 Add a (currently failing) test for indirect call handling
The code pointer discovery in macaw can't handle this case because we never
write the code pointers into memory - we only read them.  We really need a way
to tell macaw about code pointers.

The easy workaround is to pull all of the function entry points out of the TOC
and just seed the macaw search with them, but it would be nice to be able to
identify them from first principles.
2017-11-14 19:00:01 -08:00

30 lines
348 B
C

#include "util.h"
int g1;
int g2;
int g3;
int g4;
int f2(long l1) {
return (int)&g2;
}
int f1(long l1) {
long i1 = (long)&g1;
i1 = l1 + i1;
return (int)i1;
}
void _start() {
long i1 = (long)&g1;
long i2 = (long)&g2;
long i3 = (long)&g3;
int (*fptr)(long) = &f1;
if(i1 > i2)
fptr = &f2;
g1 = fptr(i3 + i2);
EXIT();
}