From f857211675dcfe7abd311e4a7bef6d1685fb4a93 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Wed, 13 Jul 2016 10:24:06 -0700 Subject: [PATCH] Use trivial types to avoid calls to new for globals To avoid initialization ordering problem avoid constructing non-trivial global objects for linker_logger. This patch also adds explicit check for bloc_size_ on alloc Change-Id: I2cb3b13a10b7fac1f52a20038af77266d3e1da96 --- linker/linker_allocator.cpp | 3 +++ linker/linker_logger.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/linker/linker_allocator.cpp b/linker/linker_allocator.cpp index 57811d861..7deddea4a 100644 --- a/linker/linker_allocator.cpp +++ b/linker/linker_allocator.cpp @@ -15,6 +15,7 @@ */ #include "linker_allocator.h" +#include "linker_debug.h" #include "linker.h" #include @@ -73,6 +74,8 @@ LinkerSmallObjectAllocator::LinkerSmallObjectAllocator() : type_(0), block_size_(0), free_pages_cnt_(0), free_blocks_list_(nullptr) {} void* LinkerSmallObjectAllocator::alloc() { + CHECK(block_size_ != 0); + if (free_blocks_list_ == nullptr) { alloc_page(); } diff --git a/linker/linker_logger.cpp b/linker/linker_logger.cpp index 7499a83fd..78f14d477 100644 --- a/linker/linker_logger.cpp +++ b/linker/linker_logger.cpp @@ -41,7 +41,7 @@ LinkerLogger g_linker_logger; static const char* kSystemLdDebugProperty = "debug.ld.all"; -static const std::string kLdDebugPropertyPrefix = "debug.ld.app."; +static const char* kLdDebugPropertyPrefix = "debug.ld.app."; static const char* kOptionErrors = "dlerror"; static const char* kOptionDlopen = "dlopen";