summaryrefslogtreecommitdiff
path: root/src/elfops/section-name.c
blob: 4832db9a0d82d110e11fdbb68d9efc70eba30e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdlib.h>
#include <libelfu/libelfu.h>


char* elfu_eScnName(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);
}