1# 2# Copyright (C) 2012 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17LOCAL_PATH := $(call my-dir) 18TEST_PATH := $(LOCAL_PATH)/.. 19 20common_cppflags := 21common_additional_dependencies := \ 22 $(LOCAL_PATH)/Android.mk \ 23 $(LOCAL_PATH)/Android.build.dt_runpath.mk \ 24 $(LOCAL_PATH)/Android.build.dlext_testzip.mk \ 25 $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk \ 26 $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk \ 27 $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk \ 28 $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk \ 29 $(LOCAL_PATH)/Android.build.linker_namespaces.mk \ 30 $(LOCAL_PATH)/Android.build.pthread_atfork.mk \ 31 $(LOCAL_PATH)/Android.build.testlib.mk \ 32 $(LOCAL_PATH)/Android.build.versioned_lib.mk \ 33 $(TEST_PATH)/Android.build.mk 34 35# ----------------------------------------------------------------------------- 36# Library to test gnu-styled hash 37# ----------------------------------------------------------------------------- 38ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) 39libgnu-hash-table-library_src_files := \ 40 dlext_test_library.cpp \ 41 42libgnu-hash-table-library_ldflags := \ 43 -Wl,--hash-style=gnu \ 44 45module := libgnu-hash-table-library 46module_tag := optional 47include $(LOCAL_PATH)/Android.build.testlib.mk 48endif 49 50# ----------------------------------------------------------------------------- 51# Library to test sysv-styled hash 52# ----------------------------------------------------------------------------- 53libsysv-hash-table-library_src_files := \ 54 dlext_test_library.cpp \ 55 56libsysv-hash-table-library_ldflags := \ 57 -Wl,--hash-style=sysv \ 58 59module := libsysv-hash-table-library 60module_tag := optional 61include $(LOCAL_PATH)/Android.build.testlib.mk 62 63# ----------------------------------------------------------------------------- 64# Library used by dlext tests - with GNU RELRO program header 65# ----------------------------------------------------------------------------- 66libdlext_test_src_files := \ 67 dlext_test_library.cpp \ 68 69libdlext_test_ldflags := \ 70 -Wl,-z,relro \ 71 72libdlext_test_shared_libraries := libtest_simple 73 74module := libdlext_test 75module_tag := optional 76include $(LOCAL_PATH)/Android.build.testlib.mk 77 78# ----------------------------------------------------------------------------- 79# create symlink to libdlext_test.so for symlink test 80# ----------------------------------------------------------------------------- 81# Use = instead of := to defer the evaluation of $@ 82$(TARGET_OUT)/lib/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \ 83 $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so 84 85ifneq ($(TARGET_2ND_ARCH),) 86# link 64 bit .so 87$(TARGET_OUT)/lib64/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \ 88 $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so 89endif 90 91# host symlinks 92$(HOST_OUT)/lib64/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \ 93 $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so 94 95$(HOST_OUT)/lib/libdlext_test.so: PRIVATE_POST_INSTALL_CMD = \ 96 $(hide) cd $(dir $@) && ln -sf $(notdir $@) libdlext_test_v2.so 97 98# ----------------------------------------------------------------------------- 99# Library used by dlext tests - without GNU RELRO program header 100# ----------------------------------------------------------------------------- 101libdlext_test_norelro_src_files := \ 102 dlext_test_library.cpp \ 103 104libdlext_test_norelro_ldflags := \ 105 -Wl,-z,norelro \ 106 107libdlext_test_norelro_shared_libraries := libtest_simple 108 109module := libdlext_test_norelro 110module_tag := optional 111build_type := target 112build_target := SHARED_LIBRARY 113include $(TEST_PATH)/Android.build.mk 114 115# ----------------------------------------------------------------------------- 116# Library used by dlext tests - different name non-default location 117# ----------------------------------------------------------------------------- 118libdlext_test_fd_src_files := \ 119 dlext_test_library.cpp \ 120 121libdlext_test_fd_shared_libraries := libtest_simple 122 123libdlext_test_fd_install_to_out_data := true 124module := libdlext_test_fd 125module_tag := optional 126build_type := target 127build_target := SHARED_LIBRARY 128include $(TEST_PATH)/Android.build.mk 129 130 131# ----------------------------------------------------------------------------- 132# Libraries used by dlext tests for open from a zip-file 133# ----------------------------------------------------------------------------- 134libdlext_test_zip_src_files := \ 135 dlext_test_library.cpp \ 136 137libdlext_test_zip_shared_libraries := libatest_simple_zip 138 139libdlext_test_zip_install_to_out_data := true 140module := libdlext_test_zip 141module_tag := optional 142build_type := target 143build_target := SHARED_LIBRARY 144include $(TEST_PATH)/Android.build.mk 145 146libatest_simple_zip_src_files := \ 147 dlopen_testlib_simple.cpp 148 149libatest_simple_zip_install_to_out_data := true 150module := libatest_simple_zip 151module_tag := optional 152build_type := target 153build_target := SHARED_LIBRARY 154include $(TEST_PATH)/Android.build.mk 155 156# ---------------------------------------------------------------------------- 157# Library with soname which does not match filename 158# ---------------------------------------------------------------------------- 159libdlext_test_different_soname_src_files := \ 160 dlext_test_library.cpp \ 161 162module := libdlext_test_different_soname 163module_tag := optional 164libdlext_test_different_soname_ldflags := -Wl,-soname=libdlext_test_soname.so 165include $(LOCAL_PATH)/Android.build.testlib.mk 166 167# ----------------------------------------------------------------------------- 168# Library used by dlext tests - zipped and aligned 169# ----------------------------------------------------------------------------- 170include $(CLEAR_VARS) 171bionic_2nd_arch_prefix := 172include $(LOCAL_PATH)/Android.build.dlext_testzip.mk 173ifneq ($(TARGET_2ND_ARCH),) 174 bionic_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 175 include $(LOCAL_PATH)/Android.build.dlext_testzip.mk 176endif 177 178# ----------------------------------------------------------------------------- 179# Library used by dlfcn tests 180# ----------------------------------------------------------------------------- 181libtest_simple_src_files := \ 182 dlopen_testlib_simple.cpp 183 184module := libtest_simple 185include $(LOCAL_PATH)/Android.build.testlib.mk 186 187# ----------------------------------------------------------------------------- 188# Library used by dlfcn nodelete tests 189# ----------------------------------------------------------------------------- 190libtest_nodelete_1_src_files := \ 191 dlopen_nodelete_1.cpp 192 193module := libtest_nodelete_1 194include $(LOCAL_PATH)/Android.build.testlib.mk 195 196# ----------------------------------------------------------------------------- 197# Library used by dlfcn nodelete tests 198# ----------------------------------------------------------------------------- 199libtest_nodelete_2_src_files := \ 200 dlopen_nodelete_2.cpp 201 202module := libtest_nodelete_2 203include $(LOCAL_PATH)/Android.build.testlib.mk 204 205# ----------------------------------------------------------------------------- 206# Library used by dlfcn nodelete tests 207# ----------------------------------------------------------------------------- 208libtest_nodelete_dt_flags_1_src_files := \ 209 dlopen_nodelete_dt_flags_1.cpp 210 211libtest_nodelete_dt_flags_1_ldflags := -Wl,-z,nodelete 212 213module := libtest_nodelete_dt_flags_1 214include $(LOCAL_PATH)/Android.build.testlib.mk 215 216# ----------------------------------------------------------------------------- 217# Build test helper libraries for linker namespaces 218# ----------------------------------------------------------------------------- 219include $(LOCAL_PATH)/Android.build.linker_namespaces.mk 220 221# ----------------------------------------------------------------------------- 222# Build DT_RUNPATH test helper libraries 223# ----------------------------------------------------------------------------- 224include $(LOCAL_PATH)/Android.build.dt_runpath.mk 225 226# ----------------------------------------------------------------------------- 227# Build library with two parents 228# ----------------------------------------------------------------------------- 229include $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk 230 231# ----------------------------------------------------------------------------- 232# Build libtest_check_order_dlsym.so with its dependencies. 233# ----------------------------------------------------------------------------- 234include $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk 235 236# ----------------------------------------------------------------------------- 237# Build libtest_check_order_siblings.so with its dependencies. 238# ----------------------------------------------------------------------------- 239include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk 240 241# ----------------------------------------------------------------------------- 242# Build libtest_check_order_root.so with its dependencies. 243# ----------------------------------------------------------------------------- 244include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk 245 246# ----------------------------------------------------------------------------- 247# Build libtest_versioned_lib.so with its dependencies. 248# ----------------------------------------------------------------------------- 249include $(LOCAL_PATH)/Android.build.versioned_lib.mk 250 251# ----------------------------------------------------------------------------- 252# Build libraries needed by pthread_atfork tests 253# ----------------------------------------------------------------------------- 254include $(LOCAL_PATH)/Android.build.pthread_atfork.mk 255 256# ----------------------------------------------------------------------------- 257# Library with dependency loop used by dlfcn tests 258# 259# libtest_with_dependency_loop -> a -> b -> c -> a 260# ----------------------------------------------------------------------------- 261libtest_with_dependency_loop_src_files := dlopen_testlib_loopy_root.cpp 262 263libtest_with_dependency_loop_shared_libraries := \ 264 libtest_with_dependency_loop_a 265 266module := libtest_with_dependency_loop 267include $(LOCAL_PATH)/Android.build.testlib.mk 268 269# ----------------------------------------------------------------------------- 270# libtest_with_dependency_loop_a.so 271# ----------------------------------------------------------------------------- 272libtest_with_dependency_loop_a_src_files := dlopen_testlib_loopy_a.cpp 273 274libtest_with_dependency_loop_a_shared_libraries := \ 275 libtest_with_dependency_loop_b_tmp 276 277module := libtest_with_dependency_loop_a 278include $(LOCAL_PATH)/Android.build.testlib.mk 279 280# ----------------------------------------------------------------------------- 281# libtest_with_dependency_loop_b.so 282# 283# this is temporary placeholder - will be removed 284# ----------------------------------------------------------------------------- 285libtest_with_dependency_loop_b_tmp_src_files := dlopen_testlib_loopy_invalid.cpp 286libtest_with_dependency_loop_b_tmp_ldflags := -Wl,-soname=libtest_with_dependency_loop_b.so 287 288module := libtest_with_dependency_loop_b_tmp 289include $(LOCAL_PATH)/Android.build.testlib.mk 290 291# ----------------------------------------------------------------------------- 292# libtest_with_dependency_loop_b.so 293# ----------------------------------------------------------------------------- 294libtest_with_dependency_loop_b_src_files := dlopen_testlib_loopy_b.cpp 295libtest_with_dependency_loop_b_shared_libraries := libtest_with_dependency_loop_c 296 297module := libtest_with_dependency_loop_b 298include $(LOCAL_PATH)/Android.build.testlib.mk 299 300# ----------------------------------------------------------------------------- 301# libtest_with_dependency_loop_c.so 302# ----------------------------------------------------------------------------- 303libtest_with_dependency_loop_c_src_files := dlopen_testlib_loopy_c.cpp 304 305libtest_with_dependency_loop_c_shared_libraries := \ 306 libtest_with_dependency_loop_a 307 308module := libtest_with_dependency_loop_c 309include $(LOCAL_PATH)/Android.build.testlib.mk 310 311# ----------------------------------------------------------------------------- 312# libtest_relo_check_dt_needed_order.so 313# | 314# +-> libtest_relo_check_dt_needed_order_1.so 315# | 316# +-> libtest_relo_check_dt_needed_order_2.so 317# ----------------------------------------------------------------------------- 318libtest_relo_check_dt_needed_order_shared_libraries := \ 319 libtest_relo_check_dt_needed_order_1 libtest_relo_check_dt_needed_order_2 320 321libtest_relo_check_dt_needed_order_src_files := dlopen_testlib_relo_check_dt_needed_order.cpp 322libtest_relo_check_dt_needed_order_1_src_files := dlopen_testlib_relo_check_dt_needed_order_1.cpp 323libtest_relo_check_dt_needed_order_2_src_files := dlopen_testlib_relo_check_dt_needed_order_2.cpp 324 325module := libtest_relo_check_dt_needed_order 326include $(LOCAL_PATH)/Android.build.testlib.mk 327module := libtest_relo_check_dt_needed_order_1 328include $(LOCAL_PATH)/Android.build.testlib.mk 329module := libtest_relo_check_dt_needed_order_2 330include $(LOCAL_PATH)/Android.build.testlib.mk 331 332# ----------------------------------------------------------------------------- 333# Library with dependency used by dlfcn tests 334# ----------------------------------------------------------------------------- 335libtest_with_dependency_src_files := \ 336 dlopen_testlib_simple.cpp 337 338libtest_with_dependency_shared_libraries := libdlext_test 339 340module := libtest_with_dependency 341include $(LOCAL_PATH)/Android.build.testlib.mk 342 343# ----------------------------------------------------------------------------- 344# Library used by ifunc tests 345# ----------------------------------------------------------------------------- 346libtest_ifunc_src_files := \ 347 dlopen_testlib_ifunc.c 348 349libtest_ifunc_clang_host := false 350module := libtest_ifunc 351build_target := SHARED_LIBRARY 352 353build_type := host 354include $(TEST_PATH)/Android.build.mk 355 356ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64 x86 x86_64)) 357 ifeq ($(TARGET_ARCH),arm64) 358 libtest_ifunc_multilib := 64 359 # TODO: This is a workaround - remove it once gcc 360 # removes its Android ifunc checks 361 libtest_ifunc_cflags := -mglibc 362 endif 363 364 build_type := target 365 libtest_ifunc_clang_target := false 366 include $(TEST_PATH)/Android.build.mk 367endif 368 369# ----------------------------------------------------------------------------- 370# Library used by atexit tests 371# ----------------------------------------------------------------------------- 372 373libtest_atexit_src_files := \ 374 atexit_testlib.cpp 375 376module := libtest_atexit 377include $(LOCAL_PATH)/Android.build.testlib.mk 378 379# ----------------------------------------------------------------------------- 380# This library is used by dl_load test to check symbol preempting 381# by main executable 382# ----------------------------------------------------------------------------- 383libdl_preempt_test_1_src_files := dl_preempt_library_1.cpp 384 385module := libdl_preempt_test_1 386include $(LOCAL_PATH)/Android.build.testlib.mk 387 388# ----------------------------------------------------------------------------- 389# This library is used by dl_load test to check symbol preempting 390# by libdl_preempt_test_1.so 391# ----------------------------------------------------------------------------- 392libdl_preempt_test_2_src_files := dl_preempt_library_2.cpp 393 394module := libdl_preempt_test_2 395include $(LOCAL_PATH)/Android.build.testlib.mk 396 397# ----------------------------------------------------------------------------- 398# Library with DF_1_GLOBAL 399# ----------------------------------------------------------------------------- 400libdl_test_df_1_global_src_files := dl_df_1_global.cpp 401libdl_test_df_1_global_ldflags := -Wl,-z,global 402 403# TODO (dimitry): host ld.gold does not yet support -z global 404# remove this line once it is updated. 405libdl_test_df_1_global_ldflags_host := -fuse-ld=bfd 406 407module := libdl_test_df_1_global 408include $(LOCAL_PATH)/Android.build.testlib.mk 409 410# ----------------------------------------------------------------------------- 411# Library using symbol from libdl_test_df_1_global 412# ----------------------------------------------------------------------------- 413libtest_dlsym_df_1_global_src_files := dl_df_1_use_global.cpp 414module := libtest_dlsym_df_1_global 415include $(LOCAL_PATH)/Android.build.testlib.mk 416 417# ----------------------------------------------------------------------------- 418# Library with weak function 419# ----------------------------------------------------------------------------- 420libtest_dlsym_weak_func_src_files := \ 421 dlsym_weak_function.cpp 422 423module := libtest_dlsym_weak_func 424include $(LOCAL_PATH)/Android.build.testlib.mk 425 426# ----------------------------------------------------------------------------- 427# Library to check RTLD_LOCAL with dlsym in 'this' 428# ----------------------------------------------------------------------------- 429libtest_dlsym_from_this_src_files := dlsym_from_this_symbol.cpp 430 431libtest_dlsym_from_this_shared_libraries_target := libdl 432libtest_dlsym_from_this_shared_libraries := libtest_dlsym_from_this_child 433 434module := libtest_dlsym_from_this 435include $(LOCAL_PATH)/Android.build.testlib.mk 436 437# ----------------------------------------------------------------------------- 438libtest_dlsym_from_this_child_src_files := dlsym_from_this_functions.cpp 439 440libtest_dlsym_from_this_child_shared_libraries := libtest_dlsym_from_this_grandchild 441 442module := libtest_dlsym_from_this_child 443include $(LOCAL_PATH)/Android.build.testlib.mk 444 445# ----------------------------------------------------------------------------- 446libtest_dlsym_from_this_grandchild_src_files := dlsym_from_this_symbol2.cpp 447 448module := libtest_dlsym_from_this_grandchild 449include $(LOCAL_PATH)/Android.build.testlib.mk 450 451# ----------------------------------------------------------------------------- 452# Empty library 453# ----------------------------------------------------------------------------- 454libtest_empty_src_files := empty.cpp 455 456module := libtest_empty 457include $(LOCAL_PATH)/Android.build.testlib.mk 458 459# ----------------------------------------------------------------------------- 460# Library with weak undefined function 461# ----------------------------------------------------------------------------- 462libtest_dlopen_weak_undefined_func_src_files := \ 463 dlopen_weak_undefined.cpp 464 465module := libtest_dlopen_weak_undefined_func 466include $(LOCAL_PATH)/Android.build.testlib.mk 467 468# ----------------------------------------------------------------------------- 469# Library with constructor that calls dlopen() b/7941716 470# ----------------------------------------------------------------------------- 471libtest_dlopen_from_ctor_src_files := \ 472 dlopen_testlib_dlopen_from_ctor.cpp 473 474module := libtest_dlopen_from_ctor 475 476libtest_dlopen_from_ctor_shared_libraries_target := libdl 477 478include $(LOCAL_PATH)/Android.build.testlib.mk 479 480# ----------------------------------------------------------------------------- 481# Library that depends on the library with constructor that calls dlopen() b/7941716 482# ----------------------------------------------------------------------------- 483 484libtest_dlopen_from_ctor_main_src_files := empty.cpp 485libtest_dlopen_from_ctor_main_shared_libraries := libtest_dlopen_from_ctor 486 487module := libtest_dlopen_from_ctor_main 488include $(LOCAL_PATH)/Android.build.testlib.mk 489 490# ----------------------------------------------------------------------------- 491# Tool to use to align the shared libraries in a zip file. 492# ----------------------------------------------------------------------------- 493include $(CLEAR_VARS) 494 495LOCAL_SRC_FILES := bionic_tests_zipalign.cpp 496LOCAL_MODULE := bionic_tests_zipalign 497LOCAL_CFLAGS := -Wall -Werror 498 499LOCAL_STATIC_LIBRARIES := libziparchive-host liblog libbase libz libutils 500 501LOCAL_MODULE_HOST_OS := darwin linux windows 502 503include $(BUILD_HOST_EXECUTABLE) 504