blob: d207f955fc35fc95a393cdf8022577b7b838afb2 [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 \
David 'Digit' Turnerc1bd5592012-06-19 11:21:29 +02009 linker_phdr.c \
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080010 rt.c \
11 dlfcn.c \
Shih-wei Liao48527c32011-07-17 12:32:43 -070012 debugger.c
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080013
Nick Kralevich468319c2011-11-11 15:53:17 -080014LOCAL_LDFLAGS := -shared
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080015
Nick Kralevich3a7ea522012-04-04 10:18:27 -070016LOCAL_CFLAGS += -fno-stack-protector \
17 -Wstrict-overflow=5 \
Elliott Hughes856512e2012-07-16 09:43:14 -070018 -fvisibility=hidden \
Raghu Gandhamd7daacb2012-07-31 12:07:22 -070019 -std=gnu99 \
20 -Wall -Wextra
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080021
David 'Digit' Turner5c734642010-01-20 12:36:51 -080022# Set LINKER_DEBUG to either 1 or 0
23#
24LOCAL_CFLAGS += -DLINKER_DEBUG=0
25
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080026# we need to access the Bionic private header <bionic_tls.h>
Gary King278d1572009-09-29 16:12:31 -070027# in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition
28# from the libc build
29ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true)
30 LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER
31endif
Andrew Hsieh6973e3d2012-06-20 14:35:51 +080032LOCAL_CFLAGS += \
33 -I$(LOCAL_PATH)/../libc/private \
34 -I$(LOCAL_PATH)/../libc/arch-$(TARGET_ARCH)/bionic
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080035
36ifeq ($(TARGET_ARCH),arm)
Raghu Gandhamd7daacb2012-07-31 12:07:22 -070037 LOCAL_CFLAGS += -DANDROID_ARM_LINKER
38endif
39
40ifeq ($(TARGET_ARCH),x86)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041 LOCAL_CFLAGS += -DANDROID_X86_LINKER
Raghu Gandhamd7daacb2012-07-31 12:07:22 -070042endif
43
44ifeq ($(TARGET_ARCH),mips)
45 LOCAL_CFLAGS += -DANDROID_MIPS_LINKER
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080046endif
47
48LOCAL_MODULE:= linker
49
David 'Digit' Turner8bff9a32010-06-10 18:29:33 -070050LOCAL_STATIC_LIBRARIES := libc_nomalloc
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080051
52#LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE
53
54#
55# include $(BUILD_EXECUTABLE)
56#
57# Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by
58# hand, as we want to insert an extra step that is not supported by the build system, and
59# is probably specific the linker only, so there's no need to modify the build system for
60# the purpose.
61
62LOCAL_MODULE_CLASS := EXECUTABLES
63LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
64
Nick Kralevich79399082011-11-04 10:11:26 -070065# we don't want crtbegin.o (because we have begin.o), so unset it
66# just for this module
67LOCAL_NO_CRT := true
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080068
69include $(BUILD_SYSTEM)/dynamic_binary.mk
70
71$(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O)
72 $(transform-o-to-static-executable)
73 @echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)"
74 $(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@
75
76#
77# end of BUILD_EXECUTABLE hack
78#