1LOCAL_PATH := $(call my-dir)
2
3include $(CLEAR_VARS)
4
5LOCAL_SRC_FILES:= \
6    debugger.cpp \
7    dlfcn.cpp \
8    linker.cpp \
9    linker_allocator.cpp \
10    linker_sdk_versions.cpp \
11    linker_block_allocator.cpp \
12    linker_libc_support.c \
13    linker_memory.cpp \
14    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
21LOCAL_SRC_FILES_mips    := arch/mips/begin.S linker_mips.cpp
22LOCAL_SRC_FILES_mips64  := arch/mips64/begin.S linker_mips.cpp
23
24# -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.
27LOCAL_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 \
36    -Wall -Wextra -Wunused -Werror \
37
38LOCAL_CFLAGS_arm += -D__work_around_b_19059885__
39LOCAL_CFLAGS_x86 += -D__work_around_b_19059885__
40
41LOCAL_CONLYFLAGS += \
42    -std=gnu99 \
43
44LOCAL_CPPFLAGS += \
45    -std=gnu++11 \
46    -Wold-style-cast \
47
48ifeq ($(TARGET_IS_64_BIT),true)
49LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
50endif
51
52# 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
61LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
62
63LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libz liblog
64
65LOCAL_FORCE_STATIC_EXECUTABLE := true
66
67LOCAL_MODULE := linker
68LOCAL_MODULE_STEM_32 := linker
69LOCAL_MODULE_STEM_64 := linker64
70LOCAL_MULTILIB := both
71
72# Leave the symbols in the shared library so that stack unwinders can produce
73# meaningful name resolution.
74LOCAL_STRIP_MODULE := keep_symbols
75
76# 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#
79# 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)
85
86include $(call first-makefiles-under,$(LOCAL_PATH))
87