0

I am new to how C++ stubs functions are used .

I went through the link How to create stub shared libraries on Linux but

1) I could not get exact complete example code in c++ in which stubs are written in C++ code . If someone can point me to exact sample example?

2) Also I was looking how exactly the stubs are replaced by exact same name shared library functions on Linux?

It will be helpful if someone can help me in my two questions.

Community
  • 1
  • 1
TechEnthusiast
  • 273
  • 4
  • 18
  • This has all the markings of an XY problem. What problem are you trying to solve. No, not the building of stub libraries, but the problem for which you believe the solution is to use stub libraries. – Sam Varshavchik Oct 01 '16 at 16:28

2 Answers2

0

The answer to your question comes with an understanding of the black art of dynamic linking. Read Ulrich Drepper's How to Write Shared Libraies for a thorough treatment of the subject.

Chris
  • 451
  • 2
  • 5
0

To answer your questions directly:

1) Stubs are not written in C++. Stubs are created by the linker automatically whenever you link a program against a shared library. They're not associated with any particular language; the linker creates them as binary/asm stubs directly from each symbol based solely on the symbol name.

2) The dynamic linker replaces/rewrites the stubs to call the actual dynamic library code that was found at runtime.

Chris Dodd
  • 119,907
  • 13
  • 134
  • 226