]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/gen-aout.c
Initial revision
[thirdparty/binutils-gdb.git] / bfd / gen-aout.c
1 /* Generate parameters for an a.out system.
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include "/usr/include/a.out.h"
21 #include <stdio.h>
22
23 /* Stuffed value of "ABCD" in a long, followed by a 0. */
24 long int str[2] = { 0x41424344, 0x0 };
25
26 main ()
27 {
28 struct exec my_exec;
29 int page_size;
30 FILE *file = fopen("gen-aout", "r");
31 if (file == NULL) {
32 fprintf(stderr, "Cannot open gen-aout!\n");
33 return -1;
34 }
35 if (fread(&my_exec, sizeof(struct exec), 1, file) != 1) {
36 fprintf(stderr, "Cannot read gen-aout!\n");
37 return -1;
38 }
39
40 if (strcmp ((char *)&str[0], "ABCD") == 0)
41 printf("#define TARGET_IS_BIG_ENDIAN_P\n");
42 else
43 printf("#define TARGET_IS_LITTLE_ENDIAN_P\n");
44
45 #ifdef N_TXTOFF
46 page_size = N_TXTOFF(my_exec);
47 if (page_size == 0)
48 printf("#define N_HEADER_IN_TEXT(x) 1\n");
49 else
50 printf("#define N_HEADER_IN_TEXT(x) 0\n");
51 #endif
52
53 printf("#define BYTES_IN_WORD 4\n");
54 printf("#define ARCH 32\n");
55 if (my_exec.a_entry == 0)
56 printf("#define ENTRY_CAN_BE_ZERO\n");
57 printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
58
59 #ifdef PAGSIZ
60 if (page_size == 0)
61 page_size = PAGSIZ;
62 #endif
63 if (page_size != 0)
64 printf("#define PAGE_SIZE %d\n", page_size);
65
66 return 0;
67 }