| // SPDX-License-Identifier: GPL-2.0-only |
| #include <linux/compiler.h> |
| #include "../util/genelf.h" |
| #define TEMPL "/tmp/perf-test-XXXXXX" |
| static int test__jit_write_elf(struct test_suite *test __maybe_unused, |
| int subtest __maybe_unused) |
| static unsigned char x86_code[] = { |
| 0xBB, 0x2A, 0x00, 0x00, 0x00, /* movl $42, %ebx */ |
| 0xB8, 0x01, 0x00, 0x00, 0x00, /* movl $1, %eax */ |
| 0xCD, 0x80 /* int $0x80 */ |
| perror("mkstemp failed"); |
| pr_info("Writing jit code to: %s\n", path); |
| ret = jit_write_elf(fd, 0, "main", x86_code, sizeof(x86_code), |
| return ret ? TEST_FAIL : 0; |
| DEFINE_SUITE("Test jit_write_elf", jit_write_elf); |