diff --git a/src/audit_plugin.cc b/src/audit_plugin.cc index dd684b0..7862d76 100644 --- a/src/audit_plugin.cc +++ b/src/audit_plugin.cc @@ -1623,8 +1623,7 @@ static int audit_plugin_init(void *p) size_t func_in_plugin = (size_t)trampoline_dummy_func_for_mem; if (func_in_mysqld < INT_MAX && func_in_plugin > INT_MAX) { - // When the distance from a hot patch function to trampoline_mem is within 2GB, - // the minimum size of hot patching is reduced from 14 to 6. + // See comment about IndirectJump in hot_patch.cc. mmap_flags |= MAP_32BIT; use_static_memory = false; } diff --git a/src/hot_patch.cc b/src/hot_patch.cc index 046954a..5e4d7f2 100644 --- a/src/hot_patch.cc +++ b/src/hot_patch.cc @@ -228,15 +228,20 @@ static bool HookFunction(ULONG_PTR targetFunction, ULONG_PTR newFunction, ULONG_ #else #define ASM_MODE 64 enum { - // overwrite 14 bytes in targetFunction. - // jump to newFunction by WriteJump(). + // Jump64 overwrites 14 bytes in targetFunction. + // This is used when the next two jump types are not available. Jump64, - // overwrite 5 bytes in targetFunction. - // jump to newFunction by WriteJump32(). + // Jump32 overwrites 5 bytes in targetFunction. + // This is used when mysqld is a Position Independent Executable(PIE). + // The mysqld would be loaded near dynamically loaded shared libraries Jump32, - // overwrite 5 bytes in targetFunction. - // jump to a region in trampolineFunction by WriteJump32() - // and then jump to newFunction by WriteJump(). + // IndirectJump overwrites 5 bytes in targetFunction and uses + // extra 14 bytes in the region of trampolineFunction. + // This is used when mysqld isn't a Position Independent Executable(PIE). + // The mysqld is loaded at the fixed position 0x00400000. + // The region of trampolineFunction is located near the mysqld + // because it is allocated in audit_plugin_init() with the MAP_32BIT + // flag if mysqld isn't a PIE. IndirectJump, } jumpType = Jump64; #endif