Changeset View
Changeset View
Standalone View
Standalone View
contrib/elftoolchain/readelf/readelf.c
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | struct eflags_desc { | ||||
const char *desc; | const char *desc; | ||||
}; | }; | ||||
struct flag_desc { | struct flag_desc { | ||||
uint64_t flag; | uint64_t flag; | ||||
const char *desc; | const char *desc; | ||||
}; | }; | ||||
struct flag_desc_list { | |||||
uint32_t type; | |||||
const char *desc_str; | |||||
struct flag_desc *desc; | |||||
}; | |||||
struct mips_option { | struct mips_option { | ||||
uint64_t flag; | uint64_t flag; | ||||
const char *desc; | const char *desc; | ||||
}; | }; | ||||
struct loc_at { | struct loc_at { | ||||
Dwarf_Attribute la_at; | Dwarf_Attribute la_at; | ||||
Dwarf_Unsigned la_off; | Dwarf_Unsigned la_off; | ||||
▲ Show 20 Lines • Show All 3,294 Lines • ▼ Show 20 Lines | for (i = 0; (uint32_t)i <= maxl; i++) { | ||||
total += c[i] * i; | total += c[i] * i; | ||||
printf("%7u\t%-10u\t(%5.1f%%)\t%5.1f%%\n", i, c[i], | printf("%7u\t%-10u\t(%5.1f%%)\t%5.1f%%\n", i, c[i], | ||||
c[i] * 100.0 / nbucket, total * 100.0 / (nchain - 1)); | c[i] * 100.0 / nbucket, total * 100.0 / (nchain - 1)); | ||||
} | } | ||||
free(c); | free(c); | ||||
free(bl); | free(bl); | ||||
} | } | ||||
static struct flag_desc gnu_property_aarch64_feature_1_and_bits[] = { | |||||
{ GNU_PROPERTY_AARCH64_FEATURE_1_BTI, "BTI" }, | |||||
{ GNU_PROPERTY_AARCH64_FEATURE_1_PAC, "PAC" }, | |||||
emaste: PAV? | |||||
{ 0, NULL } | |||||
}; | |||||
static struct flag_desc_list gnu_property_aarch64[] = { | |||||
{ | |||||
GNU_PROPERTY_AARCH64_FEATURE_1_AND, | |||||
"AArch64 features", | |||||
gnu_property_aarch64_feature_1_and_bits | |||||
}, | |||||
{ 0, NULL, NULL } | |||||
}; | |||||
static struct flag_desc gnu_property_x86_feature_1_and_bits[] = { | static struct flag_desc gnu_property_x86_feature_1_and_bits[] = { | ||||
{ GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT" }, | { GNU_PROPERTY_X86_FEATURE_1_IBT, "IBT" }, | ||||
{ GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK" }, | { GNU_PROPERTY_X86_FEATURE_1_SHSTK, "SHSTK" }, | ||||
{ 0, NULL } | { 0, NULL } | ||||
}; | }; | ||||
static struct flag_desc_list gnu_property_x86[] = { | |||||
{ | |||||
GNU_PROPERTY_X86_FEATURE_1_AND, | |||||
"x64 features", | |||||
gnu_property_x86_feature_1_and_bits | |||||
}, | |||||
{ 0, NULL, NULL } | |||||
}; | |||||
static struct { | |||||
unsigned int emachine; | |||||
struct flag_desc_list *flag_list; | |||||
} gnu_property_archs[] = { | |||||
{ EM_AARCH64, gnu_property_aarch64 }, | |||||
{ EM_X86_64, gnu_property_x86 }, | |||||
{ 0, NULL } | |||||
}; | |||||
static void | static void | ||||
dump_gnu_property_type_0(struct readelf *re, const char *buf, size_t sz) | dump_gnu_property_type_0(struct readelf *re, const char *buf, size_t sz) | ||||
{ | { | ||||
struct flag_desc_list *desc_list; | |||||
struct flag_desc *desc; | |||||
size_t i; | size_t i; | ||||
uint32_t type, prop_sz; | uint32_t type, prop_sz; | ||||
printf(" Properties: "); | printf(" Properties: "); | ||||
while (sz > 0) { | while (sz > 0) { | ||||
if (sz < 8) | if (sz < 8) | ||||
goto bad; | goto bad; | ||||
type = *(const uint32_t *)(const void *)buf; | type = *(const uint32_t *)(const void *)buf; | ||||
prop_sz = *(const uint32_t *)(const void *)(buf + 4); | prop_sz = *(const uint32_t *)(const void *)(buf + 4); | ||||
buf += 8; | buf += 8; | ||||
sz -= 8; | sz -= 8; | ||||
if (prop_sz > sz) | if (prop_sz > sz) | ||||
goto bad; | goto bad; | ||||
if (type >= GNU_PROPERTY_LOPROC && | if (type >= GNU_PROPERTY_LOPROC && | ||||
type <= GNU_PROPERTY_HIPROC) { | type <= GNU_PROPERTY_HIPROC) { | ||||
if (re->ehdr.e_machine != EM_X86_64) { | desc_list = NULL; | ||||
for (i = 0; gnu_property_archs[i].flag_list != NULL; | |||||
i++) { | |||||
if (gnu_property_archs[i].emachine == | |||||
re->ehdr.e_machine) { | |||||
desc_list = | |||||
gnu_property_archs[i].flag_list; | |||||
break; | |||||
} | |||||
} | |||||
if (desc_list == NULL) { | |||||
printf("machine type %x unknown\n", | printf("machine type %x unknown\n", | ||||
re->ehdr.e_machine); | re->ehdr.e_machine); | ||||
goto unknown; | goto unknown; | ||||
} | } | ||||
switch (type) { | |||||
case GNU_PROPERTY_X86_FEATURE_1_AND: | desc = NULL; | ||||
printf("x86 features:"); | for (i = 0; desc_list[i].desc != NULL; i++) { | ||||
if (desc_list[i].type == type) { | |||||
desc = desc_list[i].desc; | |||||
break; | |||||
} | |||||
} | |||||
if (desc != NULL) { | |||||
Not Done Inline ActionsWe probably need to handle the NULL case? emaste: We probably need to handle the NULL case? | |||||
Done Inline ActionsThe NULL case here is the same as the missing default case in the old version. andrew: The NULL case here is the same as the missing default case in the old version. | |||||
Not Done Inline ActionsOk, fair point. We ought to add it, I don't care if it's a later commit (or if I have to do it) emaste: Ok, fair point. We ought to add it, I don't care if it's a later commit (or if I have to do it) | |||||
printf("%s:", desc_list[i].desc_str); | |||||
if (prop_sz != 4) | if (prop_sz != 4) | ||||
goto bad; | goto bad; | ||||
dump_flags(gnu_property_x86_feature_1_and_bits, | dump_flags(desc, | ||||
*(const uint32_t *)(const void *)buf); | *(const uint32_t *)(const void *)buf); | ||||
break; | |||||
} | } | ||||
} | } | ||||
buf += roundup2(prop_sz, 8); | buf += roundup2(prop_sz, 8); | ||||
sz -= roundup2(prop_sz, 8); | sz -= roundup2(prop_sz, 8); | ||||
} | } | ||||
return; | return; | ||||
bad: | bad: | ||||
▲ Show 20 Lines • Show All 4,340 Lines • Show Last 20 Lines |
PAV?