PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
elf64_get_symbol_name.c
Go to the documentation of this file.
1#include "common/elf.h"
2
3const char* elf64_get_symbol_name(const Elf64_File* elf, const Elf64_Sym* symbol)
4{
5 if (elf == NULL || symbol == NULL)
6 {
7 return NULL;
8 }
9
10 if (elf->symtab == NULL)
11 {
12 return NULL;
13 }
14
15 Elf64_Shdr* strtabHdr = ELF64_GET_SHDR(elf, elf->symtab->sh_link);
16 char* strTable = ELF64_AT_OFFSET(elf, strtabHdr->sh_offset);
17 return &strTable[symbol->st_name];
18}
#define ELF64_AT_OFFSET(elf, offset)
Get a pointer to a location in the ELF file at the given offset.
Definition elf.h:814
const char * elf64_get_symbol_name(const Elf64_File *elf, const Elf64_Sym *symbol)
Get the name of a symbol.
#define ELF64_GET_SHDR(elf, index)
Get the section header at the given index from an ELF file.
Definition elf.h:805
#define NULL
Pointer error value.
Definition NULL.h:23
ELF File Helper structure.
Definition elf.h:781
Elf64_Shdr * symtab
The symbol table section, or NULL if not found.
Definition elf.h:784
ELF64 Section Header.
Definition elf.h:468
Elf64_Word sh_link
Definition elf.h:475
Elf64_Off sh_offset
Section's file offset in bytes.
Definition elf.h:473
ELF64 Symbol Table Entry.
Definition elf.h:543
Elf64_Word st_name
Definition elf.h:544