+ }
+
+ esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd);
+ }
+
+ breakloop:
+ return sec_flags;
+}
+
+
+/* The PE version; see above for the general comments.
+
+ Since to set the SEC_LINK_ONCE and associated flags, we have to
+ look at the symbol table anyway, we return the symbol table index
+ of the symbol being used as the COMDAT symbol. This is admittedly
+ ugly, but there's really nowhere else that we have access to the
+ required information. FIXME: Is the COMDAT symbol index used for
+ any purpose other than objdump? */
+
+static bfd_boolean
+styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
+ bfd *abfd;
+ PTR hdr;
+ const char *name;
+ asection *section;
+ flagword *flags_ptr;
+{
+ struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
+ long styp_flags = internal_s->s_flags;
+ flagword sec_flags;
+ bfd_boolean result = TRUE;
+
+ /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */
+ sec_flags = SEC_READONLY;
+
+ /* Process each flag bit in styp_flags in turn. */
+ while (styp_flags)
+ {
+ long flag = styp_flags & - styp_flags;
+ char * unhandled = NULL;
+
+ styp_flags &= ~ flag;
+
+ /* We infer from the distinct read/write/execute bits the settings
+ of some of the bfd flags; the actual values, should we need them,
+ are also in pei_section_data (abfd, section)->pe_flags. */
+
+ switch (flag)
+ {
+ case STYP_DSECT:
+ unhandled = "STYP_DSECT";
+ break;
+ case STYP_GROUP:
+ unhandled = "STYP_GROUP";
+ break;
+ case STYP_COPY:
+ unhandled = "STYP_COPY";
+ break;
+ case STYP_OVER:
+ unhandled = "STYP_OVER";
+ break;
+#ifdef SEC_NEVER_LOAD
+ case STYP_NOLOAD:
+ sec_flags |= SEC_NEVER_LOAD;
+ break;
+#endif
+ case IMAGE_SCN_MEM_READ:
+ /* Ignored, assume it always to be true. */
+ break;
+ case IMAGE_SCN_TYPE_NO_PAD:
+ /* Skip. */
+ break;
+ case IMAGE_SCN_LNK_OTHER:
+ unhandled = "IMAGE_SCN_LNK_OTHER";
+ break;
+ case IMAGE_SCN_MEM_NOT_CACHED:
+ unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
+ break;
+ case IMAGE_SCN_MEM_NOT_PAGED:
+ unhandled = "IMAGE_SCN_MEM_NOT_PAGED";
+ break;
+ case IMAGE_SCN_MEM_EXECUTE:
+ sec_flags |= SEC_CODE;
+ break;
+ case IMAGE_SCN_MEM_WRITE:
+ sec_flags &= ~ SEC_READONLY;
+ break;
+ case IMAGE_SCN_MEM_DISCARDABLE:
+ /* The MS PE spec sets the DISCARDABLE flag on .reloc sections
+ but we do not want them to be labelled as debug section, since
+ then strip would remove them. */
+ if (strncmp (name, ".reloc", sizeof ".reloc" - 1) != 0)
+ sec_flags |= SEC_DEBUGGING;
+ break;
+ case IMAGE_SCN_MEM_SHARED:
+ sec_flags |= SEC_SHARED;
+ break;
+ case IMAGE_SCN_LNK_REMOVE:
+ sec_flags |= SEC_EXCLUDE;
+ break;
+ case IMAGE_SCN_CNT_CODE:
+ sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
+ break;
+ case IMAGE_SCN_CNT_INITIALIZED_DATA:
+ sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
+ break;
+ case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
+ sec_flags |= SEC_ALLOC;
+ break;
+ case IMAGE_SCN_LNK_INFO:
+ /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
+ defined. coff_compute_section_file_positions uses
+ COFF_PAGE_SIZE to ensure that the low order bits of the
+ section VMA and the file offset match. If we don't know
+ COFF_PAGE_SIZE, we can't ensure the correct correspondence,
+ and demand page loading of the file will fail. */
+#ifdef COFF_PAGE_SIZE
+ sec_flags |= SEC_DEBUGGING;
+#endif
+ break;
+ case IMAGE_SCN_LNK_COMDAT:
+ /* COMDAT gets very special treatment. */
+ sec_flags = handle_COMDAT (abfd, sec_flags, hdr, name, section);
+ break;
+ default:
+ /* Silently ignore for now. */
+ break;
+ }
+
+ /* If the section flag was not handled, report it here. */
+ if (unhandled != NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s (%s): Section flag %s (0x%x) ignored"),
+ bfd_archive_filename (abfd), name, unhandled, flag);
+ result = FALSE;