]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Generate parameters for an a.out system. |
b3adc24a | 2 | Copyright (C) 1990-2020 Free Software Foundation, Inc. |
252b5132 | 3 | |
cd123cb7 | 4 | This file is part of BFD, the Binary File Descriptor library. |
252b5132 | 5 | |
cd123cb7 NC |
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 3 of the License, or | |
9 | (at your option) any later version. | |
252b5132 | 10 | |
cd123cb7 NC |
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. | |
252b5132 | 15 | |
cd123cb7 NC |
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., 51 Franklin Street - Fifth Floor, Boston, | |
19 | MA 02110-1301, USA. */ | |
252b5132 RH |
20 | |
21 | #include "/usr/include/a.out.h" | |
22 | #include <stdio.h> | |
23 | ||
d45913a0 DA |
24 | #ifndef _ |
25 | #define _(X) X | |
26 | #endif | |
27 | ||
252b5132 | 28 | int |
b2e951ec | 29 | main (int argc, char** argv) |
252b5132 RH |
30 | { |
31 | struct exec my_exec; | |
32 | int page_size; | |
b2e951ec NC |
33 | char * target; |
34 | char * arch = "unknown"; | |
35 | FILE * file; | |
252b5132 | 36 | |
b2e951ec NC |
37 | target = argv[1]; |
38 | if (target == NULL) | |
39 | { | |
40 | fprintf (stderr, "Usage: gen-aout target_name\n"); | |
41 | exit (1); | |
42 | } | |
43 | ||
44 | file = fopen ("gen-aout", "r"); | |
45 | if (file == NULL) | |
46 | { | |
47 | fprintf (stderr, "Cannot open gen-aout!\n"); | |
252b5132 | 48 | return -1; |
b2e951ec NC |
49 | } |
50 | ||
51 | if (fread (&my_exec, sizeof (struct exec), 1, file) != 1) | |
52 | { | |
252b5132 RH |
53 | fprintf(stderr, "Cannot read gen-aout!\n"); |
54 | return -1; | |
b2e951ec | 55 | } |
252b5132 | 56 | |
b2e951ec | 57 | fclose (file); |
252b5132 RH |
58 | |
59 | #ifdef N_TXTOFF | |
bbb1afc8 | 60 | page_size = N_TXTOFF (&my_exec); |
252b5132 | 61 | if (page_size == 0) |
b2e951ec | 62 | printf ("#define N_HEADER_IN_TEXT(x) 1\n"); |
252b5132 | 63 | else |
b2e951ec | 64 | printf ("#define N_HEADER_IN_TEXT(x) 0\n"); |
252b5132 RH |
65 | #endif |
66 | ||
67 | printf("#define BYTES_IN_WORD %d\n", sizeof (int)); | |
b2e951ec NC |
68 | if (my_exec.a_entry == 0) |
69 | { | |
70 | printf ("#define ENTRY_CAN_BE_ZERO\n"); | |
71 | printf ("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n"); | |
72 | } | |
73 | else | |
74 | { | |
75 | printf ("/*#define ENTRY_CAN_BE_ZERO*/\n"); | |
76 | printf ("/*#define N_SHARED_LIB(x) 0*/\n"); | |
77 | } | |
252b5132 | 78 | |
b2e951ec | 79 | printf ("#define TEXT_START_ADDR %d\n", my_exec.a_entry); |
252b5132 RH |
80 | |
81 | #ifdef PAGSIZ | |
82 | if (page_size == 0) | |
83 | page_size = PAGSIZ; | |
84 | #endif | |
b2e951ec | 85 | |
252b5132 | 86 | if (page_size != 0) |
b2e951ec | 87 | printf ("#define TARGET_PAGE_SIZE %d\n", page_size); |
252b5132 | 88 | else |
b2e951ec NC |
89 | printf ("/* #define TARGET_PAGE_SIZE ??? */\n"); |
90 | ||
91 | printf ("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n"); | |
252b5132 RH |
92 | |
93 | #ifdef vax | |
94 | arch = "vax"; | |
252b5132 RH |
95 | #endif |
96 | if (arch[0] == '1') | |
97 | { | |
98 | fprintf (stderr, _("warning: preprocessor substituted architecture name inside string;")); | |
99 | fprintf (stderr, _(" fix DEFAULT_ARCH in the output file yourself\n")); | |
100 | arch = "unknown"; | |
101 | } | |
b2e951ec NC |
102 | printf ("#define DEFAULT_ARCH bfd_arch_%s\n\n", arch); |
103 | ||
104 | printf ("/* Do not \"beautify\" the CONCAT* macro args. Traditional C will not"); | |
105 | printf (" remove whitespace added here, and thus will fail to concatenate"); | |
106 | printf (" the tokens. */"); | |
107 | printf ("\n#define MY(OP) CONCAT2 (%s_,OP)\n\n", target); | |
108 | printf ("#define TARGETNAME \"a.out-%s\"\n\n", target); | |
109 | ||
110 | printf ("#include \"sysdep.h\"\n"); | |
111 | printf ("#include \"bfd.h\"\n"); | |
112 | printf ("#include \"libbfd.h\"\n"); | |
113 | printf ("#include \"libaout.h\"\n"); | |
114 | printf ("\n#include \"aout-target.h\"\n"); | |
252b5132 RH |
115 | |
116 | return 0; | |
117 | } |