ref: 6ae55e2a61f1de10f7d41e37ff5bf9fa532532be
parent: 4fc7dfcc3f4ca59064142c3c830b2720914b5e8c
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Nov 27 14:54:27 EST 2017
[objdump] Add printstrings() This function prints the string table
--- a/objdump/main.c
+++ b/objdump/main.c
@@ -49,6 +49,25 @@
hdr->relsize);
}
+static void
+printstrings(struct myrohdr *hdr)
+{
+ size_t off, begin;;
+ char *s = NULL;
+
+ puts("strings:");
+ for (off = 0; off < strsiz; off++) {
+ if (s == NULL) {
+ s = &strings[off];
+ begin = off;
+ }
+ if (strings[off] == '\0') {
+ printf("\t[%zd] \"%s\"\n", begin, s);
+ s = NULL;
+ }
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -77,6 +96,7 @@
}
printhdr(&hdr);
+ printstrings(&hdr);
goto close_file;