Tuesday, January 10, 2012

Building Individual File/Directory in the Kernel

You can build an individual output object file, with:
make fs/buffer.o

For directory, do this: make (directory name)

This will build JUST fs/buffer.o (if it needs rebuilding) and not the entire kernel. To force it to need re-building, use 'touch' on the associated source file:
touch fs/buffer.c

Using the same technique, you can create the preprocessed file for a C
 source file.  This is useful if you're having trouble tracking down 
macro expansion or where defines/prototypes are coming from exactly.

make fs/buffer.i

Using the same technique, you can create the assembly file for a C source file. This is useful to get an idea what actual machine instructions are generated from the C source code.
make fs/buffer.s

Another way to get the raw assembly, is to dump the object file using 'objdump'

objdump -d fs/buffer.o > fs/buffer.disassem

This will produce a disassembly of the object file, which should show how the assembly was translated into machine instructions.
If the object has been compiled with debug symbols (using '-g'), then you might get more information using the '-S' option with objdump:
objdump -S -d fs/buffer.o >fs/buffer.disassem

You can also request that the toolchain show mixed source and assembly, by passing extra flags:
make EXTRA_CFLAGS="-g -Wa,-a,-ad -fverbose-asm" fs/buffer.o >fs/buffer.mixed


No comments:

Post a Comment