github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/vdso/BUILD (about)

     1  # Description:
     2  #   This VDSO is a shared library that provides the same interfaces as the
     3  #   normal system VDSO (time, gettimeofday, clock_gettimeofday) but which uses
     4  #   timekeeping parameters managed by the sandbox kernel.
     5  
     6  load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain", "select_arch", "vdso_linker_option")
     7  
     8  package(licenses = ["notice"])
     9  
    10  genrule(
    11      name = "vdso",
    12      srcs = [
    13          "barrier.h",
    14          "compiler.h",
    15          "cycle_clock.h",
    16          "seqlock.h",
    17          "syscalls.h",
    18          "vdso.cc",
    19          "vdso_amd64.lds",
    20          "vdso_arm64.lds",
    21          "vdso_time.h",
    22          "vdso_time.cc",
    23      ],
    24      outs = [
    25          "vdso.so",
    26      ],
    27      cmd = "$(CC) $(CC_FLAGS) " +
    28            "-I. " +
    29            "-O2 " +
    30            "-std=c++11 " +
    31            "-fPIC " +
    32            "-fno-sanitize=all " +
    33            # Some toolchains enable stack protector by default. Disable it, the
    34            # VDSO has no hooks to handle failures.
    35            "-fno-stack-protector " +
    36            vdso_linker_option +
    37            select_arch(
    38                amd64 = "-m64 ",
    39                arm64 = "",
    40            ) +
    41            "-shared " +
    42            "-nostdlib " +
    43            "-Wl,-soname=linux-vdso.so.1 " +
    44            "-Wl,--hash-style=sysv " +
    45            "-Wl,--no-undefined " +
    46            "-Wl,-Bsymbolic " +
    47            "-Wl,-z,max-page-size=4096 " +
    48            "-Wl,-z,common-page-size=4096 " +
    49            select_arch(
    50                amd64 = "-Wl,-T$(location vdso_amd64.lds) ",
    51                arm64 = "-Wl,-T$(location vdso_arm64.lds) ",
    52                no_match_error = "unsupported architecture",
    53            ) +
    54            "-o $(location vdso.so) " +
    55            "$(location vdso.cc) " +
    56            "$(location vdso_time.cc) " +
    57            "&& $(location :check_vdso) " +
    58            "--check-data " +
    59            "--vdso $(location vdso.so) ",
    60      exec_tools = [
    61          ":check_vdso",
    62      ],
    63      features = ["-pie"],
    64      toolchains = [
    65          cc_toolchain,
    66          ":no_pie_cc_flags",
    67      ],
    68      visibility = ["//:sandbox"],
    69  )
    70  
    71  cc_flags_supplier(
    72      name = "no_pie_cc_flags",
    73      features = ["-pie"],
    74  )
    75  
    76  py_binary(
    77      name = "check_vdso",
    78      srcs = ["check_vdso.py"],
    79      python_version = "PY3",
    80      visibility = ["//:sandbox"],
    81  )