gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/pkg/sentry/platform/systrap/sysmsg/gen_offsets_go.sh (about) 1 # Copyright 2020 The gVisor Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # This script generates a golang file which contains: 16 # * byte array with the sysmsg stub binary blob. 17 # * set of variables with addresses of exported symbols. 18 19 #!/bin/bash 20 21 set -e 22 set -u 23 24 FILE=$1 25 NAME=$2 26 27 PREFIX=${NAME}_blob_offset__ 28 BLOB=${NAME}_blob 29 OBJNAME=$3 30 31 AWK_CMD='$2 ~ /^[tBCTA]$/ { print "var '$PREFIX'" $3 " = 0x" $1 }' 32 33 cat << EOF 34 /* Autogenerated by $0, do not edit */ 35 package sysmsg 36 37 EOF 38 39 nm "$OBJNAME" | grep "__export_" | tr . _ | awk "$AWK_CMD"