Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 908
user2458855 Avatar asked Dec 26 '22 02:12

user2458855


1 Answers

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.

like image 114
Igor Skochinsky Avatar answered Jan 02 '23 20:01

Igor Skochinsky