- size_t data_pad = 0;
- unsigned char exec_bytes[EXEC_BYTES_SIZE];
- struct exec *execp = exec_hdr (abfd);
-
- execp->a_text = obj_textsec (abfd)->size;
-
- if (abfd->flags & D_PAGED)
- execp->a_info = ZMAGIC;
- else if (abfd->flags & WP_TEXT)
- execp->a_info = NMAGIC;
- else
- execp->a_info = OMAGIC;
-
- if (abfd->flags & D_PAGED)
- {
- data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1)
- & (- PAGE_SIZE)) - obj_datasec(abfd)->size;
-
- if (data_pad > obj_bsssec(abfd)->size)
- execp->a_bss = 0;
- else
- execp->a_bss = obj_bsssec(abfd)->size - data_pad;
- execp->a_data = obj_datasec(abfd)->size + data_pad;
-
- }
- else {
- execp->a_data = obj_datasec (abfd)->size;
- execp->a_bss = obj_bsssec (abfd)->size;
- }
-
- execp->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist);
- execp->a_entry = bfd_get_start_address (abfd);
-
- execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *
- obj_reloc_entry_size (abfd));
-
- execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *
- obj_reloc_entry_size (abfd));
-
- bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes);
-
- bfd_seek (abfd, 0L, false);
- bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd);