Android.mk revision 70b1668a76d3b719ae690903ea790fda964a5458
1LOCAL_PATH:= $(call my-dir)
2include $(CLEAR_VARS)
3
4LOCAL_SRC_FILES:= \
5	arch/$(TARGET_ARCH)/begin.S \
6	linker.c \
7	linker_environ.c \
8	linker_format.c \
9	rt.c \
10	dlfcn.c \
11	debugger.c
12
13ifeq ($(TARGET_ARCH),sh)
14# SH-4A series virtual address range from 0x00000000 to 0x7FFFFFFF.
15LINKER_TEXT_BASE := 0x70000100
16else
17# This is aligned to 4K page boundary so that both GNU ld and gold work.  Gold
18# actually produces a correct binary with starting address 0xB0000100 but the
19# extra objcopy step to rename symbols causes the resulting binary to be misaligned
20# and unloadable.  Increasing the alignment adds an extra 3840 bytes in padding
21# but switching to gold saves about 1M of space.
22LINKER_TEXT_BASE := 0xB0001000
23endif
24
25# The maximum size set aside for the linker, from
26# LINKER_TEXT_BASE rounded down to a megabyte.
27LINKER_AREA_SIZE := 0x01000000
28
29LOCAL_LDFLAGS := -Wl,-Ttext,$(LINKER_TEXT_BASE)
30
31LOCAL_CFLAGS += -DPRELINK
32LOCAL_CFLAGS += -DLINKER_TEXT_BASE=$(LINKER_TEXT_BASE)
33LOCAL_CFLAGS += -DLINKER_AREA_SIZE=$(LINKER_AREA_SIZE)
34
35# Set LINKER_DEBUG to either 1 or 0
36#
37LOCAL_CFLAGS += -DLINKER_DEBUG=0
38
39# we need to access the Bionic private header <bionic_tls.h>
40# in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition
41# from the libc build
42ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
43    LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
44endif
45LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private
46
47ifeq ($(TARGET_ARCH),arm)
48LOCAL_CFLAGS += -DANDROID_ARM_LINKER
49else
50  ifeq ($(TARGET_ARCH),x86)
51    LOCAL_CFLAGS += -DANDROID_X86_LINKER
52  endif
53endif
54
55LOCAL_MODULE:= linker
56
57LOCAL_STATIC_LIBRARIES := libc_nomalloc
58
59#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
60
61#
62# include $(BUILD_EXECUTABLE)
63#
64# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
65# hand, as we want to insert an extra step that is not supported by the build system, and
66# is probably specific the linker only, so there's no need to modify the build system for
67# the purpose.
68
69LOCAL_MODULE_CLASS := EXECUTABLES
70LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
71
72
73include $(BUILD_SYSTEM)/dynamic_binary.mk
74
75$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
76	$(transform-o-to-static-executable)
77	@echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
78	$(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
79
80#
81# end of BUILD_EXECUTABLE hack
82#
83
84# we don't want crtbegin.o (because we have begin.o), so unset it
85# just for this module
86$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O :=
87# This line is not strictly necessary because the dynamic linker is built
88# as a static executable, but it won't hurt if in the future we start
89# building the linker as a dynamic one.
90$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O :=
91