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 \ |
Shih-wei Liao | 48527c3 | 2011-07-17 12:32:43 -0700 | [diff] [blame] | 11 | debugger.c |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 12 | |
Nick Kralevich | 8e8a7b1 | 2011-11-03 09:25:06 -0700 | [diff] [blame] | 13 | ifeq ($(TARGET_ARCH),sh) |
| 14 | # SH-4A series virtual address range from 0x00000000 to 0x7FFFFFFF. |
| 15 | LINKER_TEXT_BASE := 0x70000100 |
| 16 | else |
| 17 | # This is aligned to 4K page boundary so that both GNU ld and gold work. Gold |
| 18 | # actually produces a correct binary with starting address 0xB0000100 but the |
| 19 | # extra objcopy step to rename symbols causes the resulting binary to be misaligned |
| 20 | # and unloadable. Increasing the alignment adds an extra 3840 bytes in padding |
| 21 | # but switching to gold saves about 1M of space. |
| 22 | LINKER_TEXT_BASE := 0xB0001000 |
| 23 | endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 24 | |
Nick Kralevich | 8e8a7b1 | 2011-11-03 09:25:06 -0700 | [diff] [blame] | 25 | # The maximum size set aside for the linker, from |
| 26 | # LINKER_TEXT_BASE rounded down to a megabyte. |
| 27 | LINKER_AREA_SIZE := 0x01000000 |
| 28 | |
| 29 | LOCAL_LDFLAGS := -Wl,-Ttext,$(LINKER_TEXT_BASE) |
| 30 | |
| 31 | LOCAL_CFLAGS += -DPRELINK |
| 32 | LOCAL_CFLAGS += -DLINKER_TEXT_BASE=$(LINKER_TEXT_BASE) |
| 33 | LOCAL_CFLAGS += -DLINKER_AREA_SIZE=$(LINKER_AREA_SIZE) |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 34 | |
David 'Digit' Turner | 5c73464 | 2010-01-20 12:36:51 -0800 | [diff] [blame] | 35 | # Set LINKER_DEBUG to either 1 or 0 |
| 36 | # |
| 37 | LOCAL_CFLAGS += -DLINKER_DEBUG=0 |
| 38 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 39 | # we need to access the Bionic private header <bionic_tls.h> |
Gary King | 278d157 | 2009-09-29 16:12:31 -0700 | [diff] [blame] | 40 | # in the linker; duplicate the HAVE_ARM_TLS_REGISTER definition |
| 41 | # from the libc build |
| 42 | ifeq ($(TARGET_ARCH)-$(ARCH_ARM_HAVE_TLS_REGISTER),arm-true) |
| 43 | LOCAL_CFLAGS += -DHAVE_ARM_TLS_REGISTER |
| 44 | endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 45 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/private |
| 46 | |
| 47 | ifeq ($(TARGET_ARCH),arm) |
| 48 | LOCAL_CFLAGS += -DANDROID_ARM_LINKER |
| 49 | else |
| 50 | ifeq ($(TARGET_ARCH),x86) |
| 51 | LOCAL_CFLAGS += -DANDROID_X86_LINKER |
| 52 | else |
Shin-ichiro KAWASAKI | ad13c57 | 2009-11-06 10:36:37 +0900 | [diff] [blame] | 53 | 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 Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 58 | endif |
| 59 | endif |
| 60 | |
| 61 | LOCAL_MODULE:= linker |
| 62 | |
David 'Digit' Turner | 8bff9a3 | 2010-06-10 18:29:33 -0700 | [diff] [blame] | 63 | LOCAL_STATIC_LIBRARIES := libc_nomalloc |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 64 | |
| 65 | #LOCAL_FORCE_STATIC_EXECUTABLE := true # not necessary when not including BUILD_EXECUTABLE |
| 66 | |
| 67 | # |
| 68 | # include $(BUILD_EXECUTABLE) |
| 69 | # |
| 70 | # Instead of including $(BUILD_EXECUTABLE), we execute the steps to create an executable by |
| 71 | # hand, as we want to insert an extra step that is not supported by the build system, and |
| 72 | # is probably specific the linker only, so there's no need to modify the build system for |
| 73 | # the purpose. |
| 74 | |
| 75 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 76 | LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX) |
| 77 | |
Nick Kralevich | 7939908 | 2011-11-04 10:11:26 -0700 | [diff] [blame^] | 78 | # we don't want crtbegin.o (because we have begin.o), so unset it |
| 79 | # just for this module |
| 80 | LOCAL_NO_CRT := true |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 81 | |
| 82 | include $(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 | # |