readelf: decode and print Xen ELF note strings
Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
4d8a9faf17
commit
ff0f134bb1
@ -3676,6 +3676,33 @@ static struct flag_desc note_feature_ctl_flags[] = {
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
dump_note_string(const char *description, const char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
int printable = 1;
|
||||
|
||||
if (len == 0 || s[--len] != '\0') {
|
||||
printable = 0;
|
||||
} else {
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isprint(s[i])) {
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (printable) {
|
||||
printf(" %s: %s\n", description, s);
|
||||
} else {
|
||||
printf(" description data:");
|
||||
for (i = 0; i < len; i++)
|
||||
printf(" %02x", (unsigned char)s[i]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dump_notes_data(struct readelf *re, const char *name, uint32_t type,
|
||||
const char *buf, size_t sz)
|
||||
@ -3716,6 +3743,30 @@ dump_notes_data(struct readelf *re, const char *name, uint32_t type,
|
||||
dump_gnu_property_type_0(re, buf, sz);
|
||||
return;
|
||||
}
|
||||
} else if (strcmp(name, "Xen") == 0) {
|
||||
switch (type) {
|
||||
case 5:
|
||||
dump_note_string("Xen version", buf, sz);
|
||||
return;
|
||||
case 6:
|
||||
dump_note_string("Guest OS", buf, sz);
|
||||
return;
|
||||
case 7:
|
||||
dump_note_string("Guest version", buf, sz);
|
||||
return;
|
||||
case 8:
|
||||
dump_note_string("Loader", buf, sz);
|
||||
return;
|
||||
case 9:
|
||||
dump_note_string("PAE mode", buf, sz);
|
||||
return;
|
||||
case 10:
|
||||
dump_note_string("Features", buf, sz);
|
||||
return;
|
||||
case 11:
|
||||
dump_note_string("BSD symtab", buf, sz);
|
||||
return;
|
||||
}
|
||||
}
|
||||
unknown:
|
||||
printf(" description data:");
|
||||
|
Loading…
Reference in New Issue
Block a user