MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / resolveMallocSymbols

Function resolveMallocSymbols

src/mallocTracer.cpp:136–150  ·  view source on GitHub ↗

Call each intercepted function at least once to ensure its GOT entry is updated with a correct target address

Source from the content-addressed store, hash-verified

134// Call each intercepted function at least once to ensure
135// its GOT entry is updated with a correct target address
136static 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
152void MallocTracer::initialize() {
153 CodeCache* lib = Profiler::instance()->findLibraryByAddress((void*)MallocTracer::initialize);

Callers 1

initializeMethod · 0.85

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected