ld --wrap option
Mon Dec 9 23:53:00 GMT 2013
I am using the ld --wrap option of a gcc-based toolchain, and the option is working as advertised, except for the cases where wrapped functions are called from within the modules in which they (the real) functions are defined. An ojbdump of the final executable disassembly shows all calls from outside of the defining module correctly resolve to __wrap_function_name, (which is currently written to then call __real_function_name to complete the execution threads.) However, for any particular function_name, all calls to function_name from within its defining module go directly to the target, "real", function, bypassing the wrapper construct.
Is there a gcc compiler/assembler/linker option to force all symbols to be undefined until link stage, which I believe would then cause all such bypassing calls to correctly link to the wrapper functions? I've tried --undefined=function_name; that didn't work; the intramodules direct calls still occurred. I also tried --defsym=function_name=__wrap_function_name, and that resulted in an infinitely loop branch-to-self in the target function.
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
More information about the Gcc-help