summaryrefslogtreecommitdiff
path: root/src/model/section-name.c
blob: 2ecd5f0a07b00c66defa054da717873759c575ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <assert.h>
#include <stdlib.h>
#include <libelf.h>
#include <gelf.h>
#include <libelfu/libelfu.h>



char* elfu_mScnName(ElfuElf *me, ElfuScn *ms)
{
  assert(me);
  assert(ms);

  if (!me->shstrtab) {
    return NULL;
  }

  if (CIRCLEQ_EMPTY(&me->shstrtab->dataList)) {
    return NULL;
  }

  /* Don't take multiple data parts into account. */
  ElfuData *md = me->shstrtab->dataList.cqh_first;
  return &((char*)md->data.d_buf)[ms->shdr.sh_name];
}