1 /******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
16 static int reloc_64_cnt;
18 static int reloc_64[4096];
21 output_int(FILE *output_file, int i)
23 fputc((i>>24) & 0xff, output_file);
24 fputc((i>>16) & 0xff, output_file);
25 fputc((i>>8) & 0xff, output_file);
26 fputc(i & 0xff, output_file);
30 output_reloc_table(FILE * output_file, int reloc_cnt, int reloc[])
33 for (i=0; i < reloc_cnt; i++)
36 printf ("reloc %x\n", reloc[i]);
38 output_int (output_file, reloc[i]);
40 if ((reloc_cnt & 1) == 0)
41 output_int (output_file, 0);
45 main(int argc, char *argv[])
47 int cnt_a, cnt_b, offset = -1;
49 FILE *orig, *other, *output_file;
53 fprintf (stderr, "reloc_diff orig_file other_file output_file\n");
57 orig = fopen(argv[1], "rb");
58 other = fopen(argv[2], "rb");
59 output_file = fopen(argv[3], "wb");
60 if(orig == NULL || other == NULL || output_file == NULL) {
61 printf("Could not open file.\n");
67 cnt_a = fread(&a, 1, 1, orig);
68 cnt_b = fread(&b, 1, 1, other);
72 fprintf (stderr, "Files >%s< and >%s< have not the same length\n",argv[1],argv[2]);
83 reloc_64[reloc_64_cnt++] = offset;
87 fprintf(stderr, "Unknown relocation");
88 fprintf(stderr, "Offset %x: %02x %02x\n", offset, a, b);
93 output_reloc_table(output_file, reloc_64_cnt, reloc_64);