blob: 7ff0a792198833499d42206922402769cfccfc44 [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("//build/toolchain/ifs_extract.gni")
import("//build/toolchain/toolchain_environment.gni")
import("//build/toolchain/zircon/user_basic_redirect.gni")
import("//build/zircon/c_utils.gni")
import("//build/zircon/zircon_cpu.gni")
# This is how the kernel depends on the built vDSO to embed the image, and
# userboot depends on it to extract addresses, via the link_output_rspfile()
# metadata protocol.
user_basic_redirect("vdso") {
public_deps = [
":libzircon",
# This is just an independent testing step that doesn't produce any
# output. But making it a dependency here ensures that a kernel can't be
# built with a vDSO that doesn't have a verified ABI.
":verify-abi",
]
}
if (toolchain_environment == "user.basic") {
# The vDSO is built as a loadable_module() with an explicit -soname switch
# rather than as a shared_library() so that it gets independent variant
# selection.
loadable_module("libzircon") {
visibility = [ ":*" ]
ldflags = [ "-Wl,-soname=libzircon.so" ]
configs += [ "//build/config/zircon:rodso" ]
exclude_toolchain_tags = [
# The vDSO can use only the basic machine ABI.
"needs-compiler-abi",
# The vDSO cannot have a writable segment.
"needs-writable-globals",
]
sources = [
"data.S",
"syscall-wrappers.cc",
"zx_cache_flush.cc",
"zx_channel_call.cc",
"zx_clock_get_monotonic.cc",
"zx_cprng_draw.cc",
"zx_deadline_after.cc",
"zx_exception_get_string.cc",
"zx_status_get_string.cc",
"zx_system_get_dcache_line_size.cc",
"zx_system_get_features.cc",
"zx_system_get_num_cpus.cc",
"zx_system_get_page_size.cc",
"zx_system_get_physmem.cc",
"zx_system_get_version_string.cc",
"zx_ticks_get.cc",
"zx_ticks_per_second.cc",
]
public_deps = [ "//zircon/vdso:public" ]
deps = [
":syscall-asm",
"//src/zircon/lib/zircon:headers",
"//zircon/kernel/lib/userabi:headers",
"//zircon/system/ulib/affine",
"//zircon/vdso:private",
]
# Instruct the linker to preserve the hidden alternate entry points.
# Note, "./" makes GN realize this is a file rather than a -l switch.
libs = [ "./alternates.ld" ]
# Set e_entry so _zx_process_exit is easy to find without reading .dynsym.
ldflags += [ "-Wl,-e,_zx_process_exit" ]
# This ensures that the vDSO is never installed into filesystem images
# since it's materialized at runtime by the kernel.
metadata = {
distribution_entries_barrier = []
distribution_entries = []
}
}
source_set("syscall-asm") {
visibility = [ ":*" ]
sources = [
"syscalls-$zircon_cpu.S",
"zx_futex_wake_handle_close_thread_exit-$zircon_cpu.S",
"zx_vmar_unmap_handle_close_thread_exit-$zircon_cpu.S",
]
deps = [
"//src/zircon/lib/zircon:headers",
"//zircon/kernel/lib/userabi:headers",
"//zircon/vdso:private",
]
}
# Make sure the vDSO that goes into the kernel matches the ABI
# that userland links against.
abi_ifs = "//src/zircon/lib/zircon/zircon.ifs"
vdso_ifs = "$target_gen_dir/libzircon.ifs"
ifs_extract("vdso.ifs") {
visibility = [ ":*" ]
outputs = [ vdso_ifs ]
deps = [ ":libzircon" ]
args = [ "--strip-ifs-target" ]
}
action("verify-abi") {
visibility = [ ":*" ]
deps = [ ":vdso.ifs" ]
sources = [
abi_ifs,
vdso_ifs,
]
outputs = [ "$target_out_dir/$target_name.ok" ]
script = "verify-abi.sh"
# This uses absolute paths so the "cp IMPL ABI" message has easily and
# universally cut&pastable paths.
args = rebase_path(sources + outputs, root_build_dir)
metadata = {
link_output_barrier = []
}
}
}