blob: b940690af96a0f02c355a15004db13dd718de284 [file] [log] [blame]
Elliott Hughes88b44fe2014-04-01 11:41:36 -07001LOCAL_PATH := $(call my-dir)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08002
Colin Cross406a75d2014-03-27 10:45:57 -07003include $(CLEAR_VARS)
Dimitry Ivanovaa9cb262016-02-16 10:13:42 -08004LOCAL_CLANG := true
5
6LOCAL_MODULE := liblinker_malloc
7
8LOCAL_SRC_FILES := \
9 linker_allocator.cpp \
10 linker_memory.cpp
11
12# We need to access Bionic private headers in the linker.
13LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
14
15include $(BUILD_STATIC_LIBRARY)
16
17include $(CLEAR_VARS)
Colin Cross36ee4ab2014-02-12 21:58:47 -080018
Dmitriy Ivanovb28ffc72015-10-12 16:27:32 -070019LOCAL_CLANG := true
20
21LOCAL_SRC_FILES := \
Colin Cross406a75d2014-03-27 10:45:57 -070022 debugger.cpp \
23 dlfcn.cpp \
24 linker.cpp \
Dmitriy Ivanovc9ce70d2015-03-10 15:30:26 -070025 linker_block_allocator.cpp \
Dmitriy Ivanov14241402014-08-26 14:16:52 -070026 linker_libc_support.c \
Dmitriy Ivanovcf1cbbe2015-10-19 16:57:46 -070027 linker_mapped_file_fragment.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070028 linker_phdr.cpp \
Dmitriy Ivanov42d5fcb2015-10-29 17:01:24 -070029 linker_sdk_versions.cpp \
Dmitriy Ivanova1feb112015-10-01 18:41:57 -070030 linker_utils.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070031 rt.cpp \
32
33LOCAL_SRC_FILES_arm := arch/arm/begin.S
34LOCAL_SRC_FILES_arm64 := arch/arm64/begin.S
35LOCAL_SRC_FILES_x86 := arch/x86/begin.c
36LOCAL_SRC_FILES_x86_64 := arch/x86_64/begin.S
Dmitriy Ivanov114ff692015-01-14 11:36:38 -080037LOCAL_SRC_FILES_mips := arch/mips/begin.S linker_mips.cpp
38LOCAL_SRC_FILES_mips64 := arch/mips64/begin.S linker_mips.cpp
Colin Cross406a75d2014-03-27 10:45:57 -070039
Chih-Hung Hsieh306ea7e2015-01-22 14:05:15 -080040# -shared is used to overwrite the -Bstatic and -static
41# flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
42# This dynamic linker is actually a shared object linked with static libraries.
Colin Cross406a75d2014-03-27 10:45:57 -070043LOCAL_LDFLAGS := \
44 -shared \
45 -Wl,-Bsymbolic \
46 -Wl,--exclude-libs,ALL \
47
48LOCAL_CFLAGS += \
49 -fno-stack-protector \
50 -Wstrict-overflow=5 \
51 -fvisibility=hidden \
Elliott Hughesd2867962014-06-03 15:22:34 -070052 -Wall -Wextra -Wunused -Werror \
Colin Cross406a75d2014-03-27 10:45:57 -070053
Dmitriy Ivanov280d5462015-09-28 10:14:17 -070054LOCAL_CFLAGS_arm += -D__work_around_b_24465209__
55LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__
Dmitriy Ivanov9185e042015-05-15 17:53:39 -070056
Colin Cross406a75d2014-03-27 10:45:57 -070057LOCAL_CONLYFLAGS += \
58 -std=gnu99 \
59
60LOCAL_CPPFLAGS += \
Dmitriy Ivanov1649e7e2015-01-22 16:04:25 -080061 -Wold-style-cast \
Colin Cross406a75d2014-03-27 10:45:57 -070062
Christopher Ferris151da682015-01-19 11:16:52 -080063ifeq ($(TARGET_IS_64_BIT),true)
64LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
65endif
66
Colin Cross406a75d2014-03-27 10:45:57 -070067# We need to access Bionic private headers in the linker.
68LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
69
70# we don't want crtbegin.o (because we have begin.o), so unset it
71# just for this module
72LOCAL_NO_CRT := true
73# TODO: split out the asflags.
74LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
75
Ying Wangf9e147b2014-09-05 15:42:12 -070076LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Colin Cross406a75d2014-03-27 10:45:57 -070077
Dimitry Ivanov3bbeca72016-02-15 19:19:35 +000078LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog
Colin Cross406a75d2014-03-27 10:45:57 -070079
Dimitry Ivanovaa9cb262016-02-16 10:13:42 -080080# Important: The liblinker_malloc should be the last library in the list
81# to overwrite any other malloc implementations by other static libraries.
82LOCAL_STATIC_LIBRARIES += liblinker_malloc
83
Ying Wangf9e147b2014-09-05 15:42:12 -070084LOCAL_FORCE_STATIC_EXECUTABLE := true
Colin Cross406a75d2014-03-27 10:45:57 -070085
86LOCAL_MODULE := linker
87LOCAL_MODULE_STEM_32 := linker
88LOCAL_MODULE_STEM_64 := linker64
89LOCAL_MULTILIB := both
90
Dmitriy Ivanovad5e8b52014-08-14 15:46:36 -070091# Leave the symbols in the shared library so that stack unwinders can produce
92# meaningful name resolution.
93LOCAL_STRIP_MODULE := keep_symbols
94
Dmitriy Ivanov797bffb2015-03-26 16:47:18 -070095# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
96# looking up symbols in the linker by mistake.
97#
Ying Wangf9e147b2014-09-05 15:42:12 -070098# Note we are using "=" instead of ":=" to defer the evaluation,
99# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
100LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
101 --prefix-symbols=__dl_ $(linked_module)
102
103include $(BUILD_EXECUTABLE)
Dmitriy Ivanovd597d262014-05-05 16:49:04 -0700104
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700105
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700106define add-linker-symlink
107$(eval _from := $(TARGET_OUT)/bin/$(1))
108$(eval _to:=$(2))
109$(_from): $(LOCAL_MODULE_MAKEFILE)
Evgenii Stepanovd11c3e52015-07-15 16:19:59 -0700110 @echo "Symlink: $$@ -> $(_to)"
111 @mkdir -p $$(dir $$@)
112 @rm -rf $$@
113 $(hide) ln -sf $(_to) $$@
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700114endef
115
116$(eval $(call add-linker-symlink,linker_asan,linker))
117ifeq ($(TARGET_IS_64_BIT),true)
118$(eval $(call add-linker-symlink,linker_asan64,linker64))
119endif
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700120
Dmitriy Ivanovd597d262014-05-05 16:49:04 -0700121include $(call first-makefiles-under,$(LOCAL_PATH))