i'm trying port c program compiled gnu toolchain os x default ld program not support --wrap flag, present in gnu's ld. man page of gnu's ld:
--wrap symbol use wrapper function symbol. undefined reference sym- bol resolved "__wrap_symbol". undefined reference "__real_symbol" resolved symbol. can used provide wrapper system function. wrapper function should called "__wrap_symbol". if wishes call system function, should call "__real_symbol". here trivial example: void * __wrap_malloc (size_t c) { printf ("malloc called %zu\n", c); return __real_malloc (c); } if link other code file using --wrap malloc, calls "malloc" call function "__wrap_malloc" instead. call "__real_malloc" in "__wrap_malloc" call real "malloc" function. may wish provide "__real_malloc" function well, links without --wrap option succeed. if this, should not put definition of "__real_malloc" in same file "__wrap_malloc"; if do, assembler may resolve call before linker has chance wrap "malloc". is there portable way of achieving this?
i faced similar issue never found equivalent. following workarounds can help, depending on intend achieve.
1) wrapping symbols during linking on os x
2) https://discussions.apple.com/thread/617779?start=0&tstart=0
Comments
Post a Comment