Call each intercepted function at least once to ensure its GOT entry is updated with a correct target address
| 134 | // Call each intercepted function at least once to ensure |
| 135 | // its GOT entry is updated with a correct target address |
| 136 | static void resolveMallocSymbols() { |
| 137 | static volatile intptr_t sink; |
| 138 | |
| 139 | void* p0 = malloc(1); |
| 140 | void* p1 = realloc(p0, 2); |
| 141 | void* p2 = calloc(1, 1); |
| 142 | void* p3 = aligned_alloc(1, 1); |
| 143 | void* p4 = NULL; |
| 144 | if (posix_memalign(&p4, sizeof(void*), sizeof(void*)) == 0) free(p4); |
| 145 | free(p3); |
| 146 | free(p2); |
| 147 | free(p1); |
| 148 | |
| 149 | sink = (intptr_t)p1 + (intptr_t)p2 + (intptr_t)p3 + (intptr_t)p4; |
| 150 | } |
| 151 | |
| 152 | void MallocTracer::initialize() { |
| 153 | CodeCache* lib = Profiler::instance()->findLibraryByAddress((void*)MallocTracer::initialize); |