Q:

jump stubs in PE files

Recently I disassembled a DLL (written in c/c++) and noticed that there are many "jump stubs" inside the code segment. These stubs do nothing but jump to a function inside the DLL. 
eg: 
jmp foo() 
jmp foo2()
...

Why does the compiler (Visual studio 2012) include these function stubs inside the binary?
Thanks!

A:

Is there a big bunch of 0xCC bytes after all the stubs? If so, you're looking at code which has been compiled with incremental linking enabled (default for debug builds).
When compiling for incremental linking, the compiler creates a stub for every function and makes sure that all calls go via the stub. In case a function needs to be replaced with updated code, the new code can be added the end and only the jump thunk needs to be patched - all existing calls will be redirected to the new code. The extra CCs are reserved for more stubs in case new functions are added.
For more background info, see MSDN.

A:

That's how the symbols for the linker and DLL are "mashed together". It guarantees that the right kind of offset is used in the symbol table, that can be resolved by the loader that loads the DLL (and thus updates the address of the functions in the DLL), and that compiled code can still deal with for example function pointers:
void (*fptr)() = foo;

If foo is just a reference to a place in the DLL, how this address is resolved will be dependent on the loader. It's much more complex to solve that, than it is to solve the problem of "here's a foo() entry point, that gets you to the real foo". 

