scripts/elf-parse.h
Source file repositories/reference/linux-study-clean/scripts/elf-parse.h
File Facts
- System
- Linux kernel
- Corpus path
scripts/elf-parse.h- Extension
.h- Size
- 7049 bytes
- Lines
- 306
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- 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
elf.htools/be_byteshift.htools/le_byteshift.h
Detected Declarations
struct elf_funcsfunction ehdr64_shofffunction ehdr32_shofffunction ehdr_shofffunction sym64_typefunction sym32_typefunction sym_typefunction rela64_write_addendfunction rela32_write_addendfunction rbefunction r2befunction r8befunction rlefunction r2lefunction r8lefunction wbefunction wlefunction w8befunction w8le
Annotated Snippet
struct elf_funcs {
int (*compare_extable)(const void *a, const void *b);
uint64_t (*ehdr_shoff)(Elf_Ehdr *ehdr);
uint16_t (*ehdr_shstrndx)(Elf_Ehdr *ehdr);
uint16_t (*ehdr_shentsize)(Elf_Ehdr *ehdr);
uint16_t (*ehdr_shnum)(Elf_Ehdr *ehdr);
uint64_t (*shdr_addr)(Elf_Shdr *shdr);
uint64_t (*shdr_offset)(Elf_Shdr *shdr);
uint64_t (*shdr_size)(Elf_Shdr *shdr);
uint64_t (*shdr_entsize)(Elf_Shdr *shdr);
uint32_t (*shdr_link)(Elf_Shdr *shdr);
uint32_t (*shdr_name)(Elf_Shdr *shdr);
uint32_t (*shdr_type)(Elf_Shdr *shdr);
uint8_t (*sym_type)(Elf_Sym *sym);
uint32_t (*sym_name)(Elf_Sym *sym);
uint64_t (*sym_value)(Elf_Sym *sym);
uint16_t (*sym_shndx)(Elf_Sym *sym);
uint64_t (*rela_offset)(Elf_Rela *rela);
uint64_t (*rela_info)(Elf_Rela *rela);
uint64_t (*rela_addend)(Elf_Rela *rela);
void (*rela_write_addend)(Elf_Rela *rela, uint64_t val);
uint32_t (*r)(const uint32_t *);
uint16_t (*r2)(const uint16_t *);
uint64_t (*r8)(const uint64_t *);
void (*w)(uint32_t, uint32_t *);
void (*w8)(uint64_t, uint64_t *);
};
extern struct elf_funcs elf_parser;
static inline uint64_t ehdr64_shoff(Elf_Ehdr *ehdr)
{
return elf_parser.r8(&ehdr->e64.e_shoff);
}
static inline uint64_t ehdr32_shoff(Elf_Ehdr *ehdr)
{
return elf_parser.r(&ehdr->e32.e_shoff);
}
static inline uint64_t ehdr_shoff(Elf_Ehdr *ehdr)
{
return elf_parser.ehdr_shoff(ehdr);
}
#define EHDR_HALF(fn_name) \
static inline uint16_t ehdr64_##fn_name(Elf_Ehdr *ehdr) \
{ \
return elf_parser.r2(&ehdr->e64.e_##fn_name); \
} \
\
static inline uint16_t ehdr32_##fn_name(Elf_Ehdr *ehdr) \
{ \
return elf_parser.r2(&ehdr->e32.e_##fn_name); \
} \
\
static inline uint16_t ehdr_##fn_name(Elf_Ehdr *ehdr) \
{ \
return elf_parser.ehdr_##fn_name(ehdr); \
}
EHDR_HALF(shentsize)
EHDR_HALF(shstrndx)
EHDR_HALF(shnum)
#define SHDR_WORD(fn_name) \
static inline uint32_t shdr64_##fn_name(Elf_Shdr *shdr) \
{ \
return elf_parser.r(&shdr->e64.sh_##fn_name); \
} \
\
static inline uint32_t shdr32_##fn_name(Elf_Shdr *shdr) \
{ \
return elf_parser.r(&shdr->e32.sh_##fn_name); \
} \
\
static inline uint32_t shdr_##fn_name(Elf_Shdr *shdr) \
{ \
return elf_parser.shdr_##fn_name(shdr); \
}
#define SHDR_ADDR(fn_name) \
static inline uint64_t shdr64_##fn_name(Elf_Shdr *shdr) \
{ \
return elf_parser.r8(&shdr->e64.sh_##fn_name); \
} \
\
static inline uint64_t shdr32_##fn_name(Elf_Shdr *shdr) \
{ \
return elf_parser.r(&shdr->e32.sh_##fn_name); \
Annotation
- Immediate include surface: `elf.h`, `tools/be_byteshift.h`, `tools/le_byteshift.h`.
- Detected declarations: `struct elf_funcs`, `function ehdr64_shoff`, `function ehdr32_shoff`, `function ehdr_shoff`, `function sym64_type`, `function sym32_type`, `function sym_type`, `function rela64_write_addend`, `function rela32_write_addend`, `function rbe`.
- Atlas domain: Support Tooling And Documentation / scripts.
- 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.