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