github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/executor/kvm_gen.cc (about)

     1  // Copyright 2017 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  // +build
     5  
     6  #include <stdio.h>
     7  
     8  #define PRINT(x)                                    \
     9  	extern const unsigned char(x)[], x##_end[]; \
    10  	print(#x, x, x##_end);
    11  
    12  void print(const char* name, const unsigned char* start, const unsigned char* end)
    13  {
    14  	printf("const char %s[] = \"", name);
    15  	for (const unsigned char* p = start; p < end; p++)
    16  		printf("\\x%02x", *p);
    17  	printf("\";\n");
    18  }
    19  
    20  int main()
    21  {
    22  	printf("// Code generated by executor/kvm_gen.cc. DO NOT EDIT.\n");
    23  #if GOARCH_amd64
    24  	PRINT(kvm_asm16_cpl3);
    25  	PRINT(kvm_asm32_paged);
    26  	PRINT(kvm_asm32_vm86);
    27  	PRINT(kvm_asm32_paged_vm86);
    28  	PRINT(kvm_asm64_enable_long);
    29  	PRINT(kvm_asm64_init_vm);
    30  	PRINT(kvm_asm64_vm_exit);
    31  	PRINT(kvm_asm64_cpl3);
    32  #elif GOARCH_ppc64le
    33  	PRINT(kvm_ppc64_mr);
    34  	PRINT(kvm_ppc64_ld);
    35  	PRINT(kvm_ppc64_recharge_dec);
    36  #endif
    37  	return 0;
    38  }