diff --git a/core/binary.mk b/core/binary.mk
index 8d41e94..353581f 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -47,6 +47,20 @@ ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
endif
+####################################################
+## Add -pg flags if profiling is turned on
+####################################################
+ifeq ($(strip $(LOCAL_PROFILE_MODULE)),true)
+ ifeq ($(TARGET_ARCH),arm)
+ LOCAL_CFLAGS += -fno-function-sections -fno-omit-frame-pointer -pg
+ # Prevent unresolve symbol from libgmon, so add libc to
+ # LOCAL_STATIC_LIBRARIES.
+ LOCAL_STATIC_LIBRARIES += libgmon libc
+ else
+ $(warning Profiling only support arm on current implementation.)
+ endif
+endif
+
###########################################################
## Define PRIVATE_ variables from global vars
###########################################################
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index ee28f21..709ff61 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -75,6 +75,7 @@ LOCAL_COPY_HEADERS:=
LOCAL_FORCE_STATIC_EXECUTABLE:=
LOCAL_ADDITIONAL_DEPENDENCIES:=
LOCAL_PRELINK_MODULE:=
+LOCAL_PROFILE_MODULE:=
LOCAL_COMPRESS_MODULE_SYMBOLS:=
LOCAL_STRIP_MODULE:=
LOCAL_POST_PROCESS_COMMAND:=true
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 77d253f..7da2990 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -20,6 +20,9 @@ ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
endif
+# Profiling don't support shared library
+LOCAL_PROFILE_MODULE := false
+
# Put the built targets of all shared libraries in a common directory
# to simplify the link line.
OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
--
1.7.4.4
diff --git a/core/binary.mk b/core/binary.mk
index 8d41e94..b86594d 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -47,6 +47,21 @@ ifeq ($(strip $(LOCAL_NO_FDO_SUPPORT)),)
LOCAL_LDFLAGS += $(TARGET_FDO_CFLAGS)
endif
+####################################################
+## Add -pg flags if profiling is turned on
+####################################################
+ifeq ($(strip $(LOCAL_PROFILE_MODULE)),true)
+ ifeq ($(TARGET_ARCH),arm)
+ # -ffunction-sections and -fomit-frame-pointer are conflict with -pg