OSDN Git Service

linker: the global group is added to all built-in namespaces
[android-x86/bionic.git] / tests / libs / Android.bp
1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 cc_defaults {
18     name: "bionic_testlib_defaults",
19     host_supported: true,
20     ldflags: [
21         "-Wl,--rpath,${ORIGIN}",
22         "-Wl,--enable-new-dtags",
23     ],
24     relative_install_path: "bionic-loader-test-libs",
25     gtest: false,
26     sanitize: {
27         address: false,
28         coverage: false,
29     },
30     stl: "libc++_static",
31     target: {
32         darwin: {
33             enabled: false,
34         },
35     },
36 }
37
38 // -----------------------------------------------------------------------------
39 // Library to test gnu-styled hash
40 // -----------------------------------------------------------------------------
41 cc_test_library {
42     name: "libgnu-hash-table-library",
43     defaults: ["bionic_testlib_defaults"],
44     srcs: ["dlext_test_library.cpp"],
45     ldflags: ["-Wl,--hash-style=gnu"],
46     arch: {
47         mips: {
48             enabled: false,
49         },
50         mips64: {
51             enabled: false,
52         },
53     },
54 }
55
56 // -----------------------------------------------------------------------------
57 // Library to test sysv-styled hash
58 // -----------------------------------------------------------------------------
59 cc_test_library {
60     name: "libsysv-hash-table-library",
61     defaults: ["bionic_testlib_defaults"],
62     srcs: ["dlext_test_library.cpp"],
63     ldflags: ["-Wl,--hash-style=sysv"],
64 }
65
66 // -----------------------------------------------------------------------------
67 // Library used by dlext tests - with GNU RELRO program header
68 // -----------------------------------------------------------------------------
69 // In Android.mk to support creating symlinks
70
71 // -----------------------------------------------------------------------------
72 // Library used by dlext tests - without GNU RELRO program header
73 // -----------------------------------------------------------------------------
74 cc_test_library {
75     name: "libdlext_test_norelro",
76     defaults: ["bionic_testlib_defaults"],
77     srcs: ["dlext_test_library.cpp"],
78     ldflags: ["-Wl,-z,norelro"],
79     shared_libs = ["libtest_simple"],
80 }
81
82 // -----------------------------------------------------------------------------
83 // Library used by dlext tests - different name non-default location
84 // -----------------------------------------------------------------------------
85 // In Android.mk to support installing to /data
86
87 // -----------------------------------------------------------------------------
88 // Libraries used by dlext tests for open from a zip-file
89 // -----------------------------------------------------------------------------
90 // In Android.mk to support installing to /data
91
92 // ----------------------------------------------------------------------------
93 // Library with soname which does not match filename
94 // ----------------------------------------------------------------------------
95 // In Android.mk to support zipped and aligned tests
96
97 // -----------------------------------------------------------------------------
98 // Library used by dlext tests - zipped and aligned
99 // -----------------------------------------------------------------------------
100 // In Android.mk to support zipped and aligned tests
101
102 // -----------------------------------------------------------------------------
103 // Library used by dlfcn tests
104 // -----------------------------------------------------------------------------
105 cc_test_library {
106     name: "libtest_simple",
107     defaults: ["bionic_testlib_defaults"],
108     srcs: ["dlopen_testlib_simple.cpp"],
109 }
110
111 // -----------------------------------------------------------------------------
112 // Library used by dlfcn nodelete tests
113 // -----------------------------------------------------------------------------
114 cc_test_library {
115     name: "libtest_nodelete_1",
116     defaults: ["bionic_testlib_defaults"],
117     srcs: ["dlopen_nodelete_1.cpp"],
118 }
119
120 // -----------------------------------------------------------------------------
121 // Library used by dlfcn nodelete tests
122 // -----------------------------------------------------------------------------
123 cc_test_library {
124     name: "libtest_nodelete_2",
125     defaults: ["bionic_testlib_defaults"],
126     srcs: ["dlopen_nodelete_2.cpp"],
127 }
128
129 // -----------------------------------------------------------------------------
130 // Library used by dlfcn nodelete tests
131 // -----------------------------------------------------------------------------
132 cc_test_library {
133     name: "libtest_nodelete_dt_flags_1",
134     defaults: ["bionic_testlib_defaults"],
135     srcs: ["dlopen_nodelete_dt_flags_1.cpp"],
136     ldflags: ["-Wl,-z,nodelete"],
137 }
138
139 // -----------------------------------------------------------------------------
140 // Build test helper libraries for linker namespaces
141 // -----------------------------------------------------------------------------
142 // include $(LOCAL_PATH)/Android.build.linker_namespaces.mk
143
144 // -----------------------------------------------------------------------------
145 // Build DT_RUNPATH test helper libraries
146 // -----------------------------------------------------------------------------
147 // include $(LOCAL_PATH)/Android.build.dt_runpath.mk
148
149 // -----------------------------------------------------------------------------
150 // Build library with two parents
151 // -----------------------------------------------------------------------------
152 // include $(LOCAL_PATH)/Android.build.dlopen_2_parents_reloc.mk
153
154 // -----------------------------------------------------------------------------
155 // Build libtest_check_order_dlsym.so with its dependencies.
156 // -----------------------------------------------------------------------------
157 // include $(LOCAL_PATH)/Android.build.dlopen_check_order_dlsym.mk
158
159 // -----------------------------------------------------------------------------
160 // Build libtest_check_order_siblings.so with its dependencies.
161 // -----------------------------------------------------------------------------
162 // include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_siblings.mk
163
164 // -----------------------------------------------------------------------------
165 // Build libtest_check_order_root.so with its dependencies.
166 // -----------------------------------------------------------------------------
167 // include $(LOCAL_PATH)/Android.build.dlopen_check_order_reloc_main_executable.mk
168
169 // -----------------------------------------------------------------------------
170 // Build libtest_versioned_lib.so with its dependencies.
171 // -----------------------------------------------------------------------------
172 // include $(LOCAL_PATH)/Android.build.versioned_lib.mk
173
174 // -----------------------------------------------------------------------------
175 // Build libraries needed by pthread_atfork tests
176 // -----------------------------------------------------------------------------
177 // include $(LOCAL_PATH)/Android.build.pthread_atfork.mk
178
179 // -----------------------------------------------------------------------------
180 // Library with dependency loop used by dlfcn tests
181 //
182 // libtest_with_dependency_loop -> a -> b -> c -> a
183 // -----------------------------------------------------------------------------
184 cc_test_library {
185     name: "libtest_with_dependency_loop",
186     defaults: ["bionic_testlib_defaults"],
187     srcs: ["dlopen_testlib_loopy_root.cpp"],
188     shared_libs: ["libtest_with_dependency_loop_a"],
189 }
190
191 // -----------------------------------------------------------------------------
192 // libtest_with_dependency_loop_a.so
193 // -----------------------------------------------------------------------------
194 cc_test_library {
195     name: "libtest_with_dependency_loop_a",
196     defaults: ["bionic_testlib_defaults"],
197     srcs: ["dlopen_testlib_loopy_a.cpp"],
198     shared_libs: ["libtest_with_dependency_loop_b_tmp"],
199 }
200
201 // -----------------------------------------------------------------------------
202 // libtest_with_dependency_loop_b.so
203 //
204 // this is temporary placeholder - will be removed
205 // -----------------------------------------------------------------------------
206 cc_test_library {
207     name: "libtest_with_dependency_loop_b_tmp",
208     defaults: ["bionic_testlib_defaults"],
209     srcs: ["dlopen_testlib_loopy_invalid.cpp"],
210     ldflags: ["-Wl,-soname=libtest_with_dependency_loop_b.so"],
211 }
212
213 // -----------------------------------------------------------------------------
214 // libtest_with_dependency_loop_b.so
215 // -----------------------------------------------------------------------------
216 cc_test_library {
217     name: "libtest_with_dependency_loop_b",
218     defaults: ["bionic_testlib_defaults"],
219     srcs: ["dlopen_testlib_loopy_b.cpp"],
220     shared_libs: ["libtest_with_dependency_loop_c"],
221 }
222
223 // -----------------------------------------------------------------------------
224 // libtest_with_dependency_loop_c.so
225 // -----------------------------------------------------------------------------
226 cc_test_library {
227     name: "libtest_with_dependency_loop_c",
228     defaults: ["bionic_testlib_defaults"],
229     srcs: ["dlopen_testlib_loopy_c.cpp"],
230     shared_libs: ["libtest_with_dependency_loop_a"],
231 }
232
233 // -----------------------------------------------------------------------------
234 // libtest_relo_check_dt_needed_order.so
235 // |
236 // +-> libtest_relo_check_dt_needed_order_1.so
237 // |
238 // +-> libtest_relo_check_dt_needed_order_2.so
239 // -----------------------------------------------------------------------------
240
241
242 cc_test_library {
243     name: "libtest_relo_check_dt_needed_order",
244     defaults: ["bionic_testlib_defaults"],
245     srcs: ["dlopen_testlib_relo_check_dt_needed_order.cpp"],
246     shared_libs: [
247         "libtest_relo_check_dt_needed_order_1",
248         "libtest_relo_check_dt_needed_order_2",
249     ],
250 }
251
252 cc_test_library {
253     name: "libtest_relo_check_dt_needed_order_1",
254     defaults: ["bionic_testlib_defaults"],
255     srcs: ["dlopen_testlib_relo_check_dt_needed_order_1.cpp"],
256 }
257
258 cc_test_library {
259     name: "libtest_relo_check_dt_needed_order_2",
260     defaults: ["bionic_testlib_defaults"],
261     srcs: ["dlopen_testlib_relo_check_dt_needed_order_2.cpp"],
262 }
263
264 // -----------------------------------------------------------------------------
265 // Library with dependency used by dlfcn tests
266 // -----------------------------------------------------------------------------
267 // In Android.mk to support dependency on libdlext_test
268
269 // -----------------------------------------------------------------------------
270 // Library used by ifunc tests
271 // -----------------------------------------------------------------------------
272 cc_test_library {
273     name: "libtest_ifunc",
274     defaults: ["bionic_testlib_defaults"],
275     srcs: ["dlopen_testlib_ifunc.cpp"],
276
277     arch: {
278         mips: {
279             enabled: false,
280         },
281         mips64: {
282             enabled: false,
283         },
284     },
285
286     target: {
287         android: {
288             shared_libs: ["libdl"],
289         },
290         host: {
291             host_ldlibs: ["-ldl"],
292         },
293     },
294 }
295
296 cc_test_library {
297     name: "libtest_ifunc_variable",
298     defaults: ["bionic_testlib_defaults"],
299     srcs: ["dlopen_testlib_ifunc_variable.cpp"],
300     shared_libs: [ "libtest_ifunc_variable_impl" ],
301
302     arch: {
303         mips: {
304             enabled: false,
305         },
306         mips64: {
307             enabled: false,
308         },
309     },
310
311     target: {
312         android: {
313             shared_libs: ["libdl"],
314         },
315         host: {
316             host_ldlibs: ["-ldl"],
317         },
318     },
319 }
320
321 cc_test_library {
322     name: "libtest_ifunc_variable_impl",
323     defaults: ["bionic_testlib_defaults"],
324     srcs: ["dlopen_testlib_ifunc_variable_impl.cpp"],
325
326     arch: {
327         mips: {
328             enabled: false,
329         },
330         mips64: {
331             enabled: false,
332         },
333     },
334
335     target: {
336         android: {
337             shared_libs: ["libdl"],
338         },
339         host: {
340             host_ldlibs: ["-ldl"],
341         },
342     },
343 }
344
345 // -----------------------------------------------------------------------------
346 // Library used by atexit tests
347 // -----------------------------------------------------------------------------
348
349 cc_test_library {
350     name: "libtest_atexit",
351     defaults: ["bionic_testlib_defaults"],
352     srcs: ["atexit_testlib.cpp"],
353 }
354
355 // -----------------------------------------------------------------------------
356 // This library is used by dl_load test to check symbol preempting
357 // by main executable
358 // -----------------------------------------------------------------------------
359 cc_test_library {
360     name: "libdl_preempt_test_1",
361     defaults: ["bionic_testlib_defaults"],
362     srcs: ["dl_preempt_library_1.cpp"],
363 }
364
365 // -----------------------------------------------------------------------------
366 // This library is used by dl_load test to check symbol preempting
367 // by libdl_preempt_test_1.so
368 // -----------------------------------------------------------------------------
369 cc_test_library {
370     name: "libdl_preempt_test_2",
371     defaults: ["bionic_testlib_defaults"],
372     srcs: ["dl_preempt_library_2.cpp"],
373 }
374
375 // -----------------------------------------------------------------------------
376 // Library with DF_1_GLOBAL
377 // -----------------------------------------------------------------------------
378 cc_test_library {
379     name: "libdl_test_df_1_global",
380     defaults: ["bionic_testlib_defaults"],
381     srcs: ["dl_df_1_global.cpp"],
382     ldflags: ["-Wl,-z,global"],
383
384     target: {
385         host: {
386             // TODO (dimitry): host ld.gold does not yet support -z global
387             // remove this line once it is updated.
388             ldflags: ["-fuse-ld=bfd"],
389         },
390     },
391 }
392
393 // -----------------------------------------------------------------------------
394 // Library using symbol from libdl_test_df_1_global
395 // -----------------------------------------------------------------------------
396 cc_test_library {
397     name: "libtest_dlsym_df_1_global",
398     defaults: ["bionic_testlib_defaults"],
399     srcs: ["dl_df_1_use_global.cpp"],
400 }
401
402 // -----------------------------------------------------------------------------
403 // Library with weak function
404 // -----------------------------------------------------------------------------
405 cc_test_library {
406     name: "libtest_dlsym_weak_func",
407     defaults: ["bionic_testlib_defaults"],
408     srcs: ["dlsym_weak_function.cpp"],
409 }
410
411 // -----------------------------------------------------------------------------
412 // Library to check RTLD_LOCAL with dlsym in 'this'
413 // -----------------------------------------------------------------------------
414 cc_test_library {
415     name: "libtest_dlsym_from_this",
416     defaults: ["bionic_testlib_defaults"],
417     srcs: ["dlsym_from_this_symbol.cpp"],
418     shared_libs: ["libtest_dlsym_from_this_child"],
419
420     target: {
421         android: {
422             shared_libs: ["libdl"],
423         },
424         host: {
425             host_ldlibs: ["-ldl"],
426         },
427     },
428 }
429
430 // -----------------------------------------------------------------------------
431 cc_test_library {
432     name: "libtest_dlsym_from_this_child",
433     defaults: ["bionic_testlib_defaults"],
434     srcs: ["dlsym_from_this_functions.cpp"],
435     shared_libs: ["libtest_dlsym_from_this_grandchild"],
436     target: {
437         android: {
438             shared_libs: ["libdl"],
439         },
440         host: {
441             host_ldlibs: ["-ldl"],
442         },
443     },
444 }
445
446 // -----------------------------------------------------------------------------
447 cc_test_library {
448     name: "libtest_dlsym_from_this_grandchild",
449     defaults: ["bionic_testlib_defaults"],
450     srcs: ["dlsym_from_this_symbol2.cpp"],
451 }
452
453 // -----------------------------------------------------------------------------
454 // Empty library
455 // -----------------------------------------------------------------------------
456 cc_test_library {
457     name: "libtest_empty",
458     defaults: ["bionic_testlib_defaults"],
459     srcs: ["empty.cpp"],
460 }
461
462 // -----------------------------------------------------------------------------
463 // Library with weak undefined function
464 // -----------------------------------------------------------------------------
465 cc_test_library {
466     name: "libtest_dlopen_weak_undefined_func",
467     defaults: ["bionic_testlib_defaults"],
468     srcs: ["dlopen_weak_undefined.cpp"],
469 }
470
471 // -----------------------------------------------------------------------------
472 // Check that RTLD_NEXT of a libc symbol works in dlopened library
473 // -----------------------------------------------------------------------------
474 cc_test_library {
475     name: "libtest_check_rtld_next_from_library",
476     defaults: ["bionic_testlib_defaults"],
477     srcs: ["check_rtld_next_from_library.cpp"],
478
479     target: {
480         android: {
481             shared_libs: ["libdl"],
482         },
483         host: {
484             host_ldlibs: ["-ldl"],
485         },
486     },
487 }
488
489 // -----------------------------------------------------------------------------
490 // Library with constructor that calls dlopen() b/7941716
491 // -----------------------------------------------------------------------------
492 cc_test_library {
493     name: "libtest_dlopen_from_ctor",
494     defaults: ["bionic_testlib_defaults"],
495     srcs: ["dlopen_testlib_dlopen_from_ctor.cpp"],
496     target: {
497         android: {
498             shared_libs: ["libdl"],
499         },
500         host: {
501             host_ldlibs: ["-ldl"],
502         },
503     },
504 }
505
506 // -----------------------------------------------------------------------------
507 // Libraries used to check init/fini call order
508 // -----------------------------------------------------------------------------
509 cc_test_library {
510     name: "libtest_init_fini_order_root",
511     defaults: ["bionic_testlib_defaults"],
512     srcs: ["dlopen_check_init_fini_root.cpp"],
513     shared_libs: [
514         "libtest_init_fini_order_child",
515         "libtest_init_fini_order_grand_child",
516     ],
517 }
518
519 cc_test_library {
520     name: "libtest_init_fini_order_root2",
521     defaults: ["bionic_testlib_defaults"],
522     srcs: ["dlopen_check_init_fini_root.cpp"],
523     shared_libs: [
524         "libtest_init_fini_order_grand_child",
525         "libtest_init_fini_order_child",
526     ],
527 }
528
529 cc_test_library {
530     name: "libtest_init_fini_order_child",
531     defaults: ["bionic_testlib_defaults"],
532     srcs: ["dlopen_check_init_fini_child.cpp"],
533     shared_libs: ["libtest_init_fini_order_grand_child"],
534 }
535
536 cc_test_library {
537     name: "libtest_init_fini_order_grand_child",
538     defaults: ["bionic_testlib_defaults"],
539     srcs: ["dlopen_check_init_fini_grand_child.cpp"],
540 }
541
542 // -----------------------------------------------------------------------------
543 // Library that depends on the library with constructor that calls dlopen() b/7941716
544 // -----------------------------------------------------------------------------
545 cc_test_library {
546     name: "libtest_dlopen_from_ctor_main",
547     defaults: ["bionic_testlib_defaults"],
548     srcs: ["empty.cpp"],
549     shared_libs: ["libtest_dlopen_from_ctor"],
550 }
551
552 // -----------------------------------------------------------------------------
553 // Tool to use to align the shared libraries in a zip file.
554 // -----------------------------------------------------------------------------
555 cc_binary_host {
556     name: "bionic_tests_zipalign",
557     srcs: ["bionic_tests_zipalign.cpp"],
558     cflags: [
559         "-Wall",
560         "-Werror",
561     ],
562
563     static_libs: [
564         "libziparchive",
565         "liblog",
566         "libbase",
567         "libz",
568         "libutils",
569     ],
570 }
571
572 cc_test_library {
573     name: "libcfi-test",
574     defaults: ["bionic_testlib_defaults"],
575     srcs: ["cfi_test_lib.cpp"],
576     sanitize: {
577         cfi: false,
578     },
579 }
580
581 cc_test_library {
582     name: "libcfi-test-bad",
583     defaults: ["bionic_testlib_defaults"],
584     srcs: ["cfi_test_bad_lib.cpp"],
585     sanitize: {
586         cfi: false,
587     },
588 }
589
590 cc_test {
591     name: "cfi_test_helper",
592     host_supported: false,
593     defaults: ["bionic_testlib_defaults"],
594     srcs: ["cfi_test_helper.cpp"],
595     ldflags: ["-rdynamic"],
596 }
597
598 cc_test {
599     name: "cfi_test_helper2",
600     host_supported: false,
601     defaults: ["bionic_testlib_defaults"],
602     srcs: ["cfi_test_helper2.cpp"],
603     shared_libs: ["libcfi-test"],
604     ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
605 }
606
607 cc_test {
608     name: "preinit_getauxval_test_helper",
609     host_supported: false,
610     defaults: ["bionic_testlib_defaults"],
611     srcs: ["preinit_getauxval_test_helper.cpp"],
612 }
613
614 cc_test {
615     name: "preinit_syscall_test_helper",
616     host_supported: false,
617     defaults: ["bionic_testlib_defaults"],
618     srcs: ["preinit_syscall_test_helper.cpp"],
619 }
620
621 cc_test {
622     name: "ld_preload_test_helper",
623     host_supported: false,
624     defaults: ["bionic_testlib_defaults"],
625     srcs: ["ld_preload_test_helper.cpp"],
626     shared_libs: ["ld_preload_test_helper_lib1"],
627     ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
628 }
629
630 cc_test_library {
631     name: "ld_preload_test_helper_lib1",
632     host_supported: false,
633     defaults: ["bionic_testlib_defaults"],
634     srcs: ["ld_preload_test_helper_lib1.cpp"],
635 }
636
637 cc_test_library {
638     name: "ld_preload_test_helper_lib2",
639     host_supported: false,
640     defaults: ["bionic_testlib_defaults"],
641     srcs: ["ld_preload_test_helper_lib2.cpp"],
642 }
643
644 cc_test {
645     name: "ld_config_test_helper",
646     host_supported: false,
647     defaults: ["bionic_testlib_defaults"],
648     srcs: ["ld_config_test_helper.cpp"],
649     shared_libs: ["ld_config_test_helper_lib1"],
650     ldflags: ["-Wl,--rpath,${ORIGIN}/.."],
651 }
652
653 cc_test_library {
654     name: "ld_config_test_helper_lib1",
655     host_supported: false,
656     defaults: ["bionic_testlib_defaults"],
657     srcs: ["ld_config_test_helper_lib1.cpp"],
658     shared_libs: ["ld_config_test_helper_lib2"],
659     relative_install_path: "/ns2",
660 }
661
662 cc_test_library {
663     name: "ld_config_test_helper_lib2",
664     host_supported: false,
665     defaults: ["bionic_testlib_defaults"],
666     srcs: ["ld_config_test_helper_lib2.cpp"],
667     relative_install_path: "/ns2",
668 }
669
670 cc_test_library {
671     name: "ld_config_test_helper_lib3",
672     host_supported: false,
673     defaults: ["bionic_testlib_defaults"],
674     srcs: ["ld_config_test_helper_lib3.cpp"],
675 }