blob: c6fb49d28a56a01867a4a547f82d27169c52f266 [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
Doug Kwan1a2917c2010-01-25 10:24:50 -080016# This is aligned to 4K page boundary so that both GNU ld and gold work. Gold
17# actually produces a correct binary with starting adding 0xB0000100 but the
18# extra objcopy step to rename symbols causes the resulting binary to be misaligned
19# and unloadable. Increasing the alignment adds an extra 3840 bytes in padding
20# but switching to gold saves about 1M of space.
21LINKER_TEXT_BASE := 0xB0001000
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090022endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080023
24# The maximum size set aside for the linker, from
25# LINKER_TEXT_BASE rounded down to a megabyte.
26LINKER_AREA_SIZE := 0x01000000
27
28LOCAL_LDFLAGS := -Wl,-Ttext,$(LINKER_TEXT_BASE)
29
30LOCAL_CFLAGS += -DPRELINK
31LOCAL_CFLAGS += -DLINKER_TEXT_BASE=$(LINKER_TEXT_BASE)
32LOCAL_CFLAGS += -DLINKER_AREA_SIZE=$(LINKER_AREA_SIZE)
33
34# we need to access the Bionic private header <bionic_tls.h>
Gary King278d1572009-09-29 16:12:31 -070035# in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition
36# from the libc build
37ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
38 LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
39endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080040LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private
41
42ifeq ($(TARGET_ARCH),arm)
43LOCAL_CFLAGS += -DANDROID_ARM_LINKER
44else
45 ifeq ($(TARGET_ARCH),x86)
46 LOCAL_CFLAGS += -DANDROID_X86_LINKER
47 else
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090048 ifeq ($(TARGET_ARCH),sh)
49 LOCAL_CFLAGS += -DANDROID_SH_LINKER
50 else
51 $(error Unsupported TARGET_ARCH $(TARGET_ARCH))
52 endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053 endif
54endif
55
56LOCAL_MODULE:= linker
57
Dima Zavin2e855792009-05-20 18:28:09 -070058LOCAL_STATIC_LIBRARIES := libcutils libc_nomalloc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080059
60#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
61
62#
63# include $(BUILD_EXECUTABLE)
64#
65# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
66# hand, as we want to insert an extra step that is not supported by the build system, and
67# is probably specific the linker only, so there's no need to modify the build system for
68# the purpose.
69
70LOCAL_MODULE_CLASS := EXECUTABLES
71LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
72
73# Executables are not prelinked.
74LOCAL_PRELINK_MODULE := false
75
76include $(BUILD_SYSTEM)/dynamic_binary.mk
77
78$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
79 $(transform-o-to-static-executable)
80 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
81 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
82
83#
84# end of BUILD_EXECUTABLE hack
85#
86
87# we don't want crtbegin.o (because we have begin.o), so unset it
88# just for this module
89$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O :=
90# This line is not strictly necessary because the dynamic linker is built
91# as a static executable, but it won't hurt if in the future we start
92# building the linker as a dynamic one.
93$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O :=