⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yank.c

📁 gdb是linux下的一个远程调试环境.能让你很方便地调试linux下的代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
static char _[] = "@(#)yank.c	5.20 93/07/30 16:39:05, Srini, AMD. ";/****************************************************************************** * Copyright 1991 Advanced Micro Devices, Inc. * * This software is the property of Advanced Micro Devices, Inc  (AMD)  which * specifically  grants the user the right to modify, use and distribute this * software provided this notice is not removed or altered.  All other rights * are reserved by AMD. * * AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS * SOFTWARE.  IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL * DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR * USE OF THIS SOFTWARE. * * So that all may benefit from your experience, please report  any  problems * or  suggestions about this software to the 29K Technical Support Center at * 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131  in  the  UK,  or * 0031-11-1129 in Japan, toll free.  The direct dial number is 512-462-4118. * * Advanced Micro Devices, Inc. * 29K Support Products * Mail Stop 573 * 5900 E. Ben White Blvd. * Austin, TX 78741 * 800-292-9263 ***************************************************************************** *      Engineer: Srini Subramanian. ***************************************************************************** **       This module is used to "yank" or load a COFF file **       Into target memory. ***************************************************************************** */#include <stdio.h>#include <memory.h>#include <ctype.h>#include "coff.h"#include "memspcs.h"#include "main.h"#include "miniint.h"#include "macros.h"#include "error.h"#ifdef	MSDOS#include <string.h>#include <stdlib.h>#else#include <string.h>#endif/* Definitions */#define FILE_BUFFER_SIZE     1024#ifdef MSDOS#define FILE_OPEN_FLAG   "rb"#else#define FILE_OPEN_FLAG   "r"#endif#define	FROM_BEGINNING	0/* Function declarations */INT32   Mini_load_coff PARAMS((char *fname,			       INT32 space, 			       INT32 sym,			       INT32 sects,			       int   msg));INT32	Mini_init_info_ptr PARAMS((INIT_INFO *init));INT32	Mini_send_init_info PARAMS((INIT_INFO *init));INT32	Mini_load_file PARAMS((char *fname,			       INT32 mspace,			       int fargc,			       char *fargs,			       INT32 sym,			       INT32 sects,			       int msg));void  convert32 PARAMS((BYTE *));void  convert16 PARAMS((BYTE *));int	SetSections PARAMS((char *));void	print_ld_msg PARAMS((INT32, int, ADDR32, INT32));void	print_ign_msg PARAMS((int, ADDR32, INT32));void	print_end_msg PARAMS((INT32, int, ADDR32, INT32));/* GLobal */GLOBAL	INIT_INFO	init_info;static	BYTE   buffer[FILE_BUFFER_SIZE];extern	char	CoffFileName[];static	INT32	Symbols=0;  /* No symbols support yet */static	INT32	Sections=STYP_ABS | STYP_TEXT | STYP_DATA | STYP_LIT | STYP_BSS;static	INT32	MSpace=I_MEM;static	int	FileArgc;static	char	ArgString[1024];static	FILE	*coff_in;static	int	InitializeProgram=1;/*** This is the function called by the main program to load** a COFF file.  It also modifies the global data structure** init.  The data structure is then sent via an INIT message** to the target.  In addition, the "argv" parameter string** is sent to the target with WRITE messages.***/INT32yank_cmd(token, token_count)   char    *token[];   int      token_count;   {   int	i;   int	j;   int	SectionsGiven=0;   int	IPFlag=0;   for (j=1; j < token_count; j++) { /* parse command */      switch (token[j][0]) {	 case	'-':		if (token[j][1] == '\0')		   return (EMSYNTAX);		if (strcmp(token[j],"-ms")==0) {/*mem stack opt */		  if (++j >= token_count)		     return (EMSYNTAX);		  if (sscanf(token[j],"%lx",&(init_info.mem_stack_size)) != 1) 		     return (EMSYNTAX);		} else if (strcmp(token[j],"-rs")==0) {/*r stack*/		  if (++j >= token_count)		     return (EMSYNTAX);		  if (sscanf(token[j],"%lx",&(init_info.reg_stack_size)) != 1) 		     return (EMSYNTAX);		} else if (strcmp(token[j],"-noi")==0) {/*no init */		  InitializeProgram = 0;		  IPFlag = 1;		} else if (strcmp(token[j],"-i")==0) {/*init*/		  InitializeProgram = 1;		  IPFlag = 1;		} else {		  if (SetSections(token[j]) == (int) -1) 		     return (EMSYNTAX);		  else		     SectionsGiven=1;		}		break;	 default: /* filename etc. */		if (!SectionsGiven) {	          Sections = STYP_ABS|STYP_TEXT|STYP_DATA|STYP_LIT|STYP_BSS; 		  SectionsGiven=0;		}		if (!IPFlag) {		  InitializeProgram = 1;		  IPFlag=0;		}	        (void) strcpy (&CoffFileName[0], token[j]);	        FileArgc = token_count - j;                (void) strcpy(ArgString, token[j]);                for (i = 1; i < FileArgc; i++) {                   strcat(ArgString, " ");                   strcat(ArgString, token[j+i]);                };		j = token_count; /* break out of for loop */		break;      };   }   if (strcmp(CoffFileName,"") == 0)  /* No COFF file given */     return (EMSYNTAX);   if (Mini_load_file(&CoffFileName[0], MSpace,			   FileArgc, ArgString,			   Symbols, Sections,			   QuietMode) != SUCCESS)  {       return(FAILURE);   } else     return(SUCCESS);};INT32Mini_load_file(filename, mspace, fileargc, fileargs, sym, sects, quietmode)char	*filename;INT32	mspace;int	fileargc;char	*fileargs;INT32	sym;INT32	sects;int	quietmode;{   if (Mini_init_info_ptr(&init_info) != SUCCESS)     return(FAILURE);   if (Mini_load_coff(filename, mspace, sym, sects, quietmode) != SUCCESS)       return(FAILURE);   init_info.argstring = fileargs;   /* complete argv string */   if (InitializeProgram) {      if (Mini_send_init_info(&init_info) != SUCCESS)        return(FAILURE);   } else {     warning(EMNOINITP);   }   return(SUCCESS);};INT32Mini_init_info_ptr(init_ptr)INIT_INFO	*init_ptr;{   /* Re-initialize INIT message */   init_ptr->text_start = 0xffffffff;   init_ptr->text_end = 0;   init_ptr->data_start = 0xffffffff;   init_ptr->data_end = 0;   init_ptr->entry_point = 0;   if (init_ptr->mem_stack_size == (UINT32) -1)       init_ptr->mem_stack_size = MEM_STACK_SIZE;   if (init_ptr->reg_stack_size == (UINT32) -1)       init_ptr->reg_stack_size = REG_STACK_SIZE;   init_ptr->argstring = (char *) 0;  return(SUCCESS);};INT32Mini_send_init_info(info_ptr)INIT_INFO	*info_ptr;{   INT32	retval;   /* Align INIT values to word boundaries */   info_ptr->text_start = ALIGN32(info_ptr->text_start);   info_ptr->text_end = ALIGN32(info_ptr->text_end);   info_ptr->data_start = ALIGN32(info_ptr->data_start);   info_ptr->data_end = ALIGN32(info_ptr->data_end);   info_ptr->mem_stack_size = ALIGN32(info_ptr->mem_stack_size);   info_ptr->reg_stack_size = ALIGN32(info_ptr->reg_stack_size);   /* Send INIT message */   if ((retval = Mini_init (info_ptr->text_start,			    info_ptr->text_end,			    info_ptr->data_start,			    info_ptr->data_end,			    info_ptr->entry_point,			    info_ptr->mem_stack_size,			    info_ptr->reg_stack_size,			    info_ptr->argstring)) != SUCCESS) {       warning(EMINIT);       return(FAILURE);   };    return (SUCCESS);}  /* Mini_send_init_info *//*** This function is used to load a COFF file.  Depending on** the global variable "target_interface", data will be loaded** by either EB29K shared memory, PCEB shared memory, EB030** shared memory or serially.**** In addition, the global data structure "init" is updated.** This data structure maintains the entry point and various** other target initialization parameters.*/INT32Mini_load_coff(filename, mspace, sym, Section, quietmode)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -