tools/bpf/bpf_jit_disasm.c
Source file repositories/reference/linux-study-clean/tools/bpf/bpf_jit_disasm.c
File Facts
- System
- Linux kernel
- Corpus path
tools/bpf/bpf_jit_disasm.c- Extension
.c- Size
- 6640 bytes
- Lines
- 335
- 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
stdint.hstdio.hstdlib.hassert.hunistd.hstring.hbfd.hdis-asm.hregex.hfcntl.hsys/klog.hsys/types.hsys/stat.hlimits.htools/dis-asm-compat.h
Detected Declarations
function get_exec_pathfunction get_asm_insnsfunction put_log_bufffunction usagefunction main
Annotated Snippet
if (opcodes) {
printf("\n\t");
for (i = 0; i < count; ++i)
printf("%02x ", (uint8_t) image[pc + i]);
}
printf("\n");
pc += count;
} while(count > 0 && pc < len);
bfd_close(bfdf);
}
static char *get_klog_buff(unsigned int *klen)
{
int ret, len;
char *buff;
len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
if (len < 0)
return NULL;
buff = malloc(len);
if (!buff)
return NULL;
ret = klogctl(CMD_ACTION_READ_ALL, buff, len);
if (ret < 0) {
free(buff);
return NULL;
}
*klen = ret;
return buff;
}
static char *get_flog_buff(const char *file, unsigned int *klen)
{
int fd, ret, len;
struct stat fi;
char *buff;
fd = open(file, O_RDONLY);
if (fd < 0)
return NULL;
ret = fstat(fd, &fi);
if (ret < 0 || !S_ISREG(fi.st_mode))
goto out;
len = fi.st_size + 1;
buff = malloc(len);
if (!buff)
goto out;
memset(buff, 0, len);
ret = read(fd, buff, len - 1);
if (ret <= 0)
goto out_free;
close(fd);
*klen = ret;
return buff;
out_free:
free(buff);
out:
close(fd);
return NULL;
}
static char *get_log_buff(const char *file, unsigned int *klen)
{
return file ? get_flog_buff(file, klen) : get_klog_buff(klen);
}
static void put_log_buff(char *buff)
{
free(buff);
}
static uint8_t *get_last_jit_image(char *haystack, size_t hlen,
unsigned int *ilen)
{
char *ptr, *pptr, *tmp;
off_t off = 0;
unsigned int proglen;
int ret, flen, pass, ulen = 0;
regmatch_t pmatch[1];
unsigned long base;
regex_t regex;
Annotation
- Immediate include surface: `stdint.h`, `stdio.h`, `stdlib.h`, `assert.h`, `unistd.h`, `string.h`, `bfd.h`, `dis-asm.h`.
- Detected declarations: `function get_exec_path`, `function get_asm_insns`, `function put_log_buff`, `function usage`, `function main`.
- 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.