📄 aout-adobe.c
字号:
rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct)); if (rawptr == NULL) { bfd_error = no_memory; return false; } abfd->tdata.bout_data = rawptr; exec_hdr (abfd) = &rawptr->e; adata(abfd).reloc_entry_size = sizeof (struct reloc_std_external); adata(abfd).symbol_entry_size = sizeof (struct external_nlist); adata(abfd).page_size = 1; /* Not applicable. */ adata(abfd).segment_size = 1; /* Not applicable. */ adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; return true;}static booleanaout_adobe_write_object_contents (abfd) bfd *abfd;{ struct external_exec swapped_hdr; static struct external_segdesc sentinel[1] = {0}; asection *sect; exec_hdr (abfd)->a_info = ZMAGIC; /* Calculate text size as total of text sections, etc. */ exec_hdr (abfd)->a_text = 0; exec_hdr (abfd)->a_data = 0; exec_hdr (abfd)->a_bss = 0; exec_hdr (abfd)->a_trsize = 0; exec_hdr (abfd)->a_drsize = 0; for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_CODE) { exec_hdr (abfd)->a_text += sect->_raw_size; exec_hdr (abfd)->a_trsize += sect->reloc_count * sizeof (struct reloc_std_external); } else if (sect->flags & SEC_DATA) { exec_hdr (abfd)->a_data += sect->_raw_size; exec_hdr (abfd)->a_drsize += sect->reloc_count * sizeof (struct reloc_std_external); } else if (sect->flags & SEC_ALLOC && !(sect->flags & SEC_LOAD)) { exec_hdr (abfd)->a_bss += sect->_raw_size; } } exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct external_nlist); exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd); aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr); bfd_seek (abfd, (file_ptr) 0, SEEK_SET); bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd); /* Now write out the section information. Text first, data next, rest afterward. */ for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_CODE) { aout_adobe_write_section (abfd, sect); } } for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_DATA) { aout_adobe_write_section (abfd, sect); } } for (sect = abfd->sections; sect; sect = sect->next) { if (!(sect->flags & (SEC_CODE|SEC_DATA))) { aout_adobe_write_section (abfd, sect); } } /* Write final `sentinel` section header (with type of 0). */ bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd); /* Now write out reloc info, followed by syms and strings */ if (bfd_get_symcount (abfd) != 0) { bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET); aout_32_write_syms (abfd); bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET); for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_CODE) { if (!aout_32_squirt_out_relocs (abfd, sect)) return false; } } bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET); for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_DATA) { if (!aout_32_squirt_out_relocs (abfd, sect)) return false; } } } return true;}static voidaout_adobe_write_section (abfd, sect) bfd *abfd; sec_ptr sect;{ /* FIXME XXX */}static booleanaout_adobe_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; unsigned char *location; file_ptr offset; int count;{ file_ptr section_start; sec_ptr sect; if (abfd->output_has_begun == false) { /* set by bfd.c handler */ /* Assign file offsets to sections. Text sections are first, and are contiguous. Then data sections. Everything else at the end. */ section_start = N_TXTOFF (ignore<-->me); for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_CODE) { sect->filepos = section_start; /* FIXME: Round to alignment */ section_start += sect->_raw_size; } } for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_DATA) { sect->filepos = section_start; /* FIXME: Round to alignment */ section_start += sect->_raw_size; } } for (sect = abfd->sections; sect; sect = sect->next) { if (sect->flags & SEC_HAS_CONTENTS && !(sect->flags & (SEC_CODE|SEC_DATA))) { sect->filepos = section_start; /* FIXME: Round to alignment */ section_start += sect->_raw_size; } } } /* regardless, once we know what we're doing, we might as well get going */ bfd_seek (abfd, section->filepos + offset, SEEK_SET); if (count != 0) { return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false; } return true;}static booleanaout_adobe_set_arch_mach (abfd, arch, machine) bfd *abfd; enum bfd_architecture arch; unsigned long machine;{ bfd_default_set_arch_mach(abfd, arch, machine); if (arch == bfd_arch_unknown) /* Unknown machine arch is OK */ return true; return false;}static int DEFUN(aout_adobe_sizeof_headers,(ignore_abfd, ignore), bfd *ignore_abfd AND boolean ignore){ return sizeof(struct internal_exec);}/* Build the transfer vector for Adobe A.Out files. *//* We don't have core files. */#define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command#define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal#define aout_32_core_file_matches_executable_p \ _bfd_dummy_core_file_matches_executable_p/* We use BSD-Unix generic archive files. */#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt#define aout_32_slurp_armap bfd_slurp_bsd_armap#define aout_32_slurp_extended_name_table bfd_true#define aout_32_write_armap bsd_write_armap#define aout_32_truncate_arname bfd_bsd_truncate_arname/* We override these routines from the usual a.out file routines. */#define aout_32_set_section_contents aout_adobe_set_section_contents#define aout_32_set_arch_mach aout_adobe_set_arch_mach#define aout_32_sizeof_headers aout_adobe_sizeof_headers#define aout_32_bfd_debug_info_start bfd_void#define aout_32_bfd_debug_info_end bfd_void#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void#define aout_32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents#define aout_32_bfd_relax_section bfd_generic_relax_sectionbfd_target a_out_adobe_vec ={ "a.out.adobe", /* name */ bfd_target_aout_flavour, true, /* data byte order is unknown (big assumed) */ true, /* hdr byte order is big */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT ), /* section flags */ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_DATA | SEC_RELOC), '_', /* symbol leading char */ ' ', /* ar_pad_char */ 16, /* ar_max_namelen */ 2, /* minumum alignment power */ _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ {_bfd_dummy_target, aout_adobe_object_p, /* bfd_check_format */ bfd_generic_archive_p, _bfd_dummy_target}, {bfd_false, aout_adobe_mkobject, /* bfd_set_format */ _bfd_generic_mkarchive, bfd_false}, {bfd_false, aout_adobe_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, JUMP_TABLE(aout_32) };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -