- table->sections = XRESIZEVEC (struct target_section, table->sections,
- new_count);
- table->sections_end = table->sections + new_count;
- }
- else
- clear_section_table (table);
-
- return old_count;
-}
-
-/* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
- Returns 0 if OK, 1 on error. */
-
-int
-build_section_table (struct bfd *some_bfd, struct target_section **start,
- struct target_section **end)
-{
- unsigned count;
-
- count = bfd_count_sections (some_bfd);
- xfree (*start);
- *start = XNEWVEC (struct target_section, count);
- *end = *start;
- bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end);
+ flagword aflag;
+
+ /* Check the section flags, but do not discard zero-length
+ sections, since some symbols may still be attached to this
+ section. For instance, we encountered on sparc-solaris 2.10
+ a shared library with an empty .bss section to which a symbol
+ named "_end" was attached. The address of this symbol still
+ needs to be relocated. */
+ aflag = bfd_section_flags (asect);
+ if (!(aflag & SEC_ALLOC))
+ continue;