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