From 43f6bc80a29fdf326729903e9f323850e9553c69 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 9 Jul 2018 18:58:37 +0000 Subject: Prevent FX_OutOfMemoryTerminate() from being folded by the linker. Copy base::debug::Alias() from Chromium. Use it to prevent ICF from combining FX_OutOfMemoryTerminate() with similar functions. BUG=chromium:860850 Change-Id: Ifccb05c0218f86e44b9bb235847e01383ec36b3f Reviewed-on: https://pdfium-review.googlesource.com/37290 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- core/fxcrt/fx_memory.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/fxcrt/fx_memory.cpp b/core/fxcrt/fx_memory.cpp index 006e03031e..4c7b36855c 100644 --- a/core/fxcrt/fx_memory.cpp +++ b/core/fxcrt/fx_memory.cpp @@ -4,10 +4,11 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include // For abort(). + #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_safe_types.h" - -#include // For abort(). +#include "third_party/base/debug/alias.h" pdfium::base::PartitionAllocatorGeneric gArrayBufferPartitionAllocator; pdfium::base::PartitionAllocatorGeneric gGeneralPartitionAllocator; @@ -45,6 +46,11 @@ void FXMEM_DefaultFree(void* pointer) { } NEVER_INLINE void FX_OutOfMemoryTerminate() { + // Convince the linker this should not be folded with similar functions using + // Identical Code Folding. + static int make_this_function_aliased = 0xbd; + base::debug::Alias(&make_this_function_aliased); + // Termimate cleanly if we can, else crash at a specific address (0xbd). abort(); #ifndef _WIN32 -- cgit v1.2.3