I would like to know why the .o file that we get from compiling a .c file that prints \"Hello, World!\" is larger than a Java .class file that also prints \"Hello, World!\"?
Most (as much as 90% for simple functions) of an ELF-format .o
file is junk. For a .o
file containing a single empty function body, you can expect a size breakdown like:
If you want to see the real size of compiled C code, use the size
command.