| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LINKER_WRAPPED_SYMBOLS_H_ | 5 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LINKER_WRAPPED_SYMBOLS_H_ |
| 6 #error This header is meant to be included only once by allocator_shim.cc | 6 #error This header is meant to be included only once by allocator_shim.cc |
| 7 #endif | 7 #endif |
| 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LINKER_WRAPPED_SYMBOLS_H_ | 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LINKER_WRAPPED_SYMBOLS_H_ |
| 9 | 9 |
| 10 // This header overrides the __wrap_X symbols when using the link-time | 10 // This header overrides the __wrap_X symbols when using the link-time |
| 11 // -Wl,-wrap,malloc shim-layer approach (see README.md). | 11 // -Wl,-wrap,malloc shim-layer approach (see README.md). |
| 12 // All references to malloc, free, etc. within the linker unit that gets the | 12 // All references to malloc, free, etc. within the linker unit that gets the |
| 13 // -wrap linker flags (e.g., libchrome.so) will be rewritten to the | 13 // -wrap linker flags (e.g., libchrome.so) will be rewritten to the |
| 14 // linker as references to __wrap_malloc, __wrap_free, which are defined here. | 14 // linker as references to __wrap_malloc, __wrap_free, which are defined here. |
| 15 | 15 |
| 16 #include "base/allocator/allocator_shim_internals.h" | 16 #include "base/allocator/allocator_shim_internals.h" |
| 17 | 17 |
| 18 extern "C" { | 18 extern "C" { |
| 19 | 19 |
| 20 SHIM_ALWAYS_EXPORT void* __wrap_calloc(size_t, size_t) | 20 SHIM_ALWAYS_EXPORT void* __wrap_calloc(size_t n, size_t size) { |
| 21 SHIM_ALIAS_SYMBOL(ShimCalloc); | 21 return ShimCalloc(n, size, nullptr); |
| 22 } |
| 22 | 23 |
| 23 SHIM_ALWAYS_EXPORT void __wrap_free(void*) | 24 SHIM_ALWAYS_EXPORT void __wrap_free(void* ptr) { |
| 24 SHIM_ALIAS_SYMBOL(ShimFree); | 25 ShimFree(ptr, nullptr); |
| 26 } |
| 25 | 27 |
| 26 SHIM_ALWAYS_EXPORT void* __wrap_malloc(size_t) | 28 SHIM_ALWAYS_EXPORT void* __wrap_malloc(size_t size) { |
| 27 SHIM_ALIAS_SYMBOL(ShimMalloc); | 29 return ShimMalloc(size, nullptr); |
| 30 } |
| 28 | 31 |
| 29 SHIM_ALWAYS_EXPORT void* __wrap_memalign(size_t, size_t) | 32 SHIM_ALWAYS_EXPORT void* __wrap_memalign(size_t align, size_t size) { |
| 30 SHIM_ALIAS_SYMBOL(ShimMemalign); | 33 return ShimMemalign(align, size, nullptr); |
| 34 } |
| 31 | 35 |
| 32 SHIM_ALWAYS_EXPORT int __wrap_posix_memalign(void**, size_t, size_t) | 36 SHIM_ALWAYS_EXPORT int __wrap_posix_memalign(void** res, |
| 33 SHIM_ALIAS_SYMBOL(ShimPosixMemalign); | 37 size_t align, |
| 38 size_t size) { |
| 39 return ShimPosixMemalign(res, align, size); |
| 40 } |
| 34 | 41 |
| 35 SHIM_ALWAYS_EXPORT void* __wrap_pvalloc(size_t) | 42 SHIM_ALWAYS_EXPORT void* __wrap_pvalloc(size_t size) { |
| 36 SHIM_ALIAS_SYMBOL(ShimPvalloc); | 43 return ShimPvalloc(size); |
| 44 } |
| 37 | 45 |
| 38 SHIM_ALWAYS_EXPORT void* __wrap_realloc(void*, size_t) | 46 SHIM_ALWAYS_EXPORT void* __wrap_realloc(void* address, size_t size) { |
| 39 SHIM_ALIAS_SYMBOL(ShimRealloc); | 47 return ShimRealloc(address, size, nullptr); |
| 48 } |
| 40 | 49 |
| 41 SHIM_ALWAYS_EXPORT void* __wrap_valloc(size_t) | 50 SHIM_ALWAYS_EXPORT void* __wrap_valloc(size_t size) { |
| 42 SHIM_ALIAS_SYMBOL(ShimValloc); | 51 return ShimValloc(size, nullptr); |
| 52 } |
| 43 | 53 |
| 44 } // extern "C" | 54 } // extern "C" |
| OLD | NEW |