mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #8670 from avagin:go_embed_data
PiperOrigin-RevId: 515200401
This commit is contained in:
+4
-25
@@ -1,33 +1,10 @@
|
||||
load("//tools:defs.bzl", "go_binary", "go_embed_data", "go_library", "go_test")
|
||||
load("//tools:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(
|
||||
default_applicable_licenses = ["//:license"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "victim",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"seccomp_test_victim.go",
|
||||
"seccomp_test_victim_amd64.go",
|
||||
"seccomp_test_victim_arm64.go",
|
||||
],
|
||||
nogo = False,
|
||||
deps = [
|
||||
":seccomp",
|
||||
"@org_golang_x_sys//unix:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_embed_data(
|
||||
name = "victim_data",
|
||||
testonly = 1,
|
||||
src = "victim",
|
||||
package = "seccomp",
|
||||
var = "victimData",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "seccomp",
|
||||
srcs = [
|
||||
@@ -51,7 +28,9 @@ go_test(
|
||||
size = "small",
|
||||
srcs = [
|
||||
"seccomp_test.go",
|
||||
":victim_data",
|
||||
],
|
||||
embedsrcs = [
|
||||
"//pkg/seccomp/victim", # keep
|
||||
],
|
||||
library = ":seccomp",
|
||||
deps = [
|
||||
|
||||
@@ -16,6 +16,7 @@ package seccomp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -32,6 +33,9 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
|
||||
//go:embed victim
|
||||
var victimData []byte
|
||||
|
||||
// newVictim makes a victim binary.
|
||||
func newVictim() (string, error) {
|
||||
f, err := ioutil.TempFile("", "victim")
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
load("//tools:defs.bzl", "go_binary")
|
||||
|
||||
package(
|
||||
default_applicable_licenses = ["//:license"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "victim",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"seccomp_test_victim.go",
|
||||
"seccomp_test_victim_amd64.go",
|
||||
"seccomp_test_victim_arm64.go",
|
||||
],
|
||||
nogo = False,
|
||||
visibility = ["//:sandbox"],
|
||||
deps = [
|
||||
"//pkg/seccomp",
|
||||
"@org_golang_x_sys//unix:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -1,29 +1,26 @@
|
||||
load("//tools:arch.bzl", "arch_genrule")
|
||||
load("//tools:defs.bzl", "go_embed_data", "go_library")
|
||||
load("//tools:defs.bzl", "go_library")
|
||||
|
||||
package(
|
||||
default_applicable_licenses = ["//:license"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
go_embed_data(
|
||||
name = "vdso_bin",
|
||||
src = "//vdso:vdso.so",
|
||||
package = "vdsodata",
|
||||
var = "Binary",
|
||||
)
|
||||
|
||||
arch_genrule(
|
||||
name = "vdso_arch",
|
||||
src = ":vdso_bin",
|
||||
template = "vdso_%s.go",
|
||||
src = "//vdso",
|
||||
template = "vdso_%s.so",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "vdsodata",
|
||||
srcs = [
|
||||
"vdsodata.go",
|
||||
":vdso_arch",
|
||||
"vdsodata_amd64.go",
|
||||
"vdsodata_arm64.go",
|
||||
],
|
||||
embedsrcs = [
|
||||
":vdso_arch", # keep
|
||||
],
|
||||
marshal = False,
|
||||
stateify = False,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build amd64
|
||||
// +build amd64
|
||||
|
||||
package vdsodata
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
// Binary contains a compiled code of vdso.so.
|
||||
//
|
||||
//go:embed vdso_amd64.so
|
||||
var Binary []byte
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build arm64
|
||||
// +build arm64
|
||||
|
||||
package vdsodata
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
// Binary contains a compiled code of vdso.so.
|
||||
//
|
||||
//go:embed vdso_arm64.so
|
||||
var Binary []byte
|
||||
@@ -1,14 +1,12 @@
|
||||
"""Go rules."""
|
||||
|
||||
load("@bazel_gazelle//:def.bzl", _gazelle = "gazelle")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "GoLibrary", _go_binary = "go_binary", _go_context = "go_context", _go_embed_data = "go_embed_data", _go_library = "go_library", _go_path = "go_path", _go_test = "go_test")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "GoLibrary", _go_binary = "go_binary", _go_context = "go_context", _go_library = "go_library", _go_path = "go_path", _go_test = "go_test")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", _go_grpc_library = "go_grpc_library", _go_proto_library = "go_proto_library")
|
||||
load("//tools/bazeldefs:defs.bzl", "select_arch", "select_system")
|
||||
|
||||
gazelle = _gazelle
|
||||
|
||||
go_embed_data = _go_embed_data
|
||||
|
||||
go_path = _go_path
|
||||
|
||||
def _go_proto_or_grpc_library(go_library_func, name, **kwargs):
|
||||
|
||||
+1
-2
@@ -10,7 +10,7 @@ load("//tools/go_marshal:defs.bzl", "go_marshal", "marshal_deps", "marshal_test_
|
||||
load("//tools/nogo:defs.bzl", "nogo_test")
|
||||
load("//tools/bazeldefs:defs.bzl", _BuildSettingInfo = "BuildSettingInfo", _bool_flag = "bool_flag", _bpf_program = "bpf_program", _build_test = "build_test", _bzl_library = "bzl_library", _coreutil = "coreutil", _default_net_util = "default_net_util", _more_shards = "more_shards", _most_shards = "most_shards", _proto_library = "proto_library", _select_system = "select_system", _short_path = "short_path", _version = "version")
|
||||
load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier = "cc_flags_supplier", _cc_grpc_library = "cc_grpc_library", _cc_library = "cc_library", _cc_proto_library = "cc_proto_library", _cc_test = "cc_test", _cc_toolchain = "cc_toolchain", _gbenchmark = "gbenchmark", _gbenchmark_internal = "gbenchmark_internal", _grpcpp = "grpcpp", _gtest = "gtest", _vdso_linker_option = "vdso_linker_option")
|
||||
load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary", _go_embed_data = "go_embed_data", _go_grpc_and_proto_libraries = "go_grpc_and_proto_libraries", _go_library = "go_library", _go_path = "go_path", _go_proto_library = "go_proto_library", _go_test = "go_test", _gotsan_flag_values = "gotsan_flag_values", _gotsan_values = "gotsan_values", _select_goarch = "select_goarch", _select_goos = "select_goos")
|
||||
load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary", _go_grpc_and_proto_libraries = "go_grpc_and_proto_libraries", _go_library = "go_library", _go_path = "go_path", _go_proto_library = "go_proto_library", _go_test = "go_test", _gotsan_flag_values = "gotsan_flag_values", _gotsan_values = "gotsan_values", _select_goarch = "select_goarch", _select_goos = "select_goos")
|
||||
load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar")
|
||||
load("//tools/bazeldefs:platforms.bzl", _default_platform = "default_platform", _platform_capabilities = "platform_capabilities", _platforms = "platforms")
|
||||
load("//tools/bazeldefs:tags.bzl", "go_suffixes")
|
||||
@@ -46,7 +46,6 @@ gazelle = _gazelle
|
||||
go_path = _go_path
|
||||
select_goos = _select_goos
|
||||
select_goarch = _select_goarch
|
||||
go_embed_data = _go_embed_data
|
||||
go_proto_library = _go_proto_library
|
||||
gotsan_values = _gotsan_values
|
||||
gotsan_flag_values = _gotsan_flag_values
|
||||
|
||||
Reference in New Issue
Block a user