bfd: Display symbol version for nm -D
[deliverable/binutils-gdb.git] / ld / testplug2.c
index 10f0efba6ccca3c91fe47bed1118ccde81626e6d..27553d07813b8e291caed595399b155c0e6ba94a 100644 (file)
@@ -1,6 +1,6 @@
 /* Test plugin for the GNU linker.  Check non-object IR file as well as
    get_input_file, get_view and release_input_file interfaces.
-   Copyright (C) 2015 Free Software Foundation, Inc.
+   Copyright (C) 2015-2020 Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
 
@@ -125,6 +125,7 @@ static bfd_boolean register_claimfile_hook = TRUE;
 static bfd_boolean register_allsymbolsread_hook = FALSE;
 static bfd_boolean register_cleanup_hook = FALSE;
 static bfd_boolean dumpresolutions = FALSE;
+static bfd_boolean allsymbolsread_silent = FALSE;
 
 /* The master list of all claimable/claimed files.  */
 static claim_file_t *claimfiles_list = NULL;
@@ -217,12 +218,15 @@ parse_symdefstr (const char *str, struct ld_plugin_symbol *sym)
   /* Finally we'll use sscanf to parse the numeric fields, then
      we'll split out the strings which we need to allocate separate
      storage for anyway so that we can add nul termination.  */
-  n = sscanf (colon2 + 1, "%i:%i:%lli", &sym->def, &sym->visibility, &size);
+  n = sscanf (colon2 + 1, "%hhi:%i:%lli", &sym->def, &sym->visibility, &size);
   if (n != 3)
     return LDPS_ERR;
 
   /* Parsed successfully, so allocate strings and fill out fields.  */
   sym->size = size;
+  sym->unused = 0;
+  sym->section_kind = 0;
+  sym->symbol_type = 0;
   sym->resolution = LDPR_UNKNOWN;
   sym->name = malloc (colon1 - str + 1);
   if (!sym->name)
@@ -307,6 +311,11 @@ set_register_hook (const char *whichhook, bfd_boolean yesno)
     register_claimfile_hook = yesno;
   else if (!strcmp ("allsymbolsread", whichhook))
     register_allsymbolsread_hook = yesno;
+  else if (!strcmp ("allsymbolsreadsilent", whichhook))
+    {
+      register_allsymbolsread_hook = yesno;
+      allsymbolsread_silent = TRUE;
+    }
   else if (!strcmp ("cleanup", whichhook))
     register_cleanup_hook = yesno;
   else
@@ -573,7 +582,8 @@ onall_symbols_read (void)
   char buffer[30];
   int fd;
   char *filename;
-  TV_MESSAGE (LDPL_INFO, "hook called: all symbols read.");
+  if (! allsymbolsread_silent)
+    TV_MESSAGE (LDPL_INFO, "hook called: all symbols read.");
   for ( ; claimfile; claimfile = claimfile->next)
     {
       enum ld_plugin_status rv;
@@ -595,7 +605,7 @@ onall_symbols_read (void)
 #define EXPECTED_VIEW "/* The first line of this file must match the expectation of"
 #define EXPECTED_VIEW_LENGTH (sizeof (EXPECTED_VIEW) - 1)
       if (file.filesize != SIZE_OF_FUNC_C
-         || SIZE_OF_FUNC_C < sizeof EXPECTED_VIEW_LENGTH
+         || SIZE_OF_FUNC_C < EXPECTED_VIEW_LENGTH
          || memcmp (view, EXPECTED_VIEW, EXPECTED_VIEW_LENGTH) != 0)
        {
          char result[EXPECTED_VIEW_LENGTH + 1];
This page took 0.024808 seconds and 4 git commands to generate.