问题描述
来自 Scudo 页面:
Some parameters of the allocator can be defined on a per-process basis through several ways:
Statically: Define a __scudo_default_options function in the program that returns the options string to be parsed. This function must have the following prototype: extern "C" const char *__scudo_default_options().
Dynamically: Use the environment variable SCUDO_OPTIONS containing the options string to be parsed. Options defined this way override any definition made through __scudo_default_options.
我对 Android 还很陌生,有人能帮我理解在 cpp 代码中将 __scudo_default_options 之类的函数放在哪里吗,我有 MainActivity.cpp 和 MidiManager.cpp
解决方法
该函数可以位于应用程序中的任何位置,只要它可以被链接器发现。将它放在主编译单元附近可能会更好。 您想确保符号具有公开可见性。
您可以在此处参考测试中的示例: https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test_main.cpp#L23
例如。在 MainActivity.cpp 中,达到以下程度:
extern "C" __attribute__((visibility("default"))) const char *
__scudo_default_options() {
return "quarantine_size_kb=256:thread_local_quarantine_size_kb=128:"
"quarantine_max_chunk_size=512";
}