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