@@ -1414,43 +1414,13 @@ cc_library_static {
14141414}
14151415
14161416// ========================================================
1417- // libc_static_dispatch.a --- libc.a ifuncs
1417+ // libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1418+ // (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
14181419// ========================================================
1419- cc_library_static {
1420- defaults : [" libc_defaults" ],
1421- name : " libc_static_dispatch" ,
14221420
1423- arch : {
1424- x86_64 : {
1425- srcs : [" arch-x86_64/static_function_dispatch.S" ],
1426- },
1427- x86 : {
1428- srcs : [" arch-x86/static_function_dispatch.S" ],
1429- },
1430- arm : {
1431- srcs : [" arch-arm/static_function_dispatch.S" ],
1432- },
1433- arm64 : {
1434- srcs : [" arch-arm64/static_function_dispatch.S" ],
1435- },
1436- riscv64 : {
1437- srcs : [" arch-riscv64/static_function_dispatch.S" ],
1438- },
1439- },
1440- }
1441-
1442- // ========================================================
1443- // libc_dynamic_dispatch.a --- libc.so ifuncs
1444- // ========================================================
1445- cc_library_static {
1421+ cc_defaults {
1422+ name : " libc_dispatch_defaults" ,
14461423 defaults : [" libc_defaults" ],
1447- name : " libc_dynamic_dispatch" ,
1448-
1449- cflags : [
1450- " -ffreestanding" ,
1451- " -fno-stack-protector" ,
1452- " -fno-jump-tables" ,
1453- ],
14541424 arch : {
14551425 x86_64 : {
14561426 srcs : [" arch-x86_64/dynamic_function_dispatch.cpp" ],
@@ -1468,6 +1438,30 @@ cc_library_static {
14681438 srcs : [" arch-riscv64/dynamic_function_dispatch.cpp" ],
14691439 },
14701440 },
1441+ // Prevent the compiler from inserting calls to libc/taking the address of
1442+ // a jump table from within an ifunc (or, in the static case, code that
1443+ // can be executed arbitrarily early).
1444+ cflags : [
1445+ " -ffreestanding" ,
1446+ " -fno-stack-protector" ,
1447+ " -fno-jump-tables" ,
1448+ ],
1449+ }
1450+
1451+ cc_library_static {
1452+ name : " libc_static_dispatch" ,
1453+ defaults : [" libc_dispatch_defaults" ],
1454+ cflags : [
1455+ " -DBIONIC_STATIC_DISPATCH" ,
1456+ ],
1457+ }
1458+
1459+ cc_library_static {
1460+ name : " libc_dynamic_dispatch" ,
1461+ defaults : [" libc_dispatch_defaults" ],
1462+ cflags : [
1463+ " -DBIONIC_DYNAMIC_DISPATCH" ,
1464+ ],
14711465}
14721466
14731467// ========================================================
0 commit comments