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