forked from Imagelibrary/rtems
2011-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* tools/build/.cvsignore, tools/build/ChangeLog, tools/build/Makefile.am, tools/build/README, tools/build/binpatch.c, tools/build/cklength.c, tools/build/configure.ac, tools/build/cvsignore-add.sh, tools/build/doxy-filter, tools/build/eolstrip.c, tools/build/install-if-change.in, tools/build/multigen, tools/build/packhex.c, tools/build/rtems-bin2c.c, tools/build/search-id.sh, tools/build/unhex.c, tools/cpu/.cvsignore, tools/cpu/ChangeLog, tools/cpu/Makefile.am, tools/cpu/configure.ac, tools/cpu/generic/.cvsignore, tools/cpu/generic/ChangeLog, tools/cpu/generic/Makefile.am, tools/cpu/generic/configure.ac, tools/cpu/generic/size_rtems.in, tools/cpu/nios2/.cvsignore, tools/cpu/nios2/ChangeLog, tools/cpu/nios2/Makefile.am, tools/cpu/nios2/README, tools/cpu/nios2/bridges.c, tools/cpu/nios2/bridges.h, tools/cpu/nios2/clocks.c, tools/cpu/nios2/clocks.h, tools/cpu/nios2/configure.ac, tools/cpu/nios2/devices.c, tools/cpu/nios2/devices.h, tools/cpu/nios2/linkcmds.c, tools/cpu/nios2/linkcmds.h, tools/cpu/nios2/memory.c, tools/cpu/nios2/memory.h, tools/cpu/nios2/nios2gen.c, tools/cpu/nios2/output.c, tools/cpu/nios2/output.h, tools/cpu/nios2/ptf.c, tools/cpu/nios2/ptf.h, tools/cpu/nios2/sample.ptf, tools/cpu/sh/.cvsignore, tools/cpu/sh/AUTHORS, tools/cpu/sh/COPYING, tools/cpu/sh/ChangeLog, tools/cpu/sh/Makefile.am, tools/cpu/sh/TODO, tools/cpu/sh/configure.ac, tools/cpu/sh/sci.c, tools/cpu/sh/sci.h, tools/cpu/sh/shgen.c, tools/schedsim/.cvsignore, tools/schedsim/ChangeLog, tools/schedsim/Makefile.am, tools/schedsim/README, tools/schedsim/configure.ac, tools/schedsim/rtems/.cvsignore, tools/schedsim/rtems/ChangeLog, tools/schedsim/rtems/Makefile.am, tools/schedsim/rtems/interr.c, tools/schedsim/rtems/rtems_init.c, tools/schedsim/rtems/rtems_sched.h, tools/schedsim/rtems/wkspace.c, tools/schedsim/rtems/sched_cpu/cpu.c, tools/schedsim/rtems/sched_cpu/cpu_asm.c, tools/schedsim/rtems/sched_cpu/rtems/asm.h, tools/schedsim/rtems/sched_cpu/rtems/stringto.h, tools/schedsim/rtems/sched_cpu/rtems/score/cpu.h, tools/schedsim/rtems/sched_cpu/rtems/score/cpu_asm.h, tools/schedsim/rtems/sched_cpu/rtems/score/cpuopts.h, tools/schedsim/rtems/sched_cpu/rtems/score/no_cpu.h, tools/schedsim/rtems/sched_cpu/rtems/score/types.h, tools/schedsim/shell/.cvsignore, tools/schedsim/shell/ChangeLog, tools/schedsim/shell/Makefile.am, tools/schedsim/shell/schedsim_priority/.cvsignore, tools/schedsim/shell/schedsim_priority/Makefile.am, tools/schedsim/shell/schedsim_priority/config.c, tools/schedsim/shell/schedsim_priority/printheir_executing.c, tools/schedsim/shell/schedsim_priority/schedsim.cc, tools/schedsim/shell/schedsim_priority/wrap_thread_dispatch.c, tools/schedsim/shell/scripts/script01, tools/schedsim/shell/scripts/script02, tools/schedsim/shell/scripts/script03, tools/schedsim/shell/scripts/script04, tools/schedsim/shell/scripts/script05, tools/schedsim/shell/scripts/script06, tools/schedsim/shell/shared/.cvsignore, tools/schedsim/shell/shared/Makefile.am, tools/schedsim/shell/shared/commands.c, tools/schedsim/shell/shared/getopt.c, tools/schedsim/shell/shared/lookup_semaphore.c, tools/schedsim/shell/shared/lookup_task.c, tools/schedsim/shell/shared/main_clocktick.c, tools/schedsim/shell/shared/main_echo.c, tools/schedsim/shell/shared/main_executing.c, tools/schedsim/shell/shared/main_heir.c, tools/schedsim/shell/shared/main_help.c, tools/schedsim/shell/shared/main_rtemsinit.c, tools/schedsim/shell/shared/main_semcreate.c, tools/schedsim/shell/shared/main_semdelete.c, tools/schedsim/shell/shared/main_semflush.c, tools/schedsim/shell/shared/main_semobtain.c, tools/schedsim/shell/shared/main_semrelease.c, tools/schedsim/shell/shared/main_taskcreate.c, tools/schedsim/shell/shared/main_taskdelete.c, tools/schedsim/shell/shared/main_taskmode.c, tools/schedsim/shell/shared/main_taskpriority.c, tools/schedsim/shell/shared/main_taskresume.c, tools/schedsim/shell/shared/main_tasksuspend.c, tools/schedsim/shell/shared/main_taskwakeafter.c, tools/schedsim/shell/shared/schedsim_shell.h, tools/schedsim/shell/shared/shell_cmdset.c, tools/schedsim/shell/shared/shell_makeargs.c, tools/schedsim/shell/shared/include/shell.h, tools/schedsim/shell/shared/include/newlib/_ansi.h, tools/schedsim/shell/shared/include/newlib/getopt.h: Removed. * configure.ac: RTEMS Scheduler Simulator is now in its own CVS module named rtems-schedsim.
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* This function will patch binary file
|
||||
*/
|
||||
|
||||
|
||||
static char buf[512];
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("usage: binpatch [-h] <ofile> <ifile> <reloc> <off> <byte0> "
|
||||
"[<byte1> [<byte2> [<byte3>]]]\n");
|
||||
printf("this function patches binary file at specified offset with\n");
|
||||
printf("up to 4 bytes provided on command line \n");
|
||||
printf("-h - prints this message\n\n");
|
||||
printf("<ofile> - output file\n");
|
||||
printf("<ifile> - input ifile\n");
|
||||
printf("<reloc> - relocation address of image\n");
|
||||
printf("<off> - offset of patch, offset in file is at off - reloc\n");
|
||||
printf("<byte0> - byte 0 of patch\n");
|
||||
printf("<byte1> - byte 1 of patch\n");
|
||||
printf("<byte2> - byte 1 of patch\n");
|
||||
printf("<byte3> - byte 1 of patch\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
FILE *ofp, *ifp;
|
||||
char patch[4], *end;
|
||||
int patchLen, tmp, i, off, cnt, patched, len, reloc;
|
||||
|
||||
|
||||
/* parse command line options */
|
||||
while ((c = getopt(argc, argv, "h")) >= 0)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
usage();
|
||||
return 0;
|
||||
default:
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(argc < 6)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Let us get offset in file */
|
||||
reloc = strtol(argv[3], &end, 0);
|
||||
if(end == argv[3] || off < 0)
|
||||
{
|
||||
fprintf(stderr, "bad reloc value %s\n", argv[3]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
off = strtol(argv[4], &end, 0);
|
||||
if(end == argv[4] || off < 0 || off < reloc)
|
||||
{
|
||||
fprintf(stderr, "bad offset value %s\n", argv[4]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
off -= reloc;
|
||||
|
||||
/* Let us get patch */
|
||||
patchLen = argc - 5;
|
||||
|
||||
for(i=0; i<patchLen; i++)
|
||||
{
|
||||
tmp = strtol(argv[5+i], &end, 0);
|
||||
|
||||
if(end == argv[4+i] || tmp < 0 || tmp > 0xff)
|
||||
{
|
||||
fprintf(stderr, "bad byte value %s\n", argv[5+i]);
|
||||
return 1;
|
||||
}
|
||||
patch[i] = tmp;
|
||||
}
|
||||
|
||||
ifp = fopen(argv[2], "r");
|
||||
if(ifp == NULL)
|
||||
{
|
||||
fprintf(stderr, "unable to open file %s\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ofp = fopen(argv[1], "w");
|
||||
if(ofp == NULL)
|
||||
{
|
||||
fprintf(stderr, "unable to open file %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
patched = 0;
|
||||
for(;;)
|
||||
{
|
||||
len = fread(buf, 1, sizeof(buf), ifp);
|
||||
|
||||
if(len == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(cnt <= off && (cnt + len) > off)
|
||||
{
|
||||
/* Perform patch */
|
||||
for(i=0; i<patchLen && (off+i)<(cnt+len); i++)
|
||||
{
|
||||
buf[off-cnt+i] = patch[i];
|
||||
}
|
||||
patched = 1;
|
||||
}
|
||||
else if(cnt > off && cnt < (off + patchLen))
|
||||
{
|
||||
/* Perform patch */
|
||||
for(i=cnt-off; i<patchLen; i++)
|
||||
{
|
||||
buf[off-cnt+i] = patch[i];
|
||||
}
|
||||
patched = 1;
|
||||
}
|
||||
|
||||
fwrite(buf, 1, len, ofp);
|
||||
|
||||
cnt += len;
|
||||
}
|
||||
|
||||
fclose(ifp);
|
||||
fclose(ofp);
|
||||
|
||||
if(!patched)
|
||||
{
|
||||
fprintf(stderr, "warning: offset is beyond input file length\n");
|
||||
fprintf(stderr, " no patch is performed\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user