diff options
Diffstat (limited to 'src/lookup/section-name.c')
-rw-r--r-- | src/lookup/section-name.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lookup/section-name.c b/src/lookup/section-name.c new file mode 100644 index 0000000..d3748f9 --- /dev/null +++ b/src/lookup/section-name.c @@ -0,0 +1,22 @@ +#include <libelf.h> +#include <gelf.h> + +#include <libelfu/libelfu.h> + + +char* elfu_sectionName(Elf *e, Elf_Scn *scn) +{ + size_t shstrndx; + GElf_Shdr shdr; + + if (elf_getshdrstrndx(e, &shstrndx) != 0) { + return NULL; + } + + if (gelf_getshdr(scn, &shdr) != &shdr) { + return NULL; + } + + /* elf_strptr returns NULL if there was an error */ + return elf_strptr(e, shstrndx, shdr.sh_name); +} |