704772bda0
These are sufficiently intertwined that they need to be done together. riscv64 is our first primary-only architecture, so that required some changes. The .bp changes are to support this --- we need to only show the python scripts the architectures they'll actually be using, rather than showing them everything and ignoring some of the results. riscv64 is also the first architecture that post-dates the kernel's 64-bit time work, so there's a bit of extra fiddling needed to handle the __NR3264_ indirection in the uapi headers. Signed-off-by: Mao Han <han_mao@linux.alibaba.com> Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com> Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com> Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn> Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn> Test: local builds for x86-64 and riscv64 Change-Id: I74044744e80b312088f805c44fbd667c9bfcdc69
71 lines
2.2 KiB
Python
Executable file
71 lines
2.2 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
import re
|
|
|
|
from gensyscalls import SupportedArchitectures, SysCallsTxtParser
|
|
from genseccomp import parse_syscall_NRs
|
|
|
|
|
|
def load_syscall_names_from_file(file_path, architecture):
|
|
parser = SysCallsTxtParser()
|
|
parser.parse_open_file(open(file_path))
|
|
arch_map = {}
|
|
for syscall in parser.syscalls:
|
|
if syscall.get(architecture):
|
|
arch_map[syscall["func"]] = syscall["name"]
|
|
|
|
return arch_map
|
|
|
|
|
|
def gen_syscall_nrs(out_file, base_syscall_file, syscall_NRs):
|
|
for arch in syscall_NRs.keys():
|
|
base_names = load_syscall_names_from_file(base_syscall_file, arch)
|
|
|
|
for func, syscall in base_names.items():
|
|
out_file.write("#define __" + arch + "_" + func + " " +
|
|
str(syscall_NRs[arch][syscall]) + "\n")
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description=
|
|
"Generates a mapping of bionic functions to system call numbers per architecture."
|
|
)
|
|
parser.add_argument("--verbose", "-v", help="Enables verbose logging.")
|
|
parser.add_argument("--out-dir",
|
|
help="The output directory for the output files")
|
|
parser.add_argument(
|
|
"base_file",
|
|
metavar="base-file",
|
|
type=str,
|
|
help="The path of the base syscall list (SYSCALLS.TXT).")
|
|
parser.add_argument(
|
|
"files",
|
|
metavar="FILE",
|
|
type=str,
|
|
nargs="+",
|
|
help=("A syscall name-number mapping file for an architecture.\n"))
|
|
args = parser.parse_args()
|
|
|
|
if args.verbose:
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
else:
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
syscall_NRs = {}
|
|
for filename in args.files:
|
|
m = re.search(r"libseccomp_gen_syscall_nrs_([^/]+)", filename)
|
|
syscall_NRs[m.group(1)] = parse_syscall_NRs(filename)
|
|
|
|
output_path = os.path.join(args.out_dir, "func_to_syscall_nrs.h")
|
|
with open(output_path, "w") as output_file:
|
|
gen_syscall_nrs(out_file=output_file,
|
|
syscall_NRs=syscall_NRs,
|
|
base_syscall_file=args.base_file)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|