blob: 5bdc2f901de8eb22a41913e0d1c059ff14b54d5e [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 Ivanovc9ce70d2015-03-10 15:30:26 -070010 linker_block_allocator.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070011 linker_environ.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
38LOCAL_CONLYFLAGS += \
39 -std=gnu99 \
40
41LOCAL_CPPFLAGS += \
42 -std=gnu++11 \
Dmitriy Ivanov1649e7e2015-01-22 16:04:25 -080043 -Wold-style-cast \
Colin Cross406a75d2014-03-27 10:45:57 -070044
Christopher Ferris151da682015-01-19 11:16:52 -080045ifeq ($(TARGET_IS_64_BIT),true)
46LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
47endif
48
Colin Cross406a75d2014-03-27 10:45:57 -070049# We need to access Bionic private headers in the linker.
50LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
51
52# we don't want crtbegin.o (because we have begin.o), so unset it
53# just for this module
54LOCAL_NO_CRT := true
55# TODO: split out the asflags.
56LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
57
Ying Wangf9e147b2014-09-05 15:42:12 -070058LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Colin Cross406a75d2014-03-27 10:45:57 -070059
Simon Baldwinaef71952015-01-16 13:22:54 +000060LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libz liblog
Colin Cross406a75d2014-03-27 10:45:57 -070061
Ying Wangf9e147b2014-09-05 15:42:12 -070062LOCAL_FORCE_STATIC_EXECUTABLE := true
Colin Cross406a75d2014-03-27 10:45:57 -070063
64LOCAL_MODULE := linker
65LOCAL_MODULE_STEM_32 := linker
66LOCAL_MODULE_STEM_64 := linker64
67LOCAL_MULTILIB := both
68
Dmitriy Ivanovad5e8b52014-08-14 15:46:36 -070069# Leave the symbols in the shared library so that stack unwinders can produce
70# meaningful name resolution.
71LOCAL_STRIP_MODULE := keep_symbols
72
Dmitriy Ivanov797bffb2015-03-26 16:47:18 -070073# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
74# looking up symbols in the linker by mistake.
75#
Ying Wangf9e147b2014-09-05 15:42:12 -070076# Note we are using "=" instead of ":=" to defer the evaluation,
77# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
78LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
79 --prefix-symbols=__dl_ $(linked_module)
80
81include $(BUILD_EXECUTABLE)
Dmitriy Ivanovd597d262014-05-05 16:49:04 -070082
83include $(call first-makefiles-under,$(LOCAL_PATH))