blob: a962c760b36395c398680cf4aa99e87adb7a5146 [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 \
15 rt.cpp \
16
17LOCAL_SRC_FILES_arm := arch/arm/begin.S
18LOCAL_SRC_FILES_arm64 := arch/arm64/begin.S
19LOCAL_SRC_FILES_x86 := arch/x86/begin.c
20LOCAL_SRC_FILES_x86_64 := arch/x86_64/begin.S
Dmitriy Ivanov114ff692015-01-14 11:36:38 -080021LOCAL_SRC_FILES_mips := arch/mips/begin.S linker_mips.cpp
22LOCAL_SRC_FILES_mips64 := arch/mips64/begin.S linker_mips.cpp
Colin Cross406a75d2014-03-27 10:45:57 -070023
Chih-Hung Hsieh306ea7e2015-01-22 14:05:15 -080024# -shared is used to overwrite the -Bstatic and -static
25# flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE.
26# This dynamic linker is actually a shared object linked with static libraries.
Colin Cross406a75d2014-03-27 10:45:57 -070027LOCAL_LDFLAGS := \
28 -shared \
29 -Wl,-Bsymbolic \
30 -Wl,--exclude-libs,ALL \
31
32LOCAL_CFLAGS += \
33 -fno-stack-protector \
34 -Wstrict-overflow=5 \
35 -fvisibility=hidden \
Elliott Hughesd2867962014-06-03 15:22:34 -070036 -Wall -Wextra -Wunused -Werror \
Colin Cross406a75d2014-03-27 10:45:57 -070037
Dmitriy Ivanov280d5462015-09-28 10:14:17 -070038LOCAL_CFLAGS_arm += -D__work_around_b_24465209__
39LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__
Dmitriy Ivanov9185e042015-05-15 17:53:39 -070040
Colin Cross406a75d2014-03-27 10:45:57 -070041LOCAL_CONLYFLAGS += \
42 -std=gnu99 \
43
44LOCAL_CPPFLAGS += \
Dmitriy Ivanov1649e7e2015-01-22 16:04:25 -080045 -Wold-style-cast \
Colin Cross406a75d2014-03-27 10:45:57 -070046
Christopher Ferris151da682015-01-19 11:16:52 -080047ifeq ($(TARGET_IS_64_BIT),true)
48LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
49endif
50
Colin Cross406a75d2014-03-27 10:45:57 -070051# We need to access Bionic private headers in the linker.
52LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
53
54# we don't want crtbegin.o (because we have begin.o), so unset it
55# just for this module
56LOCAL_NO_CRT := true
57# TODO: split out the asflags.
58LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
59
Ying Wangf9e147b2014-09-05 15:42:12 -070060LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Colin Cross406a75d2014-03-27 10:45:57 -070061
tony.ys_liub4474402015-07-29 18:00:22 +080062LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog
Colin Cross406a75d2014-03-27 10:45:57 -070063
Ying Wangf9e147b2014-09-05 15:42:12 -070064LOCAL_FORCE_STATIC_EXECUTABLE := true
Colin Cross406a75d2014-03-27 10:45:57 -070065
66LOCAL_MODULE := linker
67LOCAL_MODULE_STEM_32 := linker
68LOCAL_MODULE_STEM_64 := linker64
69LOCAL_MULTILIB := both
70
Dmitriy Ivanovad5e8b52014-08-14 15:46:36 -070071# Leave the symbols in the shared library so that stack unwinders can produce
72# meaningful name resolution.
73LOCAL_STRIP_MODULE := keep_symbols
74
Dmitriy Ivanov797bffb2015-03-26 16:47:18 -070075# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
76# looking up symbols in the linker by mistake.
77#
Ying Wangf9e147b2014-09-05 15:42:12 -070078# Note we are using "=" instead of ":=" to defer the evaluation,
79# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
80LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
81 --prefix-symbols=__dl_ $(linked_module)
82
83include $(BUILD_EXECUTABLE)
Dmitriy Ivanovd597d262014-05-05 16:49:04 -070084
Evgenii Stepanovd640b222015-07-10 17:54:01 -070085
Evgenii Stepanovd640b222015-07-10 17:54:01 -070086define add-linker-symlink
87$(eval _from := $(TARGET_OUT)/bin/$(1))
88$(eval _to:=$(2))
89$(_from): $(LOCAL_MODULE_MAKEFILE)
Evgenii Stepanovd11c3e52015-07-15 16:19:59 -070090 @echo "Symlink: $$@ -> $(_to)"
91 @mkdir -p $$(dir $$@)
92 @rm -rf $$@
93 $(hide) ln -sf $(_to) $$@
Evgenii Stepanovd640b222015-07-10 17:54:01 -070094endef
95
96$(eval $(call add-linker-symlink,linker_asan,linker))
97ifeq ($(TARGET_IS_64_BIT),true)
98$(eval $(call add-linker-symlink,linker_asan64,linker64))
99endif
Evgenii Stepanovd640b222015-07-10 17:54:01 -0700100
Dmitriy Ivanovd597d262014-05-05 16:49:04 -0700101include $(call first-makefiles-under,$(LOCAL_PATH))