From 34e3f1468822717071530e351263921c1b208d63 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 2 Jan 2015 20:49:43 +0000 Subject: [PATCH] readelf: Correct rounding on note padding In general 64-bit ELF notes use 4-byte padding, not 8, despite what is claimed in various specs. Upstream elftoolchain ticket 472 https://sourceforge.net/p/elftoolchain/tickets/472/ Sponsored by: The FreeBSD Foundation --- contrib/elftoolchain/readelf/readelf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/elftoolchain/readelf/readelf.c b/contrib/elftoolchain/readelf/readelf.c index dac20aac8855..764e94d0fb27 100644 --- a/contrib/elftoolchain/readelf/readelf.c +++ b/contrib/elftoolchain/readelf/readelf.c @@ -1492,6 +1492,7 @@ note_type(unsigned int osabi, unsigned int et, unsigned int nt) return "NT_FPREGSET (Floating point information)"; case NT_PRPSINFO: return "NT_PRPSINFO (Process information)"; +#if 0 case NT_AUXV: return "NT_AUXV (Auxiliary vector)"; case NT_PRXFPREG: @@ -1506,12 +1507,14 @@ note_type(unsigned int osabi, unsigned int et, unsigned int nt) return "NT_LWPSTATUS (Linux lwpstatus_t type)"; case NT_LWPSINFO: return "NT_LWPSINFO (Linux lwpinfo_t type)"; +#endif default: snprintf(s_nt, sizeof(s_nt), "", nt); return (s_nt); } } else { switch (nt) { +#if 0 case NT_ABI_TAG: switch (osabi) { case ELFOSABI_FREEBSD: @@ -1529,11 +1532,13 @@ note_type(unsigned int osabi, unsigned int et, unsigned int nt) return "NT_GNU_BUILD_ID (Build id set by ld(1))"; case NT_GNU_GOLD_VERSION: return "NT_GNU_GOLD_VERSION (GNU gold version)"; +#endif default: snprintf(s_nt, sizeof(s_nt), "", nt); return (s_nt); } } + (void)osabi; } static struct { @@ -3592,13 +3597,8 @@ dump_notes_content(struct readelf *re, const char *buf, size_t sz, off_t off) (uintmax_t) note->n_descsz); printf(" %s\n", note_type(re->ehdr.e_ident[EI_OSABI], re->ehdr.e_type, note->n_type)); - buf += sizeof(Elf_Note); - if (re->ec == ELFCLASS32) - buf += roundup2(note->n_namesz, 4) + - roundup2(note->n_descsz, 4); - else - buf += roundup2(note->n_namesz, 8) + - roundup2(note->n_descsz, 8); + buf += sizeof(Elf_Note) + roundup2(note->n_namesz, 4) + + roundup2(note->n_descsz, 4); } }