Hello,

Ulrich Lauther wrote:

> So, what is the difference between a call to foo() and taking its
> address, from the linkers point of view?

There is lazy binding for function symbols by default, i.e. without an
actual call the symbol will not be resolved. See man ld.so/dlopen....
Somehow taking the address of a function causes the symbol being
resolved at loading time, instead. This is what is observable.

It is mentioned in the man pages that there is never lazy binding for
variables. Lazy binding of functions could be done by some intermediate
function overwriting its own entry in a table. This trick won't work
for variables, and function pointers, without using extra function
calls for the indirection, where no function call should be in the
code.

I think you can observe all this using objdump -r/-R?

Bernd Strieder
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to