Do not place symbols into a discarded .dynsym
authorEgeyar Bagcioglu <egeyar.bagcioglu@oracle.com>
Wed, 3 Oct 2018 21:27:32 +0000 (23:27 +0200)
committerAlan Modra <amodra@gmail.com>
Tue, 9 Oct 2018 07:06:59 +0000 (17:36 +1030)
Prevents getting an error about dynamic symbols in sections indexed
64K+ when .dynsym is discarded.

* elflink.c (elf_link_output_extsym): Do not place symbols into a
discarded .dynsym.

bfd/ChangeLog
bfd/elflink.c

index 86387d8c6ffc046a2a1af2d10f3a66a32c654361..68c1ff665be5e08f4a28545d13c8e2e0656d27b0 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-09  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>
+
+       * elflink.c (elf_link_output_extsym): Do not place symbols into a
+       discarded .dynsym.
+
 2018-10-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/23428
index 02618bed8fea01db1f3e24d92b53aaa6aac1ff4f..78d8c543412125ecc36117bf6441c8a2fa16d621 100644 (file)
@@ -10024,9 +10024,10 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
   /* If this symbol should be put in the .dynsym section, then put it
      there now.  We already know the symbol index.  We also fill in
      the entry in the .hash section.  */
-  if (elf_hash_table (flinfo->info)->dynsym != NULL
-      && h->dynindx != -1
-      && elf_hash_table (flinfo->info)->dynamic_sections_created)
+  if (h->dynindx != -1
+      && elf_hash_table (flinfo->info)->dynamic_sections_created
+      && elf_hash_table (flinfo->info)->dynsym != NULL
+      && !discarded_section (elf_hash_table (flinfo->info)->dynsym))
     {
       bfd_byte *esym;