| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | LOCAL_PATH:= $(call my-dir) | 
 | 2 | include $(CLEAR_VARS) | 
 | 3 |  | 
 | 4 | LOCAL_SRC_FILES:= \ | 
 | 5 | 	arch/$(TARGET_ARCH)/begin.S \ | 
 | 6 | 	linker.c \ | 
| David 'Digit' Turner | be57559 | 2010-12-16 19:52:02 +0100 | [diff] [blame] | 7 | 	linker_environ.c \ | 
| David 'Digit' Turner | 5c73464 | 2010-01-20 12:36:51 -0800 | [diff] [blame] | 8 | 	linker_format.c \ | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 9 | 	rt.c \ | 
 | 10 | 	dlfcn.c \ | 
 | 11 | 	debugger.c \ | 
 | 12 | 	ba.c | 
 | 13 |  | 
| Shin-ichiro KAWASAKI | ad13c57 | 2009-11-06 10:36:37 +0900 | [diff] [blame] | 14 | ifeq ($(TARGET_ARCH),sh) | 
 | 15 | # SH-4A series virtual address range from 0x00000000 to 0x7FFFFFFF. | 
 | 16 | LINKER_TEXT_BASE := 0x70000100 | 
 | 17 | else | 
| Doug Kwan | 1a2917c | 2010-01-25 10:24:50 -0800 | [diff] [blame] | 18 | # This is aligned to 4K page boundary so that both GNU ld and gold work.  Gold | 
| Doug Kwan | 90f82e5 | 2010-01-25 11:09:31 -0800 | [diff] [blame] | 19 | # actually produces a correct binary with starting address 0xB0000100 but the | 
| Doug Kwan | 1a2917c | 2010-01-25 10:24:50 -0800 | [diff] [blame] | 20 | # extra objcopy step to rename symbols causes the resulting binary to be misaligned | 
 | 21 | # and unloadable.  Increasing the alignment adds an extra 3840 bytes in padding | 
 | 22 | # but switching to gold saves about 1M of space. | 
 | 23 | LINKER_TEXT_BASE := 0xB0001000 | 
| Shin-ichiro KAWASAKI | ad13c57 | 2009-11-06 10:36:37 +0900 | [diff] [blame] | 24 | endif | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 25 |  | 
 | 26 | # The maximum size set aside for the linker, from | 
 | 27 | # LINKER_TEXT_BASE rounded down to a megabyte. | 
 | 28 | LINKER_AREA_SIZE := 0x01000000 | 
 | 29 |  | 
 | 30 | LOCAL_LDFLAGS := -Wl,-Ttext,$(LINKER_TEXT_BASE) | 
 | 31 |  | 
 | 32 | LOCAL_CFLAGS += -DPRELINK | 
 | 33 | LOCAL_CFLAGS += -DLINKER_TEXT_BASE=$(LINKER_TEXT_BASE) | 
 | 34 | LOCAL_CFLAGS += -DLINKER_AREA_SIZE=$(LINKER_AREA_SIZE) | 
 | 35 |  | 
| David 'Digit' Turner | 5c73464 | 2010-01-20 12:36:51 -0800 | [diff] [blame] | 36 | # Set LINKER_DEBUG to either 1 or 0 | 
 | 37 | # | 
 | 38 | LOCAL_CFLAGS += -DLINKER_DEBUG=0 | 
 | 39 |  | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 40 | # we need to access the Bionic private header <bionic_tls.h> | 
| Gary King | 278d157 | 2009-09-29 16:12:31 -0700 | [diff] [blame] | 41 | # in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition | 
 | 42 | # from the libc build | 
 | 43 | ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true) | 
 | 44 |     LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER | 
 | 45 | endif | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 46 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private | 
 | 47 |  | 
 | 48 | ifeq ($(TARGET_ARCH),arm) | 
 | 49 | LOCAL_CFLAGS += -DANDROID_ARM_LINKER | 
 | 50 | else | 
 | 51 |   ifeq ($(TARGET_ARCH),x86) | 
 | 52 |     LOCAL_CFLAGS += -DANDROID_X86_LINKER | 
| Bruce Beare | e0b4844 | 2011-05-03 21:04:40 -0700 | [diff] [blame] | 53 |     LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/arch-x86/bionic | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 54 |   else | 
| Shin-ichiro KAWASAKI | ad13c57 | 2009-11-06 10:36:37 +0900 | [diff] [blame] | 55 |     ifeq ($(TARGET_ARCH),sh) | 
 | 56 |       LOCAL_CFLAGS += -DANDROID_SH_LINKER | 
 | 57 |     else | 
 | 58 |       $(error Unsupported TARGET_ARCH $(TARGET_ARCH)) | 
 | 59 |     endif | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 60 |   endif | 
 | 61 | endif | 
 | 62 |  | 
 | 63 | LOCAL_MODULE:= linker | 
 | 64 |  | 
| David 'Digit' Turner | 8bff9a3 | 2010-06-10 18:29:33 -0700 | [diff] [blame] | 65 | LOCAL_STATIC_LIBRARIES := libc_nomalloc | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 66 |  | 
 | 67 | #LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE | 
 | 68 |  | 
 | 69 | # | 
 | 70 | # include $(BUILD_EXECUTABLE) | 
 | 71 | # | 
 | 72 | # Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by | 
 | 73 | # hand, as we want to insert an extra step that is not supported by the build system, and | 
 | 74 | # is probably specific the linker only, so there's no need to modify the build system for | 
 | 75 | # the purpose. | 
 | 76 |  | 
 | 77 | LOCAL_MODULE_CLASS := EXECUTABLES | 
 | 78 | LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX) | 
 | 79 |  | 
 | 80 | # Executables are not prelinked. | 
 | 81 | LOCAL_PRELINK_MODULE := false | 
 | 82 |  | 
 | 83 | include $(BUILD_SYSTEM)/dynamic_binary.mk | 
 | 84 |  | 
 | 85 | $(linked_module): $(TARGET_CRTBEGIN_STATIC_O) $(all_objects) $(all_libraries) $(TARGET_CRTEND_O) | 
 | 86 | 	$(transform-o-to-static-executable) | 
 | 87 | 	@echo "target PrefixSymbols: $(PRIVATE_MODULE) ($@)" | 
 | 88 | 	$(hide) $(TARGET_OBJCOPY) --prefix-symbols=__dl_ $@ | 
 | 89 |  | 
 | 90 | # | 
 | 91 | # end of BUILD_EXECUTABLE hack | 
 | 92 | # | 
 | 93 |  | 
 | 94 | # we don't want crtbegin.o (because we have begin.o), so unset it | 
 | 95 | # just for this module | 
 | 96 | $(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_STATIC_O := | 
 | 97 | # This line is not strictly necessary because the dynamic linker is built | 
| David 'Digit' Turner | be57559 | 2010-12-16 19:52:02 +0100 | [diff] [blame] | 98 | # as a static executable, but it won't hurt if in the future we start | 
| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 99 | # building the linker as a dynamic one. | 
 | 100 | $(LOCAL_BUILT_MODULE): TARGET_CRTBEGIN_DYNAMIC_O := |