tools/perf/tests/genelf.c
Source file repositories/reference/linux-study-clean/tools/perf/tests/genelf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/tests/genelf.c- Extension
.c- Size
- 1067 bytes
- Lines
- 54
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
limits.hstdio.hstdlib.hstring.hunistd.hlinux/compiler.hdebug.htests.hlibelf.h../util/genelf.h
Detected Declarations
function test__jit_write_elf
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/compiler.h>
#include "debug.h"
#include "tests.h"
#ifdef HAVE_JITDUMP
#include <libelf.h>
#include "../util/genelf.h"
#endif
#define TEMPL "/tmp/perf-test-XXXXXX"
static int test__jit_write_elf(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
#ifdef HAVE_JITDUMP
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 */
};
char path[PATH_MAX];
int fd, ret;
strcpy(path, TEMPL);
fd = mkstemp(path);
if (fd < 0) {
perror("mkstemp failed");
return TEST_FAIL;
}
pr_info("Writing jit code to: %s\n", path);
ret = jit_write_elf(fd, 0, "main", x86_code, sizeof(x86_code),
NULL, 0, NULL, 0, 0);
close(fd);
unlink(path);
return ret ? TEST_FAIL : 0;
#else
return TEST_SKIP;
#endif
}
DEFINE_SUITE("Test jit_write_elf", jit_write_elf);
Annotation
- Immediate include surface: `limits.h`, `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `linux/compiler.h`, `debug.h`, `tests.h`.
- Detected declarations: `function test__jit_write_elf`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.