A CIL Tutorial - Department of Computer Science - ETH Zürich
A CIL Tutorial - Department of Computer Science - ETH Zürich
A CIL Tutorial - Department of Computer Science - ETH Zürich
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CHAPTER 13. WHOLE-PROGRAM ANALYSIS 112<br />
extern int foo(int x);<br />
../test/tut13b.c<br />
int bar(int x)<br />
{<br />
return foo(x);<br />
}<br />
int main()<br />
{<br />
bar(1);<br />
return 0;<br />
}<br />
Now we can build this program with the whole program analysis by executing the following<br />
commands:<br />
$ ciltutcc --merge -o tut13a.o -c test/tut13a.c<br />
$ ciltutcc --merge -o tut13b.o -c test/tut13b.c<br />
$ ciltutcc --merge --enable-tut13 --tut13-out tut13.dot -o tut13 tut13a.o tut13b.o<br />
Then, we can generate a graph from the .dot le as follows:<br />
$ dot -Tpdf tut13.dot -o tut13.pdf<br />
to produce the graph in Figure 13.1. Which is the call-graph for the whole program.<br />
When doing whole program analysis, it is also necessary to override ar. For example, the<br />
command:<br />
$ ar r tut13.a tut13a.o<br />
Should be replaced with the command:<br />
$ ciltutcc --merge --mode=AR r tut13.a tut13a.o