Ying Wang | f25d677 | 2014-01-23 15:17:50 -0800 | [diff] [blame] | 1 | # Define the libc run-time (crt) support object files that must be built, |
| 2 | # which are needed to build all other objects (shared/static libs and |
| 3 | # executables) |
| 4 | # ========================================================================== |
| 5 | # AArch64, ARM, MIPS, and x86 all need crtbegin_so/crtend_so. |
| 6 | # |
| 7 | # For x86, the .init section must point to a function that calls all |
| 8 | # entries in the .ctors section. (on ARM this is done through the |
| 9 | # .init_array section instead). |
| 10 | # |
| 11 | # For all the platforms, the .fini_array section must point to a function |
| 12 | # that will call __cxa_finalize(&__dso_handle) in order to ensure that |
| 13 | # static C++ destructors are properly called on dlclose(). |
| 14 | # |
| 15 | # Args: |
| 16 | # my_2nd_arch_prefix: set to $(TARGET_2ND_ARCH_VAR_PREFIX) if it's |
| 17 | # for the 2nd arch; otherwise empty. |
| 18 | |
| 19 | my_arch := $(TARGET_$(my_2nd_arch_prefix)ARCH) |
| 20 | |
| 21 | my_libc_crt_target_crtbegin_file := $(libc_crt_target_crtbegin_file_$(my_arch)) |
| 22 | my_libc_crt_target_crtbegin_so_file := $(libc_crt_target_crtbegin_so_file_$(my_arch)) |
| 23 | |
| 24 | my_libc_crt_target_cflags := \ |
| 25 | $(libc_crt_target_cflags) \ |
| 26 | $(libc_crt_target_cflags_$(my_arch)) |
| 27 | |
| 28 | my_libc_crt_target_so_cflags := \ |
| 29 | $(libc_crt_target_so_cflags_$(my_arch)) \ |
| 30 | $(my_libc_crt_target_cflags) |
| 31 | |
| 32 | my_libc_crt_target_ldflags := $(libc_crt_target_ldflags_$(my_arch)) |
| 33 | |
| 34 | |
Ying Wang | f25d677 | 2014-01-23 15:17:50 -0800 | [diff] [blame] | 35 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o |
| 36 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 37 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags) |
Colin Cross | 24958ae | 2015-02-11 17:40:45 -0800 | [diff] [blame] | 38 | $(GEN): $(LOCAL_PATH)/bionic/crtbrand.c |
| 39 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 40 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 41 | $(transform-d-to-p) |
| 42 | -include $(GEN:%.o=%.P) |
Ying Wang | f25d677 | 2014-01-23 15:17:50 -0800 | [diff] [blame] | 43 | |
| 44 | |
| 45 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o |
| 46 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 47 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags) |
| 48 | $(GEN): $(my_libc_crt_target_crtbegin_so_file) |
| 49 | @mkdir -p $(dir $@) |
| 50 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 51 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 52 | $(transform-d-to-p) |
| 53 | -include $(GEN:%.o=%.P) |
| 54 | |
| 55 | |
| 56 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o |
| 57 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 58 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_so_cflags) |
| 59 | $(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend_so.S |
| 60 | @mkdir -p $(dir $@) |
| 61 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 62 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 63 | $(transform-d-to-p) |
| 64 | -include $(GEN:%.o=%.P) |
| 65 | |
| 66 | |
| 67 | # The following two are installed to device |
| 68 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_SHARED_LIBRARIES)/crtbegin_so.o |
| 69 | $(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o |
| 70 | $(hide) mkdir -p $(dir $@) && cp -f $< $@ |
| 71 | ALL_GENERATED_SOURCES += $(GEN) |
| 72 | |
| 73 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_SHARED_LIBRARIES)/crtend_so.o |
| 74 | $(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o |
| 75 | $(hide) mkdir -p $(dir $@) && cp -f $< $@ |
| 76 | ALL_GENERATED_SOURCES += $(GEN) |
| 77 | |
| 78 | |
| 79 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o |
| 80 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 81 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags) |
| 82 | $(GEN): $(my_libc_crt_target_crtbegin_file) |
| 83 | @mkdir -p $(dir $@) |
| 84 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 85 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 86 | $(transform-d-to-p) |
| 87 | -include $(GEN:%.o=%.P) |
| 88 | |
| 89 | |
| 90 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o |
| 91 | $(GEN): PRIVATE_LD := $($(my_2nd_arch_prefix)TARGET_LD) |
| 92 | $(GEN): PRIVATE_LDFLAGS := $(my_libc_crt_target_ldflags) |
| 93 | $(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static1.o \ |
| 94 | $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o |
| 95 | @mkdir -p $(dir $@) |
| 96 | $(hide) $(PRIVATE_LD) $(PRIVATE_LDFLAGS) -r -o $@ $^ |
| 97 | |
| 98 | |
| 99 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o |
| 100 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 101 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags) |
| 102 | $(GEN): $(my_libc_crt_target_crtbegin_file) |
| 103 | @mkdir -p $(dir $@) |
| 104 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 105 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 106 | $(transform-d-to-p) |
| 107 | -include $(GEN:%.o=%.P) |
| 108 | |
| 109 | |
| 110 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o |
| 111 | $(GEN): PRIVATE_LD := $($(my_2nd_arch_prefix)TARGET_LD) |
| 112 | $(GEN): PRIVATE_LDFLAGS := $(my_libc_crt_target_ldflags) |
| 113 | $(GEN): $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic1.o \ |
| 114 | $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbrand.o |
| 115 | @mkdir -p $(dir $@) |
| 116 | $(hide) $(PRIVATE_LD) $(PRIVATE_LDFLAGS) -r -o $@ $^ |
| 117 | |
| 118 | |
| 119 | # We rename crtend.o to crtend_android.o to avoid a |
| 120 | # name clash between gcc and bionic. |
| 121 | GEN := $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o |
| 122 | $(GEN): PRIVATE_CC := $($(my_2nd_arch_prefix)TARGET_CC) |
| 123 | $(GEN): PRIVATE_CFLAGS := $(my_libc_crt_target_cflags) |
| 124 | $(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend.S |
| 125 | @mkdir -p $(dir $@) |
| 126 | $(hide) $(PRIVATE_CC) $(PRIVATE_CFLAGS) \ |
| 127 | -MD -MF $(@:%.o=%.d) -o $@ -c $< |
| 128 | $(transform-d-to-p) |
| 129 | -include $(GEN:%.o=%.P) |
| 130 | |
| 131 | # Clear temp vars |
| 132 | my_libc_crt_target_ldflags := |
| 133 | my_libc_crt_target_so_cflags := |
| 134 | my_libc_crt_target_cflags := |
| 135 | my_libc_crt_target_crtbegin_so_file := |
| 136 | my_libc_crt_target_crtbegin_file := |
| 137 | my_arch := |