]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
objcopy fixes for commit 68bbe1183379
authorAlan Modra <amodra@gmail.com>
Sat, 5 Oct 2024 01:26:20 +0000 (10:56 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 5 Oct 2024 01:28:37 +0000 (10:58 +0930)
* objcopy.c (is_specified_symbol): Handle NULL name.
(filter_symbols): Drop syms with a NULL name.

binutils/objcopy.c

index 24e31cc58052363a428322253ec51fb19f4ce013..2ed1afbb8cb7c0fed955b3b2c469530644577c60 100644 (file)
@@ -1251,6 +1251,9 @@ is_specified_symbol_predicate (void **slot, void *data)
 static bool
 is_specified_symbol (const char *name, htab_t htab)
 {
+  if (name == NULL)
+    return false;
+
   if (wildcard)
     {
       struct is_specified_symbol_predicate_data data;
@@ -1576,6 +1579,9 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
       bool rem_leading_char;
       bool add_leading_char;
 
+      if (name == NULL)
+       continue;
+
       undefined = bfd_is_und_section (bfd_asymbol_section (sym));
 
       if (add_sym_list)
@@ -1590,14 +1596,14 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
        {
          char *new_name;
 
-         if (name != NULL
-             && name[0] == '_'
+         if (name[0] == '_'
              && name[1] == '_'
              && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
            {
-             fatal (_("redefining symbols does not work on LTO-compiled object files"));
+             fatal (_("redefining symbols does not work"
+                      " on LTO-compiled object files"));
            }
-         
+
          new_name = (char *) lookup_sym_redefinition (name);
          if (new_name == name
              && (flags & BSF_SECTION_SYM) != 0)
@@ -2956,7 +2962,7 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
          pset = find_section_list (padd->name, false,
                                    SECTION_CONTEXT_SET_FLAGS);
          if (pset != NULL)
-           {         
+           {
              flags = pset->flags | SEC_HAS_CONTENTS;
              flags = check_new_section_flags (flags, obfd, padd->name);
            }