blob: e0c79ed841997aa5e90d5d7d0abfa5d13b81ecd1 [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 \
Colin Cross406a75d2014-03-27 10:45:57 -070012 linker_environ.cpp \
Dmitriy Ivanov14241402014-08-26 14:16:52 -070013 linker_libc_support.c \
Dmitriy Ivanov19656ce2015-03-10 17:48:27 -070014 linker_memory.cpp \
Colin Cross406a75d2014-03-27 10:45:57 -070015 linker_phdr.cpp \
16 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 Ivanov9185e042015-05-15 17:53:39 -070039LOCAL_CFLAGS_arm += -D__work_around_b_19059885__
40LOCAL_CFLAGS_x86 += -D__work_around_b_19059885__
41
Nikola Veljkovic3cec6ec2015-05-21 18:23:55 +020042# For mips r6 (both 32bit and 64bit), GDB cannot stop on a breakpoint
43# if rt.cpp is compiled with compact branches optimization.
44# Unfortunately, we cannot turn generation of JIC compact branch off,
45# but we can add unoptimized code which will allow GDB to insert a
46# breakpoint on it.
47# TODO: Remove this after GDB is fixed.
48ifeq ($(TARGET_ARCH),mips64)
49LOCAL_CFLAGS += -fno-omit-frame-pointer
50endif
51
Colin Cross406a75d2014-03-27 10:45:57 -070052LOCAL_CONLYFLAGS += \
53 -std=gnu99 \
54
55LOCAL_CPPFLAGS += \
56 -std=gnu++11 \
Dmitriy Ivanov1649e7e2015-01-22 16:04:25 -080057 -Wold-style-cast \
Colin Cross406a75d2014-03-27 10:45:57 -070058
Christopher Ferris151da682015-01-19 11:16:52 -080059ifeq ($(TARGET_IS_64_BIT),true)
60LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
61endif
62
Colin Cross406a75d2014-03-27 10:45:57 -070063# We need to access Bionic private headers in the linker.
64LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
65
66# we don't want crtbegin.o (because we have begin.o), so unset it
67# just for this module
68LOCAL_NO_CRT := true
69# TODO: split out the asflags.
70LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
71
Ying Wangf9e147b2014-09-05 15:42:12 -070072LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Colin Cross406a75d2014-03-27 10:45:57 -070073
Simon Baldwinaef71952015-01-16 13:22:54 +000074LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libz liblog
Colin Cross406a75d2014-03-27 10:45:57 -070075
Ying Wangf9e147b2014-09-05 15:42:12 -070076LOCAL_FORCE_STATIC_EXECUTABLE := true
Colin Cross406a75d2014-03-27 10:45:57 -070077
78LOCAL_MODULE := linker
79LOCAL_MODULE_STEM_32 := linker
80LOCAL_MODULE_STEM_64 := linker64
81LOCAL_MULTILIB := both
82
Dmitriy Ivanovad5e8b52014-08-14 15:46:36 -070083# Leave the symbols in the shared library so that stack unwinders can produce
84# meaningful name resolution.
85LOCAL_STRIP_MODULE := keep_symbols
86
Dmitriy Ivanov797bffb2015-03-26 16:47:18 -070087# Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
88# looking up symbols in the linker by mistake.
89#
Ying Wangf9e147b2014-09-05 15:42:12 -070090# Note we are using "=" instead of ":=" to defer the evaluation,
91# because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point.
92LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \
93 --prefix-symbols=__dl_ $(linked_module)
94
95include $(BUILD_EXECUTABLE)
Dmitriy Ivanovd597d262014-05-05 16:49:04 -070096
97include $(call first-makefiles-under,$(LOCAL_PATH))