nixprof: only save STT_FUNC

This commit is contained in:
Gabriel Corona 2015-08-25 01:56:04 +02:00
parent ceca8c72bf
commit 8fc2d5d069
2 changed files with 5 additions and 1 deletions

View File

@ -176,6 +176,9 @@ struct elf64_symbol {
#define ELF_PRINT_SECTIONS 2 #define ELF_PRINT_SECTIONS 2
#define ELF_PRINT_ALL (ELF_PRINT_PROGRAM_HEADERS | ELF_PRINT_SECTIONS) #define ELF_PRINT_ALL (ELF_PRINT_PROGRAM_HEADERS | ELF_PRINT_SECTIONS)
/* Symbol types */
#define STT_FUNC 2 /* Function, code */
/** /**
* Checks that elfFile points to a valid elf file. * Checks that elfFile points to a valid elf file.
* *

View File

@ -190,8 +190,9 @@ static void elf_syms(FILE* out,const char* libfile)
uint64_t st_value = elf32 ? sym[i].st_value : sym64[i].st_value; uint64_t st_value = elf32 ? sym[i].st_value : sym64[i].st_value;
uint32_t st_name = elf32 ? sym[i].st_name : sym64[i].st_name; uint32_t st_name = elf32 ? sym[i].st_name : sym64[i].st_name;
uint16_t st_shndx = elf32 ? sym[i].st_shndx : sym64[i].st_shndx; uint16_t st_shndx = elf32 ? sym[i].st_shndx : sym64[i].st_shndx;
uint16_t st_type = (elf32 ? sym[i].st_info : sym64[i].st_info) & 0xf;
uint64_t st_size = elf32 ? sym[i].st_size : sym64[i].st_size; uint64_t st_size = elf32 ? sym[i].st_size : sym64[i].st_size;
if (st_value && st_name && st_shndx) if (st_type == STT_FUNC && st_value && st_name && st_shndx)
{ {
char* name=(char*)elf_getSection(data,dynstr);// sym[i].st_shndx char* name=(char*)elf_getSection(data,dynstr);// sym[i].st_shndx
// printf("Symbol %d: %s, %08" PRIx64 ", % " PRIi64 " bytes\n", // printf("Symbol %d: %s, %08" PRIx64 ", % " PRIi64 " bytes\n",