Display the contents of a .debug.macinfo section
[deliverable/binutils-gdb.git] / bfd / gen-aout.c
CommitLineData
252b5132 1/* Generate parameters for an a.out system.
7898deda
NC
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc.
252b5132
RH
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21#include "/usr/include/a.out.h"
22#include <stdio.h>
23
24int
25main (argc, argv)
26 int argc; char** argv;
27{
28 struct exec my_exec;
29 int page_size;
30 char *target = "unknown", *arch = "unknown";
31 FILE *file = fopen("gen-aout", "r");
32
33 if (file == NULL) {
34 fprintf(stderr, "Cannot open gen-aout!\n");
35 return -1;
36 }
37 if (fread(&my_exec, sizeof(struct exec), 1, file) != 1) {
38 fprintf(stderr, "Cannot read gen-aout!\n");
39 return -1;
40 }
41
42 target = argv[1];
43 if (target == NULL) {
44 fprintf(stderr, "Usage: gen-aout target_name\n");
45 exit (1);
46 }
47
48#ifdef N_TXTOFF
49 page_size = N_TXTOFF(my_exec);
50 if (page_size == 0)
51 printf("#define N_HEADER_IN_TEXT(x) 1\n");
52 else
53 printf("#define N_HEADER_IN_TEXT(x) 0\n");
54#endif
55
56 printf("#define BYTES_IN_WORD %d\n", sizeof (int));
57 if (my_exec.a_entry == 0) {
58 printf("#define ENTRY_CAN_BE_ZERO\n");
59 printf("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
60 }
61 else {
62 printf("/*#define ENTRY_CAN_BE_ZERO*/\n");
63 printf("/*#define N_SHARED_LIB(x) 0*/\n");
64 }
65
66 printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
67
68#ifdef PAGSIZ
69 if (page_size == 0)
70 page_size = PAGSIZ;
71#endif
72 if (page_size != 0)
73 printf("#define TARGET_PAGE_SIZE %d\n", page_size);
74 else
75 printf("/* #define TARGET_PAGE_SIZE ??? */\n");
76 printf("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n");
77
78#ifdef vax
79 arch = "vax";
80#endif
81#ifdef m68k
82 arch = "m68k";
83#endif
84 if (arch[0] == '1')
85 {
86 fprintf (stderr, _("warning: preprocessor substituted architecture name inside string;"));
87 fprintf (stderr, _(" fix DEFAULT_ARCH in the output file yourself\n"));
88 arch = "unknown";
89 }
90 printf("#define DEFAULT_ARCH bfd_arch_%s\n", arch);
91
92 printf("\n#define MY(OP) CAT(%s_,OP)\n", target);
93 printf("#define TARGETNAME \"a.out-%s\"\n\n", target);
94
95 printf("#include \"bfd.h\"\n");
96 printf("#include \"sysdep.h\"\n");
97 printf("#include \"libbfd.h\"\n");
98 printf("#include \"libaout.h\"\n");
99 printf("\n#include \"aout-target.h\"\n");
100
101 return 0;
102}
This page took 0.085768 seconds and 4 git commands to generate.