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 17package { 18 default_team: "trendy_team_native_tools_libraries", 19 default_applicable_licenses: ["bionic_tests_license"], 20} 21 22cc_defaults { 23 name: "bionic_testlib_defaults", 24 host_supported: true, 25 cflags: [ 26 "-Wall", 27 "-Werror", 28 ], 29 ldflags: [ 30 "-Wl,--rpath,${ORIGIN}", 31 "-Wl,--enable-new-dtags", 32 ], 33 static_libs: ["libbase"], 34 relative_install_path: "bionic-loader-test-libs", 35 gtest: false, 36 sanitize: { 37 address: false, 38 }, 39 stl: "libc++_static", 40 target: { 41 darwin: { 42 enabled: false, 43 }, 44 }, 45 strip: { 46 none: true, 47 }, 48} 49 50// ----------------------------------------------------------------------------- 51// Test library ELFs for linker page size related tests 52// ----------------------------------------------------------------------------- 53cc_test_library { 54 name: "libtest_elf_max_page_size_4kib", 55 defaults: ["bionic_testlib_defaults"], 56 srcs: ["elf_max_page_size.c"], 57 ldflags: ["-z max-page-size=0x1000"], 58} 59 60// ----------------------------------------------------------------------------- 61// Libraries and helper binaries for ELF TLS 62// ----------------------------------------------------------------------------- 63cc_test_library { 64 name: "libtest_elftls_shared_var", 65 defaults: ["bionic_testlib_defaults"], 66 srcs: ["elftls_shared_var.cpp"], 67} 68 69cc_test_library { 70 name: "libtest_elftls_shared_var_ie", 71 defaults: ["bionic_testlib_defaults"], 72 srcs: ["elftls_shared_var_ie.cpp"], 73 shared_libs: ["libtest_elftls_shared_var"], 74} 75 76cc_test_library { 77 name: "libtest_elftls_tprel", 78 defaults: ["bionic_testlib_defaults"], 79 srcs: ["elftls_tprel.cpp"], 80} 81 82cc_test { 83 name: "elftls_dlopen_ie_error_helper", 84 defaults: ["bionic_testlib_defaults"], 85 srcs: ["elftls_dlopen_ie_error_helper.cpp"], 86 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 87} 88 89cc_test_library { 90 name: "libtest_elftls_dynamic", 91 defaults: ["bionic_testlib_defaults"], 92 srcs: ["elftls_dynamic.cpp"], 93 shared_libs: ["libtest_elftls_shared_var"], 94} 95 96cc_test { 97 name: "thread_exit_cb_helper", 98 defaults: ["bionic_testlib_defaults"], 99 srcs: ["thread_exit_cb_helper.cpp"], 100} 101 102cc_test { 103 name: "tls_properties_helper", 104 defaults: ["bionic_testlib_defaults"], 105 srcs: ["tls_properties_helper.cpp"], 106 shared_libs: ["libtest_elftls_shared_var"], 107} 108 109cc_test_library { 110 name: "libtest_elftls_dynamic_filler_1", 111 defaults: ["bionic_testlib_defaults"], 112 srcs: ["elftls_dynamic_filler.cpp"], 113 cflags: [ 114 "-DTLS_FILLER=100", 115 ], 116} 117 118cc_test_library { 119 name: "libtest_elftls_dynamic_filler_2", 120 defaults: ["bionic_testlib_defaults"], 121 srcs: ["elftls_dynamic_filler.cpp"], 122 cflags: [ 123 "-DTLS_FILLER=200", 124 ], 125} 126 127cc_test_library { 128 name: "libtest_elftls_dynamic_filler_3", 129 defaults: ["bionic_testlib_defaults"], 130 srcs: ["elftls_dynamic_filler.cpp"], 131 cflags: [ 132 "-DTLS_FILLER=300", 133 ], 134} 135 136cc_test_library { 137 name: "libtest_elftls_dynamic_filler_4", 138 defaults: ["bionic_testlib_defaults"], 139 srcs: ["elftls_dynamic_filler.cpp"], 140 cflags: [ 141 "-DTLS_FILLER=400", 142 ], 143} 144 145cc_test_library { 146 name: "libtest_elftls_dynamic_filler_5", 147 defaults: ["bionic_testlib_defaults"], 148 srcs: ["elftls_dynamic_filler.cpp"], 149 cflags: [ 150 "-DTLS_FILLER=500", 151 ], 152} 153 154cc_test { 155 name: "elftls_dtv_resize_helper", 156 defaults: [ 157 "bionic_testlib_defaults", 158 "bionic_targets_only", 159 ], 160 srcs: ["elftls_dtv_resize_helper.cpp"], 161 include_dirs: [ 162 "bionic/libc", 163 ], 164 static_libs: [ 165 "libbase", 166 ], 167} 168 169cc_test { 170 name: "elftls_align_test_helper", 171 defaults: ["bionic_testlib_defaults"], 172 srcs: ["elftls_align_test_helper.cpp"], 173 stl: "none", // avoid including extra TLS variables in the executable 174} 175 176cc_test { 177 name: "elftls_skew_align_test_helper", 178 defaults: ["bionic_testlib_defaults"], 179 srcs: ["elftls_skew_align_test_helper.cpp"], 180 stl: "none", // avoid including extra TLS variables in the executable 181} 182 183// ----------------------------------------------------------------------------- 184// Library to test gnu-styled hash 185// ----------------------------------------------------------------------------- 186cc_test_library { 187 name: "libgnu-hash-table-library", 188 defaults: ["bionic_testlib_defaults"], 189 srcs: ["dlext_test_library.cpp"], 190 ldflags: ["-Wl,--hash-style=gnu"], 191} 192 193// ----------------------------------------------------------------------------- 194// Library to test sysv-styled hash 195// ----------------------------------------------------------------------------- 196cc_test_library { 197 name: "libsysv-hash-table-library", 198 defaults: ["bionic_testlib_defaults"], 199 srcs: ["dlext_test_library.cpp"], 200 ldflags: ["-Wl,--hash-style=sysv"], 201} 202 203// ----------------------------------------------------------------------------- 204// Library used by dlext tests - with GNU RELRO program header 205// ----------------------------------------------------------------------------- 206cc_test_library { 207 name: "libdlext_test", 208 defaults: ["bionic_testlib_defaults"], 209 srcs: ["dlext_test_library.cpp"], 210 ldflags: ["-Wl,-z,relro"], 211 shared_libs: ["libtest_simple"], 212} 213 214// ----------------------------------------------------------------------------- 215// Library used by dlext tests - without GNU RELRO program header 216// ----------------------------------------------------------------------------- 217cc_test_library { 218 name: "libdlext_test_norelro", 219 defaults: ["bionic_testlib_defaults"], 220 srcs: ["dlext_test_library.cpp"], 221 ldflags: ["-Wl,-z,norelro"], 222 shared_libs: ["libtest_simple"], 223} 224 225// ----------------------------------------------------------------------------- 226// Library used by dlext tests - recursive use of RELRO sharing 227// ----------------------------------------------------------------------------- 228cc_test_library { 229 name: "libdlext_test_recursive", 230 defaults: ["bionic_testlib_defaults"], 231 srcs: ["dlext_test_recursive_library.cpp"], 232 ldflags: ["-Wl,-z,relro"], 233 shared_libs: ["libdlext_test"], 234} 235 236// ----------------------------------------------------------------------------- 237// Library used by dlext tests - different name non-default location 238// ----------------------------------------------------------------------------- 239cc_test_library { 240 name: "libdlext_test_fd", 241 defaults: ["bionic_testlib_defaults"], 242 host_supported: false, 243 srcs: ["dlext_test_library.cpp"], 244 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 245 relative_install_path: "bionic-loader-test-libs/libdlext_test_fd", 246 shared_libs: ["libtest_simple"], 247} 248 249// ----------------------------------------------------------------------------- 250// Libraries used by dlext tests for open from a zip-file 251// ----------------------------------------------------------------------------- 252cc_test_library { 253 name: "libdlext_test_zip", 254 defaults: ["bionic_testlib_defaults"], 255 host_supported: false, 256 srcs: ["dlext_test_library.cpp"], 257 shared_libs: ["libatest_simple_zip"], 258 relative_install_path: "bionic-loader-test-libs/libdlext_test_zip", 259} 260 261cc_test_library { 262 name: "libatest_simple_zip", 263 defaults: ["bionic_testlib_defaults"], 264 host_supported: false, 265 srcs: ["dlopen_testlib_simple.cpp"], 266 relative_install_path: "bionic-loader-test-libs/libatest_simple_zip", 267} 268 269// ---------------------------------------------------------------------------- 270// Library with soname which does not match filename 271// ---------------------------------------------------------------------------- 272cc_test_library { 273 name: "libdlext_test_different_soname", 274 defaults: ["bionic_testlib_defaults"], 275 srcs: ["dlext_test_library.cpp"], 276 ldflags: ["-Wl,-soname=libdlext_test_soname.so"], 277} 278 279// ----------------------------------------------------------------------------- 280// Library used by dlext tests - zipped and aligned 281// ----------------------------------------------------------------------------- 282// In Android.mk to support zipped and aligned tests 283 284// ----------------------------------------------------------------------------- 285// Library used by dlfcn tests 286// ----------------------------------------------------------------------------- 287cc_test_library { 288 name: "libtest_simple", 289 defaults: ["bionic_testlib_defaults"], 290 srcs: ["dlopen_testlib_simple.cpp"], 291} 292 293// ----------------------------------------------------------------------------- 294// Libraries and binaries used by memtag_stack_dlopen_test tests 295// ----------------------------------------------------------------------------- 296cc_test_library { 297 name: "libtest_simple_memtag_stack", 298 sanitize: { 299 memtag_stack: true, 300 }, 301 srcs: ["dlopen_testlib_simple.cpp"], 302} 303 304cc_test_library { 305 name: "libtest_depends_on_simple_memtag_stack", 306 sanitize: { 307 memtag_stack: false, 308 }, 309 shared_libs: [ 310 "libtest_simple_memtag_stack", 311 ], 312 srcs: ["dlopen_testlib_depends_on_simple.cpp"], 313} 314 315cc_binary { 316 name: "testbinary_is_stack_mte_after_dlopen", 317 sanitize: { 318 memtag_stack: false, 319 memtag_heap: true, 320 }, 321 srcs: ["testbinary_is_stack_mte_after_dlopen.cpp"], 322} 323 324cc_binary { 325 name: "testbinary_depends_on_simple_memtag_stack", 326 sanitize: { 327 memtag_stack: false, 328 memtag_heap: true, 329 }, 330 shared_libs: [ 331 "libtest_simple_memtag_stack", 332 ], 333 srcs: ["testbinary_is_stack_mte.cpp"], 334} 335 336cc_binary { 337 name: "testbinary_depends_on_depends_on_simple_memtag_stack", 338 sanitize: { 339 memtag_stack: false, 340 memtag_heap: true, 341 }, 342 shared_libs: [ 343 "libtest_depends_on_simple_memtag_stack", 344 ], 345 srcs: ["testbinary_is_stack_mte.cpp"], 346} 347 348// ----------------------------------------------------------------------------- 349// Libraries used by hwasan_test 350// ----------------------------------------------------------------------------- 351cc_test_library { 352 name: "libtest_simple_hwasan", 353 arch: { 354 arm64: { 355 enabled: true, 356 }, 357 }, 358 sanitize: { 359 hwaddress: true, 360 }, 361 relative_install_path: "hwasan", 362 enabled: false, 363 srcs: ["dlopen_testlib_simple_hwasan.cpp"], 364} 365 366cc_test_library { 367 // A weird name. This is the vanilla (non-HWASan) copy of the library that 368 // is used for the hwasan test. 369 name: "libtest_simple_hwasan_nohwasan", 370 arch: { 371 arm64: { 372 enabled: true, 373 }, 374 }, 375 stem: "libtest_simple_hwasan", 376 enabled: false, 377 srcs: ["dlopen_testlib_simple_hwasan.cpp"], 378} 379 380// ----------------------------------------------------------------------------- 381// Library used by dlext direct unload on the namespace boundary tests 382// ----------------------------------------------------------------------------- 383cc_test_library { 384 name: "libtest_missing_symbol", 385 defaults: ["bionic_testlib_defaults"], 386 srcs: ["dlopen_testlib_missing_symbol.cpp"], 387 allow_undefined_symbols: true, 388 relative_install_path: "bionic-loader-test-libs/public_namespace_libs", 389} 390 391// ----------------------------------------------------------------------------- 392// Library used by dlext indirect unload on the namespace boundary tests 393// 394// These libraries produce following dependency graph: 395// libtest_missing_symbol_root (private ns) 396// +-> libbnstest_public (public ns) 397// +-> libtest_missing_symbol_child_public (public ns) 398// +-> libnstest_public (public ns) 399// +-> libtest_missing_symbol_child_private (private_ns) 400// +-> libnstest_public (public_ns) 401// 402// All libraries except libtest_missing_symbol are located in 403// private_namespace_libs/ 404// ----------------------------------------------------------------------------- 405cc_test_library { 406 name: "libtest_missing_symbol_child_public", 407 defaults: ["bionic_testlib_defaults"], 408 srcs: ["empty.cpp"], 409 relative_install_path: "bionic-loader-test-libs/public_namespace_libs", 410 shared_libs: ["libnstest_public"], 411} 412 413cc_test_library { 414 name: "libtest_missing_symbol_child_private", 415 defaults: ["bionic_testlib_defaults"], 416 srcs: ["empty.cpp"], 417 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 418 shared_libs: ["libnstest_public"], 419} 420 421cc_test_library { 422 name: "libtest_missing_symbol_root", 423 defaults: ["bionic_testlib_defaults"], 424 srcs: ["dlopen_testlib_missing_symbol.cpp"], 425 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 426 allow_undefined_symbols: true, 427 shared_libs: [ 428 "libnstest_public", 429 "libtest_missing_symbol_child_public", 430 "libtest_missing_symbol_child_private", 431 ], 432} 433 434// ----------------------------------------------------------------------------- 435// ----------------------------------------------------------------------------- 436// Library used by dlfcn nodelete tests 437// ----------------------------------------------------------------------------- 438cc_test_library { 439 name: "libtest_nodelete_1", 440 defaults: ["bionic_testlib_defaults"], 441 srcs: ["dlopen_nodelete_1.cpp"], 442} 443 444// ----------------------------------------------------------------------------- 445// Library used by dlfcn nodelete tests 446// ----------------------------------------------------------------------------- 447cc_test_library { 448 name: "libtest_nodelete_2", 449 defaults: ["bionic_testlib_defaults"], 450 srcs: ["dlopen_nodelete_2.cpp"], 451} 452 453// ----------------------------------------------------------------------------- 454// Library used by dlfcn nodelete tests 455// ----------------------------------------------------------------------------- 456cc_test_library { 457 name: "libtest_nodelete_dt_flags_1", 458 defaults: ["bionic_testlib_defaults"], 459 srcs: ["dlopen_nodelete_dt_flags_1.cpp"], 460 ldflags: ["-Wl,-z,nodelete"], 461} 462 463// ----------------------------------------------------------------------------- 464// Build test helper libraries for linker namespaces 465// 466// This set of libraries is used to verify linker namespaces. 467// 468// Test cases 469// 1. Check that private libraries loaded in different namespaces are 470// different. Check that dlsym does not confuse them. 471// 2. Check that public libraries loaded in different namespaces are shared 472// between them. 473// 3. Check that namespace sticks on dlopen 474// 4. Check that having access to shared library (libnstest_public.so) 475// does not expose symbols from dependent library (libnstest_public_internal.so) 476// 477// Dependency tree (visibility) 478// libnstest_root.so (this should be local to the namespace) 479// +-> libnstest_public.so 480// +-> libnstest_public_internal.so 481// +-> libnstest_private.so 482// 483// libnstest_dlopened.so (library in private namespace dlopened from libnstest_root.so) 484// ----------------------------------------------------------------------------- 485cc_test_library { 486 name: "libnstest_root", 487 defaults: ["bionic_testlib_defaults"], 488 srcs: ["namespaces_root.cpp"], 489 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 490 shared_libs: [ 491 "libnstest_public", 492 "libnstest_private", 493 ], 494} 495 496cc_test_library { 497 name: "libnstest_public_internal", 498 defaults: ["bionic_testlib_defaults"], 499 srcs: ["namespaces_public_internal.cpp"], 500 relative_install_path: "bionic-loader-test-libs/public_namespace_libs", 501} 502 503cc_test_library { 504 name: "libnstest_public", 505 defaults: ["bionic_testlib_defaults"], 506 srcs: ["namespaces_public.cpp"], 507 relative_install_path: "bionic-loader-test-libs/public_namespace_libs", 508 shared_libs: ["libnstest_public_internal"], 509} 510 511cc_test_library { 512 name: "libnstest_private", 513 defaults: ["bionic_testlib_defaults"], 514 srcs: ["namespaces_private.cpp"], 515 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 516} 517 518cc_test_library { 519 name: "libnstest_dlopened", 520 defaults: ["bionic_testlib_defaults"], 521 srcs: ["namespaces_dlopened.cpp"], 522 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 523} 524 525// ----------------------------------------------------------------------------- 526// Build test helper libraries for linker namespaces for allow all shared libs 527// 528// This set of libraries is used to verify linker namespaces for allow all 529// shared libs. 530// 531// Test cases 532// 1. Check that namespace a exposes libnstest_ns_a_public1 to 533// namespace b while keeping libnstest_ns_a_public1_internal as an 534// internal lib. 535// 2. Check that namespace b exposes all libraries to namespace a. 536// 537// Dependency tree (visibility) 538// libnstest_ns_b_public2.so (ns:b) 539// +-> libnstest_ns_a_public1.so (ns:a) 540// +-> libnstest_ns_a_public2_internal.so (ns:a) 541// +-> libnstest_ns_b_public3.so (ns:b) 542// 543// ----------------------------------------------------------------------------- 544cc_test_library { 545 name: "libnstest_ns_a_public1", 546 defaults: ["bionic_testlib_defaults"], 547 srcs: ["libnstest_ns_a_public1.cpp"], 548 relative_install_path: "bionic-loader-test-libs/ns_a", 549 shared_libs: [ 550 "libnstest_ns_a_public1_internal", 551 "libnstest_ns_b_public3", 552 ], 553} 554 555cc_test_library { 556 name: "libnstest_ns_a_public1_internal", 557 defaults: ["bionic_testlib_defaults"], 558 srcs: ["libnstest_ns_a_public1_internal.cpp"], 559 relative_install_path: "bionic-loader-test-libs/ns_a", 560} 561 562cc_test_library { 563 name: "libnstest_ns_b_public2", 564 defaults: ["bionic_testlib_defaults"], 565 srcs: ["libnstest_ns_b_public2.cpp"], 566 relative_install_path: "bionic-loader-test-libs/ns_b", 567 shared_libs: ["libnstest_ns_a_public1"], 568} 569 570cc_test_library { 571 name: "libnstest_ns_b_public3", 572 defaults: ["bionic_testlib_defaults"], 573 srcs: ["libnstest_ns_b_public3.cpp"], 574 relative_install_path: "bionic-loader-test-libs/ns_b", 575} 576 577// ----------------------------------------------------------------------------- 578// Build test helper libraries for linker namespaces 579// 580// This set of libraries is to test isolated namespaces 581// 582// Isolated namespaces do not allow loading of the library outside of 583// the search paths. 584// 585// This library cannot be loaded in isolated namespace because one of DT_NEEDED 586// libraries is outside of the search paths. 587// 588// libnstest_root_not_isolated.so (DT_RUNPATH = $ORIGIN/../private_namespace_libs_external/) 589// +-> libnstest_public.so 590// +-> libnstest_private_external.so (located in $ORIGIN/../private_namespace_libs_external/) 591// 592// Search path: $NATIVE_TESTS/private_namespace_libs/ 593// 594// ----------------------------------------------------------------------------- 595 596cc_test_library { 597 name: "libnstest_root_not_isolated", 598 defaults: ["bionic_testlib_defaults"], 599 host_supported: false, 600 srcs: ["namespaces_root.cpp"], 601 shared_libs: [ 602 "libnstest_public", 603 "libnstest_private_external", 604 ], 605 relative_install_path: "bionic-loader-test-libs/private_namespace_libs", 606 ldflags: ["-Wl,--rpath,$ORIGIN/../private_namespace_libs_external"], 607} 608 609cc_test_library { 610 name: "libnstest_private_external", 611 defaults: ["bionic_testlib_defaults"], 612 host_supported: false, 613 srcs: ["namespaces_private.cpp"], 614 relative_install_path: "bionic-loader-test-libs/private_namespace_libs_external", 615} 616 617// ----------------------------------------------------------------------------- 618// ns_hidden_child linker namespace test 619// ----------------------------------------------------------------------------- 620 621cc_test { 622 name: "ns_hidden_child_helper", 623 host_supported: false, 624 defaults: ["bionic_testlib_defaults"], 625 srcs: ["ns_hidden_child_helper.cpp"], 626 shared_libs: [ 627 "libns_hidden_child_internal", 628 "libns_hidden_child_global", 629 "libdl_android", 630 ], 631 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 632} 633 634cc_test_library { 635 name: "libns_hidden_child_global", 636 defaults: ["bionic_testlib_defaults"], 637 host_supported: false, 638 srcs: ["ns_hidden_child_global.cpp"], 639 shared_libs: ["libns_hidden_child_internal"], 640 ldflags: ["-Wl,-z,global"], 641} 642 643cc_test_library { 644 name: "libns_hidden_child_internal", 645 defaults: ["bionic_testlib_defaults"], 646 host_supported: false, 647 srcs: ["ns_hidden_child_internal.cpp"], 648} 649 650cc_test_library { 651 name: "libns_hidden_child_public", 652 defaults: ["bionic_testlib_defaults"], 653 host_supported: false, 654 srcs: ["ns_hidden_child_public.cpp"], 655 shared_libs: ["libns_hidden_child_internal"], 656} 657 658cc_test_library { 659 name: "libns_hidden_child_app", 660 defaults: ["bionic_testlib_defaults"], 661 host_supported: false, 662 srcs: ["ns_hidden_child_app.cpp"], 663 shared_libs: ["libns_hidden_child_public"], 664 relative_install_path: "bionic-loader-test-libs/ns_hidden_child_app", 665} 666 667// ----------------------------------------------------------------------------- 668// Build DT_RUNPATH test helper libraries 669// 670// Dependencies 671// 672// libtest_dt_runpath_d.so runpath: ${ORIGIN}/dt_runpath_b_c_x, ${ORIGIN}/dt_runpath_y/${LIB} 673// |-> dt_runpath_b_c_x/libtest_dt_runpath_b.so runpath: ${ORIGIN}/../dt_runpath_a 674// | |-> dt_runpath_a/libtest_dt_runpath_a.so 675// |-> dt_runpath_b_c_x/libtest_dt_runpath_c.so runpath: ${ORIGIN}/invalid_dt_runpath 676// | |-> libtest_dt_runpath_a.so (soname) 677// |-> dt_runpath_y/lib[64]/libtest_dt_runpath_y.so 678// 679// This one is used to test dlopen 680// dt_runpath_b_c_x/libtest_dt_runpath_x.so 681// 682// ----------------------------------------------------------------------------- 683 684// A leaf library in a non-standard directory. 685cc_test_library { 686 name: "libtest_dt_runpath_a", 687 defaults: ["bionic_testlib_defaults"], 688 srcs: ["empty.cpp"], 689 relative_install_path: "bionic-loader-test-libs/dt_runpath_a", 690} 691 692// Depends on library A with a DT_RUNPATH 693cc_test_library { 694 name: "libtest_dt_runpath_b", 695 defaults: ["bionic_testlib_defaults"], 696 srcs: ["empty.cpp"], 697 shared_libs: ["libtest_dt_runpath_a"], 698 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x", 699 ldflags: ["-Wl,--rpath,${ORIGIN}/../dt_runpath_a"], 700} 701 702// Depends on library A with an incorrect DT_RUNPATH. This does not matter 703// because B is the first in the D (below) dependency order, and library A 704// is already loaded using the correct DT_RUNPATH from library B. 705cc_test_library { 706 name: "libtest_dt_runpath_c", 707 defaults: ["bionic_testlib_defaults"], 708 srcs: ["empty.cpp"], 709 shared_libs: ["libtest_dt_runpath_a"], 710 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x", 711 ldflags: ["-Wl,--rpath,${ORIGIN}/invalid_dt_runpath"], 712} 713 714// D depends on B, C, and Y with DT_RUNPATH. 715cc_test_library { 716 name: "libtest_dt_runpath_d", 717 defaults: ["bionic_testlib_defaults"], 718 srcs: ["dlopen_b.cpp"], 719 shared_libs: [ 720 "libtest_dt_runpath_b", 721 "libtest_dt_runpath_c", 722 "libtest_dt_runpath_y", 723 ], 724 ldflags: [ 725 "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x", 726 "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}", 727 ], 728} 729 730// D version for open-from-zip test with runpath 731cc_test_library { 732 name: "libtest_dt_runpath_d_zip", 733 srcs: ["dlopen_b.cpp"], 734 shared_libs: [ 735 "libtest_dt_runpath_b", 736 "libtest_dt_runpath_c", 737 "libtest_dt_runpath_y", 738 ], 739 cflags: [ 740 "-Wall", 741 "-Werror", 742 ], 743 gtest: false, 744 relative_install_path: "libtest_dt_runpath_d_zip", 745 ldflags: [ 746 "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x", 747 "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}", 748 ], 749 sanitize: { 750 address: false, 751 }, 752 stl: "libc++_static", 753 target: { 754 darwin: { 755 enabled: false, 756 }, 757 }, 758} 759 760// A leaf library in a directory library D has DT_RUNPATH for. 761cc_test_library { 762 name: "libtest_dt_runpath_x", 763 defaults: ["bionic_testlib_defaults"], 764 srcs: ["empty.cpp"], 765 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x", 766} 767 768// A leaf library in lib or lib64 directory 769cc_test_library { 770 name: "libtest_dt_runpath_y", 771 defaults: ["bionic_testlib_defaults"], 772 srcs: ["empty.cpp"], 773 774 multilib: { 775 lib32: { 776 relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib", 777 }, 778 lib64: { 779 relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib64", 780 }, 781 }, 782} 783 784// ----------------------------------------------------------------------------- 785// Build library with two parents 786// 787// Libraries used by dlfcn tests to verify local group ref_counting 788// libtest_two_parents*.so 789// ----------------------------------------------------------------------------- 790 791// ..._child.so - correct answer 792cc_test_library { 793 name: "libtest_two_parents_child", 794 defaults: ["bionic_testlib_defaults"], 795 srcs: ["dlopen_2_parents_reloc_answer.cpp"], 796} 797 798// ..._parent1.so - correct answer 799cc_test_library { 800 name: "libtest_two_parents_parent1", 801 defaults: ["bionic_testlib_defaults"], 802 srcs: ["dlopen_check_order_reloc_answer_impl.cpp"], 803 shared_libs: ["libtest_two_parents_child"], 804 cflags: ["-D__ANSWER=42"], 805} 806 807// ..._parent2.so - incorrect answer 808cc_test_library { 809 name: "libtest_two_parents_parent2", 810 defaults: ["bionic_testlib_defaults"], 811 srcs: ["dlopen_check_order_reloc_answer_impl.cpp"], 812 shared_libs: ["libtest_two_parents_child"], 813 cflags: ["-D__ANSWER=1"], 814} 815 816// ----------------------------------------------------------------------------- 817// Build libtest_check_order_dlsym.so with its dependencies. 818// 819// Libraries used by dlfcn tests to verify correct load order: 820// ----------------------------------------------------------------------------- 821 822// libtest_check_order_2_right.so 823cc_test_library { 824 name: "libtest_check_order_dlsym_2_right", 825 defaults: ["bionic_testlib_defaults"], 826 srcs: ["dlopen_check_order_dlsym_answer.cpp"], 827 cflags: ["-D__ANSWER=42"], 828} 829 830// libtest_check_order_a.so 831cc_test_library { 832 name: "libtest_check_order_dlsym_a", 833 defaults: ["bionic_testlib_defaults"], 834 srcs: ["dlopen_check_order_dlsym_answer.cpp"], 835 cflags: ["-D__ANSWER=1"], 836} 837 838// libtest_check_order_b.so 839cc_test_library { 840 name: "libtest_check_order_dlsym_b", 841 defaults: ["bionic_testlib_defaults"], 842 srcs: ["dlopen_check_order_dlsym_answer.cpp"], 843 cflags: [ 844 "-D__ANSWER=2", 845 "-D__ANSWER2=43", 846 ], 847} 848 849// libtest_check_order_c.so 850cc_test_library { 851 name: "libtest_check_order_dlsym_3_c", 852 defaults: ["bionic_testlib_defaults"], 853 srcs: ["dlopen_check_order_dlsym_answer.cpp"], 854 cflags: ["-D__ANSWER=3"], 855} 856 857// libtest_check_order_d.so 858cc_test_library { 859 name: "libtest_check_order_dlsym_d", 860 defaults: ["bionic_testlib_defaults"], 861 shared_libs: ["libtest_check_order_dlsym_b"], 862 srcs: ["dlopen_check_order_dlsym_answer.cpp"], 863 cflags: [ 864 "-D__ANSWER=4", 865 "-D__ANSWER2=4", 866 ], 867} 868 869// libtest_check_order_left.so 870cc_test_library { 871 name: "libtest_check_order_dlsym_1_left", 872 defaults: ["bionic_testlib_defaults"], 873 shared_libs: [ 874 "libtest_check_order_dlsym_a", 875 "libtest_check_order_dlsym_b", 876 ], 877 srcs: ["empty.cpp"], 878} 879 880// libtest_check_order.so 881cc_test_library { 882 name: "libtest_check_order_dlsym", 883 defaults: ["bionic_testlib_defaults"], 884 shared_libs: [ 885 "libtest_check_order_dlsym_1_left", 886 "libtest_check_order_dlsym_2_right", 887 "libtest_check_order_dlsym_3_c", 888 ], 889 srcs: ["empty.cpp"], 890} 891 892// ----------------------------------------------------------------------------- 893// Build libtest_check_order_siblings.so with its dependencies. 894// 895// Libraries used by dlfcn tests to verify correct relocation order: 896// libtest_check_order_reloc_siblings*.so 897// ----------------------------------------------------------------------------- 898 899// ..._1.so - empty 900cc_test_library { 901 name: "libtest_check_order_reloc_siblings_1", 902 defaults: ["bionic_testlib_defaults"], 903 shared_libs: [ 904 "libtest_check_order_reloc_siblings_a", 905 "libtest_check_order_reloc_siblings_b", 906 ], 907 srcs: ["empty.cpp"], 908} 909 910// ..._2.so - empty 911cc_test_library { 912 name: "libtest_check_order_reloc_siblings_2", 913 defaults: ["bionic_testlib_defaults"], 914 shared_libs: [ 915 "libtest_check_order_reloc_siblings_c", 916 "libtest_check_order_reloc_siblings_d", 917 ], 918 srcs: [ 919 "dlopen_check_order_reloc_grandchild_answer.cpp", 920 ], 921 allow_undefined_symbols: true, 922} 923 924// ..._3.so - get_answer2(); 925cc_test_library { 926 name: "libtest_check_order_reloc_siblings_3", 927 defaults: ["bionic_testlib_defaults"], 928 shared_libs: [ 929 "libtest_check_order_reloc_siblings_e", 930 "libtest_check_order_reloc_siblings_f", 931 ], 932 srcs: [ 933 "dlopen_check_order_reloc_nephew_answer.cpp", 934 ], 935} 936 937// ..._a.so <- correct impl 938cc_test_library { 939 name: "libtest_check_order_reloc_siblings_a", 940 defaults: ["bionic_testlib_defaults"], 941 srcs: [ 942 "dlopen_check_order_reloc_answer_impl.cpp", 943 ], 944 cflags: ["-D__ANSWER=42"], 945} 946 947// ..._b.so 948cc_test_library { 949 name: "libtest_check_order_reloc_siblings_b", 950 defaults: ["bionic_testlib_defaults"], 951 srcs: [ 952 "dlopen_check_order_reloc_answer_impl.cpp", 953 ], 954 cflags: ["-D__ANSWER=1"], 955} 956 957// ..._c.so 958cc_test_library { 959 name: "libtest_check_order_reloc_siblings_c", 960 defaults: ["bionic_testlib_defaults"], 961 shared_libs: [ 962 "libtest_check_order_reloc_siblings_c_1", 963 "libtest_check_order_reloc_siblings_c_2", 964 ], 965 srcs: [ 966 "dlopen_check_order_reloc_answer_impl.cpp", 967 ], 968 cflags: ["-D__ANSWER=2"], 969} 970 971// ..._d.so 972cc_test_library { 973 name: "libtest_check_order_reloc_siblings_d", 974 defaults: ["bionic_testlib_defaults"], 975 srcs: [ 976 "dlopen_check_order_reloc_answer_impl.cpp", 977 ], 978 cflags: ["-D__ANSWER=3"], 979} 980 981// ..._e.so 982cc_test_library { 983 name: "libtest_check_order_reloc_siblings_e", 984 defaults: ["bionic_testlib_defaults"], 985 srcs: [ 986 "dlopen_check_order_reloc_answer_impl.cpp", 987 ], 988 cflags: [ 989 "-D__ANSWER=4", 990 ], 991} 992 993// ..._f.so <- get_answer() 994cc_test_library { 995 name: "libtest_check_order_reloc_siblings_f", 996 defaults: ["bionic_testlib_defaults"], 997 srcs: [ 998 "dlopen_check_order_reloc_answer.cpp", 999 ], 1000} 1001 1002// ..._c_1.so 1003cc_test_library { 1004 name: "libtest_check_order_reloc_siblings_c_1", 1005 defaults: ["bionic_testlib_defaults"], 1006 srcs: [ 1007 "dlopen_check_order_reloc_grandchild_answer_impl.cpp", 1008 ], 1009 cflags: ["-D__ANSWER=42"], 1010} 1011 1012// ..._c_2.so 1013cc_test_library { 1014 name: "libtest_check_order_reloc_siblings_c_2", 1015 defaults: ["bionic_testlib_defaults"], 1016 srcs: [ 1017 "dlopen_check_order_reloc_grandchild_answer_impl.cpp", 1018 ], 1019 cflags: ["-D__ANSWER=0"], 1020} 1021 1022// libtest_check_order_reloc_siblings.so 1023cc_test_library { 1024 name: "libtest_check_order_reloc_siblings", 1025 defaults: ["bionic_testlib_defaults"], 1026 shared_libs: [ 1027 "libtest_check_order_reloc_siblings_1", 1028 "libtest_check_order_reloc_siblings_2", 1029 "libtest_check_order_reloc_siblings_3", 1030 ], 1031 srcs: [ 1032 "empty.cpp", 1033 ], 1034} 1035 1036// ----------------------------------------------------------------------------- 1037// Build libtest_check_order_root.so with its dependencies. 1038// 1039// Libraries used by dlfcn tests to verify correct relocation order: 1040// libtest_check_order_reloc_root*.so 1041// ----------------------------------------------------------------------------- 1042 1043// ..._1.so - empty 1044cc_test_library { 1045 name: "libtest_check_order_reloc_root_1", 1046 defaults: ["bionic_testlib_defaults"], 1047 srcs: ["empty.cpp"], 1048} 1049 1050// ..._2.so - this one has the incorrect answer 1051cc_test_library { 1052 name: "libtest_check_order_reloc_root_2", 1053 defaults: ["bionic_testlib_defaults"], 1054 srcs: ["dlopen_check_order_reloc_root_answer_impl.cpp"], 1055 cflags: ["-D__ANSWER=2"], 1056} 1057 1058// libtest_check_order_reloc_root.so <- implements get_answer3() 1059cc_test_library { 1060 name: "libtest_check_order_reloc_root", 1061 defaults: ["bionic_testlib_defaults"], 1062 srcs: ["dlopen_check_order_reloc_root_answer.cpp"], 1063 shared_libs: [ 1064 "libtest_check_order_reloc_root_1", 1065 "libtest_check_order_reloc_root_2", 1066 ], 1067} 1068 1069// ----------------------------------------------------------------------------- 1070// Build libtest_versioned_lib.so with its dependencies. 1071// 1072// Libraries used to test versioned symbols 1073// ----------------------------------------------------------------------------- 1074 1075cc_test_library { 1076 name: "libtest_versioned_uselibv1", 1077 defaults: ["bionic_testlib_defaults"], 1078 srcs: ["versioned_uselib.cpp"], 1079 shared_libs: ["libtest_versioned_libv1"], 1080} 1081 1082cc_test_library { 1083 name: "libtest_versioned_uselibv2", 1084 defaults: ["bionic_testlib_defaults"], 1085 srcs: ["versioned_uselib.cpp"], 1086 shared_libs: ["libtest_versioned_libv2"], 1087 version_script: "versioned_uselib.map", 1088} 1089 1090cc_test_library { 1091 name: "libtest_versioned_uselibv2_other", 1092 defaults: ["bionic_testlib_defaults"], 1093 srcs: ["versioned_uselib.cpp"], 1094 shared_libs: [ 1095 "libtest_versioned_otherlib_empty", 1096 "libtest_versioned_libv2", 1097 ], 1098} 1099 1100cc_test_library { 1101 name: "libtest_versioned_uselibv3_other", 1102 defaults: ["bionic_testlib_defaults"], 1103 srcs: ["versioned_uselib.cpp"], 1104 shared_libs: [ 1105 "libtest_versioned_otherlib_empty", 1106 "libtest_versioned_lib", 1107 ], 1108} 1109 1110// lib v1 - this one used during static linking but never used at runtime 1111// which forces libtest_versioned_uselibv1 to use function v1 from 1112// libtest_versioned_lib.so 1113cc_test_library { 1114 name: "libtest_versioned_libv1", 1115 defaults: ["bionic_testlib_defaults"], 1116 srcs: ["versioned_lib_v1.cpp"], 1117 version_script: "versioned_lib_v1.map", 1118 ldflags: ["-Wl,-soname,libtest_versioned_lib.so"], 1119} 1120 1121// lib v2 - to make libtest_versioned_uselibv2.so use version 2 of versioned_function() 1122cc_test_library { 1123 name: "libtest_versioned_libv2", 1124 defaults: ["bionic_testlib_defaults"], 1125 srcs: ["versioned_lib_v2.cpp"], 1126 version_script: "versioned_lib_v2.map", 1127 ldflags: ["-Wl,-soname,libtest_versioned_lib.so"], 1128} 1129 1130// last version - this one is used at the runtime and exports 3 versions 1131// of versioned_symbol(). 1132cc_test_library { 1133 name: "libtest_versioned_lib", 1134 defaults: ["bionic_testlib_defaults"], 1135 srcs: ["versioned_lib_v3.cpp"], 1136 version_script: "versioned_lib_v3.map", 1137} 1138 1139// This library is empty, the actual implementation will provide an unversioned 1140// symbol for versioned_function(). 1141cc_test_library { 1142 name: "libtest_versioned_otherlib_empty", 1143 defaults: ["bionic_testlib_defaults"], 1144 srcs: ["empty.cpp"], 1145 ldflags: ["-Wl,-soname,libtest_versioned_otherlib.so"], 1146} 1147 1148cc_test_library { 1149 name: "libtest_versioned_otherlib", 1150 defaults: ["bionic_testlib_defaults"], 1151 srcs: ["versioned_lib_other.cpp"], 1152 version_script: "versioned_lib_other.map", 1153} 1154 1155// ----------------------------------------------------------------------------- 1156// Build libraries needed by pthread_atfork tests 1157 1158// This library used to test phtread_atfork handler behaviour 1159// during/after dlclose. 1160// ----------------------------------------------------------------------------- 1161cc_test_library { 1162 name: "libtest_pthread_atfork", 1163 defaults: ["bionic_testlib_defaults"], 1164 srcs: ["pthread_atfork.cpp"], 1165} 1166 1167// ----------------------------------------------------------------------------- 1168// Library with dependency loop used by dlfcn tests 1169// 1170// libtest_with_dependency_loop -> a -> b -> c -> a 1171// ----------------------------------------------------------------------------- 1172cc_test_library { 1173 name: "libtest_with_dependency_loop", 1174 defaults: ["bionic_testlib_defaults"], 1175 srcs: ["dlopen_testlib_loopy_root.cpp"], 1176 shared_libs: ["libtest_with_dependency_loop_a"], 1177} 1178 1179// ----------------------------------------------------------------------------- 1180// libtest_with_dependency_loop_a.so 1181// ----------------------------------------------------------------------------- 1182cc_test_library { 1183 name: "libtest_with_dependency_loop_a", 1184 defaults: ["bionic_testlib_defaults"], 1185 srcs: ["dlopen_testlib_loopy_a.cpp"], 1186 shared_libs: ["libtest_with_dependency_loop_b_tmp"], 1187} 1188 1189// ----------------------------------------------------------------------------- 1190// libtest_with_dependency_loop_b.so 1191// 1192// this is temporary placeholder - will be removed 1193// ----------------------------------------------------------------------------- 1194cc_test_library { 1195 name: "libtest_with_dependency_loop_b_tmp", 1196 defaults: ["bionic_testlib_defaults"], 1197 srcs: ["dlopen_testlib_loopy_invalid.cpp"], 1198 ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"], 1199} 1200 1201// ----------------------------------------------------------------------------- 1202// libtest_with_dependency_loop_b.so 1203// ----------------------------------------------------------------------------- 1204cc_test_library { 1205 name: "libtest_with_dependency_loop_b", 1206 defaults: ["bionic_testlib_defaults"], 1207 srcs: ["dlopen_testlib_loopy_b.cpp"], 1208 shared_libs: ["libtest_with_dependency_loop_c"], 1209} 1210 1211// ----------------------------------------------------------------------------- 1212// libtest_with_dependency_loop_c.so 1213// ----------------------------------------------------------------------------- 1214cc_test_library { 1215 name: "libtest_with_dependency_loop_c", 1216 defaults: ["bionic_testlib_defaults"], 1217 srcs: ["dlopen_testlib_loopy_c.cpp"], 1218 shared_libs: ["libtest_with_dependency_loop_a"], 1219} 1220 1221// ----------------------------------------------------------------------------- 1222// libtest_relo_check_dt_needed_order.so 1223// | 1224// +-> libtest_relo_check_dt_needed_order_1.so 1225// | 1226// +-> libtest_relo_check_dt_needed_order_2.so 1227// ----------------------------------------------------------------------------- 1228 1229cc_test_library { 1230 name: "libtest_relo_check_dt_needed_order", 1231 defaults: ["bionic_testlib_defaults"], 1232 srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"], 1233 shared_libs: [ 1234 "libtest_relo_check_dt_needed_order_1", 1235 "libtest_relo_check_dt_needed_order_2", 1236 ], 1237} 1238 1239cc_test_library { 1240 name: "libtest_relo_check_dt_needed_order_1", 1241 defaults: ["bionic_testlib_defaults"], 1242 srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"], 1243} 1244 1245cc_test_library { 1246 name: "libtest_relo_check_dt_needed_order_2", 1247 defaults: ["bionic_testlib_defaults"], 1248 srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"], 1249} 1250 1251// ----------------------------------------------------------------------------- 1252// Library with dependency used by dlfcn tests 1253// ----------------------------------------------------------------------------- 1254cc_test_library { 1255 name: "libtest_with_dependency", 1256 defaults: ["bionic_testlib_defaults"], 1257 srcs: ["dlopen_testlib_simple.cpp"], 1258 shared_libs: ["libdlext_test"], 1259} 1260 1261// ----------------------------------------------------------------------------- 1262// Library used by ifunc tests 1263// ----------------------------------------------------------------------------- 1264cc_test_library { 1265 name: "libtest_ifunc", 1266 defaults: ["bionic_testlib_defaults"], 1267 srcs: ["dlopen_testlib_ifunc.cpp"], 1268} 1269 1270cc_test_library { 1271 name: "libtest_ifunc_variable", 1272 defaults: ["bionic_testlib_defaults"], 1273 srcs: ["dlopen_testlib_ifunc_variable.cpp"], 1274 shared_libs: ["libtest_ifunc_variable_impl"], 1275} 1276 1277cc_test_library { 1278 name: "libtest_ifunc_variable_impl", 1279 defaults: ["bionic_testlib_defaults"], 1280 srcs: ["dlopen_testlib_ifunc_variable_impl.cpp"], 1281} 1282 1283// ----------------------------------------------------------------------------- 1284// Library used by atexit tests 1285// ----------------------------------------------------------------------------- 1286 1287cc_test_library { 1288 name: "libtest_atexit", 1289 defaults: ["bionic_testlib_defaults"], 1290 srcs: ["atexit_testlib.cpp"], 1291} 1292 1293// ----------------------------------------------------------------------------- 1294// This library is used by dl_load test to check symbol preempting 1295// by main executable 1296// ----------------------------------------------------------------------------- 1297cc_test_library { 1298 name: "libdl_preempt_test_1", 1299 defaults: ["bionic_testlib_defaults"], 1300 srcs: ["dl_preempt_library_1.cpp"], 1301} 1302 1303// ----------------------------------------------------------------------------- 1304// This library is used by dl_load test to check symbol preempting 1305// by libdl_preempt_test_1.so 1306// ----------------------------------------------------------------------------- 1307cc_test_library { 1308 name: "libdl_preempt_test_2", 1309 defaults: ["bionic_testlib_defaults"], 1310 srcs: ["dl_preempt_library_2.cpp"], 1311} 1312 1313// ----------------------------------------------------------------------------- 1314// Library with DF_1_GLOBAL 1315// ----------------------------------------------------------------------------- 1316cc_test_library { 1317 name: "libdl_test_df_1_global", 1318 defaults: ["bionic_testlib_defaults"], 1319 srcs: ["dl_df_1_global.cpp"], 1320 ldflags: ["-Wl,-z,global"], 1321} 1322 1323// ----------------------------------------------------------------------------- 1324// Library using symbol from libdl_test_df_1_global 1325// ----------------------------------------------------------------------------- 1326cc_test_library { 1327 name: "libtest_dlsym_df_1_global", 1328 defaults: ["bionic_testlib_defaults"], 1329 srcs: ["dl_df_1_use_global.cpp"], 1330} 1331 1332// ----------------------------------------------------------------------------- 1333// Library with DF_1_GLOBAL which will be dlopened 1334// (note: libdl_test_df_1_global above will be included in DT_NEEDED) 1335// ----------------------------------------------------------------------------- 1336cc_test_library { 1337 name: "libtest_dlopen_df_1_global", 1338 defaults: ["bionic_testlib_defaults"], 1339 srcs: ["dl_df_1_global_dummy.cpp"], 1340 ldflags: ["-Wl,-z,global"], 1341} 1342 1343// ----------------------------------------------------------------------------- 1344// Library with weak function 1345// ----------------------------------------------------------------------------- 1346cc_test_library { 1347 name: "libtest_dlsym_weak_func", 1348 defaults: ["bionic_testlib_defaults"], 1349 srcs: ["dlsym_weak_function.cpp"], 1350} 1351 1352// ----------------------------------------------------------------------------- 1353// Library to check RTLD_LOCAL with dlsym in 'this' 1354// ----------------------------------------------------------------------------- 1355cc_test_library { 1356 name: "libtest_dlsym_from_this", 1357 defaults: ["bionic_testlib_defaults"], 1358 srcs: ["dlsym_from_this_symbol.cpp"], 1359 shared_libs: ["libtest_dlsym_from_this_child"], 1360} 1361 1362// ----------------------------------------------------------------------------- 1363cc_test_library { 1364 name: "libtest_dlsym_from_this_child", 1365 defaults: ["bionic_testlib_defaults"], 1366 srcs: ["dlsym_from_this_functions.cpp"], 1367 shared_libs: ["libtest_dlsym_from_this_grandchild"], 1368} 1369 1370// ----------------------------------------------------------------------------- 1371cc_test_library { 1372 name: "libtest_dlsym_from_this_grandchild", 1373 defaults: ["bionic_testlib_defaults"], 1374 srcs: ["dlsym_from_this_symbol2.cpp"], 1375} 1376 1377// ----------------------------------------------------------------------------- 1378// Empty library 1379// ----------------------------------------------------------------------------- 1380cc_test_library { 1381 name: "libtest_empty", 1382 defaults: ["bionic_testlib_defaults"], 1383 srcs: ["empty.cpp"], 1384} 1385 1386// ----------------------------------------------------------------------------- 1387// Library for inaccessible shared library test 1388// ----------------------------------------------------------------------------- 1389cc_test_library { 1390 name: "libtestshared", 1391 defaults: ["bionic_testlib_defaults"], 1392 srcs: ["empty.cpp"], 1393 relative_install_path: "bionic-loader-test-libs/inaccessible_libs", 1394} 1395 1396// ----------------------------------------------------------------------------- 1397// Library with weak undefined function 1398// ----------------------------------------------------------------------------- 1399cc_test_library { 1400 name: "libtest_dlopen_weak_undefined_func", 1401 defaults: ["bionic_testlib_defaults"], 1402 srcs: ["dlopen_weak_undefined.cpp"], 1403} 1404 1405// ----------------------------------------------------------------------------- 1406// Check that RTLD_NEXT of a libc symbol works in dlopened library 1407// ----------------------------------------------------------------------------- 1408cc_test_library { 1409 name: "libtest_check_rtld_next_from_library", 1410 defaults: ["bionic_testlib_defaults"], 1411 srcs: ["check_rtld_next_from_library.cpp"], 1412 native_coverage: false, 1413} 1414 1415// ----------------------------------------------------------------------------- 1416// Library with constructor that calls dlopen() b/7941716 1417// ----------------------------------------------------------------------------- 1418cc_test_library { 1419 name: "libtest_dlopen_from_ctor", 1420 defaults: ["bionic_testlib_defaults"], 1421 srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"], 1422} 1423 1424// ----------------------------------------------------------------------------- 1425// Libraries used to check init/fini call order 1426// ----------------------------------------------------------------------------- 1427cc_test_library { 1428 name: "libtest_init_fini_order_root", 1429 defaults: ["bionic_testlib_defaults"], 1430 srcs: ["dlopen_check_init_fini_root.cpp"], 1431 shared_libs: [ 1432 "libtest_init_fini_order_child", 1433 "libtest_init_fini_order_grand_child", 1434 ], 1435} 1436 1437cc_test_library { 1438 name: "libtest_init_fini_order_root2", 1439 defaults: ["bionic_testlib_defaults"], 1440 srcs: ["dlopen_check_init_fini_root.cpp"], 1441 shared_libs: [ 1442 "libtest_init_fini_order_grand_child", 1443 "libtest_init_fini_order_child", 1444 ], 1445} 1446 1447cc_test_library { 1448 name: "libtest_init_fini_order_child", 1449 defaults: ["bionic_testlib_defaults"], 1450 srcs: ["dlopen_check_init_fini_child.cpp"], 1451 shared_libs: ["libtest_init_fini_order_grand_child"], 1452} 1453 1454cc_test_library { 1455 name: "libtest_init_fini_order_grand_child", 1456 defaults: ["bionic_testlib_defaults"], 1457 srcs: ["dlopen_check_init_fini_grand_child.cpp"], 1458} 1459 1460// ----------------------------------------------------------------------------- 1461// Library that depends on the library with constructor that calls dlopen() b/7941716 1462// ----------------------------------------------------------------------------- 1463cc_test_library { 1464 name: "libtest_dlopen_from_ctor_main", 1465 defaults: ["bionic_testlib_defaults"], 1466 srcs: ["empty.cpp"], 1467 shared_libs: ["libtest_dlopen_from_ctor"], 1468} 1469 1470// ----------------------------------------------------------------------------- 1471// Libraries with non-trivial thread_local variable to test dlclose() 1472// ----------------------------------------------------------------------------- 1473cc_test_library { 1474 name: "libtest_thread_local_dtor", 1475 defaults: ["bionic_testlib_defaults"], 1476 srcs: ["thread_local_dtor.cpp"], 1477} 1478 1479cc_test_library { 1480 name: "libtest_thread_local_dtor2", 1481 defaults: ["bionic_testlib_defaults"], 1482 srcs: ["thread_local_dtor2.cpp"], 1483} 1484 1485// ----------------------------------------------------------------------------- 1486// Library dt_needs libtest_thread_local_dtor/2 (to check no-unload on load_group) 1487// ----------------------------------------------------------------------------- 1488cc_test_library { 1489 name: "libtest_indirect_thread_local_dtor", 1490 defaults: ["bionic_testlib_defaults"], 1491 srcs: ["empty.cpp"], 1492 shared_libs: [ 1493 "libtest_thread_local_dtor", 1494 "libtest_thread_local_dtor2", 1495 ], 1496} 1497 1498// ----------------------------------------------------------------------------- 1499// Tool to use to align the shared libraries in a zip file. 1500// ----------------------------------------------------------------------------- 1501cc_binary_host { 1502 name: "bionic_tests_zipalign", 1503 srcs: ["bionic_tests_zipalign.cpp"], 1504 cflags: [ 1505 "-Wall", 1506 "-Werror", 1507 ], 1508 1509 static_libs: [ 1510 "libziparchive", 1511 "liblog", 1512 "libbase", 1513 "libz", 1514 "libutils", 1515 ], 1516} 1517 1518cc_test_library { 1519 name: "libcfi-test", 1520 defaults: ["bionic_testlib_defaults"], 1521 srcs: ["cfi_test_lib.cpp"], 1522 sanitize: { 1523 cfi: false, 1524 }, 1525} 1526 1527cc_test_library { 1528 name: "libcfi-test-bad", 1529 defaults: ["bionic_testlib_defaults"], 1530 srcs: ["cfi_test_bad_lib.cpp"], 1531 sanitize: { 1532 cfi: false, 1533 }, 1534} 1535 1536cc_test { 1537 name: "cfi_test_helper", 1538 host_supported: false, 1539 defaults: ["bionic_testlib_defaults"], 1540 srcs: ["cfi_test_helper.cpp"], 1541 ldflags: ["-rdynamic"], 1542} 1543 1544cc_test { 1545 name: "cfi_test_helper2", 1546 host_supported: false, 1547 defaults: ["bionic_testlib_defaults"], 1548 srcs: ["cfi_test_helper2.cpp"], 1549 shared_libs: ["libcfi-test"], 1550 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 1551} 1552 1553cc_test { 1554 name: "preinit_getauxval_test_helper", 1555 host_supported: false, 1556 defaults: ["bionic_testlib_defaults"], 1557 srcs: ["preinit_getauxval_test_helper.cpp"], 1558} 1559 1560cc_test { 1561 name: "preinit_syscall_test_helper", 1562 host_supported: false, 1563 defaults: ["bionic_testlib_defaults"], 1564 srcs: ["preinit_syscall_test_helper.cpp"], 1565} 1566 1567cc_test { 1568 name: "ld_preload_test_helper", 1569 host_supported: false, 1570 defaults: ["bionic_testlib_defaults"], 1571 srcs: ["ld_preload_test_helper.cpp"], 1572 shared_libs: ["ld_preload_test_helper_lib1"], 1573 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 1574} 1575 1576cc_test_library { 1577 name: "ld_preload_test_helper_lib1", 1578 host_supported: false, 1579 defaults: ["bionic_testlib_defaults"], 1580 srcs: ["ld_preload_test_helper_lib1.cpp"], 1581} 1582 1583cc_test_library { 1584 name: "ld_preload_test_helper_lib2", 1585 host_supported: false, 1586 defaults: ["bionic_testlib_defaults"], 1587 srcs: ["ld_preload_test_helper_lib2.cpp"], 1588} 1589 1590cc_test { 1591 name: "ld_config_test_helper", 1592 host_supported: false, 1593 defaults: ["bionic_testlib_defaults"], 1594 srcs: ["ld_config_test_helper.cpp"], 1595 shared_libs: ["ld_config_test_helper_lib1"], 1596 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 1597} 1598 1599cc_test_library { 1600 name: "ld_config_test_helper_lib1", 1601 host_supported: false, 1602 defaults: ["bionic_testlib_defaults"], 1603 srcs: ["ld_config_test_helper_lib1.cpp"], 1604 shared_libs: ["ld_config_test_helper_lib2"], 1605 relative_install_path: "bionic-loader-test-libs/ns2", 1606 // Mark the library DF_1_GLOBAL so it is added to every linker namespace. 1607 ldflags: ["-Wl,-z,global"], 1608} 1609 1610cc_test_library { 1611 name: "ld_config_test_helper_lib2", 1612 host_supported: false, 1613 defaults: ["bionic_testlib_defaults"], 1614 srcs: ["ld_config_test_helper_lib2.cpp"], 1615 relative_install_path: "bionic-loader-test-libs/ns2", 1616} 1617 1618cc_test_library { 1619 name: "ld_config_test_helper_lib3", 1620 host_supported: false, 1621 defaults: ["bionic_testlib_defaults"], 1622 srcs: ["ld_config_test_helper_lib3.cpp"], 1623} 1624 1625cc_test { 1626 name: "exec_linker_helper", 1627 host_supported: false, 1628 defaults: ["bionic_testlib_defaults"], 1629 srcs: ["exec_linker_helper.cpp"], 1630 shared_libs: ["exec_linker_helper_lib"], 1631 ldflags: ["-Wl,--rpath,${ORIGIN}/.."], 1632} 1633 1634cc_test_library { 1635 name: "exec_linker_helper_lib", 1636 host_supported: false, 1637 defaults: ["bionic_testlib_defaults"], 1638 srcs: ["exec_linker_helper_lib.cpp"], 1639} 1640 1641cc_test_library { 1642 name: "libsegment_gap_outer", 1643 host_supported: false, 1644 defaults: ["bionic_testlib_defaults"], 1645 srcs: ["segment_gap_outer.cpp"], 1646 ldflags: ["-Wl,-T,bionic/tests/libs/segment_gap_outer.lds"], 1647} 1648 1649cc_test_library { 1650 name: "libsegment_gap_inner", 1651 host_supported: false, 1652 defaults: ["bionic_testlib_defaults"], 1653 srcs: ["segment_gap_inner.cpp"], 1654} 1655 1656// ----------------------------------------------------------------------------- 1657// Check that we support all kinds of relocations: regular, "relocation packer", 1658// and both the old and new SHT_RELR constants. 1659// ----------------------------------------------------------------------------- 1660 1661// This is what got standardized for SHT_RELR. 1662cc_test_library { 1663 name: "librelocations-RELR", 1664 ldflags: [ 1665 "-Wl,--pack-dyn-relocs=relr", 1666 "-Wl,--no-use-android-relr-tags", 1667 ], 1668 host_supported: false, 1669 defaults: ["bionic_testlib_defaults"], 1670 srcs: ["relocations.cpp"], 1671} 1672 1673// This is the same encoding as SHT_RELR, but using OS-specific constants. 1674cc_test_library { 1675 name: "librelocations-ANDROID_RELR", 1676 ldflags: [ 1677 "-Wl,--pack-dyn-relocs=relr", 1678 "-Wl,--use-android-relr-tags", 1679 ], 1680 host_supported: false, 1681 defaults: ["bionic_testlib_defaults"], 1682 srcs: ["relocations.cpp"], 1683} 1684 1685// This is the old relocation packer encoding (DT_ANDROID_REL/DT_ANDROID_RELA). 1686cc_test_library { 1687 name: "librelocations-ANDROID_REL", 1688 ldflags: ["-Wl,--pack-dyn-relocs=android"], 1689 host_supported: false, 1690 defaults: ["bionic_testlib_defaults"], 1691 srcs: ["relocations.cpp"], 1692} 1693 1694// This is not packed at all. 1695cc_test_library { 1696 name: "librelocations-fat", 1697 ldflags: ["-Wl,--pack-dyn-relocs=none"], 1698 host_supported: false, 1699 defaults: ["bionic_testlib_defaults"], 1700 srcs: ["relocations.cpp"], 1701} 1702 1703cc_defaults { 1704 name: "bionic_targets_only", 1705 enabled: false, 1706 target: { 1707 android: { 1708 enabled: true, 1709 }, 1710 linux_bionic: { 1711 enabled: true, 1712 }, 1713 }, 1714} 1715 1716cc_test { 1717 name: "heap_tagging_sync_helper", 1718 defaults: [ 1719 "bionic_testlib_defaults", 1720 "bionic_targets_only", 1721 ], 1722 srcs: ["heap_tagging_helper.cpp"], 1723 sanitize: { 1724 memtag_heap: true, 1725 diag: { 1726 memtag_heap: true, 1727 }, 1728 hwaddress: false, 1729 }, 1730} 1731 1732cc_test { 1733 name: "heap_tagging_async_helper", 1734 defaults: [ 1735 "bionic_testlib_defaults", 1736 "bionic_targets_only", 1737 ], 1738 srcs: ["heap_tagging_helper.cpp"], 1739 sanitize: { 1740 memtag_heap: true, 1741 diag: { 1742 memtag_heap: false, 1743 }, 1744 hwaddress: false, 1745 }, 1746} 1747 1748cc_test { 1749 name: "heap_tagging_disabled_helper", 1750 defaults: [ 1751 "bionic_testlib_defaults", 1752 "bionic_targets_only", 1753 ], 1754 srcs: ["heap_tagging_helper.cpp"], 1755 sanitize: { 1756 memtag_heap: false, 1757 hwaddress: false, 1758 }, 1759} 1760 1761cc_test { 1762 name: "heap_tagging_static_sync_helper", 1763 defaults: [ 1764 "bionic_testlib_defaults", 1765 "bionic_targets_only", 1766 ], 1767 srcs: ["heap_tagging_helper.cpp"], 1768 static_executable: true, 1769 sanitize: { 1770 memtag_heap: true, 1771 diag: { 1772 memtag_heap: true, 1773 }, 1774 hwaddress: false, 1775 }, 1776} 1777 1778cc_test { 1779 name: "heap_tagging_static_async_helper", 1780 defaults: [ 1781 "bionic_testlib_defaults", 1782 "bionic_targets_only", 1783 ], 1784 srcs: ["heap_tagging_helper.cpp"], 1785 static_executable: true, 1786 sanitize: { 1787 memtag_heap: true, 1788 diag: { 1789 memtag_heap: false, 1790 }, 1791 hwaddress: false, 1792 }, 1793} 1794 1795cc_test { 1796 name: "heap_tagging_static_disabled_helper", 1797 defaults: [ 1798 "bionic_testlib_defaults", 1799 "bionic_targets_only", 1800 ], 1801 srcs: ["heap_tagging_helper.cpp"], 1802 static_executable: true, 1803 sanitize: { 1804 memtag_heap: false, 1805 hwaddress: false, 1806 }, 1807} 1808 1809cc_test { 1810 name: "stack_tagging_helper", 1811 defaults: [ 1812 "bionic_testlib_defaults", 1813 "bionic_targets_only", 1814 ], 1815 srcs: ["stack_tagging_helper.cpp"], 1816 sanitize: { 1817 memtag_heap: true, 1818 memtag_stack: true, 1819 diag: { 1820 memtag_heap: true, 1821 }, 1822 hwaddress: false, 1823 }, 1824 header_libs: ["bionic_libc_platform_headers"], 1825 cflags: ["-fexceptions"], 1826} 1827 1828cc_test { 1829 name: "stack_tagging_static_helper", 1830 defaults: [ 1831 "bionic_testlib_defaults", 1832 "bionic_targets_only", 1833 ], 1834 srcs: ["stack_tagging_helper.cpp"], 1835 static_executable: true, 1836 sanitize: { 1837 memtag_heap: true, 1838 memtag_stack: true, 1839 diag: { 1840 memtag_heap: true, 1841 }, 1842 hwaddress: false, 1843 }, 1844 header_libs: ["bionic_libc_platform_headers"], 1845 cflags: ["-fexceptions"], 1846} 1847 1848cc_genrule { 1849 name: "libdlext_test_zip_zipaligned", 1850 out: ["bionic-loader-test-libs/libdlext_test_zip/libdlext_test_zip_zipaligned.zip"], 1851 tools: [ 1852 "soong_zip", 1853 "bionic_tests_zipalign", 1854 ], 1855 srcs: [ 1856 ":libdlext_test_zip", 1857 ":libatest_simple_zip", 1858 ":exec_linker_helper", 1859 ":exec_linker_helper_lib", 1860 ], 1861 cmd: "mkdir -p $(genDir)/zipdir/libdir &&" + 1862 " cp $(in) $(genDir)/zipdir/libdir/ &&" + 1863 " touch $(genDir)/zipdir/empty_file.txt &&" + 1864 " $(location soong_zip) -o $(out).unaligned -L 0 -C $(genDir)/zipdir -D $(genDir)/zipdir &&" + 1865 " $(location bionic_tests_zipalign) 16384 $(out).unaligned $(out)", 1866 1867} 1868 1869cc_genrule { 1870 name: "libdlext_test_runpath_zip_zipaligned", 1871 out: ["bionic-loader-test-libs/libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip"], 1872 tools: [ 1873 "soong_zip", 1874 "bionic_tests_zipalign", 1875 ], 1876 srcs: [ 1877 ":libtest_dt_runpath_d_zip", 1878 ":libtest_dt_runpath_a", 1879 ":libtest_dt_runpath_b", 1880 ":libtest_dt_runpath_c", 1881 ":libtest_dt_runpath_x", 1882 ":libtest_dt_runpath_y", 1883 ], 1884 cmd: "mkdir -p $(genDir)/zipdir/libdir &&" + 1885 " if [[ \"$$CC_MULTILIB\" = lib32 ]]; then" + 1886 " PRIVATE_LIB_OR_LIB64=lib;" + 1887 " else" + 1888 " PRIVATE_LIB_OR_LIB64=lib64;" + 1889 " fi &&" + 1890 " if [[ -n \"$$CC_NATIVE_BRIDGE\" ]]; then" + 1891 " PRIVATE_LIB_OR_LIB64=$$PRIVATE_LIB_OR_LIB64/$$CC_NATIVE_BRIDGE;" + 1892 " fi &&" + 1893 " mkdir -p $(genDir)/zipdir/libdir/dt_runpath_a &&" + 1894 " mkdir -p $(genDir)/zipdir/libdir/dt_runpath_b_c_x &&" + 1895 " mkdir -p $(genDir)/zipdir/libdir/dt_runpath_y/$$PRIVATE_LIB_OR_LIB64 &&" + 1896 " cp $(location :libtest_dt_runpath_d_zip) $(genDir)/zipdir/libdir &&" + 1897 " cp $(location :libtest_dt_runpath_a) $(genDir)/zipdir/libdir/dt_runpath_a &&" + 1898 " cp $(location :libtest_dt_runpath_b) $(genDir)/zipdir/libdir/dt_runpath_b_c_x &&" + 1899 " cp $(location :libtest_dt_runpath_c) $(genDir)/zipdir/libdir/dt_runpath_b_c_x &&" + 1900 " cp $(location :libtest_dt_runpath_x) $(genDir)/zipdir/libdir/dt_runpath_b_c_x &&" + 1901 " cp $(location :libtest_dt_runpath_y) $(genDir)/zipdir/libdir/dt_runpath_y/$$PRIVATE_LIB_OR_LIB64 &&" + 1902 " touch $(genDir)/zipdir/empty_file.txt &&" + 1903 " $(location soong_zip) -o $(out).unaligned -L 0 -C $(genDir)/zipdir -D $(genDir)/zipdir &&" + 1904 " $(location bionic_tests_zipalign) 16384 $(out).unaligned $(out)", 1905} 1906 1907cc_defaults { 1908 name: "memtag_globals_defaults", 1909 defaults: [ 1910 "bionic_testlib_defaults", 1911 "bionic_targets_only" 1912 ], 1913 cflags: [ 1914 "-Wno-array-bounds", 1915 "-Wno-unused-variable", 1916 ], 1917 header_libs: ["bionic_libc_platform_headers"], 1918 sanitize: { 1919 hwaddress: false, 1920 memtag_heap: true, 1921 memtag_globals: true, 1922 diag: { 1923 memtag_heap: true, 1924 } 1925 }, 1926} 1927 1928cc_test_library { 1929 name: "memtag_globals_dso", 1930 defaults: [ "memtag_globals_defaults" ], 1931 srcs: ["memtag_globals_dso.cpp"], 1932} 1933 1934cc_test { 1935 name: "memtag_globals_binary", 1936 defaults: [ "memtag_globals_defaults" ], 1937 srcs: ["memtag_globals_binary.cpp"], 1938 shared_libs: [ "memtag_globals_dso" ], 1939 // This binary is used in the bionic-unit-tests as a data dependency, and is 1940 // in the same folder as memtag_globals_dso. But, the default cc_test rules 1941 // make this binary (when just explicitly built and shoved in 1942 // /data/nativetest64/) end up in a subfolder called 1943 // 'memtag_globals_binary'. When this happens, the explicit build fails to 1944 // find the DSO because the default rpath is just ${ORIGIN}, and because we 1945 // want this to be usable both from bionic-unit-tests and explicit builds, 1946 // let's just not put it in a subdirectory. 1947 no_named_install_directory: true, 1948} 1949 1950cc_test { 1951 name: "memtag_globals_binary_static", 1952 defaults: [ "memtag_globals_defaults" ], 1953 srcs: ["memtag_globals_binary.cpp"], 1954 static_libs: [ "memtag_globals_dso" ], 1955 no_named_install_directory: true, 1956 static_executable: true, 1957} 1958 1959// This is a regression test for b/314038442, where binaries built *without* MTE 1960// globals would have out-of-bounds RELR relocations, which where then `ldg`'d, 1961// which resulted in linker crashes. 1962cc_test { 1963 name: "mte_globals_relr_regression_test_b_314038442", 1964 defaults: [ 1965 "bionic_testlib_defaults", 1966 "bionic_targets_only" 1967 ], 1968 cflags: [ "-Wno-array-bounds" ], 1969 ldflags: [ "-Wl,--pack-dyn-relocs=relr" ], 1970 srcs: ["mte_globals_relr_regression_test_b_314038442.cpp"], 1971 no_named_install_directory: true, 1972 sanitize: { 1973 memtag_globals: false, 1974 }, 1975} 1976 1977// Same test as above, but also for MTE globals, just for the sake of it. 1978cc_test { 1979 name: "mte_globals_relr_regression_test_b_314038442_mte", 1980 defaults: [ 1981 "bionic_testlib_defaults", 1982 "bionic_targets_only" 1983 ], 1984 cflags: [ "-Wno-array-bounds" ], 1985 ldflags: [ "-Wl,--pack-dyn-relocs=relr" ], 1986 srcs: ["mte_globals_relr_regression_test_b_314038442.cpp"], 1987 no_named_install_directory: true, 1988 sanitize: { 1989 memtag_globals: true, 1990 }, 1991} 1992