aoutf1.h
来自「基于4个mips核的noc设计」· C头文件 代码 · 共 859 行 · 第 1/2 页
H
859 行
#else aout_32_swap_exec_header_in#endif (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize); memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff); /* FP stuff takes up whole rest of struct, except c_ucode. */ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff); /* Ucode is the last thing in the struct -- just before the end */ intcore->c_ucode = bfd_h_get_32 (abfd, intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); intcore->c_stacktop = 0x0E000000; /* By experimentation */}/* byte-swap in the Sparc core structure */static voidswapcore_sparc (abfd, ext, intcore) bfd *abfd; char *ext; struct internal_sunos_core *intcore;{ struct external_sparc_core *extcore = (struct external_sparc_core *) ext; intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic); intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len); intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs); intcore->c_regs_size = sizeof (extcore->c_regs);#if ARCH_SIZE == 64 aout_64_swap_exec_header_in#else aout_32_swap_exec_header_in#endif (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr); intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr); intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize); memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff); /* FP stuff takes up whole rest of struct, except c_ucode. */ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff); /* Ucode is the last thing in the struct -- just before the end */ intcore->c_ucode = bfd_h_get_32 (abfd, intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); /* Supposedly the user stack grows downward from the bottom of kernel memory. Presuming that this remains true, this definition will work. */ /* Now sun has provided us with another challenge. The value is different for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or the other based on the current value of the stack pointer. This loses (a) if the stack pointer has been clobbered, or (b) if the stack is larger than 128 megabytes. It's times like these you're glad they're switching to ELF. Note that using include files or nlist on /vmunix would be wrong, because we want the value for this core file, no matter what kind of machine we were compiled on or are running on. */#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) { bfd_vma sp = bfd_h_get_32 (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6); if (sp < SPARC_USRSTACK_SPARC10) intcore->c_stacktop = SPARC_USRSTACK_SPARC10; else intcore->c_stacktop = SPARC_USRSTACK_SPARC2; }}/* byte-swap in the Solaris BCP core structure */static voidswapcore_solaris_bcp (abfd, ext, intcore) bfd *abfd; char *ext; struct internal_sunos_core *intcore;{ struct external_solaris_bcp_core *extcore = (struct external_solaris_bcp_core *) ext; intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic); intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len); intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs); intcore->c_regs_size = sizeof (extcore->c_regs); /* The Solaris BCP exdata structure does not contain an a_syms field, so we are unable to synthesize an internal exec header. Luckily we are able to figure out the start address of the data section, which is the only thing needed from the internal exec header, from the exdata structure. As of Solaris 2.3, BCP core files for statically linked executables are buggy. The exdata structure is not properly filled in, and the data section is written from address zero instead of the data start address. */ memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec)); intcore->c_data_addr = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg); intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo); intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize); intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize); memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); intcore->fp_stuff_pos = (long) (((struct external_solaris_bcp_core *) 0)->fp_stuff); /* FP stuff takes up whole rest of struct, except c_ucode. */ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff); /* Ucode is the last thing in the struct -- just before the end */ intcore->c_ucode = bfd_h_get_32 (abfd, intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore); /* Supposedly the user stack grows downward from the bottom of kernel memory. Presuming that this remains true, this definition will work. */ /* Now sun has provided us with another challenge. The value is different for sparc2 and sparc10 (both running SunOS 4.1.3). We pick one or the other based on the current value of the stack pointer. This loses (a) if the stack pointer has been clobbered, or (b) if the stack is larger than 128 megabytes. It's times like these you're glad they're switching to ELF. Note that using include files or nlist on /vmunix would be wrong, because we want the value for this core file, no matter what kind of machine we were compiled on or are running on. */#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000) { bfd_vma sp = bfd_h_get_32 (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6); if (sp < SPARC_USRSTACK_SPARC10) intcore->c_stacktop = SPARC_USRSTACK_SPARC10; else intcore->c_stacktop = SPARC_USRSTACK_SPARC2; }}/* need this cast because ptr is really void * */#define core_hdr(bfd) ((bfd)->tdata.sun_core_data)#define core_datasec(bfd) (core_hdr(bfd)->data_section)#define core_stacksec(bfd) (core_hdr(bfd)->stack_section)#define core_regsec(bfd) (core_hdr(bfd)->reg_section)#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section)/* These are stored in the bfd's tdata */struct sun_core_struct{ struct internal_sunos_core *hdr; /* core file header */ asection *data_section; asection *stack_section; asection *reg_section; asection *reg2_section;};static const bfd_target *sunos4_core_file_p (abfd) bfd *abfd;{ unsigned char longbuf[4]; /* Raw bytes of various header fields */ bfd_size_type core_size; unsigned long core_mag; struct internal_sunos_core *core; char *extcore; struct mergem { struct sun_core_struct suncoredata; struct internal_sunos_core internal_sunos_core; char external_core[1]; } *mergem; if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_mag = bfd_h_get_32 (abfd, longbuf); if (core_mag != CORE_MAGIC) return 0; /* SunOS core headers can vary in length; second word is size; */ if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_size = bfd_h_get_32 (abfd, longbuf); /* Sanity check */ if (core_size > 20000) return 0; if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0) return 0; mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem)); if (mergem == NULL) return 0; extcore = mergem->external_core; if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size) { bfd_release (abfd, (char *) mergem); return 0; } /* Validate that it's a core file we know how to handle, due to sun botching the positioning of registers and other fields in a machine dependent way. */ core = &mergem->internal_sunos_core; switch (core_size) { case SPARC_CORE_LEN: swapcore_sparc (abfd, extcore, core); break; case SUN3_CORE_LEN: swapcore_sun3 (abfd, extcore, core); break; case SOLARIS_BCP_CORE_LEN: swapcore_solaris_bcp (abfd, extcore, core); break; default: bfd_set_error (bfd_error_system_call); /* FIXME */ bfd_release (abfd, (char *) mergem); return 0; } abfd->tdata.sun_core_data = &mergem->suncoredata; abfd->tdata.sun_core_data->hdr = core; /* create the sections. This is raunchy, but bfd_close wants to reclaim them */ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); if (core_stacksec (abfd) == NULL) { loser: bfd_release (abfd, (char *) mergem); return 0; } core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); if (core_datasec (abfd) == NULL) { loser1: bfd_release (abfd, core_stacksec (abfd)); goto loser; } core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); if (core_regsec (abfd) == NULL) { loser2: bfd_release (abfd, core_datasec (abfd)); goto loser1; } core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); if (core_reg2sec (abfd) == NULL) { bfd_release (abfd, core_regsec (abfd)); goto loser2; } core_stacksec (abfd)->name = ".stack"; core_datasec (abfd)->name = ".data"; core_regsec (abfd)->name = ".reg"; core_reg2sec (abfd)->name = ".reg2"; core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; core_regsec (abfd)->flags = SEC_HAS_CONTENTS; core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS; core_stacksec (abfd)->_raw_size = core->c_ssize; core_datasec (abfd)->_raw_size = core->c_dsize; core_regsec (abfd)->_raw_size = core->c_regs_size; core_reg2sec (abfd)->_raw_size = core->fp_stuff_size; core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); core_datasec (abfd)->vma = core->c_data_addr; core_regsec (abfd)->vma = 0; core_reg2sec (abfd)->vma = 0; core_stacksec (abfd)->filepos = core->c_len + core->c_dsize; core_datasec (abfd)->filepos = core->c_len; /* We'll access the regs afresh in the core file, like any section: */ core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos; core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos; /* Align to word at least */ core_stacksec (abfd)->alignment_power = 2; core_datasec (abfd)->alignment_power = 2; core_regsec (abfd)->alignment_power = 2; core_reg2sec (abfd)->alignment_power = 2; abfd->sections = core_stacksec (abfd); core_stacksec (abfd)->next = core_datasec (abfd); core_datasec (abfd)->next = core_regsec (abfd); core_regsec (abfd)->next = core_reg2sec (abfd); abfd->section_count = 4; return abfd->xvec;}static char *sunos4_core_file_failing_command (abfd) bfd *abfd;{ return core_hdr (abfd)->hdr->c_cmdname;}static intsunos4_core_file_failing_signal (abfd) bfd *abfd;{ return core_hdr (abfd)->hdr->c_signo;}static booleansunos4_core_file_matches_executable_p (core_bfd, exec_bfd) bfd *core_bfd; bfd *exec_bfd;{ if (core_bfd->xvec != exec_bfd->xvec) { bfd_set_error (bfd_error_system_call); return false; } /* Solaris core files do not include an aouthdr. */ if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN) return true; return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr), (char *) exec_hdr (exec_bfd), sizeof (struct internal_exec)) == 0) ? true : false;}#define MY_set_sizes sunos4_set_sizesstatic booleansunos4_set_sizes (abfd) bfd *abfd;{ switch (bfd_get_arch (abfd)) { default: return false; case bfd_arch_sparc: adata (abfd).page_size = 0x2000; adata (abfd).segment_size = 0x2000; adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; return true; case bfd_arch_m68k: adata (abfd).page_size = 0x2000; adata (abfd).segment_size = 0x20000; adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE; return true; }}/* We default to setting the toolversion field to 1, as is required by SunOS. */#ifndef MY_exec_hdr_flags#define MY_exec_hdr_flags 1#endif#ifndef MY_entry_is_text_address#define MY_entry_is_text_address 0#endif#ifndef MY_add_dynamic_symbols#define MY_add_dynamic_symbols 0#endif#ifndef MY_add_one_symbol#define MY_add_one_symbol 0#endif#ifndef MY_link_dynamic_object#define MY_link_dynamic_object 0#endif#ifndef MY_write_dynamic_symbol#define MY_write_dynamic_symbol 0#endif#ifndef MY_check_dynamic_reloc#define MY_check_dynamic_reloc 0#endif#ifndef MY_finish_dynamic_link#define MY_finish_dynamic_link 0#endifstatic CONST struct aout_backend_data sunos4_aout_backend ={ 0, /* zmagic files are not contiguous */ 1, /* text includes header */ MY_entry_is_text_address, MY_exec_hdr_flags, 0, /* default text vma */ sunos4_set_sizes, 0, /* header is counted in zmagic text */ MY_add_dynamic_symbols, MY_add_one_symbol, MY_link_dynamic_object, MY_write_dynamic_symbol, MY_check_dynamic_reloc, MY_finish_dynamic_link};#define MY_core_file_failing_command sunos4_core_file_failing_command#define MY_core_file_failing_signal sunos4_core_file_failing_signal#define MY_core_file_matches_executable_p sunos4_core_file_matches_executable_p#define MY_bfd_debug_info_start bfd_void#define MY_bfd_debug_info_end bfd_void#define MY_bfd_debug_info_accumulate \ (void (*) PARAMS ((bfd *, struct sec *))) bfd_void#define MY_core_file_p sunos4_core_file_p#define MY_write_object_contents NAME(aout,sunos4_write_object_contents)#define MY_backend_data &sunos4_aout_backend#ifndef TARGET_IS_LITTLE_ENDIAN_P#define TARGET_IS_BIG_ENDIAN_P#endif#include "aout-target.h"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?