2018-04-27 17:37:02 +00:00
|
|
|
# Description:
|
|
|
|
# This VDSO is a shared library that provides the same interfaces as the
|
|
|
|
# normal system VDSO (time, gettimeofday, clock_gettimeofday) but which uses
|
|
|
|
# timekeeping parameters managed by the sandbox kernel.
|
|
|
|
|
2019-04-01 17:28:11 +00:00
|
|
|
load("@bazel_tools//tools/cpp:cc_flags_supplier.bzl", "cc_flags_supplier")
|
|
|
|
|
2019-01-31 19:11:44 +00:00
|
|
|
package(licenses = ["notice"])
|
2018-04-27 17:37:02 +00:00
|
|
|
|
2019-03-13 20:26:13 +00:00
|
|
|
config_setting(
|
|
|
|
name = "x86_64",
|
|
|
|
constraint_values = ["@bazel_tools//platforms:x86_64"],
|
|
|
|
)
|
|
|
|
|
2019-04-18 23:20:45 +00:00
|
|
|
config_setting(
|
|
|
|
name = "aarch64",
|
|
|
|
constraint_values = ["@bazel_tools//platforms:aarch64"],
|
|
|
|
)
|
|
|
|
|
2018-04-27 17:37:02 +00:00
|
|
|
genrule(
|
|
|
|
name = "vdso",
|
|
|
|
srcs = [
|
|
|
|
"barrier.h",
|
|
|
|
"compiler.h",
|
|
|
|
"cycle_clock.h",
|
|
|
|
"seqlock.h",
|
|
|
|
"syscalls.h",
|
|
|
|
"vdso.cc",
|
2019-04-18 23:20:45 +00:00
|
|
|
"vdso_amd64.lds",
|
|
|
|
"vdso_arm64.lds",
|
2018-04-27 17:37:02 +00:00
|
|
|
"vdso_time.h",
|
|
|
|
"vdso_time.cc",
|
|
|
|
],
|
|
|
|
outs = [
|
|
|
|
"vdso.so",
|
|
|
|
],
|
|
|
|
cmd = "$(CC) $(CC_FLAGS) " +
|
|
|
|
"-I. " +
|
|
|
|
"-O2 " +
|
|
|
|
"-std=c++11 " +
|
|
|
|
"-fPIC " +
|
2018-05-04 20:14:59 +00:00
|
|
|
# Some toolchains enable stack protector by default. Disable it, the
|
|
|
|
# VDSO has no hooks to handle failures.
|
|
|
|
"-fno-stack-protector " +
|
2018-04-27 17:37:02 +00:00
|
|
|
"-fuse-ld=gold " +
|
2019-03-13 20:26:13 +00:00
|
|
|
select({
|
|
|
|
":x86_64": "-m64 ",
|
|
|
|
"//conditions:default": "",
|
|
|
|
}) +
|
2018-04-27 17:37:02 +00:00
|
|
|
"-shared " +
|
|
|
|
"-nostdlib " +
|
|
|
|
"-Wl,-soname=linux-vdso.so.1 " +
|
|
|
|
"-Wl,--hash-style=sysv " +
|
|
|
|
"-Wl,--no-undefined " +
|
|
|
|
"-Wl,-Bsymbolic " +
|
|
|
|
"-Wl,-z,max-page-size=4096 " +
|
|
|
|
"-Wl,-z,common-page-size=4096 " +
|
2019-04-18 23:20:45 +00:00
|
|
|
select(
|
|
|
|
{
|
|
|
|
":x86_64": "-Wl,-T$(location vdso_amd64.lds) ",
|
|
|
|
":aarch64": "-Wl,-T$(location vdso_arm64.lds) ",
|
|
|
|
},
|
|
|
|
no_match_error = "Unsupported architecture",
|
|
|
|
) +
|
2018-04-27 17:37:02 +00:00
|
|
|
"-o $(location vdso.so) " +
|
|
|
|
"$(location vdso.cc) " +
|
|
|
|
"$(location vdso_time.cc) " +
|
|
|
|
"&& $(location :check_vdso) " +
|
|
|
|
"--check-data " +
|
|
|
|
"--vdso $(location vdso.so) ",
|
|
|
|
features = ["-pie"],
|
2019-03-27 17:49:05 +00:00
|
|
|
toolchains = [
|
|
|
|
"@bazel_tools//tools/cpp:current_cc_toolchain",
|
2019-04-01 17:28:11 +00:00
|
|
|
":no_pie_cc_flags",
|
2019-03-27 17:49:05 +00:00
|
|
|
],
|
2018-04-27 17:37:02 +00:00
|
|
|
tools = [
|
|
|
|
":check_vdso",
|
|
|
|
],
|
|
|
|
visibility = ["//:sandbox"],
|
|
|
|
)
|
|
|
|
|
2019-04-01 17:28:11 +00:00
|
|
|
cc_flags_supplier(
|
|
|
|
name = "no_pie_cc_flags",
|
|
|
|
features = ["-pie"],
|
|
|
|
)
|
|
|
|
|
2018-04-27 17:37:02 +00:00
|
|
|
py_binary(
|
|
|
|
name = "check_vdso",
|
|
|
|
srcs = ["check_vdso.py"],
|
2019-04-29 20:18:46 +00:00
|
|
|
python_version = "PY2",
|
2018-04-27 17:37:02 +00:00
|
|
|
visibility = ["//:sandbox"],
|
|
|
|
)
|