ARM cmse_scan segfault
authorAlan Modra <amodra@gmail.com>
Wed, 20 Nov 2019 22:27:00 +0000 (08:57 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 21 Nov 2019 10:38:30 +0000 (21:08 +1030)
This code in elf_link_add_object_symbols:

      ret = elf_add_dt_needed_tag (abfd, info, soname, add_needed);
      if (ret < 0)
goto error_return;

      /* If we have already included this dynamic object in the
 link, just ignore it.  There is no reason to include a
 particular dynamic object more than once.  */
      if (ret > 0)
return TRUE;

prevents a shared library from being loaded twice by ensuring that any
library soname doesn't match the soname of one already loaded.  This
happens before sym_hashes are allocated, which leaves sym_hashes NULL.

cmse_scan looks at library symbols, and when attempting to look up a
global symbol will segfault if sym_hashes is zero.

* elf32-arm.c (elf32_arm_size_stubs): Exclude dynamic library
BFDs that have not been loaded.

bfd/ChangeLog
bfd/elf32-arm.c

index ffe527c52a397e44f8f7a6e2a00e12e246a54b89..a1ef734af6a882809113578786e2c2b5827c8c6e 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-21  Alan Modra  <amodra@gmail.com>
+
+       * elf32-arm.c (elf32_arm_size_stubs): Exclude dynamic library
+       BFDs that have not been loaded.
+
 2019-11-19  Alan Modra  <amodra@gmail.com>
 
        PR 25197
index f27ee421833f37fb25ae81b8ed476c78bff28663..dca208f06aa8112f3b1d33db18acad07173fe044 100644 (file)
@@ -6527,8 +6527,11 @@ elf32_arm_size_stubs (bfd *output_bfd,
          asection *section;
          Elf_Internal_Sym *local_syms = NULL;
 
-         if (!is_arm_elf (input_bfd)
-             || (elf_dyn_lib_class (input_bfd) & DYN_AS_NEEDED) != 0)
+         if (!is_arm_elf (input_bfd))
+           continue;
+         if ((input_bfd->flags & DYNAMIC) != 0
+             && (elf_sym_hashes (input_bfd) == NULL
+                 || (elf_dyn_lib_class (input_bfd) & DYN_AS_NEEDED) != 0))
            continue;
 
          num_a8_relocs = 0;
This page took 0.031328 seconds and 4 git commands to generate.