blob: 6c26eb328e346faa26f7c91a0c418aed6fe26e41 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001LOCAL_PATH:= $(call my-dir)
2include $(CLEAR_VARS)
3
4LOCAL_SRC_FILES:= \
5 arch/$(TARGET_ARCH)/begin.S \
6 linker.c \
7 rt.c \
8 dlfcn.c \
9 debugger.c \
10 ba.c
11
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090012ifeq ($(TARGET_ARCH),sh)
13# SH-4A series virtual address range from 0x00000000 to 0x7FFFFFFF.
14LINKER_TEXT_BASE := 0x70000100
15else
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080016LINKER_TEXT_BASE := 0xB0000100
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090017endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080018
19# The maximum size set aside for the linker, from
20# LINKER_TEXT_BASE rounded down to a megabyte.
21LINKER_AREA_SIZE := 0x01000000
22
23LOCAL_LDFLAGS := -Wl,-Ttext,$(LINKER_TEXT_BASE)
24
25LOCAL_CFLAGS += -DPRELINK
26LOCAL_CFLAGS += -DLINKER_TEXT_BASE=$(LINKER_TEXT_BASE)
27LOCAL_CFLAGS += -DLINKER_AREA_SIZE=$(LINKER_AREA_SIZE)
28
29# we need to access the Bionic private header <bionic_tls.h>
30# in the linker
31LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private
32
33ifeq ($(TARGET_ARCH),arm)
34LOCAL_CFLAGS += -DANDROID_ARM_LINKER
35else
36 ifeq ($(TARGET_ARCH),x86)
37 LOCAL_CFLAGS += -DANDROID_X86_LINKER
38 else
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090039 ifeq ($(TARGET_ARCH),sh)
40 LOCAL_CFLAGS += -DANDROID_SH_LINKER
41 else
42 $(error Unsupported TARGET_ARCH $(TARGET_ARCH))
43 endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080044 endif
45endif
46
47LOCAL_MODULE:= linker
48
Dima Zavin2e855792009-05-20 18:28:09 -070049LOCAL_STATIC_LIBRARIES := libcutils libc_nomalloc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080050
51#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
52
53#
54# include $(BUILD_EXECUTABLE)
55#
56# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
57# hand, as we want to insert an extra step that is not supported by the build system, and
58# is probably specific the linker only, so there's no need to modify the build system for
59# the purpose.
60
61LOCAL_MODULE_CLASS := EXECUTABLES
62LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
63
64# Executables are not prelinked.
65LOCAL_PRELINK_MODULE := false
66
67include $(BUILD_SYSTEM)/dynamic_binary.mk
68
69$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
70 $(transform-o-to-static-executable)
71 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
72 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
73
74#
75# end of BUILD_EXECUTABLE hack
76#
77
78# we don't want crtbegin.o (because we have begin.o), so unset it
79# just for this module
80$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O :=
81# This line is not strictly necessary because the dynamic linker is built
82# as a static executable, but it won't hurt if in the future we start
83# building the linker as a dynamic one.
84$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O :=