blob: c2d369e687f89810ec8cee17e7930238690f4a2a [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>
Gary King278d1572009-09-29 16:12:31 -070030# in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition
31# from the libc build
32ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
33 LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
34endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080035LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private
36
37ifeq ($(TARGET_ARCH),arm)
38LOCAL_CFLAGS += -DANDROID_ARM_LINKER
39else
40 ifeq ($(TARGET_ARCH),x86)
41 LOCAL_CFLAGS += -DANDROID_X86_LINKER
42 else
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090043 ifeq ($(TARGET_ARCH),sh)
44 LOCAL_CFLAGS += -DANDROID_SH_LINKER
45 else
46 $(error Unsupported TARGET_ARCH $(TARGET_ARCH))
47 endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080048 endif
49endif
50
51LOCAL_MODULE:= linker
52
Dima Zavin2e855792009-05-20 18:28:09 -070053LOCAL_STATIC_LIBRARIES := libcutils libc_nomalloc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080054
55#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
56
57#
58# include $(BUILD_EXECUTABLE)
59#
60# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
61# hand, as we want to insert an extra step that is not supported by the build system, and
62# is probably specific the linker only, so there's no need to modify the build system for
63# the purpose.
64
65LOCAL_MODULE_CLASS := EXECUTABLES
66LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
67
68# Executables are not prelinked.
69LOCAL_PRELINK_MODULE := false
70
71include $(BUILD_SYSTEM)/dynamic_binary.mk
72
73$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
74 $(transform-o-to-static-executable)
75 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
76 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
77
78#
79# end of BUILD_EXECUTABLE hack
80#
81
82# we don't want crtbegin.o (because we have begin.o), so unset it
83# just for this module
84$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O :=
85# This line is not strictly necessary because the dynamic linker is built
86# as a static executable, but it won't hurt if in the future we start
87# building the linker as a dynamic one.
88$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O :=