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
17cc_defaults {
18    name: "bionic_testlib_defaults",
19    host_supported: true,
20    cflags: [
21        "-Wall",
22        "-Werror",
23    ],
24    ldflags: [
25        "-Wl,--rpath,${ORIGIN}",
26        "-Wl,--enable-new-dtags",
27    ],
28    relative_install_path: "bionic-loader-test-libs",
29    gtest: false,
30    sanitize: {
31        address: false,
32        fuzzer: false,
33    },
34    stl: "libc++_static",
35    target: {
36        darwin: {
37            enabled: false,
38        },
39    },
40}
41
42// -----------------------------------------------------------------------------
43// Libraries and helper binaries for ELF TLS
44// -----------------------------------------------------------------------------
45cc_test_library {
46    name: "libtest_elftls_shared_var",
47    defaults: ["bionic_testlib_defaults"],
48    srcs: ["elftls_shared_var.cpp"],
49    cflags: ["-fno-emulated-tls"],
50}
51
52cc_test_library {
53    name: "libtest_elftls_shared_var_ie",
54    defaults: ["bionic_testlib_defaults"],
55    srcs: ["elftls_shared_var_ie.cpp"],
56    cflags: ["-fno-emulated-tls"],
57    shared_libs: ["libtest_elftls_shared_var"],
58}
59
60cc_test_library {
61    name: "libtest_elftls_tprel",
62    defaults: ["bionic_testlib_defaults"],
63    srcs: ["elftls_tprel.cpp"],
64    cflags: ["-fno-emulated-tls"],
65}
66
67cc_test {
68    name: "elftls_dlopen_ie_error_helper",
69    defaults: ["bionic_testlib_defaults"],
70    srcs: ["elftls_dlopen_ie_error_helper.cpp"],
71    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
72}
73
74cc_test_library {
75    name: "libtest_elftls_dynamic",
76    defaults: ["bionic_testlib_defaults"],
77    srcs: ["elftls_dynamic.cpp"],
78    cflags: ["-fno-emulated-tls"],
79    shared_libs: ["libtest_elftls_shared_var"],
80}
81
82cc_test_library {
83    name: "libtest_elftls_dynamic_filler_1",
84    defaults: ["bionic_testlib_defaults"],
85    srcs: ["elftls_dynamic_filler.cpp"],
86    cflags: [
87        "-fno-emulated-tls",
88        "-DTLS_FILLER=100",
89    ],
90}
91
92cc_test_library {
93    name: "libtest_elftls_dynamic_filler_2",
94    defaults: ["bionic_testlib_defaults"],
95    srcs: ["elftls_dynamic_filler.cpp"],
96    cflags: [
97        "-fno-emulated-tls",
98        "-DTLS_FILLER=200",
99    ],
100}
101
102cc_test_library {
103    name: "libtest_elftls_dynamic_filler_3",
104    defaults: ["bionic_testlib_defaults"],
105    srcs: ["elftls_dynamic_filler.cpp"],
106    cflags: [
107        "-fno-emulated-tls",
108        "-DTLS_FILLER=300",
109    ],
110}
111
112// -----------------------------------------------------------------------------
113// Library to test gnu-styled hash
114// -----------------------------------------------------------------------------
115cc_test_library {
116    name: "libgnu-hash-table-library",
117    defaults: ["bionic_testlib_defaults"],
118    srcs: ["dlext_test_library.cpp"],
119    ldflags: ["-Wl,--hash-style=gnu"],
120}
121
122// -----------------------------------------------------------------------------
123// Library to test sysv-styled hash
124// -----------------------------------------------------------------------------
125cc_test_library {
126    name: "libsysv-hash-table-library",
127    defaults: ["bionic_testlib_defaults"],
128    srcs: ["dlext_test_library.cpp"],
129    ldflags: ["-Wl,--hash-style=sysv"],
130}
131
132// -----------------------------------------------------------------------------
133// Library used by dlext tests - with GNU RELRO program header
134// -----------------------------------------------------------------------------
135cc_test_library {
136    name: "libdlext_test",
137    defaults: ["bionic_testlib_defaults"],
138    srcs: ["dlext_test_library.cpp"],
139    ldflags: ["-Wl,-z,relro"],
140    shared_libs: ["libtest_simple"],
141}
142
143// -----------------------------------------------------------------------------
144// Library used by dlext tests - without GNU RELRO program header
145// -----------------------------------------------------------------------------
146cc_test_library {
147    name: "libdlext_test_norelro",
148    defaults: ["bionic_testlib_defaults"],
149    srcs: ["dlext_test_library.cpp"],
150    ldflags: ["-Wl,-z,norelro"],
151    shared_libs: ["libtest_simple"],
152}
153
154// -----------------------------------------------------------------------------
155// Library used by dlext tests - recursive use of RELRO sharing
156// -----------------------------------------------------------------------------
157cc_test_library {
158    name: "libdlext_test_recursive",
159    defaults: ["bionic_testlib_defaults"],
160    srcs: ["dlext_test_recursive_library.cpp"],
161    ldflags: ["-Wl,-z,relro"],
162    shared_libs: ["libdlext_test"],
163}
164
165// -----------------------------------------------------------------------------
166// Library used by dlext tests - different name non-default location
167// -----------------------------------------------------------------------------
168cc_test_library {
169    name: "libdlext_test_fd",
170    defaults: ["bionic_testlib_defaults"],
171    host_supported: false,
172    srcs: ["dlext_test_library.cpp"],
173    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
174    relative_install_path: "bionic-loader-test-libs/libdlext_test_fd",
175    shared_libs: ["libtest_simple"],
176}
177
178// -----------------------------------------------------------------------------
179// Libraries used by dlext tests for open from a zip-file
180// -----------------------------------------------------------------------------
181cc_test_library {
182    name: "libdlext_test_zip",
183    defaults: ["bionic_testlib_defaults"],
184    host_supported: false,
185    srcs: ["dlext_test_library.cpp"],
186    shared_libs: ["libatest_simple_zip"],
187    relative_install_path: "bionic-loader-test-libs/libdlext_test_zip",
188}
189
190cc_test_library {
191    name: "libatest_simple_zip",
192    defaults: ["bionic_testlib_defaults"],
193    host_supported: false,
194    srcs: ["dlopen_testlib_simple.cpp"],
195    relative_install_path: "bionic-loader-test-libs/libatest_simple_zip",
196}
197
198// ----------------------------------------------------------------------------
199// Library with soname which does not match filename
200// ----------------------------------------------------------------------------
201cc_test_library {
202    name: "libdlext_test_different_soname",
203    defaults: ["bionic_testlib_defaults"],
204    srcs: ["dlext_test_library.cpp"],
205    ldflags: ["-Wl,-soname=libdlext_test_soname.so"],
206}
207
208// -----------------------------------------------------------------------------
209// Library used by dlext tests - zipped and aligned
210// -----------------------------------------------------------------------------
211// In Android.mk to support zipped and aligned tests
212
213// -----------------------------------------------------------------------------
214// Library used by dlfcn tests
215// -----------------------------------------------------------------------------
216cc_test_library {
217    name: "libtest_simple",
218    defaults: ["bionic_testlib_defaults"],
219    srcs: ["dlopen_testlib_simple.cpp"],
220}
221
222// -----------------------------------------------------------------------------
223// Library used by dlext direct unload on the namespace boundary tests
224// -----------------------------------------------------------------------------
225cc_test_library {
226    name: "libtest_missing_symbol",
227    defaults: ["bionic_testlib_defaults"],
228    srcs: ["dlopen_testlib_missing_symbol.cpp"],
229    allow_undefined_symbols: true,
230    relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
231}
232
233// -----------------------------------------------------------------------------
234// Library used by dlext indirect unload on the namespace boundary tests
235//
236// These libraries produce following dependency graph:
237// libtest_missing_symbol_root (private ns)
238// +-> libbnstest_public (public ns)
239// +-> libtest_missing_symbol_child_public (public ns)
240//     +-> libnstest_public (public ns)
241// +-> libtest_missing_symbol_child_private (private_ns)
242//     +-> libnstest_public (public_ns)
243//
244// All libraries except libtest_missing_symbol are located in
245// private_namespace_libs/
246// -----------------------------------------------------------------------------
247cc_test_library {
248    name: "libtest_missing_symbol_child_public",
249    defaults: ["bionic_testlib_defaults"],
250    srcs: ["empty.cpp"],
251    relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
252    shared_libs: ["libnstest_public"],
253}
254
255cc_test_library {
256    name: "libtest_missing_symbol_child_private",
257    defaults: ["bionic_testlib_defaults"],
258    srcs: ["empty.cpp"],
259    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
260    shared_libs: ["libnstest_public"],
261}
262
263cc_test_library {
264    name: "libtest_missing_symbol_root",
265    defaults: ["bionic_testlib_defaults"],
266    srcs: ["dlopen_testlib_missing_symbol.cpp"],
267    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
268    allow_undefined_symbols: true,
269    shared_libs: [
270        "libnstest_public",
271        "libtest_missing_symbol_child_public",
272        "libtest_missing_symbol_child_private",
273    ],
274}
275
276// -----------------------------------------------------------------------------
277// -----------------------------------------------------------------------------
278// Library used by dlfcn nodelete tests
279// -----------------------------------------------------------------------------
280cc_test_library {
281    name: "libtest_nodelete_1",
282    defaults: ["bionic_testlib_defaults"],
283    srcs: ["dlopen_nodelete_1.cpp"],
284}
285
286// -----------------------------------------------------------------------------
287// Library used by dlfcn nodelete tests
288// -----------------------------------------------------------------------------
289cc_test_library {
290    name: "libtest_nodelete_2",
291    defaults: ["bionic_testlib_defaults"],
292    srcs: ["dlopen_nodelete_2.cpp"],
293}
294
295// -----------------------------------------------------------------------------
296// Library used by dlfcn nodelete tests
297// -----------------------------------------------------------------------------
298cc_test_library {
299    name: "libtest_nodelete_dt_flags_1",
300    defaults: ["bionic_testlib_defaults"],
301    srcs: ["dlopen_nodelete_dt_flags_1.cpp"],
302    ldflags: ["-Wl,-z,nodelete"],
303}
304
305// -----------------------------------------------------------------------------
306// Build test helper libraries for linker namespaces
307//
308// This set of libraries is used to verify linker namespaces.
309//
310// Test cases
311// 1. Check that private libraries loaded in different namespaces are
312//    different. Check that dlsym does not confuse them.
313// 2. Check that public libraries loaded in different namespaces are shared
314//    between them.
315// 3. Check that namespace sticks on dlopen
316// 4. Check that having access to shared library (libnstest_public.so)
317//    does not expose symbols from dependent library (libnstest_public_internal.so)
318//
319// Dependency tree (visibility)
320// libnstest_root.so (this should be local to the namespace)
321// +-> libnstest_public.so
322//     +-> libnstest_public_internal.so
323// +-> libnstest_private.so
324//
325// libnstest_dlopened.so (library in private namespace dlopened from libnstest_root.so)
326// -----------------------------------------------------------------------------
327cc_test_library {
328    name: "libnstest_root",
329    defaults: ["bionic_testlib_defaults"],
330    srcs: ["namespaces_root.cpp"],
331    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
332    shared_libs: [
333        "libnstest_public",
334        "libnstest_private",
335    ],
336}
337
338cc_test_library {
339    name: "libnstest_public_internal",
340    defaults: ["bionic_testlib_defaults"],
341    srcs: ["namespaces_public_internal.cpp"],
342    relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
343}
344
345cc_test_library {
346    name: "libnstest_public",
347    defaults: ["bionic_testlib_defaults"],
348    srcs: ["namespaces_public.cpp"],
349    relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
350    shared_libs: ["libnstest_public_internal"],
351}
352
353cc_test_library {
354    name: "libnstest_private",
355    defaults: ["bionic_testlib_defaults"],
356    srcs: ["namespaces_private.cpp"],
357    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
358}
359
360cc_test_library {
361    name: "libnstest_dlopened",
362    defaults: ["bionic_testlib_defaults"],
363    srcs: ["namespaces_dlopened.cpp"],
364    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
365}
366
367// -----------------------------------------------------------------------------
368// Build test helper libraries for linker namespaces for allow all shared libs
369//
370// This set of libraries is used to verify linker namespaces for allow all
371// shared libs.
372//
373// Test cases
374// 1. Check that namespace a exposes libnstest_ns_a_public1 to
375//    namespace b while keeping libnstest_ns_a_public1_internal as an
376//    internal lib.
377// 2. Check that namespace b exposes all libraries to namespace a.
378//
379// Dependency tree (visibility)
380// libnstest_ns_b_public2.so  (ns:b)
381// +-> libnstest_ns_a_public1.so  (ns:a)
382//     +-> libnstest_ns_a_public2_internal.so  (ns:a)
383//     +-> libnstest_ns_b_public3.so  (ns:b)
384//
385// -----------------------------------------------------------------------------
386cc_test_library {
387    name: "libnstest_ns_a_public1",
388    defaults: ["bionic_testlib_defaults"],
389    srcs: ["libnstest_ns_a_public1.cpp"],
390    relative_install_path: "bionic-loader-test-libs/ns_a",
391    shared_libs: [
392        "libnstest_ns_a_public1_internal",
393        "libnstest_ns_b_public3",
394    ],
395}
396
397cc_test_library {
398    name: "libnstest_ns_a_public1_internal",
399    defaults: ["bionic_testlib_defaults"],
400    srcs: ["libnstest_ns_a_public1_internal.cpp"],
401    relative_install_path: "bionic-loader-test-libs/ns_a",
402}
403
404cc_test_library {
405    name: "libnstest_ns_b_public2",
406    defaults: ["bionic_testlib_defaults"],
407    srcs: ["libnstest_ns_b_public2.cpp"],
408    relative_install_path: "bionic-loader-test-libs/ns_b",
409    shared_libs: ["libnstest_ns_a_public1"],
410}
411
412cc_test_library {
413    name: "libnstest_ns_b_public3",
414    defaults: ["bionic_testlib_defaults"],
415    srcs: ["libnstest_ns_b_public3.cpp"],
416    relative_install_path: "bionic-loader-test-libs/ns_b",
417}
418
419// -----------------------------------------------------------------------------
420// Build test helper libraries for linker namespaces
421//
422// This set of libraries is to test isolated namespaces
423//
424// Isolated namespaces do not allow loading of the library outside of
425// the search paths.
426//
427// This library cannot be loaded in isolated namespace because one of DT_NEEDED
428// libraries is outside of the search paths.
429//
430// libnstest_root_not_isolated.so (DT_RUNPATH = $ORIGIN/../private_namespace_libs_external/)
431// +-> libnstest_public.so
432// +-> libnstest_private_external.so (located in $ORIGIN/../private_namespace_libs_external/)
433//
434// Search path: $NATIVE_TESTS/private_namespace_libs/
435//
436// -----------------------------------------------------------------------------
437
438cc_test_library {
439    name: "libnstest_root_not_isolated",
440    defaults: ["bionic_testlib_defaults"],
441    host_supported: false,
442    srcs: ["namespaces_root.cpp"],
443    shared_libs: [
444        "libnstest_public",
445        "libnstest_private_external",
446    ],
447    relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
448    ldflags: ["-Wl,--rpath,$ORIGIN/../private_namespace_libs_external"],
449}
450
451cc_test_library {
452    name: "libnstest_private_external",
453    defaults: ["bionic_testlib_defaults"],
454    host_supported: false,
455    srcs: ["namespaces_private.cpp"],
456    relative_install_path: "bionic-loader-test-libs/private_namespace_libs_external",
457}
458
459// -----------------------------------------------------------------------------
460// ns_hidden_child linker namespace test
461// -----------------------------------------------------------------------------
462
463cc_test {
464    name: "ns_hidden_child_helper",
465    host_supported: false,
466    defaults: ["bionic_testlib_defaults"],
467    srcs: ["ns_hidden_child_helper.cpp"],
468    shared_libs: [
469        "libns_hidden_child_internal",
470        "libns_hidden_child_global",
471        "libdl_android",
472    ],
473    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
474}
475
476cc_test_library {
477    name: "libns_hidden_child_global",
478    defaults: ["bionic_testlib_defaults"],
479    host_supported: false,
480    srcs: ["ns_hidden_child_global.cpp"],
481    shared_libs: ["libns_hidden_child_internal"],
482    ldflags: ["-Wl,-z,global"],
483}
484
485cc_test_library {
486    name: "libns_hidden_child_internal",
487    defaults: ["bionic_testlib_defaults"],
488    host_supported: false,
489    srcs: ["ns_hidden_child_internal.cpp"],
490}
491
492cc_test_library {
493    name: "libns_hidden_child_public",
494    defaults: ["bionic_testlib_defaults"],
495    host_supported: false,
496    srcs: ["ns_hidden_child_public.cpp"],
497    shared_libs: ["libns_hidden_child_internal"],
498}
499
500cc_test_library {
501    name: "libns_hidden_child_app",
502    defaults: ["bionic_testlib_defaults"],
503    host_supported: false,
504    srcs: ["ns_hidden_child_app.cpp"],
505    shared_libs: ["libns_hidden_child_public"],
506    relative_install_path: "bionic-loader-test-libs/ns_hidden_child_app",
507}
508
509// -----------------------------------------------------------------------------
510// Build DT_RUNPATH test helper libraries
511//
512// Dependencies
513//
514// libtest_dt_runpath_d.so                       runpath: ${ORIGIN}/dt_runpath_b_c_x, ${ORIGIN}/dt_runpath_y/${LIB}
515// |-> dt_runpath_b_c_x/libtest_dt_runpath_b.so  runpath: ${ORIGIN}/../dt_runpath_a
516// |   |-> dt_runpath_a/libtest_dt_runpath_a.so
517// |-> dt_runpath_b_c_x/libtest_dt_runpath_c.so  runpath: ${ORIGIN}/invalid_dt_runpath
518// |   |-> libtest_dt_runpath_a.so (soname)
519// |-> dt_runpath_y/lib[64]/libtest_dt_runpath_y.so
520//
521// This one is used to test dlopen
522// dt_runpath_b_c_x/libtest_dt_runpath_x.so
523//
524// -----------------------------------------------------------------------------
525
526// A leaf library in a non-standard directory.
527cc_test_library {
528    name: "libtest_dt_runpath_a",
529    defaults: ["bionic_testlib_defaults"],
530    srcs: ["empty.cpp"],
531    relative_install_path: "bionic-loader-test-libs/dt_runpath_a",
532}
533
534// Depends on library A with a DT_RUNPATH
535cc_test_library {
536    name: "libtest_dt_runpath_b",
537    defaults: ["bionic_testlib_defaults"],
538    srcs: ["empty.cpp"],
539    shared_libs: ["libtest_dt_runpath_a"],
540    relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
541    ldflags: ["-Wl,--rpath,${ORIGIN}/../dt_runpath_a"],
542}
543
544// Depends on library A with an incorrect DT_RUNPATH. This does not matter
545// because B is the first in the D (below) dependency order, and library A
546// is already loaded using the correct DT_RUNPATH from library B.
547cc_test_library {
548    name: "libtest_dt_runpath_c",
549    defaults: ["bionic_testlib_defaults"],
550    srcs: ["empty.cpp"],
551    shared_libs: ["libtest_dt_runpath_a"],
552    relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
553    ldflags: ["-Wl,--rpath,${ORIGIN}/invalid_dt_runpath"],
554}
555
556// D depends on B, C, and Y with DT_RUNPATH.
557cc_test_library {
558    name: "libtest_dt_runpath_d",
559    defaults: ["bionic_testlib_defaults"],
560    srcs: ["dlopen_b.cpp"],
561    shared_libs: [
562        "libtest_dt_runpath_b",
563        "libtest_dt_runpath_c",
564        "libtest_dt_runpath_y",
565    ],
566    ldflags: [
567        "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x",
568        "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}",
569    ],
570}
571
572// D version for open-from-zip test with runpath
573cc_test_library {
574    name: "libtest_dt_runpath_d_zip",
575    srcs: ["dlopen_b.cpp"],
576    shared_libs: [
577        "libtest_dt_runpath_b",
578        "libtest_dt_runpath_c",
579        "libtest_dt_runpath_y",
580    ],
581    cflags: [
582        "-Wall",
583        "-Werror",
584    ],
585    gtest: false,
586    relative_install_path: "libtest_dt_runpath_d_zip",
587    ldflags: [
588        "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x",
589        "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}",
590    ],
591    sanitize: {
592        address: false,
593        fuzzer: false,
594    },
595    stl: "libc++_static",
596    target: {
597        darwin: {
598            enabled: false,
599        },
600    },
601}
602
603// A leaf library in a directory library D has DT_RUNPATH for.
604cc_test_library {
605    name: "libtest_dt_runpath_x",
606    defaults: ["bionic_testlib_defaults"],
607    srcs: ["empty.cpp"],
608    relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
609}
610
611// A leaf library in lib or lib64 directory
612cc_test_library {
613    name: "libtest_dt_runpath_y",
614    defaults: ["bionic_testlib_defaults"],
615    srcs: ["empty.cpp"],
616
617    multilib: {
618        lib32: {
619            relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib",
620        },
621        lib64: {
622            relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib64",
623        },
624    },
625}
626
627// -----------------------------------------------------------------------------
628// Build library with two parents
629//
630// Libraries used by dlfcn tests to verify local group ref_counting
631// libtest_two_parents*.so
632// -----------------------------------------------------------------------------
633
634// ..._child.so - correct answer
635cc_test_library {
636    name: "libtest_two_parents_child",
637    defaults: ["bionic_testlib_defaults"],
638    srcs: ["dlopen_2_parents_reloc_answer.cpp"],
639}
640
641// ..._parent1.so - correct answer
642cc_test_library {
643    name: "libtest_two_parents_parent1",
644    defaults: ["bionic_testlib_defaults"],
645    srcs: ["dlopen_check_order_reloc_answer_impl.cpp"],
646    shared_libs: ["libtest_two_parents_child"],
647    cflags: ["-D__ANSWER=42"],
648}
649
650// ..._parent2.so - incorrect answer
651cc_test_library {
652    name: "libtest_two_parents_parent2",
653    defaults: ["bionic_testlib_defaults"],
654    srcs: ["dlopen_check_order_reloc_answer_impl.cpp"],
655    shared_libs: ["libtest_two_parents_child"],
656    cflags: ["-D__ANSWER=1"],
657}
658
659// -----------------------------------------------------------------------------
660// Build libtest_check_order_dlsym.so with its dependencies.
661//
662// Libraries used by dlfcn tests to verify correct load order:
663// -----------------------------------------------------------------------------
664
665// libtest_check_order_2_right.so
666cc_test_library {
667    name: "libtest_check_order_dlsym_2_right",
668    defaults: ["bionic_testlib_defaults"],
669    srcs: ["dlopen_check_order_dlsym_answer.cpp"],
670    cflags: ["-D__ANSWER=42"],
671}
672
673// libtest_check_order_a.so
674cc_test_library {
675    name: "libtest_check_order_dlsym_a",
676    defaults: ["bionic_testlib_defaults"],
677    srcs: ["dlopen_check_order_dlsym_answer.cpp"],
678    cflags: ["-D__ANSWER=1"],
679}
680
681// libtest_check_order_b.so
682cc_test_library {
683    name: "libtest_check_order_dlsym_b",
684    defaults: ["bionic_testlib_defaults"],
685    srcs: ["dlopen_check_order_dlsym_answer.cpp"],
686    cflags: [
687        "-D__ANSWER=2",
688        "-D__ANSWER2=43",
689    ],
690}
691
692// libtest_check_order_c.so
693cc_test_library {
694    name: "libtest_check_order_dlsym_3_c",
695    defaults: ["bionic_testlib_defaults"],
696    srcs: ["dlopen_check_order_dlsym_answer.cpp"],
697    cflags: ["-D__ANSWER=3"],
698}
699
700// libtest_check_order_d.so
701cc_test_library {
702    name: "libtest_check_order_dlsym_d",
703    defaults: ["bionic_testlib_defaults"],
704    shared_libs: ["libtest_check_order_dlsym_b"],
705    srcs: ["dlopen_check_order_dlsym_answer.cpp"],
706    cflags: [
707        "-D__ANSWER=4",
708        "-D__ANSWER2=4",
709    ],
710}
711
712// libtest_check_order_left.so
713cc_test_library {
714    name: "libtest_check_order_dlsym_1_left",
715    defaults: ["bionic_testlib_defaults"],
716    shared_libs: [
717        "libtest_check_order_dlsym_a",
718        "libtest_check_order_dlsym_b",
719    ],
720    srcs: ["empty.cpp"],
721}
722
723// libtest_check_order.so
724cc_test_library {
725    name: "libtest_check_order_dlsym",
726    defaults: ["bionic_testlib_defaults"],
727    shared_libs: [
728        "libtest_check_order_dlsym_1_left",
729        "libtest_check_order_dlsym_2_right",
730        "libtest_check_order_dlsym_3_c",
731    ],
732    srcs: ["empty.cpp"],
733}
734
735// -----------------------------------------------------------------------------
736// Build libtest_check_order_siblings.so with its dependencies.
737//
738// Libraries used by dlfcn tests to verify correct relocation order:
739// libtest_check_order_reloc_siblings*.so
740// -----------------------------------------------------------------------------
741
742// ..._1.so - empty
743cc_test_library {
744    name: "libtest_check_order_reloc_siblings_1",
745    defaults: ["bionic_testlib_defaults"],
746    shared_libs: [
747        "libtest_check_order_reloc_siblings_a",
748        "libtest_check_order_reloc_siblings_b",
749    ],
750    srcs: ["empty.cpp"],
751}
752
753// ..._2.so - empty
754cc_test_library {
755    name: "libtest_check_order_reloc_siblings_2",
756    defaults: ["bionic_testlib_defaults"],
757    shared_libs: [
758        "libtest_check_order_reloc_siblings_c",
759        "libtest_check_order_reloc_siblings_d",
760    ],
761    srcs: [
762        "dlopen_check_order_reloc_grandchild_answer.cpp",
763    ],
764    allow_undefined_symbols: true,
765}
766
767// ..._3.so - get_answer2();
768cc_test_library {
769    name: "libtest_check_order_reloc_siblings_3",
770    defaults: ["bionic_testlib_defaults"],
771    shared_libs: [
772        "libtest_check_order_reloc_siblings_e",
773        "libtest_check_order_reloc_siblings_f",
774    ],
775    srcs: [
776        "dlopen_check_order_reloc_nephew_answer.cpp",
777    ],
778}
779
780// ..._a.so <- correct impl
781cc_test_library {
782    name: "libtest_check_order_reloc_siblings_a",
783    defaults: ["bionic_testlib_defaults"],
784    srcs: [
785        "dlopen_check_order_reloc_answer_impl.cpp",
786    ],
787    cflags: ["-D__ANSWER=42"],
788}
789
790// ..._b.so
791cc_test_library {
792    name: "libtest_check_order_reloc_siblings_b",
793    defaults: ["bionic_testlib_defaults"],
794    srcs: [
795        "dlopen_check_order_reloc_answer_impl.cpp",
796    ],
797    cflags: ["-D__ANSWER=1"],
798}
799
800// ..._c.so
801cc_test_library {
802    name: "libtest_check_order_reloc_siblings_c",
803    defaults: ["bionic_testlib_defaults"],
804    shared_libs: [
805        "libtest_check_order_reloc_siblings_c_1",
806        "libtest_check_order_reloc_siblings_c_2",
807    ],
808    srcs: [
809        "dlopen_check_order_reloc_answer_impl.cpp",
810    ],
811    cflags: ["-D__ANSWER=2"],
812}
813
814// ..._d.so
815cc_test_library {
816    name: "libtest_check_order_reloc_siblings_d",
817    defaults: ["bionic_testlib_defaults"],
818    srcs: [
819        "dlopen_check_order_reloc_answer_impl.cpp",
820    ],
821    cflags: ["-D__ANSWER=3"],
822}
823
824// ..._e.so
825cc_test_library {
826    name: "libtest_check_order_reloc_siblings_e",
827    defaults: ["bionic_testlib_defaults"],
828    srcs: [
829        "dlopen_check_order_reloc_answer_impl.cpp",
830    ],
831    cflags: [
832        "-D__ANSWER=4",
833    ],
834}
835
836// ..._f.so <- get_answer()
837cc_test_library {
838    name: "libtest_check_order_reloc_siblings_f",
839    defaults: ["bionic_testlib_defaults"],
840    srcs: [
841        "dlopen_check_order_reloc_answer.cpp",
842    ],
843}
844
845// ..._c_1.so
846cc_test_library {
847    name: "libtest_check_order_reloc_siblings_c_1",
848    defaults: ["bionic_testlib_defaults"],
849    srcs: [
850        "dlopen_check_order_reloc_grandchild_answer_impl.cpp",
851    ],
852    cflags: ["-D__ANSWER=42"],
853}
854
855// ..._c_2.so
856cc_test_library {
857    name: "libtest_check_order_reloc_siblings_c_2",
858    defaults: ["bionic_testlib_defaults"],
859    srcs: [
860        "dlopen_check_order_reloc_grandchild_answer_impl.cpp",
861    ],
862    cflags: ["-D__ANSWER=0"],
863}
864
865// libtest_check_order_reloc_siblings.so
866cc_test_library {
867    name: "libtest_check_order_reloc_siblings",
868    defaults: ["bionic_testlib_defaults"],
869    shared_libs: [
870        "libtest_check_order_reloc_siblings_1",
871        "libtest_check_order_reloc_siblings_2",
872        "libtest_check_order_reloc_siblings_3",
873    ],
874    srcs: [
875        "empty.cpp",
876    ],
877}
878
879// -----------------------------------------------------------------------------
880// Build libtest_check_order_root.so with its dependencies.
881//
882// Libraries used by dlfcn tests to verify correct relocation order:
883// libtest_check_order_reloc_root*.so
884// -----------------------------------------------------------------------------
885
886// ..._1.so - empty
887cc_test_library {
888    name: "libtest_check_order_reloc_root_1",
889    defaults: ["bionic_testlib_defaults"],
890    srcs: ["empty.cpp"],
891}
892
893// ..._2.so - this one has the incorrect answer
894cc_test_library {
895    name: "libtest_check_order_reloc_root_2",
896    defaults: ["bionic_testlib_defaults"],
897    srcs: ["dlopen_check_order_reloc_root_answer_impl.cpp"],
898    cflags: ["-D__ANSWER=2"],
899}
900
901// libtest_check_order_reloc_root.so <- implements get_answer3()
902cc_test_library {
903    name: "libtest_check_order_reloc_root",
904    defaults: ["bionic_testlib_defaults"],
905    srcs: ["dlopen_check_order_reloc_root_answer.cpp"],
906    shared_libs: [
907        "libtest_check_order_reloc_root_1",
908        "libtest_check_order_reloc_root_2",
909    ],
910}
911
912// -----------------------------------------------------------------------------
913// Build libtest_versioned_lib.so with its dependencies.
914//
915// Libraries used to test versioned symbols
916// -----------------------------------------------------------------------------
917
918cc_test_library {
919    name: "libtest_versioned_uselibv1",
920    defaults: ["bionic_testlib_defaults"],
921    srcs: ["versioned_uselib.cpp"],
922    shared_libs: ["libtest_versioned_libv1"],
923}
924
925cc_test_library {
926    name: "libtest_versioned_uselibv2",
927    defaults: ["bionic_testlib_defaults"],
928    srcs: ["versioned_uselib.cpp"],
929    shared_libs: ["libtest_versioned_libv2"],
930    version_script: "versioned_uselib.map",
931}
932
933cc_test_library {
934    name: "libtest_versioned_uselibv2_other",
935    defaults: ["bionic_testlib_defaults"],
936    srcs: ["versioned_uselib.cpp"],
937    shared_libs: [
938        "libtest_versioned_otherlib_empty",
939        "libtest_versioned_libv2",
940    ],
941}
942
943cc_test_library {
944    name: "libtest_versioned_uselibv3_other",
945    defaults: ["bionic_testlib_defaults"],
946    srcs: ["versioned_uselib.cpp"],
947    shared_libs: [
948        "libtest_versioned_otherlib_empty",
949        "libtest_versioned_lib",
950    ],
951}
952
953// lib v1 - this one used during static linking but never used at runtime
954// which forces libtest_versioned_uselibv1 to use function v1 from
955// libtest_versioned_lib.so
956cc_test_library {
957    name: "libtest_versioned_libv1",
958    defaults: ["bionic_testlib_defaults"],
959    srcs: ["versioned_lib_v1.cpp"],
960    version_script: "versioned_lib_v1.map",
961    ldflags: ["-Wl,-soname,libtest_versioned_lib.so"],
962}
963
964// lib v2 - to make libtest_versioned_uselibv2.so use version 2 of versioned_function()
965cc_test_library {
966    name: "libtest_versioned_libv2",
967    defaults: ["bionic_testlib_defaults"],
968    srcs: ["versioned_lib_v2.cpp"],
969    version_script: "versioned_lib_v2.map",
970    ldflags: ["-Wl,-soname,libtest_versioned_lib.so"],
971}
972
973// last version - this one is used at the runtime and exports 3 versions
974// of versioned_symbol().
975cc_test_library {
976    name: "libtest_versioned_lib",
977    defaults: ["bionic_testlib_defaults"],
978    srcs: ["versioned_lib_v3.cpp"],
979    version_script: "versioned_lib_v3.map",
980}
981
982// This library is empty, the actual implementation will provide an unversioned
983// symbol for versioned_function().
984cc_test_library {
985    name: "libtest_versioned_otherlib_empty",
986    defaults: ["bionic_testlib_defaults"],
987    srcs: ["empty.cpp"],
988    ldflags: ["-Wl,-soname,libtest_versioned_otherlib.so"],
989}
990
991cc_test_library {
992    name: "libtest_versioned_otherlib",
993    defaults: ["bionic_testlib_defaults"],
994    srcs: ["versioned_lib_other.cpp"],
995    version_script: "versioned_lib_other.map",
996}
997
998// -----------------------------------------------------------------------------
999// Build libraries needed by pthread_atfork tests
1000
1001// This library used to test phtread_atfork handler behaviour
1002// during/after dlclose.
1003// -----------------------------------------------------------------------------
1004cc_test_library {
1005    name: "libtest_pthread_atfork",
1006    defaults: ["bionic_testlib_defaults"],
1007    srcs: ["pthread_atfork.cpp"],
1008}
1009
1010// -----------------------------------------------------------------------------
1011// Library with dependency loop used by dlfcn tests
1012//
1013// libtest_with_dependency_loop -> a -> b -> c -> a
1014// -----------------------------------------------------------------------------
1015cc_test_library {
1016    name: "libtest_with_dependency_loop",
1017    defaults: ["bionic_testlib_defaults"],
1018    srcs: ["dlopen_testlib_loopy_root.cpp"],
1019    shared_libs: ["libtest_with_dependency_loop_a"],
1020}
1021
1022// -----------------------------------------------------------------------------
1023// libtest_with_dependency_loop_a.so
1024// -----------------------------------------------------------------------------
1025cc_test_library {
1026    name: "libtest_with_dependency_loop_a",
1027    defaults: ["bionic_testlib_defaults"],
1028    srcs: ["dlopen_testlib_loopy_a.cpp"],
1029    shared_libs: ["libtest_with_dependency_loop_b_tmp"],
1030}
1031
1032// -----------------------------------------------------------------------------
1033// libtest_with_dependency_loop_b.so
1034//
1035// this is temporary placeholder - will be removed
1036// -----------------------------------------------------------------------------
1037cc_test_library {
1038    name: "libtest_with_dependency_loop_b_tmp",
1039    defaults: ["bionic_testlib_defaults"],
1040    srcs: ["dlopen_testlib_loopy_invalid.cpp"],
1041    ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"],
1042}
1043
1044// -----------------------------------------------------------------------------
1045// libtest_with_dependency_loop_b.so
1046// -----------------------------------------------------------------------------
1047cc_test_library {
1048    name: "libtest_with_dependency_loop_b",
1049    defaults: ["bionic_testlib_defaults"],
1050    srcs: ["dlopen_testlib_loopy_b.cpp"],
1051    shared_libs: ["libtest_with_dependency_loop_c"],
1052}
1053
1054// -----------------------------------------------------------------------------
1055// libtest_with_dependency_loop_c.so
1056// -----------------------------------------------------------------------------
1057cc_test_library {
1058    name: "libtest_with_dependency_loop_c",
1059    defaults: ["bionic_testlib_defaults"],
1060    srcs: ["dlopen_testlib_loopy_c.cpp"],
1061    shared_libs: ["libtest_with_dependency_loop_a"],
1062}
1063
1064// -----------------------------------------------------------------------------
1065// libtest_relo_check_dt_needed_order.so
1066// |
1067// +-> libtest_relo_check_dt_needed_order_1.so
1068// |
1069// +-> libtest_relo_check_dt_needed_order_2.so
1070// -----------------------------------------------------------------------------
1071
1072cc_test_library {
1073    name: "libtest_relo_check_dt_needed_order",
1074    defaults: ["bionic_testlib_defaults"],
1075    srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"],
1076    shared_libs: [
1077        "libtest_relo_check_dt_needed_order_1",
1078        "libtest_relo_check_dt_needed_order_2",
1079    ],
1080}
1081
1082cc_test_library {
1083    name: "libtest_relo_check_dt_needed_order_1",
1084    defaults: ["bionic_testlib_defaults"],
1085    srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"],
1086}
1087
1088cc_test_library {
1089    name: "libtest_relo_check_dt_needed_order_2",
1090    defaults: ["bionic_testlib_defaults"],
1091    srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"],
1092}
1093
1094// -----------------------------------------------------------------------------
1095// Library with dependency used by dlfcn tests
1096// -----------------------------------------------------------------------------
1097cc_test_library {
1098    name: "libtest_with_dependency",
1099    defaults: ["bionic_testlib_defaults"],
1100    srcs: ["dlopen_testlib_simple.cpp"],
1101    shared_libs: ["libdlext_test"],
1102}
1103
1104// -----------------------------------------------------------------------------
1105// Library used by ifunc tests
1106// -----------------------------------------------------------------------------
1107cc_test_library {
1108    name: "libtest_ifunc",
1109    defaults: ["bionic_testlib_defaults"],
1110    srcs: ["dlopen_testlib_ifunc.cpp"],
1111}
1112
1113cc_test_library {
1114    name: "libtest_ifunc_variable",
1115    defaults: ["bionic_testlib_defaults"],
1116    srcs: ["dlopen_testlib_ifunc_variable.cpp"],
1117    shared_libs: ["libtest_ifunc_variable_impl"],
1118}
1119
1120cc_test_library {
1121    name: "libtest_ifunc_variable_impl",
1122    defaults: ["bionic_testlib_defaults"],
1123    srcs: ["dlopen_testlib_ifunc_variable_impl.cpp"],
1124}
1125
1126// -----------------------------------------------------------------------------
1127// Library used by atexit tests
1128// -----------------------------------------------------------------------------
1129
1130cc_test_library {
1131    name: "libtest_atexit",
1132    defaults: ["bionic_testlib_defaults"],
1133    srcs: ["atexit_testlib.cpp"],
1134}
1135
1136// -----------------------------------------------------------------------------
1137// This library is used by dl_load test to check symbol preempting
1138// by main executable
1139// -----------------------------------------------------------------------------
1140cc_test_library {
1141    name: "libdl_preempt_test_1",
1142    defaults: ["bionic_testlib_defaults"],
1143    srcs: ["dl_preempt_library_1.cpp"],
1144}
1145
1146// -----------------------------------------------------------------------------
1147// This library is used by dl_load test to check symbol preempting
1148// by libdl_preempt_test_1.so
1149// -----------------------------------------------------------------------------
1150cc_test_library {
1151    name: "libdl_preempt_test_2",
1152    defaults: ["bionic_testlib_defaults"],
1153    srcs: ["dl_preempt_library_2.cpp"],
1154}
1155
1156// -----------------------------------------------------------------------------
1157// Library with DF_1_GLOBAL
1158// -----------------------------------------------------------------------------
1159cc_test_library {
1160    name: "libdl_test_df_1_global",
1161    defaults: ["bionic_testlib_defaults"],
1162    srcs: ["dl_df_1_global.cpp"],
1163    ldflags: ["-Wl,-z,global"],
1164
1165    target: {
1166        host: {
1167            // TODO (dimitry): host ld.gold does not yet support -z global
1168            // remove this line once it is updated.
1169            ldflags: ["-fuse-ld=bfd"],
1170        },
1171    },
1172}
1173
1174// -----------------------------------------------------------------------------
1175// Library using symbol from libdl_test_df_1_global
1176// -----------------------------------------------------------------------------
1177cc_test_library {
1178    name: "libtest_dlsym_df_1_global",
1179    defaults: ["bionic_testlib_defaults"],
1180    srcs: ["dl_df_1_use_global.cpp"],
1181}
1182
1183// -----------------------------------------------------------------------------
1184// Library with DF_1_GLOBAL which will be dlopened
1185// (note: libdl_test_df_1_global above will be included in DT_NEEDED)
1186// -----------------------------------------------------------------------------
1187cc_test_library {
1188    name: "libtest_dlopen_df_1_global",
1189    defaults: ["bionic_testlib_defaults"],
1190    srcs: ["dl_df_1_global_dummy.cpp"],
1191    ldflags: ["-Wl,-z,global"],
1192
1193    target: {
1194        host: {
1195            // TODO (dimitry): host ld.gold does not yet support -z global
1196            // remove this line once it is updated.
1197            ldflags: ["-fuse-ld=bfd"],
1198        },
1199    },
1200}
1201
1202// -----------------------------------------------------------------------------
1203// Library with weak function
1204// -----------------------------------------------------------------------------
1205cc_test_library {
1206    name: "libtest_dlsym_weak_func",
1207    defaults: ["bionic_testlib_defaults"],
1208    srcs: ["dlsym_weak_function.cpp"],
1209}
1210
1211// -----------------------------------------------------------------------------
1212// Library to check RTLD_LOCAL with dlsym in 'this'
1213// -----------------------------------------------------------------------------
1214cc_test_library {
1215    name: "libtest_dlsym_from_this",
1216    defaults: ["bionic_testlib_defaults"],
1217    srcs: ["dlsym_from_this_symbol.cpp"],
1218    shared_libs: ["libtest_dlsym_from_this_child"],
1219}
1220
1221// -----------------------------------------------------------------------------
1222cc_test_library {
1223    name: "libtest_dlsym_from_this_child",
1224    defaults: ["bionic_testlib_defaults"],
1225    srcs: ["dlsym_from_this_functions.cpp"],
1226    shared_libs: ["libtest_dlsym_from_this_grandchild"],
1227}
1228
1229// -----------------------------------------------------------------------------
1230cc_test_library {
1231    name: "libtest_dlsym_from_this_grandchild",
1232    defaults: ["bionic_testlib_defaults"],
1233    srcs: ["dlsym_from_this_symbol2.cpp"],
1234}
1235
1236// -----------------------------------------------------------------------------
1237// Empty library
1238// -----------------------------------------------------------------------------
1239cc_test_library {
1240    name: "libtest_empty",
1241    defaults: ["bionic_testlib_defaults"],
1242    srcs: ["empty.cpp"],
1243}
1244
1245// -----------------------------------------------------------------------------
1246// Library for inaccessible shared library test
1247// -----------------------------------------------------------------------------
1248cc_test_library {
1249    name: "libtestshared",
1250    defaults: ["bionic_testlib_defaults"],
1251    srcs: ["empty.cpp"],
1252    relative_install_path: "bionic-loader-test-libs/inaccessible_libs",
1253}
1254
1255// -----------------------------------------------------------------------------
1256// Library with weak undefined function
1257// -----------------------------------------------------------------------------
1258cc_test_library {
1259    name: "libtest_dlopen_weak_undefined_func",
1260    defaults: ["bionic_testlib_defaults"],
1261    srcs: ["dlopen_weak_undefined.cpp"],
1262}
1263
1264// -----------------------------------------------------------------------------
1265// Check that RTLD_NEXT of a libc symbol works in dlopened library
1266// -----------------------------------------------------------------------------
1267cc_test_library {
1268    name: "libtest_check_rtld_next_from_library",
1269    defaults: ["bionic_testlib_defaults"],
1270    srcs: ["check_rtld_next_from_library.cpp"],
1271}
1272
1273// -----------------------------------------------------------------------------
1274// Library with constructor that calls dlopen() b/7941716
1275// -----------------------------------------------------------------------------
1276cc_test_library {
1277    name: "libtest_dlopen_from_ctor",
1278    defaults: ["bionic_testlib_defaults"],
1279    srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"],
1280}
1281
1282// -----------------------------------------------------------------------------
1283// Libraries used to check init/fini call order
1284// -----------------------------------------------------------------------------
1285cc_test_library {
1286    name: "libtest_init_fini_order_root",
1287    defaults: ["bionic_testlib_defaults"],
1288    srcs: ["dlopen_check_init_fini_root.cpp"],
1289    shared_libs: [
1290        "libtest_init_fini_order_child",
1291        "libtest_init_fini_order_grand_child",
1292    ],
1293}
1294
1295cc_test_library {
1296    name: "libtest_init_fini_order_root2",
1297    defaults: ["bionic_testlib_defaults"],
1298    srcs: ["dlopen_check_init_fini_root.cpp"],
1299    shared_libs: [
1300        "libtest_init_fini_order_grand_child",
1301        "libtest_init_fini_order_child",
1302    ],
1303}
1304
1305cc_test_library {
1306    name: "libtest_init_fini_order_child",
1307    defaults: ["bionic_testlib_defaults"],
1308    srcs: ["dlopen_check_init_fini_child.cpp"],
1309    shared_libs: ["libtest_init_fini_order_grand_child"],
1310}
1311
1312cc_test_library {
1313    name: "libtest_init_fini_order_grand_child",
1314    defaults: ["bionic_testlib_defaults"],
1315    srcs: ["dlopen_check_init_fini_grand_child.cpp"],
1316}
1317
1318// -----------------------------------------------------------------------------
1319// Library that depends on the library with constructor that calls dlopen() b/7941716
1320// -----------------------------------------------------------------------------
1321cc_test_library {
1322    name: "libtest_dlopen_from_ctor_main",
1323    defaults: ["bionic_testlib_defaults"],
1324    srcs: ["empty.cpp"],
1325    shared_libs: ["libtest_dlopen_from_ctor"],
1326}
1327
1328// -----------------------------------------------------------------------------
1329// Libraries with non-trivial thread_local variable to test dlclose()
1330// -----------------------------------------------------------------------------
1331cc_test_library {
1332    name: "libtest_thread_local_dtor",
1333    defaults: ["bionic_testlib_defaults"],
1334    srcs: ["thread_local_dtor.cpp"],
1335}
1336
1337cc_test_library {
1338    name: "libtest_thread_local_dtor2",
1339    defaults: ["bionic_testlib_defaults"],
1340    srcs: ["thread_local_dtor2.cpp"],
1341}
1342
1343// -----------------------------------------------------------------------------
1344// Library dt_needs libtest_thread_local_dtor/2 (to check no-unload on load_group)
1345// -----------------------------------------------------------------------------
1346cc_test_library {
1347    name: "libtest_indirect_thread_local_dtor",
1348    defaults: ["bionic_testlib_defaults"],
1349    srcs: ["empty.cpp"],
1350    shared_libs: [
1351        "libtest_thread_local_dtor",
1352        "libtest_thread_local_dtor2",
1353    ],
1354}
1355
1356// -----------------------------------------------------------------------------
1357// Tool to use to align the shared libraries in a zip file.
1358// -----------------------------------------------------------------------------
1359cc_binary_host {
1360    name: "bionic_tests_zipalign",
1361    srcs: ["bionic_tests_zipalign.cpp"],
1362    cflags: [
1363        "-Wall",
1364        "-Werror",
1365    ],
1366
1367    static_libs: [
1368        "libziparchive",
1369        "liblog",
1370        "libbase",
1371        "libz",
1372        "libutils",
1373    ],
1374}
1375
1376cc_test_library {
1377    name: "libcfi-test",
1378    defaults: ["bionic_testlib_defaults"],
1379    srcs: ["cfi_test_lib.cpp"],
1380    sanitize: {
1381        cfi: false,
1382    },
1383}
1384
1385cc_test_library {
1386    name: "libcfi-test-bad",
1387    defaults: ["bionic_testlib_defaults"],
1388    srcs: ["cfi_test_bad_lib.cpp"],
1389    sanitize: {
1390        cfi: false,
1391    },
1392}
1393
1394cc_test {
1395    name: "cfi_test_helper",
1396    host_supported: false,
1397    defaults: ["bionic_testlib_defaults"],
1398    srcs: ["cfi_test_helper.cpp"],
1399    ldflags: ["-rdynamic"],
1400}
1401
1402cc_test {
1403    name: "cfi_test_helper2",
1404    host_supported: false,
1405    defaults: ["bionic_testlib_defaults"],
1406    srcs: ["cfi_test_helper2.cpp"],
1407    shared_libs: ["libcfi-test"],
1408    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1409}
1410
1411cc_test {
1412    name: "preinit_getauxval_test_helper",
1413    host_supported: false,
1414    defaults: ["bionic_testlib_defaults"],
1415    srcs: ["preinit_getauxval_test_helper.cpp"],
1416}
1417
1418cc_test {
1419    name: "preinit_syscall_test_helper",
1420    host_supported: false,
1421    defaults: ["bionic_testlib_defaults"],
1422    srcs: ["preinit_syscall_test_helper.cpp"],
1423}
1424
1425cc_test {
1426    name: "ld_preload_test_helper",
1427    host_supported: false,
1428    defaults: ["bionic_testlib_defaults"],
1429    srcs: ["ld_preload_test_helper.cpp"],
1430    shared_libs: ["ld_preload_test_helper_lib1"],
1431    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1432}
1433
1434cc_test_library {
1435    name: "ld_preload_test_helper_lib1",
1436    host_supported: false,
1437    defaults: ["bionic_testlib_defaults"],
1438    srcs: ["ld_preload_test_helper_lib1.cpp"],
1439}
1440
1441cc_test_library {
1442    name: "ld_preload_test_helper_lib2",
1443    host_supported: false,
1444    defaults: ["bionic_testlib_defaults"],
1445    srcs: ["ld_preload_test_helper_lib2.cpp"],
1446}
1447
1448cc_test {
1449    name: "ld_config_test_helper",
1450    host_supported: false,
1451    defaults: ["bionic_testlib_defaults"],
1452    srcs: ["ld_config_test_helper.cpp"],
1453    shared_libs: ["ld_config_test_helper_lib1"],
1454    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1455}
1456
1457cc_test_library {
1458    name: "ld_config_test_helper_lib1",
1459    host_supported: false,
1460    defaults: ["bionic_testlib_defaults"],
1461    srcs: ["ld_config_test_helper_lib1.cpp"],
1462    shared_libs: ["ld_config_test_helper_lib2"],
1463    relative_install_path: "bionic-loader-test-libs/ns2",
1464}
1465
1466cc_test_library {
1467    name: "ld_config_test_helper_lib2",
1468    host_supported: false,
1469    defaults: ["bionic_testlib_defaults"],
1470    srcs: ["ld_config_test_helper_lib2.cpp"],
1471    relative_install_path: "bionic-loader-test-libs/ns2",
1472}
1473
1474cc_test_library {
1475    name: "ld_config_test_helper_lib3",
1476    host_supported: false,
1477    defaults: ["bionic_testlib_defaults"],
1478    srcs: ["ld_config_test_helper_lib3.cpp"],
1479}
1480
1481cc_test {
1482    name: "exec_linker_helper",
1483    host_supported: false,
1484    defaults: ["bionic_testlib_defaults"],
1485    srcs: ["exec_linker_helper.cpp"],
1486    shared_libs: ["exec_linker_helper_lib"],
1487    ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1488}
1489
1490cc_test_library {
1491    name: "exec_linker_helper_lib",
1492    host_supported: false,
1493    defaults: ["bionic_testlib_defaults"],
1494    srcs: ["exec_linker_helper_lib.cpp"],
1495}
1496
1497cc_test_library {
1498    name: "libsegment_gap_outer",
1499    host_supported: false,
1500    defaults: ["bionic_testlib_defaults"],
1501    srcs: ["segment_gap_outer.cpp"],
1502    ldflags: ["-Wl,-T,bionic/tests/libs/segment_gap_outer.lds"],
1503}
1504
1505cc_test_library {
1506    name: "libsegment_gap_inner",
1507    host_supported: false,
1508    defaults: ["bionic_testlib_defaults"],
1509    srcs: ["segment_gap_inner.cpp"],
1510}
1511
1512
1513// -----------------------------------------------------------------------------
1514// Check that we support all kinds of relocations: regular, "relocation packer",
1515// and both the old and new SHT_RELR constants.
1516// -----------------------------------------------------------------------------
1517
1518// This is what got standardized for SHT_RELR.
1519cc_test_library {
1520    name: "librelocations-RELR",
1521    ldflags: [
1522        "-Wl,--pack-dyn-relocs=relr",
1523        "-Wl,--no-use-android-relr-tags",
1524    ],
1525    host_supported: false,
1526    defaults: ["bionic_testlib_defaults"],
1527    srcs: ["relocations.cpp"],
1528
1529    // Hack to ensure we're using llvm-objcopy because our binutils prebuilt
1530    // only supports the old numbers (http://b/141010852).
1531    strip: {
1532      keep_symbols: true,
1533    },
1534}
1535
1536// This is the same encoding as SHT_RELR, but using OS-specific constants.
1537cc_test_library {
1538    name: "librelocations-ANDROID_RELR",
1539    ldflags: [
1540        "-Wl,--pack-dyn-relocs=relr",
1541        "-Wl,--use-android-relr-tags",
1542    ],
1543    host_supported: false,
1544    defaults: ["bionic_testlib_defaults"],
1545    srcs: ["relocations.cpp"],
1546}
1547
1548// This is the old relocation packer encoding (DT_ANDROID_REL/DT_ANDROID_RELA).
1549cc_test_library {
1550    name: "librelocations-ANDROID_REL",
1551    ldflags: ["-Wl,--pack-dyn-relocs=android"],
1552    host_supported: false,
1553    defaults: ["bionic_testlib_defaults"],
1554    srcs: ["relocations.cpp"],
1555}
1556
1557// This is not packed at all.
1558cc_test_library {
1559    name: "librelocations-fat",
1560    ldflags: ["-Wl,--pack-dyn-relocs=none"],
1561    host_supported: false,
1562    defaults: ["bionic_testlib_defaults"],
1563    srcs: ["relocations.cpp"],
1564}
1565