0

I want to print symbol of .o file (same of nm command). I iterate on each section. And use this condition:

if (section[i].sh_type == SHT_SYMTAB)
      {
                        sym = (Elf64_Sym *)((char *)content + 
                        section[i].sh_offset);
      }

When I have my Elf64_Sym struct, i want print the symbol name. The struct is:

typedef struct {
    uint32_t      st_name;
    unsigned char st_info;
    unsigned char st_other;
    uint16_t      st_shndx;
    Elf64_Addr    st_value;
    uint64_t      st_size;
} Elf64_Sym;

How to print the st_name ? His type is uint32_t. I don't understand how to print it.

An idea ? Thanks you !

Mathie
  • 7
  • 5

1 Answers1

0

the st_name is an offset in the .shstrtab.

The string you're searching for is (char *)(addr of shstrtab) + sym->st_name;

Nathan Schwarz
  • 631
  • 5
  • 19