//
// libdl
//
cc_library_static {
    name: "libdl_static",

    srcs: [
        "libdl.cpp",
        "libdl_cfi.cpp",
    ],

    cflags: [
        "-Wall",
        "-Wextra",
        "-Wunused",
        "-Werror",
    ],

    // For private/CFIShadow.h.
    include_dirs: ["bionic/libc"],

    stl: "none",

    sanitize: {
        never: true,
    },
}

cc_library {
    name: "libdl",
    static_ndk_lib: true,

    defaults: ["linux_bionic_supported"],

    // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
    // libgcc.a are made static to libdl.so.  This in turn ensures that libraries that
    // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
    // to provide those symbols, but will instead pull them from libgcc.a.  Specifically,
    // we use this property to make sure libc.so has its own copy of the code from
    // libgcc.a it uses.
    //
    // DO NOT REMOVE --exclude-libs!

    ldflags: ["-Wl,--exclude-libs=libgcc.a"],

    // for x86, exclude libgcc_eh.a for the same reasons as above
    arch: {
        arm: {
            version_script: "libdl.arm.map",
            ldflags: ["-Wl,--hash-style=both"],
        },
        arm64: {
            version_script: "libdl.arm64.map",
        },
        mips: {
            version_script: "libdl.mips.map",
        },
        mips64: {
            version_script: "libdl.mips64.map",
        },
        x86: {
            ldflags: [
                "-Wl,--exclude-libs=libgcc_eh.a",
                "-Wl,--hash-style=both",
            ],
            version_script: "libdl.x86.map",
        },
        x86_64: {
            ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
            version_script: "libdl.x86_64.map",
        },
    },
    shared: {
        whole_static_libs: ["libdl_static"],
    },
    static: {
        srcs: ["libdl_static.c"],
    },
    cflags: [
        "-Wall",
        "-Wextra",
        "-Wunused",
        "-Werror",
    ],
    stl: "none",

    nocrt: true,
    system_shared_libs: [],

    // This is placeholder library the actual implementation is (currently)
    // provided by the linker.
    shared_libs: ["ld-android"],

    sanitize: {
        never: true,
    },
}

ndk_library {
    name: "libdl",
    symbol_file: "libdl.map.txt",
    first_version: "9",
}

llndk_library {
    name: "libdl",
    symbol_file: "libdl.map.txt",
}