To generate a call graph: 1. Fetch, build, and install the 'egypt' Perl package from: http://www.gson.org/egypt/ wget http://www.gson.org/egypt/download/egypt-1.10.tar.gz tar -xf egypt-1.10.tar.gz cd egypt-1.10/ perl Makefile.PL make sudo make install Program is installed to /usr/local/bin/egypt 2. Install GraphViz sudo apt install graphviz 3. Modify the target source's Makefile to include the gcc option: -fdump-rtl-expand In the Linux source-tree this can be done on a per-directory basis to target subsystems. E.g. for ecryptfs: diff --git a/fs/ecryptfs/Makefile b/fs/ecryptfs/Makefile index 49678a6..f28fd7b 100644 --- a/fs/ecryptfs/Makefile +++ b/fs/ecryptfs/Makefile @@ -1,7 +1,7 @@ # # Makefile for the Linux eCryptfs # +ccflags-y += -fdump-rtl-expand obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o ecryptfs-y := dentry.o file.o inode.o main.o super.o mmap.o read_write.o \ 4. (Re)build the kernel make O=../builds/amd64/ bzImage which will generate .expand files where-ever the gcc flag is used ls fs/ecryptfs/*.expand crypto.c.192r.expand dentry.c.192r.expand inode.c.192r.expand kthread.c.192r.expand messaging.c.192r.expand mmap.c.192r.expand super.c.192r.expand debug.c.192r.expand file.c.192r.expand keystore.c.192r.expand main.c.192r.expand miscdev.c.192r.expand read_write.c.192r.expand 5. Generate the structured data and pass it through graphviz to generate a directed graph in SVG egypt *.expand | dot -Grankdir=LR -Tsvg -o ecryptfs_callgraph.svg