PR26482, ASAN: _bfd_xcoff_sizeof_headers coff-rs6000.c:2585
authorAlan Modra <amodra@gmail.com>
Tue, 25 Aug 2020 06:45:27 +0000 (16:15 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 25 Aug 2020 13:37:10 +0000 (23:07 +0930)
PR 26482
* coff-rs6000.c (_bfd_xcoff_sizeof_headers): Ignore sections that
won't be output.

bfd/ChangeLog
bfd/coff-rs6000.c

index 7cf99f68f37003fcc9e718532ec1849ace5b7aee..c3342ca0966f2c5ffcb291d0aa0ff8f13ed70ca2 100644 (file)
@@ -1,3 +1,9 @@
+2020-08-25  Alan Modra  <amodra@gmail.com>
+
+       PR 26482
+       * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Ignore sections that
+       won't be output.
+
 2020-08-25  Alan Modra  <amodra@gmail.com>
 
        PR 26463
index 00c9d7c7f4b94463aed185fda9dfdb94d6e4aca2..48c583bfd02c20df4b898266fe6ef8b003684407 100644 (file)
@@ -2580,11 +2580,13 @@ _bfd_xcoff_sizeof_headers (bfd *abfd,
       /* Sum.  */
       for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
        for (s = sub->sections; s != NULL; s = s->next)
-         {
-           struct nbr_reloc_lineno *e = &n_rl[s->output_section->index];
-           e->reloc_count += s->reloc_count;
-           e->lineno_count += s->lineno_count;
-         }
+         if (s->output_section->owner == abfd
+             && !bfd_section_removed_from_list (abfd, s->output_section))
+           {
+             struct nbr_reloc_lineno *e = &n_rl[s->output_section->index];
+             e->reloc_count += s->reloc_count;
+             e->lineno_count += s->lineno_count;
+           }
 
       /* Add the size of a section for each section with an overflow.  */
       for (s = abfd->sections; s != NULL; s = s->next)