From: Pawel W. <paw...@gm...> - 2009-07-10 19:18:48
|
Hi, Here is patch to fix some case-typos and to reorder the output similar to gnu readelf. What is the future of readelf ? The wiki says merge with elfdump, does the include teaching elfdump the readelf output format ? Index: readelf/readelf.c =================================================================== --- readelf/readelf.c (revision 419) +++ readelf/readelf.c (working copy) @@ -528,7 +528,7 @@ switch (sbind) { case STB_LOCAL: return "LOCAL"; - case STB_GLOBAL: return "GLOBAl"; + case STB_GLOBAL: return "GLOBAL"; case STB_WEAK: return "WEAK"; default: if (sbind >= STB_LOOS && sbind <= STB_HIOS) @@ -1347,7 +1347,7 @@ printf(" %-23s%-17s%-18s%s\n", "[Nr] Name", "Type", "Address", "Offset"); printf(" %-18s%-17s%-7s%-6s%-6s%s\n", "Size", - "EntSize", "FLags", "Link", "Info", "Align"); + "EntSize", "Flags", "Link", "Info", "Align"); } } for (i = 0; (size_t)i < re->shnum; i++) { @@ -1684,6 +1684,8 @@ } if (d->d_size <= 0) return; + printf("\nSymbol table (%s)", s->name); + printf(" contains %ju entries:\n", s->sz / s->entsize); printf("%7s%9s%14s%5s%8s%6s%9s%5s\n", "Num:", "Value", "Size", "Type", "Bind", "Vis", "Ndx", "Name"); for (j = 0; (uint64_t)j < s->sz / s->entsize; j++) { @@ -1782,7 +1784,7 @@ errx(EX_SOFTWARE, "calloc failed"); for (i = 0; (uint32_t)i < nbucket; i++) c[bl[i]]++; - printf("Histogram for bucket list length (total of %u buckets):\n", + printf("\nHistogram for bucket list length (total of %u buckets):\n", nbucket); printf(" Length\tNumber\t\t%% of total\tCoverage\n"); total = 0; @@ -1853,6 +1855,26 @@ return; } + vname[0] = "*local*"; + vname[1] = "*global*"; + if (vs_s) { + printf("\nVersion symbol section (%s):\n", vs_s->name); + if ((d = elf_getdata(vs_s->scn, NULL)) != NULL && d->d_size > + 0) { + j = d->d_size / sizeof(Elf32_Half); + vs = d->d_buf; + for (i = 0; i < j; i++) { + if ((i & 3) == 0) { + if (i > 0) + putchar('\n'); + printf(" %03x", i); + } + printf(" %3d %-12s ", vs[i], vname[vs[i]]); + } + putchar('\n'); + } + } + if (vd_s) { printf("\nVersion definition section (%s):\n", vd_s->name); if ((d = elf_getdata(vd_s->scn, NULL)) != NULL && d->d_size > @@ -1914,26 +1936,6 @@ } } } - - vname[0] = "*local*"; - vname[1] = "*global*"; - if (vs_s) { - printf("\nVersion symbol section (%s:)\n", vs_s->name); - if ((d = elf_getdata(vs_s->scn, NULL)) != NULL && d->d_size > - 0) { - j = d->d_size / sizeof(Elf32_Half); - vs = d->d_buf; - for (i = 0; i < j; i++) { - if ((i & 3) == 0) { - if (i > 0) - putchar('\n'); - printf(" %03x", i); - } - printf(" %3d %-12s ", vs[i], vname[vs[i]]); - } - putchar('\n'); - } - } #undef SAVE_VERSION_NAME } @@ -2083,10 +2085,10 @@ if (re->options & RE_H) dump_ehdr(re); + if (re->options & RE_SS) + dump_shdr(re); if (re->options & RE_L) dump_phdr(re); - if (re->options & RE_SS) - dump_shdr(re); if (re->options & RE_D) dump_dynamic(re); if (re->options & RE_R) Regards -- Pawel |