ElfSection
Description
Decoded section header. name is borrowed from the file’s .shstrtab and stays valid until ElfFileDeinit.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Elf.c:42:
}
const ElfSection *text = ElfFileFindSection(&elf, ".text");
bool ok = text != NULL && text->size > 0 && (text->flags & 0x4); // SHF_EXECINSTR = 0x4
- In
Dwarf.c:596:
out->string_pool = StrInit(alloc);
const ElfSection *line_section = ElfFileFindSection(elf, ".debug_line");
if (!line_section || line_section->size == 0) {
// No debug info — empty result is still success.
- In
Elf.c:215:
StrReadFmt(cursor, FMT_SHDR64_LE, name, type, flags, addr, offset, size_, link, info, addralign, entsize);
ElfSection s;
s.name = elf_str_at(self, shstr_off, shstr_size, name);
s.type = type;- In
Elf.c:236:
// ---------------------------------------------------------------------------
static bool elf_decode_symbol_table(ElfFile *self, const ElfSection *symtab, ElfSymbols *out) {
if (!symtab || symtab->size == 0) {
return true;- In
Elf.c:256:
return false;
}
const ElfSection *strtab = &self->sections.data[strtab_idx];
if (!elf_range_ok(self, strtab->offset, strtab->size)) {
LOG_ERROR("ElfFile: strtab out of range");- In
Elf.c:288:
static bool elf_decode_symbols(ElfFile *self) {
const ElfSection *symtab = NULL;
const ElfSection *dynsymtab = NULL;- In
Elf.c:289:
static bool elf_decode_symbols(ElfFile *self) {
const ElfSection *symtab = NULL;
const ElfSection *dynsymtab = NULL;
for (u64 i = 0; i < self->sections.length; ++i) {- In
Elf.c:292:
for (u64 i = 0; i < self->sections.length; ++i) {
const ElfSection *s = &self->sections.data[i];
if (s->type == ELF_SECTION_TYPE_SYMTAB) {
symtab = s;- In
Elf.c:413:
}
const ElfSection *ElfFileFindSection(const ElfFile *self, const char *name) {
if (!self || !name)
return NULL;- In
Elf.c:417:
return NULL;
for (u64 i = 0; i < self->sections.length; ++i) {
const ElfSection *s = &self->sections.data[i];
if (s->name && ZstrCompare(s->name, name) == 0) {
return s;- In
Elf.h:116:
u32 info; // section-specific
u64 entry_size; // for table-shaped sections
} ElfSection;
///
- In
Elf.h:131:
} ElfSymbol;
typedef Vec(ElfSection) ElfSections;
typedef Vec(ElfSymbol) ElfSymbols;- In
Elf.h:231:
/// Find a section by name (first match). Returns NULL if absent.
///
const ElfSection *ElfFileFindSection(const ElfFile *self, const char *name);
#endif // MISRA_PARSERS_ELF_H
Last updated on