+ for (;;)
+ {
+ bfd_size_type amt = sizeof (*ext);
+ if (bfd_bread ( ext, amt, abfd) != amt)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+
+ return NULL;
+ }
+ switch (ext->e_type[0])
+ {
+ case N_TEXT:
+ section_name = ".text";
+ flags = SEC_CODE | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
+ break;
+
+ case N_DATA:
+ section_name = ".data";
+ flags = SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS;
+ break;
+
+ case N_BSS:
+ section_name = ".bss";
+ flags = SEC_DATA | SEC_HAS_CONTENTS;
+ break;
+
+ case 0:
+ goto no_more_sections;
+
+ default:
+ (*_bfd_error_handler)
+ (_("%B: Unknown section type in a.out.adobe file: %x\n"),
+ abfd, ext->e_type[0]);
+ goto no_more_sections;
+ }
+
+ /* First one is called ".text" or whatever; subsequent ones are
+ ".text1", ".text2", ... */
+ bfd_set_error (bfd_error_no_error);
+ sect = bfd_make_section_with_flags (abfd, section_name, flags);
+ trynum = 0;
+
+ while (!sect)
+ {
+ if (bfd_get_error () != bfd_error_no_error)
+ /* Some other error -- slide into the sunset. */
+ return NULL;
+ sprintf (try_again, "%s%d", section_name, ++trynum);
+ sect = bfd_make_section_with_flags (abfd, try_again, flags);
+ }
+
+ /* Fix the name, if it is a sprintf'd name. */
+ if (sect->name == try_again)
+ {
+ amt = strlen (sect->name);
+ newname = bfd_zalloc (abfd, amt);
+ if (newname == NULL)
+ return NULL;
+ strcpy (newname, sect->name);
+ sect->name = newname;
+ }
+
+ /* Assumed big-endian. */
+ sect->size = ((ext->e_size[0] << 8)
+ | ext->e_size[1] << 8
+ | ext->e_size[2]);
+ sect->vma = H_GET_32 (abfd, ext->e_virtbase);
+ sect->filepos = H_GET_32 (abfd, ext->e_filebase);
+ /* FIXME XXX alignment? */
+
+ /* Set relocation information for first section of each type. */
+ if (trynum == 0)
+ switch (ext->e_type[0])
+ {
+ case N_TEXT:
+ sect->rel_filepos = N_TRELOFF (*execp);
+ sect->reloc_count = execp->a_trsize;
+ break;
+
+ case N_DATA:
+ sect->rel_filepos = N_DRELOFF (*execp);
+ sect->reloc_count = execp->a_drsize;
+ break;
+
+ default:
+ break;
+ }
+ }
+ no_more_sections: