home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / bfd / gen-aout.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  3KB  |  92 lines

  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. int
  24. main (argc, argv)
  25.      int argc; char** argv;
  26. {
  27.   struct exec my_exec;
  28.   int page_size;
  29.   char *target;
  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.   target = argv[1];
  41.   if (target == NULL) {
  42.       fprintf(stderr, "Usage: gen-aout target_name\n");
  43.       exit (1);
  44.   }
  45.  
  46.   printf("pagesize = %d\n", getpagesize());
  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 4\n");
  57.   printf("#define ARCH 32\n");
  58.   if (my_exec.a_entry == 0) {
  59.       printf("#define ENTRY_CAN_BE_ZERO\n");
  60.       printf("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
  61.   }
  62.   else {
  63.       printf("/*#define ENTRY_CAN_BE_ZERO*/\n");
  64.       printf("/*#define N_SHARED_LIB(x) 0*/\n");
  65.   }
  66.  
  67.   printf("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
  68.  
  69. #ifdef PAGSIZ
  70.   if (page_size == 0)
  71.     page_size = PAGSIZ;
  72. #endif
  73.   if (page_size != 0)
  74.     printf("#define PAGE_SIZE %d\n", page_size);
  75.   else
  76.     printf("/* #define PAGE_SIZE ??? */\n");
  77.   printf("#define SEGMENT_SIZE PAGE_SIZE\n");
  78.  
  79.   printf("#define DEFAULT_ARCH bfd_arch_m68k\n");
  80.  
  81.   printf("\n#define MY(OP) CAT(%s_,OP)\n", target);
  82.   printf("#define TARGETNAME \"a.out-%s\"\n\n", target);
  83.  
  84.   printf("#include \"bfd.h\"\n");
  85.   printf("#include \"sysdep.h\"\n");
  86.   printf("#include \"libbfd.h\"\n");
  87.   printf("#include \"libaout.h\"\n");
  88.   printf("\n#include \"aout-target.h\"\n");
  89.  
  90.   return 0;
  91. }
  92.