blob: 63fa58f0b48f6a722b6df272b4a751f66b93845c [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("$zx/kernel/syscalls/abigen.gni")
import("$zx/public/gn/toolchain/environment_redirect.gni")
import("rodso.gni")
library("vdso") {
kernel = true
sources = [
"vdso-image.S",
"vdso.cpp",
]
# vdso-image.S includes the vDSO (aka libzircon.so) contents and so must
# be reassembled when that changes. But listing $zx/system/ulib/zircon
# in deps here will make GN try to link libzircon.so into the kernel.
# Fortunately, vdso-image.S also includes the "vdso-code.h" header file
# and normal depfile magic will discover that. This header file is
# generated (below) from libzircon.so itself, so it will always be
# touched when libzircon.so has been touched and thus ensure vdso-image.S
# is reassembled with the new vDSO contents.
if (is_kernel) {
deps = [
":gen-categories",
":rodso",
":vdso-code-header",
"$zx/kernel/lib/version:config-buildid-header",
"$zx/kernel/syscalls",
"$zx/kernel/vm:headers",
"$zx/system/ulib/fbl",
]
public_configs = [ ":vdso-valid-sysret" ]
public_deps = [
# Dependents can use the generated header via $public_configs
# (above), and so need to depend on the generation action.
":gen-vdso-valid-sysret",
# <lib/rodso.h> has #include <object/handle.h>.
"$zx/kernel/object",
]
}
}
source_set("rodso") {
sources = [
"rodso.cpp",
]
deps = [
":headers",
"$zx/kernel/vm:headers",
]
}
config("vdso-valid-sysret") {
visibility = [ ":*" ]
include_dirs = [ target_gen_dir ]
}
action("gen-vdso-valid-sysret") {
visibility = [ ":*" ]
# TODO(mcgrathr): Move the script to this dir.
script = "$zx/scripts/gen-vdso-valid-sysret.sh"
sources = [
"$target_gen_dir/vdso-code.h",
]
outputs = [
"$target_gen_dir/vdso-valid-sysret.h",
]
args = rebase_path(sources + outputs)
deps = [
":gen-vdso-code-header",
]
}
# Redirect to the userland vDSO shared library target.
environment_redirect("userland") {
environment_label = "$zx/public/gn/toolchain:user"
deps = [
"$zx/system/ulib/zircon",
]
}
group("vdso-code-header") {
deps = [
":gen-vdso-code-header",
]
public_configs = [ ":vdso-code-header.config" ]
}
config("vdso-code-header.config") {
visibility = [ ":vdso-code-header" ]
include_dirs = [ target_gen_dir ]
}
# This generated header file tells the vdso.cpp code
# where the segment boundaries and entry points are.
rodso_code_header("gen-vdso-code-header") {
visibility = [ ":*" ]
name = "VDSO"
outputs = [
"$target_gen_dir/vdso-code.h",
]
deps = [
":userland",
]
}
abigen("gen-categories") {
visibility = [ ":*" ]
gen = [
{
args = [ "-category" ]
outputs = [
"$target_gen_dir/zircon/syscall-category.inc",
]
},
]
}