Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae695c9f authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Remove use of static libdexfile to avoid linking in ART internal code.

- Create a static library libunwindstack_no_dex without DEX support.
- Use it in libdebuggerd_handler_fallback, whose only use is in the
  linker, which shouldn't need that support.
- Use it in init_first_stage, which doesn't need DEX support either.
- Also need a libbacktrace_no_dex since it's in the dependency chain
  from init_first_stage to libunwindstack_no_dex.

Also restrict the *_no_dex libs and libdebuggerd_handler_fallback as
much as possible to avoid inadvertent use of these reduced
functionality libs.

Test: m init_first_stage on Cuttlefish
  where BOARD_BUILD_SYSTEM_ROOT_IMAGE=false
Test: m system_image com.android.runtime
Test: Build & boot
Test: atest linker-unit-tests libunwindstack_unit_test debuggerd_test
Bug: 142944931
Bug: 151466650
Change-Id: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
Merged-In: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
parent e39a7cf0
Loading
Loading
Loading
Loading
+9 −13
Original line number Original line Diff line number Diff line
@@ -103,9 +103,14 @@ cc_library_static {
    export_include_dirs: ["include"],
    export_include_dirs: ["include"],
}
}


// Fallback implementation.
// Fallback implementation, for use in the Bionic linker only.
cc_library_static {
cc_library_static {
    name: "libdebuggerd_handler_fallback",
    name: "libdebuggerd_handler_fallback",
    visibility: ["//bionic/linker"],
    apex_available: [
        "com.android.runtime",
        "//apex_available:platform",
    ],
    defaults: ["debuggerd_defaults"],
    defaults: ["debuggerd_defaults"],
    recovery_available: true,
    recovery_available: true,
    srcs: [
    srcs: [
@@ -118,8 +123,7 @@ cc_library_static {
        "libasync_safe",
        "libasync_safe",
        "libbase",
        "libbase",
        "libdebuggerd",
        "libdebuggerd",
        "libunwindstack",
        "libunwindstack_no_dex",
        "libdexfile_support_static",  // libunwindstack dependency
        "liblzma",
        "liblzma",
        "libcutils",
        "libcutils",
    ],
    ],
@@ -127,14 +131,6 @@ cc_library_static {
    header_libs: ["bionic_libc_platform_headers"],
    header_libs: ["bionic_libc_platform_headers"],
    export_header_lib_headers: ["bionic_libc_platform_headers"],
    export_header_lib_headers: ["bionic_libc_platform_headers"],


    target: {
        recovery: {
            exclude_static_libs: [
                "libdexfile_support_static",
            ],
        },
    },

    export_include_dirs: ["include"],
    export_include_dirs: ["include"],
}
}


@@ -188,7 +184,7 @@ cc_library_static {
    ],
    ],


    static_libs: [
    static_libs: [
        "libdexfile_support_static",  // libunwindstack dependency
        "libdexfile_support",  // libunwindstack dependency
        "libunwindstack",
        "libunwindstack",
        "liblzma",
        "liblzma",
        "libbase",
        "libbase",
@@ -201,7 +197,7 @@ cc_library_static {
    target: {
    target: {
        recovery: {
        recovery: {
            exclude_static_libs: [
            exclude_static_libs: [
                "libdexfile_support_static",
                "libdexfile_support",
            ],
            ],
        },
        },
    },
    },
+2 −3
Original line number Original line Diff line number Diff line
@@ -105,9 +105,8 @@ LOCAL_STATIC_LIBRARIES := \
    libgsi \
    libgsi \
    libcom.android.sysprop.apex \
    libcom.android.sysprop.apex \
    liblzma \
    liblzma \
    libdexfile_support_static \
    libunwindstack_no_dex \
    libunwindstack \
    libbacktrace_no_dex \
    libbacktrace \
    libmodprobe \
    libmodprobe \
    libext2_uuid \
    libext2_uuid \
    libprotobuf-cpp-lite \
    libprotobuf-cpp-lite \
+37 −10
Original line number Original line Diff line number Diff line
@@ -46,16 +46,9 @@ cc_library_headers {
    export_include_dirs: ["include"],
    export_include_dirs: ["include"],
}
}


cc_library {
cc_defaults {
    name: "libbacktrace",
    name: "libbacktrace_defaults",
    vendor_available: false,
    recovery_available: true,
    vndk: {
        enabled: true,
        support_system_process: true,
    },
    defaults: ["libbacktrace_common"],
    defaults: ["libbacktrace_common"],
    host_supported: true,


    cflags: [
    cflags: [
        "-Wexit-time-destructors",
        "-Wexit-time-destructors",
@@ -80,7 +73,6 @@ cc_library {
            shared_libs: [
            shared_libs: [
                "libbase",
                "libbase",
                "liblog",
                "liblog",
                "libunwindstack",
            ],
            ],


            static_libs: [
            static_libs: [
@@ -93,6 +85,26 @@ cc_library {
                whole_static_libs: ["libasync_safe"],
                whole_static_libs: ["libasync_safe"],
            },
            },
        },
        },
    },
}

cc_library {
    name: "libbacktrace",
    vendor_available: false,
    recovery_available: true,
    vndk: {
        enabled: true,
        support_system_process: true,
    },
    host_supported: true,
    defaults: ["libbacktrace_defaults"],

    target: {
        linux: {
            shared_libs: [
                "libunwindstack",
            ],
        },
        vendor: {
        vendor: {
            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
            cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
        },
        },
@@ -102,6 +114,21 @@ cc_library {
    },
    },
}
}


// Static library without DEX support to avoid dependencies on the ART APEX.
cc_library_static {
    name: "libbacktrace_no_dex",
    visibility: ["//system/core/debuggerd"],
    defaults: ["libbacktrace_defaults"],
    cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
    target: {
        linux: {
            static_libs: [
                "libunwindstack_no_dex",
            ],
        },
    },
}

cc_test_library {
cc_test_library {
    name: "libbacktrace_test",
    name: "libbacktrace_test",
    defaults: ["libbacktrace_common"],
    defaults: ["libbacktrace_common"],
+47 −29
Original line number Original line Diff line number Diff line
@@ -35,20 +35,13 @@ cc_defaults {
    },
    },
}
}


cc_library {
cc_defaults {
    name: "libunwindstack",
    name: "libunwindstack_defaults",
    vendor_available: true,
    recovery_available: true,
    vndk: {
        enabled: true,
        support_system_process: true,
    },
    defaults: ["libunwindstack_flags"],
    defaults: ["libunwindstack_flags"],
    export_include_dirs: ["include"],
    export_include_dirs: ["include"],


    srcs: [
    srcs: [
        "ArmExidx.cpp",
        "ArmExidx.cpp",
        "DexFile.cpp",
        "DexFiles.cpp",
        "DexFiles.cpp",
        "DwarfCfa.cpp",
        "DwarfCfa.cpp",
        "DwarfEhFrameWithHdr.cpp",
        "DwarfEhFrameWithHdr.cpp",
@@ -77,7 +70,6 @@ cc_library {
    ],
    ],


    cflags: [
    cflags: [
        "-DDEXFILE_SUPPORT",
        "-Wexit-time-destructors",
        "-Wexit-time-destructors",
    ],
    ],


@@ -89,24 +81,6 @@ cc_library {
                "-g",
                "-g",
            ],
            ],
        },
        },
        vendor: {
            cflags: ["-UDEXFILE_SUPPORT"],
            exclude_srcs: [
                "DexFile.cpp",
            ],
            exclude_shared_libs: [
                "libdexfile_support",
            ],
        },
        recovery: {
            cflags: ["-UDEXFILE_SUPPORT"],
            exclude_srcs: [
                "DexFile.cpp",
            ],
            exclude_shared_libs: [
                "libdexfile_support",
            ],
        },
    },
    },


    arch: {
    arch: {
@@ -130,12 +104,56 @@ cc_library {


    shared_libs: [
    shared_libs: [
        "libbase",
        "libbase",
        "libdexfile_support",
        "liblog",
        "liblog",
        "liblzma",
        "liblzma",
    ],
    ],
}
}


cc_library {
    name: "libunwindstack",
    vendor_available: true,
    recovery_available: true,
    vndk: {
        enabled: true,
        support_system_process: true,
    },
    defaults: ["libunwindstack_defaults"],

    srcs: ["DexFile.cpp"],
    cflags: ["-DDEXFILE_SUPPORT"],
    shared_libs: ["libdexfile_support"],

    target: {
        vendor: {
            cflags: ["-UDEXFILE_SUPPORT"],
            exclude_srcs: ["DexFile.cpp"],
            exclude_shared_libs: ["libdexfile_support"],
        },
        recovery: {
            cflags: ["-UDEXFILE_SUPPORT"],
            exclude_srcs: ["DexFile.cpp"],
            exclude_shared_libs: ["libdexfile_support"],
        },
    },
}

// Static library without DEX support to avoid dependencies on the ART APEX.
cc_library_static {
    name: "libunwindstack_no_dex",
    recovery_available: true,
    defaults: ["libunwindstack_defaults"],

    visibility: [
        "//system/core/debuggerd",
        "//system/core/init",
        "//system/core/libbacktrace",
    ],
    apex_available: [
        "//apex_available:platform",
        "com.android.runtime",
    ],
}

//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Unit Tests
// Unit Tests
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------