buildtools: zero elf info variable in pmdinfogen
[dpdk.git] / buildtools / pmdinfogen / pmdinfogen.c
index beb06f1..e73fc76 100644 (file)
@@ -15,6 +15,8 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <errno.h>
+#include <libgen.h>
+
 #include <rte_common.h>
 #include "pmdinfogen.h"
 
@@ -224,13 +226,14 @@ static int parse_elf(struct elf_info *info, const char *filename)
        }
        if (!info->symtab_start)
                fprintf(stderr, "%s has no symtab?\n", filename);
-
-       /* Fix endianness in symbols */
-       for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
-               sym->st_shndx = TO_NATIVE(endian, 16, sym->st_shndx);
-               sym->st_name  = TO_NATIVE(endian, 32, sym->st_name);
-               sym->st_value = TO_NATIVE(endian, ADDR_SIZE, sym->st_value);
-               sym->st_size  = TO_NATIVE(endian, ADDR_SIZE, sym->st_size);
+       else {
+               /* Fix endianness in symbols */
+               for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
+                       sym->st_shndx = TO_NATIVE(endian, 16, sym->st_shndx);
+                       sym->st_name  = TO_NATIVE(endian, 32, sym->st_name);
+                       sym->st_value = TO_NATIVE(endian, ADDR_SIZE, sym->st_value);
+                       sym->st_size  = TO_NATIVE(endian, ADDR_SIZE, sym->st_size);
+               }
        }
 
        if (symtab_shndx_idx != ~0U) {
@@ -267,6 +270,7 @@ struct opt_tag {
 
 static const struct opt_tag opt_tags[] = {
        {"_param_string_export", "params"},
+       {"_kmod_dep_export", "kmod"},
 };
 
 static int complete_pmd_entry(struct elf_info *info, struct pmd_driver *drv)
@@ -384,7 +388,7 @@ static void output_pmd_info_string(struct elf_info *info, char *outfile)
                        else
                                fprintf(ofd, " ");
                }
-               fprintf(ofd, "]}\";");
+               fprintf(ofd, "]}\";\n");
                drv = drv->next;
        }
 
@@ -393,12 +397,13 @@ static void output_pmd_info_string(struct elf_info *info, char *outfile)
 
 int main(int argc, char **argv)
 {
-       struct elf_info info;
+       struct elf_info info = {0};
        int rc = 1;
 
        if (argc < 3) {
                fprintf(stderr,
-                       "usage: pmdinfo <object file> <c output file>\n");
+                       "usage: %s <object file> <c output file>\n",
+                       basename(argv[0]));
                exit(127);
        }
        parse_elf(&info, argv[1]);