Open fangshufeng opened 5 years ago
static int (*orig_strlen)(const char *__s); int my_strlen(const char *__s) { printf("===\n"); return orig_strlen(__s); } int main(int argc, const char * argv[]) { @autoreleasepool { strlen("s"); // 1 struct rebinding strlen_rebinding = { "strlen", my_strlen, (void *)&orig_strlen }; rebind_symbols((struct rebinding[1]){ strlen_rebinding }, 1); char *str = "HelloWorld"; strlen(str); }
hello : I think the old method (strlen("s")) should be called before calling the rebind_symbols method to ensure that lazy bind is already the real address, right?
strlen("s")
rebind_symbols
I'm agree with you
hello : I think the old method (
strlen("s")
) should be called before calling therebind_symbols
method to ensure that lazy bind is already the real address, right?