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