FreeCalypso > hg > freecalypso-reveng
view objgrep/main.c @ 167:c25367bb7656
objgrep: written, compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Jul 2014 00:54:33 +0000 |
parents | leo-obj/tool/main.c@25d3ead621f8 |
children | 466b3926019c |
line wrap: on
line source
/* * objgrep main() function */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "globals.h" #include "intstruct.h" main(argc, argv) char **argv; { unsigned n; if (argc != 4) { fprintf(stderr, "usage: %s <objfile> <section> <binfile>\n", argv[0]); exit(2); } objfilename = argv[1]; mmap_objfile(); initial_parse_hdr(); get_int_section_table(); for (n = 0; n < nsections; n++) if (!strcmp(sections[n].name, argv[2])) { grep_section = sections + n; break; } if (!grep_section) { fprintf(stderr, "no section named \"%s\" found in %s\n", argv[2], objfilename); exit(2); } get_int_symbol_table(); prepare_pattern(); binfilename = argv[3]; mmap_binfile(); if (!do_grep()) { printf("no match\n"); exit(1); } printf("%s:%s found in %s at 0x%x\n", objfilename, grep_section->name, binfilename, match_offset); exit(0); }