blob: 585a73809a5a83867a0bee0ad67c9678aab360d6 [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)
Colin Cross36ee4ab2014-02-12 21:58:47 -08004
Colin Cross406a75d2014-03-27 10:45:57 -07005LOCAL_SRC_FILES:= \
6 debugger.cpp \
7 dlfcn.cpp \
8 linker.cpp \
Dmitriy Ivanov19656ce2015-03-10 17:48:27 -07009 linker_allocator.cpp \
Dmitriy Ivanov79fd6682015-05-21 17:43:49 -070010 linker_sdk_versions.cpp \
Dmitriy Ivanovc9ce70d2015-03-10 15:30:26 -070011 linker_block_allocator.cpp \
Dmitriy Ivanov14241402014-08-26 14:16:52 -070012 linker_libc_support.c \
Dmitriy Ivanov19656ce2015-03-10 17:48:27 -070013 linker_memory.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070014 linker_phdr.cpp \
Dmitriy Ivanova1feb112015-10-01 18:41:57 -070015 linker_utils.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070016 rt.cpp \
17
18LOCAL_SRC_FILES_arm := arch/arm/begin.S
19LOCAL_SRC_FILES_arm64 := arch/arm64/begin.S
20LOCAL_SRC_FILES_x86 := arch/x86/begin.c
21LOCAL_SRC_FILES_x86_64 := arch/x86_64/begin.S
Dmitriy Ivanov114ff692015-01-14 11:36:38 -080022LOCAL_SRC_FILES_mips := arch/mips/begin.S linker_mips.cpp
23LOCAL_SRC_FILES_mips64 := arch/mips64/begin.S linker_mips.cpp
Colin Cross406a75d2014-03-27 10:45:57 -070024
Chih-Hung Hsieh306ea7e2015-01-22 14:05:15 -080025# -shared is used to overwrite the -Bstatic and -static
26# flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
27# This dynamic linker is actually a shared object linked with static libraries.
Colin Cross406a75d2014-03-27 10:45:57 -070028LOCAL_LDFLAGS := \
29 -shared \
30 -Wl,-Bsymbolic \
31 -Wl,--exclude-libs,ALL \
32
33LOCAL_CFLAGS += \
34 -fno-stack-protector \
35 -Wstrict-overflow=5 \
36 -fvisibility=hidden \
Elliott Hughesd2867962014-06-03 15:22:34 -070037 -Wall -Wextra -Wunused -Werror \
Colin Cross406a75d2014-03-27 10:45:57 -070038
Dmitriy Ivanov280d5462015-09-28 10:14:17 -070039LOCAL_CFLAGS_arm += -D__work_around_b_24465209__
40LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__
Dmitriy Ivanov9185e042015-05-15 17:53:39 -070041
Colin Cross406a75d2014-03-27 10:45:57 -070042LOCAL_CONLYFLAGS += \
43 -std=gnu99 \
44
45LOCAL_CPPFLAGS += \
Dmitriy Ivanov1649e7e2015-01-22 16:04:25 -080046 -Wold-style-cast \
Colin Cross406a75d2014-03-27 10:45:57 -070047
Christopher Ferris151da682015-01-19 11:16:52 -080048ifeq ($(TARGET_IS_64_BIT),true)
49LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
50endif
51
Colin Cross406a75d2014-03-27 10:45:57 -070052# We need to access Bionic private headers in the linker.
53LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
54
55# we don't want crtbegin.o (because we have begin.o), so unset it
56# just for this module
57LOCAL_NO_CRT := true
58# TODO: split out the asflags.
59LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
60
Ying Wangf9e147b2014-09-05 15:42:12 -070061LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Colin Cross406a75d2014-03-27 10:45:57 -070062
tony.ys_liub4474402015-07-29 18:00:22 +080063LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog
Colin Cross406a75d2014-03-27 10:45:57 -070064
Ying Wangf9e147b2014-09-05 15:42:12 -070065LOCAL_FORCE_STATIC_EXECUTABLE := true
Colin Cross406a75d2014-03-27 10:45:57 -070066
67LOCAL_MODULE := linker
68LOCAL_MODULE_STEM_32 := linker
69LOCAL_MODULE_STEM_64 := linker64
70LOCAL_MULTILIB := both
71
Dmitriy Ivanovad5e8b52014-08-14 15:46:36 -070072# Leave the symbols in the shared library so that stack unwinders can produce
73# meaningful name resolution.
74LOCAL_STRIP_MODULE := keep_symbols
75
Dmitriy Ivanov797bffb2015-03-26 16:47:18 -070076# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
77# looking up symbols in the linker by mistake.
78#
Ying Wangf9e147b2014-09-05 15:42:12 -070079# Note we are using "=" instead of ":=" to defer the evaluation,
80# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
81LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
82 --prefix-symbols=__dl_ $(linked_module)
83
84include $(BUILD_EXECUTABLE)
Dmitriy Ivanovd597d262014-05-05 16:49:04 -070085
Evgenii Stepanovd640b222015-07-10 17:54:01 -070086
Evgenii Stepanovd640b222015-07-10 17:54:01 -070087define add-linker-symlink
88$(eval _from := $(TARGET_OUT)/bin/$(1))
89$(eval _to:=$(2))
90$(_from): $(LOCAL_MODULE_MAKEFILE)
Evgenii Stepanovd11c3e52015-07-15 16:19:59 -070091 @echo "Symlink: $$@ -> $(_to)"
92 @mkdir -p $$(dir $$@)
93 @rm -rf $$@
94 $(hide) ln -sf $(_to) $$@
Evgenii Stepanovd640b222015-07-10 17:54:01 -070095endef
96
97$(eval $(call add-linker-symlink,linker_asan,linker))
98ifeq ($(TARGET_IS_64_BIT),true)
99$(eval $(call add-linker-symlink,linker_asan64,linker64))
100endif
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700101
Dmitriy Ivanovd597d262014-05-05 16:49:04 -0700102include $(call first-makefiles-under,$(LOCAL_PATH))