blob: 9be85c8741a317989a242ab23e69f8cf2096a2ce [file] [log] [blame]
Colin Cross2722ebb2016-07-11 16:20:06 -07001//
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,
Chih-Hung Hsieh84f0dcd2017-10-02 11:47:31 -070020 cflags: [
21 "-Wall",
22 "-Werror",
23 ],
Dimitry Ivanova36e59b2016-09-01 11:37:39 -070024 ldflags: [
Dimitry Ivanovd11d1e42016-10-05 02:51:17 -070025 "-Wl,--rpath,${ORIGIN}",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -070026 "-Wl,--enable-new-dtags",
27 ],
28 relative_install_path: "bionic-loader-test-libs",
29 gtest: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070030 sanitize: {
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -070031 address: false,
Mitch Phillipsdfde0ee2019-05-01 14:26:13 -070032 fuzzer: false,
Colin Cross2722ebb2016-07-11 16:20:06 -070033 },
Yabin Cui1f553ea2017-01-13 12:31:59 -080034 stl: "libc++_static",
Colin Cross2722ebb2016-07-11 16:20:06 -070035 target: {
36 darwin: {
37 enabled: false,
38 },
39 },
40}
41
42// -----------------------------------------------------------------------------
Ryan Pricharde4ee12f2019-01-15 20:35:00 -080043// Libraries and helper binaries for ELF TLS
Elliott Hughes9724e932018-03-23 18:46:07 -070044// -----------------------------------------------------------------------------
45cc_test_library {
Ryan Pricharde4ee12f2019-01-15 20:35:00 -080046 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
Ryan Prichard06d2d792019-01-23 23:19:19 -080074cc_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"],
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -070086 cflags: [
87 "-fno-emulated-tls",
88 "-DTLS_FILLER=100",
89 ],
Ryan Prichard06d2d792019-01-23 23:19:19 -080090}
91
92cc_test_library {
93 name: "libtest_elftls_dynamic_filler_2",
94 defaults: ["bionic_testlib_defaults"],
95 srcs: ["elftls_dynamic_filler.cpp"],
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -070096 cflags: [
97 "-fno-emulated-tls",
98 "-DTLS_FILLER=200",
99 ],
Ryan Prichard06d2d792019-01-23 23:19:19 -0800100}
101
102cc_test_library {
103 name: "libtest_elftls_dynamic_filler_3",
104 defaults: ["bionic_testlib_defaults"],
105 srcs: ["elftls_dynamic_filler.cpp"],
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700106 cflags: [
107 "-fno-emulated-tls",
108 "-DTLS_FILLER=300",
109 ],
Ryan Prichard06d2d792019-01-23 23:19:19 -0800110}
111
Elliott Hughes9724e932018-03-23 18:46:07 -0700112// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700113// Library to test gnu-styled hash
114// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700115cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700116 name: "libgnu-hash-table-library",
117 defaults: ["bionic_testlib_defaults"],
118 srcs: ["dlext_test_library.cpp"],
119 ldflags: ["-Wl,--hash-style=gnu"],
120 arch: {
121 mips: {
122 enabled: false,
123 },
124 mips64: {
125 enabled: false,
126 },
127 },
128}
129
130// -----------------------------------------------------------------------------
131// Library to test sysv-styled hash
132// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700133cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700134 name: "libsysv-hash-table-library",
135 defaults: ["bionic_testlib_defaults"],
136 srcs: ["dlext_test_library.cpp"],
137 ldflags: ["-Wl,--hash-style=sysv"],
138}
139
140// -----------------------------------------------------------------------------
141// Library used by dlext tests - with GNU RELRO program header
142// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700143cc_test_library {
144 name: "libdlext_test",
145 defaults: ["bionic_testlib_defaults"],
146 srcs: ["dlext_test_library.cpp"],
147 ldflags: ["-Wl,-z,relro"],
148 shared_libs: ["libtest_simple"],
149}
Colin Cross2722ebb2016-07-11 16:20:06 -0700150
151// -----------------------------------------------------------------------------
152// Library used by dlext tests - without GNU RELRO program header
153// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700154cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700155 name: "libdlext_test_norelro",
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700156 defaults: ["bionic_testlib_defaults"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700157 srcs: ["dlext_test_library.cpp"],
158 ldflags: ["-Wl,-z,norelro"],
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800159 shared_libs: ["libtest_simple"],
Colin Cross2722ebb2016-07-11 16:20:06 -0700160}
161
162// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700163// Library used by dlext tests - recursive use of RELRO sharing
164// -----------------------------------------------------------------------------
165cc_test_library {
166 name: "libdlext_test_recursive",
167 defaults: ["bionic_testlib_defaults"],
168 srcs: ["dlext_test_recursive_library.cpp"],
169 ldflags: ["-Wl,-z,relro"],
170 shared_libs: ["libdlext_test"],
171}
172
173// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700174// Library used by dlext tests - different name non-default location
175// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700176cc_test_library {
177 name: "libdlext_test_fd",
178 defaults: ["bionic_testlib_defaults"],
179 host_supported: false,
180 srcs: ["dlext_test_library.cpp"],
181 ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
182 relative_install_path: "bionic-loader-test-libs/libdlext_test_fd",
183 shared_libs: ["libtest_simple"],
184}
Colin Cross2722ebb2016-07-11 16:20:06 -0700185
186// -----------------------------------------------------------------------------
187// Libraries used by dlext tests for open from a zip-file
188// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700189cc_test_library {
190 name: "libdlext_test_zip",
191 defaults: ["bionic_testlib_defaults"],
192 host_supported: false,
193 srcs: ["dlext_test_library.cpp"],
194 shared_libs: ["libatest_simple_zip"],
195 relative_install_path: "bionic-loader-test-libs/libdlext_test_zip",
196}
197
198cc_test_library {
199 name: "libatest_simple_zip",
200 defaults: ["bionic_testlib_defaults"],
201 host_supported: false,
202 srcs: ["dlopen_testlib_simple.cpp"],
203 relative_install_path: "bionic-loader-test-libs/libatest_simple_zip",
204}
Colin Cross2722ebb2016-07-11 16:20:06 -0700205
206// ----------------------------------------------------------------------------
207// Library with soname which does not match filename
208// ----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700209cc_test_library {
210 name: "libdlext_test_different_soname",
211 defaults: ["bionic_testlib_defaults"],
212 srcs: ["dlext_test_library.cpp"],
213 ldflags: ["-Wl,-soname=libdlext_test_soname.so"],
214}
Colin Cross2722ebb2016-07-11 16:20:06 -0700215
216// -----------------------------------------------------------------------------
217// Library used by dlext tests - zipped and aligned
218// -----------------------------------------------------------------------------
219// In Android.mk to support zipped and aligned tests
220
221// -----------------------------------------------------------------------------
222// Library used by dlfcn tests
223// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700224cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700225 name: "libtest_simple",
226 defaults: ["bionic_testlib_defaults"],
227 srcs: ["dlopen_testlib_simple.cpp"],
228}
229
230// -----------------------------------------------------------------------------
dimitry965d06d2017-11-28 16:03:07 +0100231// Library used by dlext direct unload on the namespace boundary tests
232// -----------------------------------------------------------------------------
233cc_test_library {
234 name: "libtest_missing_symbol",
235 defaults: ["bionic_testlib_defaults"],
236 srcs: ["dlopen_testlib_missing_symbol.cpp"],
237 allow_undefined_symbols: true,
238 relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
239}
240
dimitry965d06d2017-11-28 16:03:07 +0100241// -----------------------------------------------------------------------------
242// Library used by dlext indirect unload on the namespace boundary tests
243//
244// These libraries produce following dependency graph:
245// libtest_missing_symbol_root (private ns)
246// +-> libbnstest_public (public ns)
247// +-> libtest_missing_symbol_child_public (public ns)
248// +-> libnstest_public (public ns)
249// +-> libtest_missing_symbol_child_private (private_ns)
250// +-> libnstest_public (public_ns)
251//
252// All libraries except libtest_missing_symbol are located in
253// private_namespace_libs/
254// -----------------------------------------------------------------------------
255cc_test_library {
256 name: "libtest_missing_symbol_child_public",
257 defaults: ["bionic_testlib_defaults"],
258 srcs: ["empty.cpp"],
259 relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
260 shared_libs: ["libnstest_public"],
261}
262
263cc_test_library {
264 name: "libtest_missing_symbol_child_private",
265 defaults: ["bionic_testlib_defaults"],
266 srcs: ["empty.cpp"],
267 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
268 shared_libs: ["libnstest_public"],
269}
270
271cc_test_library {
272 name: "libtest_missing_symbol_root",
273 defaults: ["bionic_testlib_defaults"],
274 srcs: ["dlopen_testlib_missing_symbol.cpp"],
275 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
276 allow_undefined_symbols: true,
277 shared_libs: [
278 "libnstest_public",
279 "libtest_missing_symbol_child_public",
280 "libtest_missing_symbol_child_private",
281 ],
282}
283
284// -----------------------------------------------------------------------------
285// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -0700286// Library used by dlfcn nodelete tests
287// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700288cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700289 name: "libtest_nodelete_1",
290 defaults: ["bionic_testlib_defaults"],
291 srcs: ["dlopen_nodelete_1.cpp"],
292}
293
294// -----------------------------------------------------------------------------
295// Library used by dlfcn nodelete tests
296// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700297cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700298 name: "libtest_nodelete_2",
299 defaults: ["bionic_testlib_defaults"],
300 srcs: ["dlopen_nodelete_2.cpp"],
301}
302
303// -----------------------------------------------------------------------------
304// Library used by dlfcn nodelete tests
305// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700306cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700307 name: "libtest_nodelete_dt_flags_1",
308 defaults: ["bionic_testlib_defaults"],
309 srcs: ["dlopen_nodelete_dt_flags_1.cpp"],
310 ldflags: ["-Wl,-z,nodelete"],
311}
312
313// -----------------------------------------------------------------------------
314// Build test helper libraries for linker namespaces
dimitry965d06d2017-11-28 16:03:07 +0100315//
316// This set of libraries is used to verify linker namespaces.
317//
318// Test cases
319// 1. Check that private libraries loaded in different namespaces are
320// different. Check that dlsym does not confuse them.
321// 2. Check that public libraries loaded in different namespaces are shared
322// between them.
323// 3. Check that namespace sticks on dlopen
324// 4. Check that having access to shared library (libnstest_public.so)
325// does not expose symbols from dependent library (libnstest_public_internal.so)
326//
327// Dependency tree (visibility)
328// libnstest_root.so (this should be local to the namespace)
329// +-> libnstest_public.so
330// +-> libnstest_public_internal.so
331// +-> libnstest_private.so
332//
333// libnstest_dlopened.so (library in private namespace dlopened from libnstest_root.so)
Colin Cross2722ebb2016-07-11 16:20:06 -0700334// -----------------------------------------------------------------------------
dimitry965d06d2017-11-28 16:03:07 +0100335cc_test_library {
336 name: "libnstest_root",
337 defaults: ["bionic_testlib_defaults"],
338 srcs: ["namespaces_root.cpp"],
339 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
340 shared_libs: [
341 "libnstest_public",
342 "libnstest_private",
343 ],
Ryan Prichardcd4e5ba2019-01-17 17:45:42 -0800344 // The dlext.ns_anonymous test copies the loaded segments of this shared
345 // object into a new mapping, so every segment must be readable. Turn off
346 // eXecute-Only-Memory. See http://b/123034666.
347 xom: false,
dimitry965d06d2017-11-28 16:03:07 +0100348}
349
350cc_test_library {
351 name: "libnstest_public_internal",
352 defaults: ["bionic_testlib_defaults"],
353 srcs: ["namespaces_public_internal.cpp"],
354 relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
355}
356
357cc_test_library {
358 name: "libnstest_public",
359 defaults: ["bionic_testlib_defaults"],
360 srcs: ["namespaces_public.cpp"],
361 relative_install_path: "bionic-loader-test-libs/public_namespace_libs",
362 shared_libs: ["libnstest_public_internal"],
363}
364
365cc_test_library {
366 name: "libnstest_private",
367 defaults: ["bionic_testlib_defaults"],
368 srcs: ["namespaces_private.cpp"],
369 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
370}
371
372cc_test_library {
373 name: "libnstest_dlopened",
374 defaults: ["bionic_testlib_defaults"],
375 srcs: ["namespaces_dlopened.cpp"],
376 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
377}
Colin Cross2722ebb2016-07-11 16:20:06 -0700378
379// -----------------------------------------------------------------------------
Logan Chien9ee45912018-01-18 12:05:09 +0800380// Build test helper libraries for linker namespaces for allow all shared libs
381//
382// This set of libraries is used to verify linker namespaces for allow all
383// shared libs.
384//
385// Test cases
386// 1. Check that namespace a exposes libnstest_ns_a_public1 to
387// namespace b while keeping libnstest_ns_a_public1_internal as an
388// internal lib.
389// 2. Check that namespace b exposes all libraries to namespace a.
390//
391// Dependency tree (visibility)
392// libnstest_ns_b_public2.so (ns:b)
393// +-> libnstest_ns_a_public1.so (ns:a)
394// +-> libnstest_ns_a_public2_internal.so (ns:a)
395// +-> libnstest_ns_b_public3.so (ns:b)
396//
397// -----------------------------------------------------------------------------
398cc_test_library {
399 name: "libnstest_ns_a_public1",
400 defaults: ["bionic_testlib_defaults"],
401 srcs: ["libnstest_ns_a_public1.cpp"],
402 relative_install_path: "bionic-loader-test-libs/ns_a",
403 shared_libs: [
404 "libnstest_ns_a_public1_internal",
405 "libnstest_ns_b_public3",
406 ],
407}
408
409cc_test_library {
410 name: "libnstest_ns_a_public1_internal",
411 defaults: ["bionic_testlib_defaults"],
412 srcs: ["libnstest_ns_a_public1_internal.cpp"],
413 relative_install_path: "bionic-loader-test-libs/ns_a",
414}
415
416cc_test_library {
417 name: "libnstest_ns_b_public2",
418 defaults: ["bionic_testlib_defaults"],
419 srcs: ["libnstest_ns_b_public2.cpp"],
420 relative_install_path: "bionic-loader-test-libs/ns_b",
421 shared_libs: ["libnstest_ns_a_public1"],
422}
423
424cc_test_library {
425 name: "libnstest_ns_b_public3",
426 defaults: ["bionic_testlib_defaults"],
427 srcs: ["libnstest_ns_b_public3.cpp"],
428 relative_install_path: "bionic-loader-test-libs/ns_b",
429}
430
431// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700432// Build test helper libraries for linker namespaces
433//
434// This set of libraries is to test isolated namespaces
435//
436// Isolated namespaces do not allow loading of the library outside of
437// the search paths.
438//
439// This library cannot be loaded in isolated namespace because one of DT_NEEDED
440// libraries is outside of the search paths.
441//
442// libnstest_root_not_isolated.so (DT_RUNPATH = $ORIGIN/../private_namespace_libs_external/)
443// +-> libnstest_public.so
444// +-> libnstest_private_external.so (located in $ORIGIN/../private_namespace_libs_external/)
445//
446// Search path: $NATIVE_TESTS/private_namespace_libs/
447//
Colin Cross2722ebb2016-07-11 16:20:06 -0700448// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700449
450cc_test_library {
451 name: "libnstest_root_not_isolated",
452 defaults: ["bionic_testlib_defaults"],
453 host_supported: false,
454 srcs: ["namespaces_root.cpp"],
455 shared_libs: [
456 "libnstest_public",
457 "libnstest_private_external",
458 ],
459 relative_install_path: "bionic-loader-test-libs/private_namespace_libs",
460 ldflags: ["-Wl,--rpath,$ORIGIN/../private_namespace_libs_external"],
461}
462
463cc_test_library {
464 name: "libnstest_private_external",
465 defaults: ["bionic_testlib_defaults"],
466 host_supported: false,
467 srcs: ["namespaces_private.cpp"],
468 relative_install_path: "bionic-loader-test-libs/private_namespace_libs_external",
469}
470
471// -----------------------------------------------------------------------------
472// Build DT_RUNPATH test helper libraries
473//
474// Dependencies
475//
476// libtest_dt_runpath_d.so runpath: ${ORIGIN}/dt_runpath_b_c_x, ${ORIGIN}/dt_runpath_y/${LIB}
477// |-> dt_runpath_b_c_x/libtest_dt_runpath_b.so runpath: ${ORIGIN}/../dt_runpath_a
478// | |-> dt_runpath_a/libtest_dt_runpath_a.so
479// |-> dt_runpath_b_c_x/libtest_dt_runpath_c.so runpath: ${ORIGIN}/invalid_dt_runpath
480// | |-> libtest_dt_runpath_a.so (soname)
481// |-> dt_runpath_y/lib[64]/libtest_dt_runpath_y.so
482//
483// This one is used to test dlopen
484// dt_runpath_b_c_x/libtest_dt_runpath_x.so
485//
486// -----------------------------------------------------------------------------
487
488// A leaf library in a non-standard directory.
489cc_test_library {
490 name: "libtest_dt_runpath_a",
491 defaults: ["bionic_testlib_defaults"],
492 srcs: ["empty.cpp"],
493 relative_install_path: "bionic-loader-test-libs/dt_runpath_a",
494}
495
496// Depends on library A with a DT_RUNPATH
497cc_test_library {
498 name: "libtest_dt_runpath_b",
499 defaults: ["bionic_testlib_defaults"],
500 srcs: ["empty.cpp"],
501 shared_libs: ["libtest_dt_runpath_a"],
502 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
503 ldflags: ["-Wl,--rpath,${ORIGIN}/../dt_runpath_a"],
504}
505
506// Depends on library A with an incorrect DT_RUNPATH. This does not matter
507// because B is the first in the D (below) dependency order, and library A
508// is already loaded using the correct DT_RUNPATH from library B.
509cc_test_library {
510 name: "libtest_dt_runpath_c",
511 defaults: ["bionic_testlib_defaults"],
512 srcs: ["empty.cpp"],
513 shared_libs: ["libtest_dt_runpath_a"],
514 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
515 ldflags: ["-Wl,--rpath,${ORIGIN}/invalid_dt_runpath"],
516}
517
518// D depends on B, C, and Y with DT_RUNPATH.
519cc_test_library {
520 name: "libtest_dt_runpath_d",
521 defaults: ["bionic_testlib_defaults"],
522 srcs: ["dlopen_b.cpp"],
523 shared_libs: [
524 "libtest_dt_runpath_b",
525 "libtest_dt_runpath_c",
526 "libtest_dt_runpath_y",
527 ],
528 ldflags: [
529 "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x",
530 "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}",
531 ],
532}
533
534// D version for open-from-zip test with runpath
535cc_test_library {
536 name: "libtest_dt_runpath_d_zip",
537 srcs: ["dlopen_b.cpp"],
538 shared_libs: [
539 "libtest_dt_runpath_b",
540 "libtest_dt_runpath_c",
541 "libtest_dt_runpath_y",
542 ],
543 cflags: [
544 "-Wall",
545 "-Werror",
546 ],
547 gtest: false,
548 relative_install_path: "libtest_dt_runpath_d_zip",
549 ldflags: [
550 "-Wl,--rpath,${ORIGIN}/dt_runpath_b_c_x",
551 "-Wl,--rpath,${ORIGIN}/dt_runpath_y/${LIB}",
552 ],
553 sanitize: {
554 address: false,
555 fuzzer: false,
556 },
557 stl: "libc++_static",
558 target: {
559 darwin: {
560 enabled: false,
561 },
562 },
563}
564
565// A leaf library in a directory library D has DT_RUNPATH for.
566cc_test_library {
567 name: "libtest_dt_runpath_x",
568 defaults: ["bionic_testlib_defaults"],
569 srcs: ["empty.cpp"],
570 relative_install_path: "bionic-loader-test-libs/dt_runpath_b_c_x",
571}
572
573// A leaf library in lib or lib64 directory
574cc_test_library {
575 name: "libtest_dt_runpath_y",
576 defaults: ["bionic_testlib_defaults"],
577 srcs: ["empty.cpp"],
578
579 multilib: {
580 lib32: {
581 relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib",
582 },
583 lib64: {
584 relative_install_path: "bionic-loader-test-libs/dt_runpath_y/lib64",
585 },
586 },
587}
Colin Cross2722ebb2016-07-11 16:20:06 -0700588
589// -----------------------------------------------------------------------------
590// Build library with two parents
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700591//
592// Libraries used by dlfcn tests to verify local group ref_counting
593// libtest_two_parents*.so
Colin Cross2722ebb2016-07-11 16:20:06 -0700594// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700595
596// ..._child.so - correct answer
597cc_test_library {
598 name: "libtest_two_parents_child",
599 defaults: ["bionic_testlib_defaults"],
600 srcs: ["dlopen_2_parents_reloc_answer.cpp"],
601}
602
603// ..._parent1.so - correct answer
604cc_test_library {
605 name: "libtest_two_parents_parent1",
606 defaults: ["bionic_testlib_defaults"],
607 srcs: ["dlopen_check_order_reloc_answer_impl.cpp"],
608 shared_libs: ["libtest_two_parents_child"],
609 cflags: ["-D__ANSWER=42"],
610}
611
612// ..._parent2.so - incorrect answer
613cc_test_library {
614 name: "libtest_two_parents_parent2",
615 defaults: ["bionic_testlib_defaults"],
616 srcs: ["dlopen_check_order_reloc_answer_impl.cpp"],
617 shared_libs: ["libtest_two_parents_child"],
618 cflags: ["-D__ANSWER=1"],
619}
Colin Cross2722ebb2016-07-11 16:20:06 -0700620
621// -----------------------------------------------------------------------------
622// Build libtest_check_order_dlsym.so with its dependencies.
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700623//
624// Libraries used by dlfcn tests to verify correct load order:
Colin Cross2722ebb2016-07-11 16:20:06 -0700625// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700626
627// libtest_check_order_2_right.so
628cc_test_library {
629 name: "libtest_check_order_dlsym_2_right",
630 defaults: ["bionic_testlib_defaults"],
631 srcs: ["dlopen_check_order_dlsym_answer.cpp"],
632 cflags: ["-D__ANSWER=42"],
633}
634
635// libtest_check_order_a.so
636cc_test_library {
637 name: "libtest_check_order_dlsym_a",
638 defaults: ["bionic_testlib_defaults"],
639 srcs: ["dlopen_check_order_dlsym_answer.cpp"],
640 cflags: ["-D__ANSWER=1"],
641}
642
643// libtest_check_order_b.so
644cc_test_library {
645 name: "libtest_check_order_dlsym_b",
646 defaults: ["bionic_testlib_defaults"],
647 srcs: ["dlopen_check_order_dlsym_answer.cpp"],
648 cflags: [
649 "-D__ANSWER=2",
650 "-D__ANSWER2=43",
651 ],
652}
653
654// libtest_check_order_c.so
655cc_test_library {
656 name: "libtest_check_order_dlsym_3_c",
657 defaults: ["bionic_testlib_defaults"],
658 srcs: ["dlopen_check_order_dlsym_answer.cpp"],
659 cflags: ["-D__ANSWER=3"],
660}
661
662// libtest_check_order_d.so
663cc_test_library {
664 name: "libtest_check_order_dlsym_d",
665 defaults: ["bionic_testlib_defaults"],
666 shared_libs: ["libtest_check_order_dlsym_b"],
667 srcs: ["dlopen_check_order_dlsym_answer.cpp"],
668 cflags: [
669 "-D__ANSWER=4",
670 "-D__ANSWER2=4",
671 ],
672}
673
674// libtest_check_order_left.so
675cc_test_library {
676 name: "libtest_check_order_dlsym_1_left",
677 defaults: ["bionic_testlib_defaults"],
678 shared_libs: [
679 "libtest_check_order_dlsym_a",
680 "libtest_check_order_dlsym_b",
681 ],
682 srcs: ["empty.cpp"],
683}
684
685// libtest_check_order.so
686cc_test_library {
687 name: "libtest_check_order_dlsym",
688 defaults: ["bionic_testlib_defaults"],
689 shared_libs: [
690 "libtest_check_order_dlsym_1_left",
691 "libtest_check_order_dlsym_2_right",
692 "libtest_check_order_dlsym_3_c",
693 ],
694 srcs: ["empty.cpp"],
695}
Colin Cross2722ebb2016-07-11 16:20:06 -0700696
697// -----------------------------------------------------------------------------
698// Build libtest_check_order_siblings.so with its dependencies.
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700699//
700// Libraries used by dlfcn tests to verify correct relocation order:
701// libtest_check_order_reloc_siblings*.so
Colin Cross2722ebb2016-07-11 16:20:06 -0700702// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700703
704// ..._1.so - empty
705cc_test_library {
706 name: "libtest_check_order_reloc_siblings_1",
707 defaults: ["bionic_testlib_defaults"],
708 shared_libs: [
709 "libtest_check_order_reloc_siblings_a",
710 "libtest_check_order_reloc_siblings_b",
711 ],
712 srcs: ["empty.cpp"],
713}
714
715// ..._2.so - empty
716cc_test_library {
717 name: "libtest_check_order_reloc_siblings_2",
718 defaults: ["bionic_testlib_defaults"],
719 shared_libs: [
720 "libtest_check_order_reloc_siblings_c",
721 "libtest_check_order_reloc_siblings_d",
722 ],
723 srcs: [
724 "dlopen_check_order_reloc_grandchild_answer.cpp",
725 ],
726 allow_undefined_symbols: true,
727}
728
729// ..._3.so - get_answer2();
730cc_test_library {
731 name: "libtest_check_order_reloc_siblings_3",
732 defaults: ["bionic_testlib_defaults"],
733 shared_libs: [
734 "libtest_check_order_reloc_siblings_e",
735 "libtest_check_order_reloc_siblings_f",
736 ],
737 srcs: [
738 "dlopen_check_order_reloc_nephew_answer.cpp",
739 ],
740}
741
742// ..._a.so <- correct impl
743cc_test_library {
744 name: "libtest_check_order_reloc_siblings_a",
745 defaults: ["bionic_testlib_defaults"],
746 srcs: [
747 "dlopen_check_order_reloc_answer_impl.cpp",
748 ],
749 cflags: ["-D__ANSWER=42"],
750}
751
752// ..._b.so
753cc_test_library {
754 name: "libtest_check_order_reloc_siblings_b",
755 defaults: ["bionic_testlib_defaults"],
756 srcs: [
757 "dlopen_check_order_reloc_answer_impl.cpp",
758 ],
759 cflags: ["-D__ANSWER=1"],
760}
761
762// ..._c.so
763cc_test_library {
764 name: "libtest_check_order_reloc_siblings_c",
765 defaults: ["bionic_testlib_defaults"],
766 shared_libs: [
767 "libtest_check_order_reloc_siblings_c_1",
768 "libtest_check_order_reloc_siblings_c_2",
769 ],
770 srcs: [
771 "dlopen_check_order_reloc_answer_impl.cpp",
772 ],
773 cflags: ["-D__ANSWER=2"],
774}
775
776// ..._d.so
777cc_test_library {
778 name: "libtest_check_order_reloc_siblings_d",
779 defaults: ["bionic_testlib_defaults"],
780 srcs: [
781 "dlopen_check_order_reloc_answer_impl.cpp",
782 ],
783 cflags: ["-D__ANSWER=3"],
784}
785
786// ..._e.so
787cc_test_library {
788 name: "libtest_check_order_reloc_siblings_e",
789 defaults: ["bionic_testlib_defaults"],
790 srcs: [
791 "dlopen_check_order_reloc_answer_impl.cpp",
792 ],
793 cflags: [
794 "-D__ANSWER=4",
795 ],
796}
797
798// ..._f.so <- get_answer()
799cc_test_library {
800 name: "libtest_check_order_reloc_siblings_f",
801 defaults: ["bionic_testlib_defaults"],
802 srcs: [
803 "dlopen_check_order_reloc_answer.cpp",
804 ],
805}
806
807// ..._c_1.so
808cc_test_library {
809 name: "libtest_check_order_reloc_siblings_c_1",
810 defaults: ["bionic_testlib_defaults"],
811 srcs: [
812 "dlopen_check_order_reloc_grandchild_answer_impl.cpp",
813 ],
814 cflags: ["-D__ANSWER=42"],
815}
816
817// ..._c_2.so
818cc_test_library {
819 name: "libtest_check_order_reloc_siblings_c_2",
820 defaults: ["bionic_testlib_defaults"],
821 srcs: [
822 "dlopen_check_order_reloc_grandchild_answer_impl.cpp",
823 ],
824 cflags: ["-D__ANSWER=0"],
825}
826
827// libtest_check_order_reloc_siblings.so
828cc_test_library {
829 name: "libtest_check_order_reloc_siblings",
830 defaults: ["bionic_testlib_defaults"],
831 shared_libs: [
832 "libtest_check_order_reloc_siblings_1",
833 "libtest_check_order_reloc_siblings_2",
834 "libtest_check_order_reloc_siblings_3",
835 ],
836 srcs: [
837 "empty.cpp",
838 ],
839}
Colin Cross2722ebb2016-07-11 16:20:06 -0700840
841// -----------------------------------------------------------------------------
842// Build libtest_check_order_root.so with its dependencies.
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700843//
844// Libraries used by dlfcn tests to verify correct relocation order:
845// libtest_check_order_reloc_root*.so
Colin Cross2722ebb2016-07-11 16:20:06 -0700846// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700847
848// ..._1.so - empty
849cc_test_library {
850 name: "libtest_check_order_reloc_root_1",
851 defaults: ["bionic_testlib_defaults"],
852 srcs: ["empty.cpp"],
853}
854
855// ..._2.so - this one has the incorrect answer
856cc_test_library {
857 name: "libtest_check_order_reloc_root_2",
858 defaults: ["bionic_testlib_defaults"],
859 srcs: ["dlopen_check_order_reloc_root_answer_impl.cpp"],
860 cflags: ["-D__ANSWER=2"],
861}
862
863// libtest_check_order_reloc_root.so <- implements get_answer3()
864cc_test_library {
865 name: "libtest_check_order_reloc_root",
866 defaults: ["bionic_testlib_defaults"],
867 srcs: ["dlopen_check_order_reloc_root_answer.cpp"],
868 shared_libs: [
869 "libtest_check_order_reloc_root_1",
870 "libtest_check_order_reloc_root_2",
871 ],
872}
Colin Cross2722ebb2016-07-11 16:20:06 -0700873
874// -----------------------------------------------------------------------------
875// Build libtest_versioned_lib.so with its dependencies.
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700876//
877// Libraries used to test versioned symbols
Colin Cross2722ebb2016-07-11 16:20:06 -0700878// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700879
880cc_test_library {
881 name: "libtest_versioned_uselibv1",
882 defaults: ["bionic_testlib_defaults"],
883 srcs: ["versioned_uselib.cpp"],
884 shared_libs: ["libtest_versioned_libv1"],
885}
886
887cc_test_library {
888 name: "libtest_versioned_uselibv2",
889 defaults: ["bionic_testlib_defaults"],
890 srcs: ["versioned_uselib.cpp"],
891 shared_libs: ["libtest_versioned_libv2"],
892 version_script: "versioned_uselib.map",
893}
894
895cc_test_library {
896 name: "libtest_versioned_uselibv2_other",
897 defaults: ["bionic_testlib_defaults"],
898 srcs: ["versioned_uselib.cpp"],
899 shared_libs: [
900 "libtest_versioned_otherlib_empty",
901 "libtest_versioned_libv2",
902 ],
903}
904
905cc_test_library {
906 name: "libtest_versioned_uselibv3_other",
907 defaults: ["bionic_testlib_defaults"],
908 srcs: ["versioned_uselib.cpp"],
909 shared_libs: [
910 "libtest_versioned_otherlib_empty",
911 "libtest_versioned_lib",
912 ],
913}
914
915// lib v1 - this one used during static linking but never used at runtime
916// which forces libtest_versioned_uselibv1 to use function v1 from
917// libtest_versioned_lib.so
918cc_test_library {
919 name: "libtest_versioned_libv1",
920 defaults: ["bionic_testlib_defaults"],
921 srcs: ["versioned_lib_v1.cpp"],
922 version_script: "versioned_lib_v1.map",
923 ldflags: ["-Wl,-soname,libtest_versioned_lib.so"],
924}
925
926// lib v2 - to make libtest_versioned_uselibv2.so use version 2 of versioned_function()
927cc_test_library {
928 name: "libtest_versioned_libv2",
929 defaults: ["bionic_testlib_defaults"],
930 srcs: ["versioned_lib_v2.cpp"],
931 version_script: "versioned_lib_v2.map",
932 ldflags: ["-Wl,-soname,libtest_versioned_lib.so"],
933}
934
935// last version - this one is used at the runtime and exports 3 versions
936// of versioned_symbol().
937cc_test_library {
938 name: "libtest_versioned_lib",
939 defaults: ["bionic_testlib_defaults"],
940 srcs: ["versioned_lib_v3.cpp"],
941 version_script: "versioned_lib_v3.map",
942}
943
944// This library is empty, the actual implementation will provide an unversioned
945// symbol for versioned_function().
946cc_test_library {
947 name: "libtest_versioned_otherlib_empty",
948 defaults: ["bionic_testlib_defaults"],
949 srcs: ["empty.cpp"],
950 ldflags: ["-Wl,-soname,libtest_versioned_otherlib.so"],
951}
952
953cc_test_library {
954 name: "libtest_versioned_otherlib",
955 defaults: ["bionic_testlib_defaults"],
956 srcs: ["versioned_lib_other.cpp"],
957 version_script: "versioned_lib_other.map",
958}
Colin Cross2722ebb2016-07-11 16:20:06 -0700959
960// -----------------------------------------------------------------------------
961// Build libraries needed by pthread_atfork tests
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700962
963// This library used to test phtread_atfork handler behaviour
964// during/after dlclose.
Colin Cross2722ebb2016-07-11 16:20:06 -0700965// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -0700966cc_test_library {
967 name: "libtest_pthread_atfork",
968 defaults: ["bionic_testlib_defaults"],
969 srcs: ["pthread_atfork.cpp"],
970}
Colin Cross2722ebb2016-07-11 16:20:06 -0700971
972// -----------------------------------------------------------------------------
973// Library with dependency loop used by dlfcn tests
974//
975// libtest_with_dependency_loop -> a -> b -> c -> a
976// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700977cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700978 name: "libtest_with_dependency_loop",
979 defaults: ["bionic_testlib_defaults"],
980 srcs: ["dlopen_testlib_loopy_root.cpp"],
981 shared_libs: ["libtest_with_dependency_loop_a"],
982}
983
984// -----------------------------------------------------------------------------
985// libtest_with_dependency_loop_a.so
986// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700987cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -0700988 name: "libtest_with_dependency_loop_a",
989 defaults: ["bionic_testlib_defaults"],
990 srcs: ["dlopen_testlib_loopy_a.cpp"],
991 shared_libs: ["libtest_with_dependency_loop_b_tmp"],
992}
993
994// -----------------------------------------------------------------------------
995// libtest_with_dependency_loop_b.so
996//
997// this is temporary placeholder - will be removed
998// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -0700999cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001000 name: "libtest_with_dependency_loop_b_tmp",
1001 defaults: ["bionic_testlib_defaults"],
1002 srcs: ["dlopen_testlib_loopy_invalid.cpp"],
1003 ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"],
1004}
1005
1006// -----------------------------------------------------------------------------
1007// libtest_with_dependency_loop_b.so
1008// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001009cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001010 name: "libtest_with_dependency_loop_b",
1011 defaults: ["bionic_testlib_defaults"],
1012 srcs: ["dlopen_testlib_loopy_b.cpp"],
1013 shared_libs: ["libtest_with_dependency_loop_c"],
1014}
1015
1016// -----------------------------------------------------------------------------
1017// libtest_with_dependency_loop_c.so
1018// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001019cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001020 name: "libtest_with_dependency_loop_c",
1021 defaults: ["bionic_testlib_defaults"],
1022 srcs: ["dlopen_testlib_loopy_c.cpp"],
1023 shared_libs: ["libtest_with_dependency_loop_a"],
1024}
1025
1026// -----------------------------------------------------------------------------
1027// libtest_relo_check_dt_needed_order.so
1028// |
1029// +-> libtest_relo_check_dt_needed_order_1.so
1030// |
1031// +-> libtest_relo_check_dt_needed_order_2.so
1032// -----------------------------------------------------------------------------
1033
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001034cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001035 name: "libtest_relo_check_dt_needed_order",
1036 defaults: ["bionic_testlib_defaults"],
1037 srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"],
1038 shared_libs: [
1039 "libtest_relo_check_dt_needed_order_1",
1040 "libtest_relo_check_dt_needed_order_2",
1041 ],
1042}
1043
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001044cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001045 name: "libtest_relo_check_dt_needed_order_1",
1046 defaults: ["bionic_testlib_defaults"],
1047 srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"],
1048}
1049
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001050cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001051 name: "libtest_relo_check_dt_needed_order_2",
1052 defaults: ["bionic_testlib_defaults"],
1053 srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"],
1054}
1055
1056// -----------------------------------------------------------------------------
1057// Library with dependency used by dlfcn tests
1058// -----------------------------------------------------------------------------
Dan Willemsen4bcfe3c2019-04-19 14:55:34 -07001059cc_test_library {
1060 name: "libtest_with_dependency",
1061 defaults: ["bionic_testlib_defaults"],
1062 srcs: ["dlopen_testlib_simple.cpp"],
1063 shared_libs: ["libdlext_test"],
1064}
Colin Cross2722ebb2016-07-11 16:20:06 -07001065
1066// -----------------------------------------------------------------------------
1067// Library used by ifunc tests
1068// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001069cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001070 name: "libtest_ifunc",
1071 defaults: ["bionic_testlib_defaults"],
Dimitry Ivanov21975b22017-05-02 16:31:56 -07001072 srcs: ["dlopen_testlib_ifunc.cpp"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001073
Colin Cross2722ebb2016-07-11 16:20:06 -07001074 arch: {
1075 mips: {
1076 enabled: false,
1077 },
1078 mips64: {
1079 enabled: false,
1080 },
1081 },
Dimitry Ivanov21975b22017-05-02 16:31:56 -07001082}
1083
1084cc_test_library {
1085 name: "libtest_ifunc_variable",
1086 defaults: ["bionic_testlib_defaults"],
1087 srcs: ["dlopen_testlib_ifunc_variable.cpp"],
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001088 shared_libs: ["libtest_ifunc_variable_impl"],
Dimitry Ivanov21975b22017-05-02 16:31:56 -07001089
1090 arch: {
1091 mips: {
1092 enabled: false,
1093 },
1094 mips64: {
1095 enabled: false,
1096 },
1097 },
Dimitry Ivanov21975b22017-05-02 16:31:56 -07001098}
1099
1100cc_test_library {
1101 name: "libtest_ifunc_variable_impl",
1102 defaults: ["bionic_testlib_defaults"],
1103 srcs: ["dlopen_testlib_ifunc_variable_impl.cpp"],
1104
1105 arch: {
1106 mips: {
1107 enabled: false,
1108 },
1109 mips64: {
1110 enabled: false,
1111 },
1112 },
Colin Cross2722ebb2016-07-11 16:20:06 -07001113}
1114
1115// -----------------------------------------------------------------------------
1116// Library used by atexit tests
1117// -----------------------------------------------------------------------------
1118
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001119cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001120 name: "libtest_atexit",
1121 defaults: ["bionic_testlib_defaults"],
1122 srcs: ["atexit_testlib.cpp"],
1123}
1124
1125// -----------------------------------------------------------------------------
1126// This library is used by dl_load test to check symbol preempting
1127// by main executable
1128// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001129cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001130 name: "libdl_preempt_test_1",
1131 defaults: ["bionic_testlib_defaults"],
1132 srcs: ["dl_preempt_library_1.cpp"],
1133}
1134
1135// -----------------------------------------------------------------------------
1136// This library is used by dl_load test to check symbol preempting
1137// by libdl_preempt_test_1.so
1138// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001139cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001140 name: "libdl_preempt_test_2",
1141 defaults: ["bionic_testlib_defaults"],
1142 srcs: ["dl_preempt_library_2.cpp"],
1143}
1144
1145// -----------------------------------------------------------------------------
1146// Library with DF_1_GLOBAL
1147// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001148cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001149 name: "libdl_test_df_1_global",
1150 defaults: ["bionic_testlib_defaults"],
1151 srcs: ["dl_df_1_global.cpp"],
1152 ldflags: ["-Wl,-z,global"],
1153
1154 target: {
1155 host: {
1156 // TODO (dimitry): host ld.gold does not yet support -z global
1157 // remove this line once it is updated.
1158 ldflags: ["-fuse-ld=bfd"],
1159 },
1160 },
1161}
1162
1163// -----------------------------------------------------------------------------
1164// Library using symbol from libdl_test_df_1_global
1165// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001166cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001167 name: "libtest_dlsym_df_1_global",
1168 defaults: ["bionic_testlib_defaults"],
1169 srcs: ["dl_df_1_use_global.cpp"],
1170}
1171
1172// -----------------------------------------------------------------------------
Jiyong Park01162f22017-10-16 15:31:09 +09001173// Library with DF_1_GLOBAL which will be dlopened
1174// (note: libdl_test_df_1_global above will be included in DT_NEEDED)
1175// -----------------------------------------------------------------------------
1176cc_test_library {
1177 name: "libtest_dlopen_df_1_global",
1178 defaults: ["bionic_testlib_defaults"],
1179 srcs: ["dl_df_1_global_dummy.cpp"],
1180 ldflags: ["-Wl,-z,global"],
1181
1182 target: {
1183 host: {
1184 // TODO (dimitry): host ld.gold does not yet support -z global
1185 // remove this line once it is updated.
1186 ldflags: ["-fuse-ld=bfd"],
1187 },
1188 },
1189}
1190
Jiyong Park01162f22017-10-16 15:31:09 +09001191// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -07001192// Library with weak function
1193// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001194cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001195 name: "libtest_dlsym_weak_func",
1196 defaults: ["bionic_testlib_defaults"],
1197 srcs: ["dlsym_weak_function.cpp"],
1198}
1199
1200// -----------------------------------------------------------------------------
1201// Library to check RTLD_LOCAL with dlsym in 'this'
1202// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001203cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001204 name: "libtest_dlsym_from_this",
1205 defaults: ["bionic_testlib_defaults"],
1206 srcs: ["dlsym_from_this_symbol.cpp"],
1207 shared_libs: ["libtest_dlsym_from_this_child"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001208}
1209
1210// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001211cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001212 name: "libtest_dlsym_from_this_child",
1213 defaults: ["bionic_testlib_defaults"],
1214 srcs: ["dlsym_from_this_functions.cpp"],
1215 shared_libs: ["libtest_dlsym_from_this_grandchild"],
1216}
1217
1218// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001219cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001220 name: "libtest_dlsym_from_this_grandchild",
1221 defaults: ["bionic_testlib_defaults"],
1222 srcs: ["dlsym_from_this_symbol2.cpp"],
1223}
1224
1225// -----------------------------------------------------------------------------
1226// Empty library
1227// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001228cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001229 name: "libtest_empty",
1230 defaults: ["bionic_testlib_defaults"],
1231 srcs: ["empty.cpp"],
1232}
1233
1234// -----------------------------------------------------------------------------
dimitry8db36a52017-10-23 15:10:10 +02001235// Library for inaccessible shared library test
1236// -----------------------------------------------------------------------------
1237cc_test_library {
1238 name: "libtestshared",
1239 defaults: ["bionic_testlib_defaults"],
1240 srcs: ["empty.cpp"],
Nan Zhangdab0fd52017-11-07 11:05:24 -08001241 relative_install_path: "bionic-loader-test-libs/inaccessible_libs",
dimitry8db36a52017-10-23 15:10:10 +02001242}
1243
1244// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -07001245// Library with weak undefined function
1246// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001247cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001248 name: "libtest_dlopen_weak_undefined_func",
1249 defaults: ["bionic_testlib_defaults"],
1250 srcs: ["dlopen_weak_undefined.cpp"],
1251}
1252
1253// -----------------------------------------------------------------------------
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001254// Check that RTLD_NEXT of a libc symbol works in dlopened library
1255// -----------------------------------------------------------------------------
1256cc_test_library {
1257 name: "libtest_check_rtld_next_from_library",
1258 defaults: ["bionic_testlib_defaults"],
1259 srcs: ["check_rtld_next_from_library.cpp"],
Dimitry Ivanovd0b5c3a2016-11-25 12:23:11 -08001260}
1261
1262// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -07001263// Library with constructor that calls dlopen() b/7941716
1264// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001265cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001266 name: "libtest_dlopen_from_ctor",
1267 defaults: ["bionic_testlib_defaults"],
1268 srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"],
Colin Cross2722ebb2016-07-11 16:20:06 -07001269}
1270
1271// -----------------------------------------------------------------------------
Dimitry Ivanovec90e242017-02-10 11:04:20 -08001272// Libraries used to check init/fini call order
Dimitry Ivanovea8f3962017-02-09 13:31:57 -08001273// -----------------------------------------------------------------------------
1274cc_test_library {
1275 name: "libtest_init_fini_order_root",
1276 defaults: ["bionic_testlib_defaults"],
1277 srcs: ["dlopen_check_init_fini_root.cpp"],
Dimitry Ivanovec90e242017-02-10 11:04:20 -08001278 shared_libs: [
1279 "libtest_init_fini_order_child",
1280 "libtest_init_fini_order_grand_child",
1281 ],
1282}
1283
1284cc_test_library {
1285 name: "libtest_init_fini_order_root2",
1286 defaults: ["bionic_testlib_defaults"],
1287 srcs: ["dlopen_check_init_fini_root.cpp"],
1288 shared_libs: [
1289 "libtest_init_fini_order_grand_child",
1290 "libtest_init_fini_order_child",
1291 ],
Dimitry Ivanovea8f3962017-02-09 13:31:57 -08001292}
1293
1294cc_test_library {
1295 name: "libtest_init_fini_order_child",
1296 defaults: ["bionic_testlib_defaults"],
1297 srcs: ["dlopen_check_init_fini_child.cpp"],
1298 shared_libs: ["libtest_init_fini_order_grand_child"],
1299}
1300
1301cc_test_library {
1302 name: "libtest_init_fini_order_grand_child",
1303 defaults: ["bionic_testlib_defaults"],
1304 srcs: ["dlopen_check_init_fini_grand_child.cpp"],
1305}
1306
1307// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -07001308// Library that depends on the library with constructor that calls dlopen() b/7941716
1309// -----------------------------------------------------------------------------
Dimitry Ivanova36e59b2016-09-01 11:37:39 -07001310cc_test_library {
Colin Cross2722ebb2016-07-11 16:20:06 -07001311 name: "libtest_dlopen_from_ctor_main",
1312 defaults: ["bionic_testlib_defaults"],
1313 srcs: ["empty.cpp"],
1314 shared_libs: ["libtest_dlopen_from_ctor"],
1315}
1316
1317// -----------------------------------------------------------------------------
dimitry55547db2018-05-25 14:17:37 +02001318// Libraries with non-trivial thread_local variable to test dlclose()
dimitry06016f22018-01-05 11:39:28 +01001319// -----------------------------------------------------------------------------
1320cc_test_library {
1321 name: "libtest_thread_local_dtor",
1322 defaults: ["bionic_testlib_defaults"],
1323 srcs: ["thread_local_dtor.cpp"],
1324}
1325
dimitry55547db2018-05-25 14:17:37 +02001326cc_test_library {
1327 name: "libtest_thread_local_dtor2",
1328 defaults: ["bionic_testlib_defaults"],
1329 srcs: ["thread_local_dtor2.cpp"],
1330}
1331
1332// -----------------------------------------------------------------------------
1333// Library dt_needs libtest_thread_local_dtor/2 (to check no-unload on load_group)
1334// -----------------------------------------------------------------------------
1335cc_test_library {
1336 name: "libtest_indirect_thread_local_dtor",
1337 defaults: ["bionic_testlib_defaults"],
1338 srcs: ["empty.cpp"],
1339 shared_libs: [
1340 "libtest_thread_local_dtor",
1341 "libtest_thread_local_dtor2",
1342 ],
1343}
1344
dimitry06016f22018-01-05 11:39:28 +01001345// -----------------------------------------------------------------------------
Colin Cross2722ebb2016-07-11 16:20:06 -07001346// Tool to use to align the shared libraries in a zip file.
1347// -----------------------------------------------------------------------------
1348cc_binary_host {
1349 name: "bionic_tests_zipalign",
1350 srcs: ["bionic_tests_zipalign.cpp"],
1351 cflags: [
1352 "-Wall",
1353 "-Werror",
1354 ],
1355
1356 static_libs: [
1357 "libziparchive",
1358 "liblog",
1359 "libbase",
1360 "libz",
1361 "libutils",
1362 ],
Colin Cross2722ebb2016-07-11 16:20:06 -07001363}
Evgenii Stepanov0a3637d2016-07-06 13:20:59 -07001364
1365cc_test_library {
1366 name: "libcfi-test",
1367 defaults: ["bionic_testlib_defaults"],
1368 srcs: ["cfi_test_lib.cpp"],
1369 sanitize: {
1370 cfi: false,
1371 },
1372}
1373
1374cc_test_library {
1375 name: "libcfi-test-bad",
1376 defaults: ["bionic_testlib_defaults"],
1377 srcs: ["cfi_test_bad_lib.cpp"],
1378 sanitize: {
1379 cfi: false,
1380 },
1381}
Evgenii Stepanov68ecec12017-01-31 13:19:30 -08001382
1383cc_test {
1384 name: "cfi_test_helper",
1385 host_supported: false,
1386 defaults: ["bionic_testlib_defaults"],
1387 srcs: ["cfi_test_helper.cpp"],
1388 ldflags: ["-rdynamic"],
1389}
1390
1391cc_test {
1392 name: "cfi_test_helper2",
1393 host_supported: false,
1394 defaults: ["bionic_testlib_defaults"],
1395 srcs: ["cfi_test_helper2.cpp"],
1396 shared_libs: ["libcfi-test"],
1397 ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1398}
Elliott Hugheseb04ed52017-03-29 13:48:02 -07001399
1400cc_test {
1401 name: "preinit_getauxval_test_helper",
1402 host_supported: false,
1403 defaults: ["bionic_testlib_defaults"],
1404 srcs: ["preinit_getauxval_test_helper.cpp"],
1405}
1406
1407cc_test {
1408 name: "preinit_syscall_test_helper",
1409 host_supported: false,
1410 defaults: ["bionic_testlib_defaults"],
1411 srcs: ["preinit_syscall_test_helper.cpp"],
1412}
Jiyong Park02586a22017-05-20 01:01:24 +09001413
1414cc_test {
1415 name: "ld_preload_test_helper",
1416 host_supported: false,
1417 defaults: ["bionic_testlib_defaults"],
1418 srcs: ["ld_preload_test_helper.cpp"],
1419 shared_libs: ["ld_preload_test_helper_lib1"],
1420 ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1421}
1422
1423cc_test_library {
1424 name: "ld_preload_test_helper_lib1",
1425 host_supported: false,
1426 defaults: ["bionic_testlib_defaults"],
1427 srcs: ["ld_preload_test_helper_lib1.cpp"],
1428}
1429
1430cc_test_library {
1431 name: "ld_preload_test_helper_lib2",
1432 host_supported: false,
1433 defaults: ["bionic_testlib_defaults"],
1434 srcs: ["ld_preload_test_helper_lib2.cpp"],
1435}
1436
1437cc_test {
1438 name: "ld_config_test_helper",
1439 host_supported: false,
1440 defaults: ["bionic_testlib_defaults"],
1441 srcs: ["ld_config_test_helper.cpp"],
1442 shared_libs: ["ld_config_test_helper_lib1"],
1443 ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1444}
1445
1446cc_test_library {
1447 name: "ld_config_test_helper_lib1",
1448 host_supported: false,
1449 defaults: ["bionic_testlib_defaults"],
1450 srcs: ["ld_config_test_helper_lib1.cpp"],
1451 shared_libs: ["ld_config_test_helper_lib2"],
Nan Zhangdab0fd52017-11-07 11:05:24 -08001452 relative_install_path: "bionic-loader-test-libs/ns2",
Jiyong Park02586a22017-05-20 01:01:24 +09001453}
1454
1455cc_test_library {
1456 name: "ld_config_test_helper_lib2",
1457 host_supported: false,
1458 defaults: ["bionic_testlib_defaults"],
1459 srcs: ["ld_config_test_helper_lib2.cpp"],
Nan Zhangdab0fd52017-11-07 11:05:24 -08001460 relative_install_path: "bionic-loader-test-libs/ns2",
Jiyong Park02586a22017-05-20 01:01:24 +09001461}
1462
1463cc_test_library {
1464 name: "ld_config_test_helper_lib3",
1465 host_supported: false,
1466 defaults: ["bionic_testlib_defaults"],
1467 srcs: ["ld_config_test_helper_lib3.cpp"],
1468}
Ryan Prichard8f639a42018-10-01 23:10:05 -07001469
1470cc_test {
1471 name: "exec_linker_helper",
1472 host_supported: false,
1473 defaults: ["bionic_testlib_defaults"],
1474 srcs: ["exec_linker_helper.cpp"],
1475 shared_libs: ["exec_linker_helper_lib"],
1476 ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
1477}
1478
1479cc_test_library {
1480 name: "exec_linker_helper_lib",
1481 host_supported: false,
1482 defaults: ["bionic_testlib_defaults"],
1483 srcs: ["exec_linker_helper_lib.cpp"],
1484}
Peter Collingbourneb39cb3c2019-03-01 13:12:49 -08001485
1486cc_test_library {
1487 name: "libsegment_gap_outer",
1488 host_supported: false,
1489 defaults: ["bionic_testlib_defaults"],
1490 srcs: ["segment_gap_outer.cpp"],
1491 ldflags: ["-Wl,-T,bionic/tests/libs/segment_gap_outer.lds"],
1492}
1493
1494cc_test_library {
1495 name: "libsegment_gap_inner",
1496 host_supported: false,
1497 defaults: ["bionic_testlib_defaults"],
1498 srcs: ["segment_gap_inner.cpp"],
1499}
Elliott Hughes6663f552020-01-24 14:36:10 -08001500
1501
1502// -----------------------------------------------------------------------------
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001503// Check that we support all kinds of relocations: regular, "relocation packer",
1504// and both the old and new SHT_RELR constants.
Elliott Hughes6663f552020-01-24 14:36:10 -08001505// -----------------------------------------------------------------------------
1506
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001507// This is what got standardized for SHT_RELR.
Elliott Hughes6663f552020-01-24 14:36:10 -08001508cc_test_library {
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001509 name: "librelocations-RELR",
1510 ldflags: [
1511 "-Wl,--pack-dyn-relocs=relr",
1512 "-Wl,--no-use-android-relr-tags",
1513 ],
Elliott Hughes6663f552020-01-24 14:36:10 -08001514 host_supported: false,
1515 defaults: ["bionic_testlib_defaults"],
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001516 srcs: ["relocations.cpp"],
1517
Elliott Hughes6663f552020-01-24 14:36:10 -08001518 // Hack to ensure we're using llvm-objcopy because our binutils prebuilt
1519 // only supports the old numbers (http://b/141010852).
1520 strip: {
1521 keep_symbols: true,
1522 },
1523}
1524
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001525// This is the same encoding as SHT_RELR, but using OS-specific constants.
Elliott Hughes6663f552020-01-24 14:36:10 -08001526cc_test_library {
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001527 name: "librelocations-ANDROID_RELR",
1528 ldflags: [
1529 "-Wl,--pack-dyn-relocs=relr",
1530 "-Wl,--use-android-relr-tags",
1531 ],
Elliott Hughes6663f552020-01-24 14:36:10 -08001532 host_supported: false,
1533 defaults: ["bionic_testlib_defaults"],
Elliott Hughes6dd1f582020-01-28 12:18:35 -08001534 srcs: ["relocations.cpp"],
1535}
1536
1537// This is the old relocation packer encoding (DT_ANDROID_REL/DT_ANDROID_RELA).
1538cc_test_library {
1539 name: "librelocations-ANDROID_REL",
1540 ldflags: ["-Wl,--pack-dyn-relocs=android"],
1541 host_supported: false,
1542 defaults: ["bionic_testlib_defaults"],
1543 srcs: ["relocations.cpp"],
1544}
1545
1546// This is not packed at all.
1547cc_test_library {
1548 name: "librelocations-fat",
1549 ldflags: ["-Wl,--pack-dyn-relocs=none"],
1550 host_supported: false,
1551 defaults: ["bionic_testlib_defaults"],
1552 srcs: ["relocations.cpp"],
Elliott Hughes6663f552020-01-24 14:36:10 -08001553}