gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/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  # Placeholder: load py_test
     7  load("//tools:arch.bzl", "select_arch")
     8  load("//tools:defs.bzl", "cc_flags_supplier", "cc_toolchain", "vdso_linker_option")
     9  
    10  package(
    11      default_applicable_licenses = ["//:license"],
    12      licenses = ["notice"],
    13  )
    14  
    15  exports_files(["check_vdso.py"])
    16  
    17  genrule(
    18      name = "vdso",
    19      srcs = [
    20          "barrier.h",
    21          "compiler.h",
    22          "cycle_clock.h",
    23          "seqlock.h",
    24          "syscalls.h",
    25          "vdso.cc",
    26          "vdso_amd64.lds",
    27          "vdso_arm64.lds",
    28          "vdso_time.h",
    29          "vdso_time.cc",
    30      ],
    31      outs = [
    32          "vdso.so",
    33      ],
    34      cmd = "$(CC) $(CC_FLAGS) " +
    35            "-I. " +
    36            "-O2 " +
    37            "-std=c++11 " +
    38            "-fPIC " +
    39            "-fno-sanitize=all " +
    40            # Some toolchains enable stack protector by default. Disable it, the
    41            # VDSO has no hooks to handle failures.
    42            "-fno-stack-protector " +
    43            vdso_linker_option +
    44            "-shared " +
    45            "-nostdlib " +
    46            "-Wl,-soname=linux-vdso.so.1 " +
    47            "-Wl,--hash-style=sysv " +
    48            "-Wl,--no-undefined " +
    49            "-Wl,-Bsymbolic " +
    50            "-Wl,-z,max-page-size=4096 " +
    51            "-Wl,-z,common-page-size=4096 " +
    52            select_arch(
    53                amd64 = "-Wl,-T$(location vdso_amd64.lds) ",
    54                arm64 = "-Wl,-T$(location vdso_arm64.lds) ",
    55                no_match_error = "unsupported architecture",
    56            ) +
    57            "-o $(location vdso.so) " +
    58            "$(location vdso.cc) " +
    59            "$(location vdso_time.cc)",
    60      features = ["-pie"],
    61      toolchains = [
    62          cc_toolchain,
    63          ":no_pie_cc_flags",
    64      ],
    65      visibility = ["//:sandbox"],
    66  )
    67  
    68  cc_flags_supplier(
    69      name = "no_pie_cc_flags",
    70      features = ["-pie"],
    71  )
    72  
    73  py_test(
    74      name = "vdso_test",
    75      srcs = ["check_vdso.py"],
    76      args = [
    77          "--check-data",
    78          "--vdso=$(location :vdso)",
    79      ],
    80      data = [":vdso"],
    81      main = "check_vdso.py",
    82      python_version = "PY3",
    83  )