Elliott Hughes | 88b44fe | 2014-04-01 11:41:36 -0700 | [diff] [blame] | 1 | LOCAL_PATH := $(call my-dir) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 2 | |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 3 | include $(CLEAR_VARS) |
Colin Cross | 36ee4ab | 2014-02-12 21:58:47 -0800 | [diff] [blame] | 4 | |
Dmitriy Ivanov | b28ffc7 | 2015-10-12 16:27:32 -0700 | [diff] [blame] | 5 | LOCAL_CLANG := true |
| 6 | |
| 7 | LOCAL_SRC_FILES := \ |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 8 | debugger.cpp \ |
| 9 | dlfcn.cpp \ |
| 10 | linker.cpp \ |
Dmitriy Ivanov | 19656ce | 2015-03-10 17:48:27 -0700 | [diff] [blame] | 11 | linker_allocator.cpp \ |
Dmitriy Ivanov | c9ce70d | 2015-03-10 15:30:26 -0700 | [diff] [blame] | 12 | linker_block_allocator.cpp \ |
Dimitry Ivanov | df91dc2 | 2016-02-25 15:22:04 -0800 | [diff] [blame] | 13 | linker_dlwarning.cpp \ |
Dimitry Ivanov | ed70f6a | 2016-02-17 16:08:03 -0800 | [diff] [blame] | 14 | linker_gdb_support.cpp \ |
Dmitriy Ivanov | 1424140 | 2014-08-26 14:16:52 -0700 | [diff] [blame] | 15 | linker_libc_support.c \ |
Dmitriy Ivanov | cf1cbbe | 2015-10-19 16:57:46 -0700 | [diff] [blame] | 16 | linker_mapped_file_fragment.cpp \ |
Dmitriy Ivanov | 19656ce | 2015-03-10 17:48:27 -0700 | [diff] [blame] | 17 | linker_memory.cpp \ |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 18 | linker_phdr.cpp \ |
Dmitriy Ivanov | 42d5fcb | 2015-10-29 17:01:24 -0700 | [diff] [blame] | 19 | linker_sdk_versions.cpp \ |
Dmitriy Ivanov | a1feb11 | 2015-10-01 18:41:57 -0700 | [diff] [blame] | 20 | linker_utils.cpp \ |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 21 | rt.cpp \ |
| 22 | |
| 23 | LOCAL_SRC_FILES_arm := arch/arm/begin.S |
| 24 | LOCAL_SRC_FILES_arm64 := arch/arm64/begin.S |
| 25 | LOCAL_SRC_FILES_x86 := arch/x86/begin.c |
| 26 | LOCAL_SRC_FILES_x86_64 := arch/x86_64/begin.S |
Dmitriy Ivanov | 114ff69 | 2015-01-14 11:36:38 -0800 | [diff] [blame] | 27 | LOCAL_SRC_FILES_mips := arch/mips/begin.S linker_mips.cpp |
| 28 | LOCAL_SRC_FILES_mips64 := arch/mips64/begin.S linker_mips.cpp |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 29 | |
Chih-Hung Hsieh | 306ea7e | 2015-01-22 14:05:15 -0800 | [diff] [blame] | 30 | # -shared is used to overwrite the -Bstatic and -static |
| 31 | # flags triggered by LOCAL_FORCE_STATIC_EXECUTABLE. |
| 32 | # This dynamic linker is actually a shared object linked with static libraries. |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 33 | LOCAL_LDFLAGS := \ |
| 34 | -shared \ |
| 35 | -Wl,-Bsymbolic \ |
| 36 | -Wl,--exclude-libs,ALL \ |
| 37 | |
| 38 | LOCAL_CFLAGS += \ |
| 39 | -fno-stack-protector \ |
| 40 | -Wstrict-overflow=5 \ |
| 41 | -fvisibility=hidden \ |
Elliott Hughes | d286796 | 2014-06-03 15:22:34 -0700 | [diff] [blame] | 42 | -Wall -Wextra -Wunused -Werror \ |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 43 | |
Dmitriy Ivanov | 280d546 | 2015-09-28 10:14:17 -0700 | [diff] [blame] | 44 | LOCAL_CFLAGS_arm += -D__work_around_b_24465209__ |
| 45 | LOCAL_CFLAGS_x86 += -D__work_around_b_24465209__ |
Dmitriy Ivanov | 9185e04 | 2015-05-15 17:53:39 -0700 | [diff] [blame] | 46 | |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 47 | LOCAL_CONLYFLAGS += \ |
| 48 | -std=gnu99 \ |
| 49 | |
Pawit Pornkitprasan | 79b8d03 | 2012-11-23 12:27:25 +0700 | [diff] [blame] | 50 | ifneq ($(TARGET_NEEDS_PRELINK_SUPPORT),true) |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 51 | LOCAL_CPPFLAGS += \ |
Pawit Pornkitprasan | 79b8d03 | 2012-11-23 12:27:25 +0700 | [diff] [blame] | 52 | -Wold-style-cast |
| 53 | else |
| 54 | LOCAL_CFLAGS += -DENABLE_PRELINK_SUPPORT |
| 55 | endif |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 56 | |
Christopher Ferris | 151da68 | 2015-01-19 11:16:52 -0800 | [diff] [blame] | 57 | ifeq ($(TARGET_IS_64_BIT),true) |
| 58 | LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT |
| 59 | endif |
| 60 | |
Adrian DC | f1e0b67 | 2016-08-27 15:09:36 +0200 | [diff] [blame] | 61 | ifeq ($(TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS),true) |
| 62 | ifeq ($(user_variant),user) |
| 63 | $(error Do not enable text relocations on user builds) |
| 64 | else |
| 65 | LOCAL_CPPFLAGS += -DTARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS |
| 66 | endif |
Adrian DC | c02be8c | 2016-08-27 15:09:36 +0200 | [diff] [blame] | 67 | endif |
| 68 | |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 69 | # We need to access Bionic private headers in the linker. |
| 70 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/ |
| 71 | |
Michael Bestas | 2b0e184 | 2014-11-24 22:12:22 +0200 | [diff] [blame] | 72 | ifeq ($(TARGET_NEEDS_NON_PIE_SUPPORT),true) |
| 73 | LOCAL_CFLAGS += -DENABLE_NON_PIE_SUPPORT |
| 74 | endif |
| 75 | |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 76 | # we don't want crtbegin.o (because we have begin.o), so unset it |
| 77 | # just for this module |
| 78 | LOCAL_NO_CRT := true |
| 79 | # TODO: split out the asflags. |
| 80 | LOCAL_ASFLAGS := $(LOCAL_CFLAGS) |
| 81 | |
Ying Wang | f9e147b | 2014-09-05 15:42:12 -0700 | [diff] [blame] | 82 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 83 | |
tony.ys_liu | b447440 | 2015-07-29 18:00:22 +0800 | [diff] [blame] | 84 | LOCAL_STATIC_LIBRARIES := libc_nomalloc libziparchive libutils libbase libz liblog |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 85 | |
Ying Wang | f9e147b | 2014-09-05 15:42:12 -0700 | [diff] [blame] | 86 | LOCAL_FORCE_STATIC_EXECUTABLE := true |
Colin Cross | 406a75d | 2014-03-27 10:45:57 -0700 | [diff] [blame] | 87 | |
| 88 | LOCAL_MODULE := linker |
| 89 | LOCAL_MODULE_STEM_32 := linker |
| 90 | LOCAL_MODULE_STEM_64 := linker64 |
| 91 | LOCAL_MULTILIB := both |
| 92 | |
Dmitriy Ivanov | ad5e8b5 | 2014-08-14 15:46:36 -0700 | [diff] [blame] | 93 | # Leave the symbols in the shared library so that stack unwinders can produce |
| 94 | # meaningful name resolution. |
| 95 | LOCAL_STRIP_MODULE := keep_symbols |
| 96 | |
Dmitriy Ivanov | 797bffb | 2015-03-26 16:47:18 -0700 | [diff] [blame] | 97 | # Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb |
| 98 | # looking up symbols in the linker by mistake. |
| 99 | # |
Ying Wang | f9e147b | 2014-09-05 15:42:12 -0700 | [diff] [blame] | 100 | # Note we are using "=" instead of ":=" to defer the evaluation, |
| 101 | # because LOCAL_2ND_ARCH_VAR_PREFIX or linked_module isn't set properly yet at this point. |
| 102 | LOCAL_POST_LINK_CMD = $(hide) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) \ |
| 103 | --prefix-symbols=__dl_ $(linked_module) |
| 104 | |
| 105 | include $(BUILD_EXECUTABLE) |
Dmitriy Ivanov | d597d26 | 2014-05-05 16:49:04 -0700 | [diff] [blame] | 106 | |
Evgenii Stepanov | d640b22 | 2015-07-10 17:54:01 -0700 | [diff] [blame] | 107 | |
Evgenii Stepanov | d640b22 | 2015-07-10 17:54:01 -0700 | [diff] [blame] | 108 | define add-linker-symlink |
| 109 | $(eval _from := $(TARGET_OUT)/bin/$(1)) |
| 110 | $(eval _to:=$(2)) |
| 111 | $(_from): $(LOCAL_MODULE_MAKEFILE) |
Evgenii Stepanov | d11c3e5 | 2015-07-15 16:19:59 -0700 | [diff] [blame] | 112 | @echo "Symlink: $$@ -> $(_to)" |
| 113 | @mkdir -p $$(dir $$@) |
| 114 | @rm -rf $$@ |
| 115 | $(hide) ln -sf $(_to) $$@ |
Evgenii Stepanov | d640b22 | 2015-07-10 17:54:01 -0700 | [diff] [blame] | 116 | endef |
| 117 | |
| 118 | $(eval $(call add-linker-symlink,linker_asan,linker)) |
| 119 | ifeq ($(TARGET_IS_64_BIT),true) |
| 120 | $(eval $(call add-linker-symlink,linker_asan64,linker64)) |
| 121 | endif |
Evgenii Stepanov | d640b22 | 2015-07-10 17:54:01 -0700 | [diff] [blame] | 122 | |
Dmitriy Ivanov | d597d26 | 2014-05-05 16:49:04 -0700 | [diff] [blame] | 123 | include $(call first-makefiles-under,$(LOCAL_PATH)) |