Changeset View
Changeset View
Standalone View
Standalone View
contrib/elftoolchain/readelf/readelf.c
Show First 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | |||||
static void dump_mips_options(struct readelf *re, struct section *s); | static void dump_mips_options(struct readelf *re, struct section *s); | ||||
static void dump_mips_option_flags(const char *name, struct mips_option *opt, | static void dump_mips_option_flags(const char *name, struct mips_option *opt, | ||||
uint64_t info); | uint64_t info); | ||||
static void dump_mips_reginfo(struct readelf *re, struct section *s); | static void dump_mips_reginfo(struct readelf *re, struct section *s); | ||||
static void dump_mips_specific_info(struct readelf *re); | static void dump_mips_specific_info(struct readelf *re); | ||||
static void dump_notes(struct readelf *re); | static void dump_notes(struct readelf *re); | ||||
static void dump_notes_content(struct readelf *re, const char *buf, size_t sz, | static void dump_notes_content(struct readelf *re, const char *buf, size_t sz, | ||||
off_t off); | off_t off); | ||||
static void dump_notes_data(const char *name, uint32_t type, const char *buf, | |||||
size_t sz) | |||||
static void dump_svr4_hash(struct section *s); | static void dump_svr4_hash(struct section *s); | ||||
static void dump_svr4_hash64(struct readelf *re, struct section *s); | static void dump_svr4_hash64(struct readelf *re, struct section *s); | ||||
static void dump_gnu_hash(struct readelf *re, struct section *s); | static void dump_gnu_hash(struct readelf *re, struct section *s); | ||||
static void dump_hash(struct readelf *re); | static void dump_hash(struct readelf *re); | ||||
static void dump_phdr(struct readelf *re); | static void dump_phdr(struct readelf *re); | ||||
static void dump_ppc_attributes(uint8_t *p, uint8_t *pe); | static void dump_ppc_attributes(uint8_t *p, uint8_t *pe); | ||||
static void dump_section_groups(struct readelf *re); | static void dump_section_groups(struct readelf *re); | ||||
static void dump_symtab(struct readelf *re, int i); | static void dump_symtab(struct readelf *re, int i); | ||||
▲ Show 20 Lines • Show All 3,157 Lines • ▼ Show 20 Lines | for (i = 0; (size_t) i < re->shnum; i++) { | ||||
} | } | ||||
dump_notes_content(re, d->d_buf, d->d_size, | dump_notes_content(re, d->d_buf, d->d_size, | ||||
s->off); | s->off); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static struct flag_desc note_feature_ctl_flags[] = { | |||||
{ NT_FREEBSD_FCTL_ASLR_DISABLE, "ASLR_DISABLE" }, | |||||
{ 0, NULL } | |||||
}; | |||||
brooks: Is it local style to declare this sort of thing nearby? style(9) would be it above all the… | |||||
emasteAuthorUnsubmitted Done Inline ActionsThey seem to be distributed in the existing file; probably they should actually be split out into a notes.c file but I would do that upstream to avoid conflicts emaste: They seem to be distributed in the existing file; probably they should actually be split out… | |||||
static void | static void | ||||
dump_notes_data(const char *name, uint32_t type, const char *buf, size_t sz) | |||||
{ | |||||
size_t i; | |||||
const uint32_t *ubuf; | |||||
/* Note data is at least 4-byte aligned */ | |||||
ubuf = (const uint32_t *)(const void *)buf; | |||||
Not Done Inline ActionsMay be print something explaining why the note is not decoded. kib: May be print something explaining why the note is not decoded. | |||||
if (strcmp(name, "FreeBSD") == 0) { | |||||
switch (type) { | |||||
case NT_FREEBSD_ABI_TAG: | |||||
if (sz != 4) | |||||
goto unknown; | |||||
printf(" ABI tag: %u\n", ubuf[0]); | |||||
return; | |||||
/* NT_FREEBSD_NOINIT_TAG carries no data, treat as unknown. */ | |||||
case NT_FREEBSD_ARCH_TAG: | |||||
if (sz != 4) | |||||
goto unknown; | |||||
printf(" Arch tag: %x\n", ubuf[0]); | |||||
return; | |||||
case NT_FREEBSD_FEATURE_CTL: | |||||
if (sz != 4) | |||||
goto unknown; | |||||
printf(" Features:"); | |||||
dump_flags(note_feature_ctl_flags, ubuf[0]); | |||||
printf("\n"); | |||||
return; | |||||
} | |||||
} | |||||
unknown: | |||||
printf(" description data:"); | |||||
for (i = 0; i < sz; i++) | |||||
printf(" %02x", (unsigned char)buf[i]); | |||||
printf("\n"); | |||||
} | |||||
static void | |||||
dump_notes_content(struct readelf *re, const char *buf, size_t sz, off_t off) | dump_notes_content(struct readelf *re, const char *buf, size_t sz, off_t off) | ||||
{ | { | ||||
Elf_Note *note; | Elf_Note *note; | ||||
const char *end, *name; | const char *end, *name; | ||||
uint32_t i; | |||||
printf("\nNotes at offset %#010jx with length %#010jx:\n", | printf("\nNotes at offset %#010jx with length %#010jx:\n", | ||||
(uintmax_t) off, (uintmax_t) sz); | (uintmax_t) off, (uintmax_t) sz); | ||||
printf(" %-13s %-15s %s\n", "Owner", "Data size", "Description"); | printf(" %-13s %-15s %s\n", "Owner", "Data size", "Description"); | ||||
end = buf + sz; | end = buf + sz; | ||||
while (buf < end) { | while (buf < end) { | ||||
if (buf + sizeof(*note) > end) { | if (buf + sizeof(*note) > end) { | ||||
warnx("invalid note header"); | warnx("invalid note header"); | ||||
Show All 15 Lines | if (note->n_namesz == 0) | ||||
name = ""; | name = ""; | ||||
else if (note->n_namesz == 4 && strncmp(name, "CORE", 4) == 0) | else if (note->n_namesz == 4 && strncmp(name, "CORE", 4) == 0) | ||||
name = "CORE"; | name = "CORE"; | ||||
else if (strnlen(name, note->n_namesz) >= note->n_namesz) | else if (strnlen(name, note->n_namesz) >= note->n_namesz) | ||||
name = "<invalid>"; | name = "<invalid>"; | ||||
printf(" %-13s %#010jx", name, (uintmax_t) note->n_descsz); | printf(" %-13s %#010jx", name, (uintmax_t) note->n_descsz); | ||||
printf(" %s\n", note_type(name, re->ehdr.e_type, | printf(" %s\n", note_type(name, re->ehdr.e_type, | ||||
note->n_type)); | note->n_type)); | ||||
printf(" description data:"); | dump_notes_data(name, note->n_type, buf, note->n_descsz); | ||||
for (i = 0; i < note->n_descsz; i++) | |||||
printf(" %02x", (unsigned char)buf[i]); | |||||
printf("\n"); | |||||
buf += roundup2(note->n_descsz, 4); | buf += roundup2(note->n_descsz, 4); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Symbol versioning sections are the same for 32bit and 64bit | * Symbol versioning sections are the same for 32bit and 64bit | ||||
* ELF objects. | * ELF objects. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 3,945 Lines • Show Last 20 Lines |
Is it local style to declare this sort of thing nearby? style(9) would be it above all the functions.