1LOCAL_PATH:= $(call my-dir) 2include $(CLEAR_VARS) 3 4LOCAL_SRC_FILES:= \ 5 arch/$(TARGET_ARCH)/begin.S \ 6 debugger.c \ 7 dlfcn.c \ 8 linker.cpp \ 9 linker_environ.c \ 10 linker_format.c \ 11 linker_phdr.c \ 12 rt.c 13 14LOCAL_LDFLAGS := -shared 15 16LOCAL_CFLAGS += -fno-stack-protector \ 17 -Wstrict-overflow=5 \ 18 -fvisibility=hidden \ 19 -std=gnu99 \ 20 -Wall -Wextra 21 22# Set LINKER_DEBUG to either 1 or 0 23# 24LOCAL_CFLAGS += -DLINKER_DEBUG=0 25 26# We need to access Bionic private headers in the linker... 27LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/ 28 29# ...one of which is <private/bionic_tls.h>, for which we 30# need HAVE_ARM_TLS_REGISTER. 31ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true) 32 LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER 33endif 34 35ifeq ($(TARGET_ARCH),arm) 36 LOCAL_CFLAGS += -DANDROID_ARM_LINKER 37endif 38 39ifeq ($(TARGET_ARCH),x86) 40 LOCAL_CFLAGS += -DANDROID_X86_LINKER 41endif 42 43ifeq ($(TARGET_ARCH),mips) 44 LOCAL_CFLAGS += -DANDROID_MIPS_LINKER 45endif 46 47LOCAL_MODULE:= linker 48LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 49 50LOCAL_STATIC_LIBRARIES := libc_nomalloc 51 52#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE 53 54# 55# include $(BUILD_EXECUTABLE) 56# 57# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by 58# hand, as we want to insert an extra step that is not supported by the build system, and 59# is probably specific the linker only, so there's no need to modify the build system for 60# the purpose. 61 62LOCAL_MODULE_CLASS := EXECUTABLES 63LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX) 64 65# we don't want crtbegin.o (because we have begin.o), so unset it 66# just for this module 67LOCAL_NO_CRT := true 68 69include $(BUILD_SYSTEM)/dynamic_binary.mk 70 71# See build/core/executable.mk 72$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(TARGET_GLOBAL_LD_DIRS) 73$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(TARGET_GLOBAL_LDFLAGS) 74$(linked_module): PRIVATE_TARGET_FDO_LIB := $(TARGET_FDO_LIB) 75$(linked_module): PRIVATE_TARGET_LIBGCC := $(TARGET_LIBGCC) 76$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_CRTBEGIN_DYNAMIC_O) 77$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(TARGET_CRTBEGIN_STATIC_O) 78$(linked_module): PRIVATE_TARGET_CRTEND_O := $(TARGET_CRTEND_O) 79$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O) 80 $(transform-o-to-static-executable) 81 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)" 82 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@ 83 84# 85# end of BUILD_EXECUTABLE hack 86# 87