Commit d7e528fc authored by Benoit Lize's avatar Benoit Lize Committed by Commit Bot

[base/allocator] Update allocator shim documentation.

We've been using the UCRT symbols since 2016, but the documentation was
never updated.

Change-Id: I2e4f6e7378d1be2d1091b2f0b0f04ce2113ae3c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404688Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806233}
parent b3d708da
...@@ -124,6 +124,9 @@ This stage takes care of overriding the symbols `malloc`, `free`, ...@@ -124,6 +124,9 @@ This stage takes care of overriding the symbols `malloc`, `free`,
allocator shim (next point). allocator shim (next point).
This is taken care of by the headers in `allocator_shim_override_*`. This is taken care of by the headers in `allocator_shim_override_*`.
*On Windows*: Windows' UCRT (Universal C Runtime) exports weak symbols, that we
can override in `allocator_shim_override_ucr_symbols_win.h`.
*On Linux/CrOS*: the allocator symbols are defined as exported global symbols *On Linux/CrOS*: the allocator symbols are defined as exported global symbols
in `allocator_shim_override_libc_symbols.h` (for `malloc`, `free` and friends) in `allocator_shim_override_libc_symbols.h` (for `malloc`, `free` and friends)
and in `allocator_shim_override_cpp_symbols.h` (for `operator new`, and in `allocator_shim_override_cpp_symbols.h` (for `operator new`,
...@@ -173,18 +176,6 @@ at build time and ultimately routes the allocator calls to the actual allocator ...@@ -173,18 +176,6 @@ at build time and ultimately routes the allocator calls to the actual allocator
headers in `allocator_shim_default_dispatch_to_*` files. headers in `allocator_shim_default_dispatch_to_*` files.
Appendixes
----------
**How does the Windows shim layer replace the malloc symbols?**
The mechanism for hooking LIBCMT in Windows is rather tricky. The core
problem is that by default, the Windows library does not declare malloc and
free as weak symbols. Because of this, they cannot be overridden. To work
around this, we start with the LIBCMT.LIB, and manually remove all allocator
related functions from it using the visual studio library tool. Once removed,
we can now link against the library and provide custom versions of the
allocator related functionality.
See the script `preb_libc.py` in this folder.
Related links Related links
------------- -------------
- [Unified allocator shim doc - Feb 2016][url-allocator-shim] - [Unified allocator shim doc - Feb 2016][url-allocator-shim]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment