blob: bd220da45214787a816d7b1dbe76392101b5fee4 [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 \
David 'Digit' Turnerbe575592010-12-16 19:52:02 +01007 linker_environ.c \
David 'Digit' Turner5c734642010-01-20 12:36:51 -08008 linker_format.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08009 rt.c \
10 dlfcn.c \
Shih-wei Liao48527c32011-07-17 12:32:43 -070011 debugger.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080012
jerpeleadcd95402011-11-18 17:06:35 +020013ifneq ($(TARGET_USES_2G_VM_SPLIT),true)
Doug Kwan1a2917c2010-01-25 10:24:50 -080014# This is aligned to 4K page boundary so that both GNU ld and gold work. Gold
Doug Kwan90f82e52010-01-25 11:09:31 -080015# actually produces a correct binary with starting address 0xB0000100 but the
Doug Kwan1a2917c2010-01-25 10:24:50 -080016# extra objcopy step to rename symbols causes the resulting binary to be misaligned
17# and unloadable. Increasing the alignment adds an extra 3840 bytes in padding
18# but switching to gold saves about 1M of space.
19LINKER_TEXT_BASE := 0xB0001000
jerpeleadcd95402011-11-18 17:06:35 +020020else
21LINKER_TEXT_BASE := 0x70001000
22LOCAL_CFLAGS += -DVM_SPLIT_2G
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090023endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080024
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
David 'Digit' Turner5c734642010-01-20 12:36:51 -080035# Set LINKER_DEBUG to either 1 or 0
36#
37LOCAL_CFLAGS += -DLINKER_DEBUG=0
38
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080039# we need to access the Bionic private header <bionic_tls.h>
Gary King278d1572009-09-29 16:12:31 -070040# 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
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080045LOCAL_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 else
Shin-ichiro KAWASAKIad13c572009-11-06 10:36:37 +090053 ifeq ($(TARGET_ARCH),sh)
54 LOCAL_CFLAGS += -DANDROID_SH_LINKER
55 else
56 $(error Unsupported TARGET_ARCH $(TARGET_ARCH))
57 endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080058 endif
59endif
andrew.boren6e4341b2011-11-25 18:34:55 -070060ifeq ($(TARGET_HAVE_TEGRA_ERRATA_657451),true)
61 LOCAL_CFLAGS += -DHAVE_TEGRA_ERRATA_657451
62endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080063
64LOCAL_MODULE:= linker
65
David 'Digit' Turner8bff9a32010-06-10 18:29:33 -070066LOCAL_STATIC_LIBRARIES := libc_nomalloc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080067
68#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
69
70#
71# include $(BUILD_EXECUTABLE)
72#
73# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
74# hand, as we want to insert an extra step that is not supported by the build system, and
75# is probably specific the linker only, so there's no need to modify the build system for
76# the purpose.
77
78LOCAL_MODULE_CLASS := EXECUTABLES
79LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
80
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080081
82include $(BUILD_SYSTEM)/dynamic_binary.mk
83
84$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
85 $(transform-o-to-static-executable)
86 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
87 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
88
89#
90# end of BUILD_EXECUTABLE hack
91#
92
93# we don't want crtbegin.o (because we have begin.o), so unset it
94# just for this module
95$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O :=
96# This line is not strictly necessary because the dynamic linker is built
David 'Digit' Turnerbe575592010-12-16 19:52:02 +010097# as a static executable, but it won't hurt if in the future we start
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080098# building the linker as a dynamic one.
99$(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O :=