readelf: Pull add_dump_section() into file scope

Get rid of a nested function this way.

Signed-off-by: Timm Bäder <tbaeder@redhat.com>
diff --git a/src/ChangeLog b/src/ChangeLog
index a7c9d2e..86dda4b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
 2021-01-08  Timm Bäder  <tbaeder@redhat.com>
 
+	* readelf.c (parse_opt): Lift add_dump_section function to...
+	(add_dump_section): ...here. New top level function. Added key
+	argument.
+
+2021-01-08  Timm Bäder  <tbaeder@redhat.com>
+
 	* arlib-argp.c (help_filter): Lift text_for_default function to...
 	(text_for_default): ... here. New file scope function taking text
 	as argument.
diff --git a/src/readelf.c b/src/readelf.c
index 0001a3d..6233b26 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -381,24 +381,26 @@
   return error_message_count != 0;
 }
 
+static void
+add_dump_section (const char *name,
+		  int key,
+		  bool implicit)
+{
+  struct section_argument *a = xmalloc (sizeof *a);
+  a->arg = name;
+  a->next = NULL;
+  a->implicit = implicit;
+  struct section_argument ***tailp
+    = key == 'x' ? &dump_data_sections_tail : &string_sections_tail;
+  **tailp = a;
+  *tailp = &a->next;
+}
 
 /* Handle program arguments.  */
 static error_t
 parse_opt (int key, char *arg,
 	   struct argp_state *state __attribute__ ((unused)))
 {
-  void add_dump_section (const char *name, bool implicit)
-  {
-    struct section_argument *a = xmalloc (sizeof *a);
-    a->arg = name;
-    a->next = NULL;
-    a->implicit = implicit;
-    struct section_argument ***tailp
-      = key == 'x' ? &dump_data_sections_tail : &string_sections_tail;
-    **tailp = a;
-    *tailp = &a->next;
-  }
-
   switch (key)
     {
     case 'a':
@@ -414,9 +416,9 @@
       print_arch = true;
       print_notes = true;
       implicit_debug_sections |= section_exception;
-      add_dump_section (".strtab", true);
-      add_dump_section (".dynstr", true);
-      add_dump_section (".comment", true);
+      add_dump_section (".strtab", key, true);
+      add_dump_section (".dynstr", key, true);
+      add_dump_section (".comment", key, true);
       any_control_option = true;
       break;
     case 'A':
@@ -562,7 +564,7 @@
 	}
       FALLTHROUGH;
     case 'x':
-      add_dump_section (arg, false);
+      add_dump_section (arg, key, false);
       any_control_option = true;
       break;
     case 'N':