+/* Return whether the specified segment is thought to hold text. */
+
+int
+subseg_text_p (segT sec)
+{
+ return (bfd_get_section_flags (stdoutput, sec) & SEC_CODE) != 0;
+}
+
+/* Return non zero if SEC has at least one byte of data. It is
+ possible that we'll return zero even on a non-empty section because
+ we don't know all the fragment types, and it is possible that an
+ fr_fix == 0 one still contributes data. Think of this as
+ seg_definitely_not_empty_p. */
+
+int
+seg_not_empty_p (segT sec ATTRIBUTE_UNUSED)
+{
+ segment_info_type *seginfo = seg_info (sec);
+ frchainS *chain;
+ fragS *frag;
+
+ if (!seginfo)
+ return 0;
+
+ for (chain = seginfo->frchainP; chain; chain = chain->frch_next)
+ {
+ for (frag = chain->frch_root; frag; frag = frag->fr_next)
+ if (frag->fr_fix)
+ return 1;
+ if (obstack_next_free (&chain->frch_obstack)
+ != chain->frch_last->fr_literal)
+ return 1;
+ }
+ return 0;
+}
+
+void
+subsegs_print_statistics (FILE *file)
+{
+ frchainS *frchp;
+ asection *s;
+
+ fprintf (file, "frag chains:\n");
+ for (s = stdoutput->sections; s; s = s->next)
+ {
+ segment_info_type *seginfo;
+
+ /* Skip gas-internal sections. */
+ if (segment_name (s)[0] == '*')
+ continue;
+
+ seginfo = seg_info (s);
+ if (!seginfo)
+ continue;
+
+ for (frchp = seginfo->frchainP; frchp; frchp = frchp->frch_next)
+ {
+ int count = 0;
+ fragS *fragp;
+
+ for (fragp = frchp->frch_root; fragp; fragp = fragp->fr_next)
+ count++;
+
+ fprintf (file, "\n");
+ fprintf (file, "\t%p %-10s\t%10d frags\n", (void *) frchp,
+ segment_name (s), count);
+ }
+ }
+}