/* * Copyright Rubber Duck Software P.C. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * @file src/glibc_hooks.c * @author Ioannis Koutras (joko@microlab.ntua.gr) * @date October 2013 * * @brief Override GLIBC hooks with dmmlib's functions */ #include #if (defined(__GLIBC__) && !defined(__UCLIBC__)) #include #include /* * glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible * to inconsistently reference libc's malloc(3)-compatible functions * (https://bugzilla.mozilla.org/show_bug.cgi?id=493541). * * These definitions interpose hooks in glibc. The functions are actually * passed an extra argument for the caller return address, which will be * ignored. */ void (* __free_hook)(void *ptr) = free; void *(* __malloc_hook)(size_t size) = malloc; void *(* __realloc_hook)(void *ptr, size_t size) = realloc; #ifdef WITH_MEMALIGN void *(* __memalign_hook)(size_t alignment, size_t size) = memalign; #endif /* WITH_MEMALIGN */ #endif /* __GLIBC__ && !__UCLIBC__ */