]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
nios2: Don't check relocations in non-loaded, non-alloced sections
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 3 Jun 2020 16:21:03 +0000 (09:21 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 3 Jun 2020 16:21:14 +0000 (09:21 -0700)
Don't do anything special with non-loaded, non-alloced sections.
In particular, any relocs in such sections should not affect GOT
and PLT reference counting (ie. we don't allow them to create GOT
or PLT entries), there's no possibility or desire to optimize TLS
relocs, and there's not much point in propagating relocs to shared
libs that the dynamic linker won't relocate.

PR ld/26066
* elf32-nios2.c (nios2_elf32_check_relocs): Skip non-loaded,
non-alloced sections.

bfd/ChangeLog
bfd/elf32-nios2.c

index 8aa38938979645c281f1dca47f2f3137aecfdd8b..08f8a50eede80f9391ba0d24418690b6b382bbb1 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-03  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26066
+       * elf32-nios2.c (nios2_elf32_check_relocs): Skip non-loaded,
+       non-alloced sections.
+
 2020-06-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-frv.c (elf32_frv_relocate_section): Don't generate
index aabec1d6d67cf3d216cdf6cf5d6288f7efc7555c..453b7cf5a3de86d3ab01eae39f5fd1e9baa3a37e 100644 (file)
@@ -4689,6 +4689,15 @@ nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
   if (bfd_link_relocatable (info))
     return TRUE;
 
+  /* Don't do anything special with non-loaded, non-alloced sections.
+     In particular, any relocs in such sections should not affect GOT
+     and PLT reference counting (ie. we don't allow them to create GOT
+     or PLT entries), there's no possibility or desire to optimize TLS
+     relocs, and there's not much point in propagating relocs to shared
+     libs that the dynamic linker won't relocate.  */
+  if ((sec->flags & SEC_ALLOC) == 0)
+    return TRUE;
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   sym_hashes_end = (sym_hashes