old-cross-binutils/bfd/gen-aout.c

121 lines
3.2 KiB
C
Raw Normal View History

1999-05-03 07:29:11 +00:00
/* Generate parameters for an a.out system.
Copyright (C) 1990-2015 Free Software Foundation, Inc.
1999-05-03 07:29:11 +00:00
This file is part of BFD, the Binary File Descriptor library.
1999-05-03 07:29:11 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
1999-05-03 07:29:11 +00:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-05-03 07:29:11 +00:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
1999-05-03 07:29:11 +00:00
#include "/usr/include/a.out.h"
#include <stdio.h>
* aoutx.h (NAME(aout,swap_ext_reloc_in)): Cast bytes->r_index to unsigned int. Cast RELOC_BASE10, RELOC_BASE13 and RELOC_BASE22 to unsigned int. (NAME(aout,final_link)): Cast enum used in assignment. (aout_link_write_symbols): Cast enums in comparisons, int values to boolean, enums in assignments to int. (aout_link_input_section_std): Cast rel->r_index to unsigned int. (aout_link_input_section_ext): Likewise. Cast enums used in comparisons with unsigned ints. (aout_link_reloc_link_order): Cast enum to int in assignment. * archive.c (_bfd_generic_read_ar_hdr_mag): Cast result of memchr calls to char *. * bfd-in.h (bfd_set_section_vma): Cast enum true to unsigned int in assignment. * bfd-in2.h (bfd_set_section_vma): Likewise. * bfd.c (bfd_record_phdr): Cast enums in assignments. * binary.c (bfd_alloc): Cast enum to long. * coffgen.c (_bfd_coff_is_local_label_name): Cast return to boolean. * dwarf2.c (read_abbrevs): Add casts to enum types. (read_attribute_value): Likewise. (arange_add): Cast result of bfd_zalloc call. (comp_unit_contains_address): Return true and false. (comp_unit_find_nearest_line): Cast return to boolean. * format.c (bfd_check_format_matches, bfd_set_format): Likewise. * gen-aout.c: define macro '_' if not defined. * libbfd.c (bfd_realloc): Cast malloc and realloc to PTR. (bfd_bwrite): Cast bfd_realloc to bfd_byte *. (bfd_write_bigendian_4byte_int): Cast return to boolean. (bfd_seek): Cast bfd_realloc to bfd_byte *. (bfd_generic_is_local_label_name): Cast return to boolean. * libcoff.h (_bfd_coff_adjust_symndx): Remove extraneous '\'. * linker.c (_bfd_link_hash_newfunc): Cast bfd_hash_allocate result to struct bfd_hash_entry *. (_bfd_generic_link_hash_newfunc): likewise. (_bfd_generic_final_link): Cast enum to unsigned int. * merge.c (sec_merge_emit): Cast return to boolean. (merge_strings): Add casts to const unsigned char *. * reloc.c (bfd_get_reloc_code_name): Cast enums in comparison to int. (bfd_generic_get_relocated_section_content): Cast enum to unsigned int. * section.c (bfd_section_hash_newfunc): Cast bfd_hash_allocate result to struct bfd_hash_entry *. (bfd_set_section_content): Add cast to PTR in comparison. * simple.c (simple_dummy_warning, simple_dummy_undefined_symbol, simple_dummy_reloc_overflow, simple_dummy_reloc_dangerous, simple_dummy_unattached_reloc, bfd_simple_get_relocated_section_contents): Add K&R declarations and function definitions. * srec.c (S3Forced): Initialize to false. (srec_get_symtab): Cast return value from bfd_alloc to asymbol *. * stabs.c (_bfd_link_section_stabs): Cast enum to int in comparisons. (_bfd_discard_section_stabs): Likewise. Also cast return to boolean. * syms.c (bfd_is_undefined_symclass): Cast return to boolean. (_bfd_stab_section_find_nearest_line): Cast enum to bfd_byte in comparisons.
2002-10-25 02:45:54 +00:00
#ifndef _
#define _(X) X
#endif
1999-05-03 07:29:11 +00:00
int
main (int argc, char** argv)
1999-05-03 07:29:11 +00:00
{
struct exec my_exec;
int page_size;
char * target;
char * arch = "unknown";
FILE * file;
1999-05-03 07:29:11 +00:00
target = argv[1];
if (target == NULL)
{
fprintf (stderr, "Usage: gen-aout target_name\n");
exit (1);
}
file = fopen ("gen-aout", "r");
if (file == NULL)
{
fprintf (stderr, "Cannot open gen-aout!\n");
1999-05-03 07:29:11 +00:00
return -1;
}
if (fread (&my_exec, sizeof (struct exec), 1, file) != 1)
{
1999-05-03 07:29:11 +00:00
fprintf(stderr, "Cannot read gen-aout!\n");
return -1;
}
1999-05-03 07:29:11 +00:00
fclose (file);
1999-05-03 07:29:11 +00:00
#ifdef N_TXTOFF
page_size = N_TXTOFF (&my_exec);
1999-05-03 07:29:11 +00:00
if (page_size == 0)
printf ("#define N_HEADER_IN_TEXT(x) 1\n");
1999-05-03 07:29:11 +00:00
else
printf ("#define N_HEADER_IN_TEXT(x) 0\n");
1999-05-03 07:29:11 +00:00
#endif
printf("#define BYTES_IN_WORD %d\n", sizeof (int));
if (my_exec.a_entry == 0)
{
printf ("#define ENTRY_CAN_BE_ZERO\n");
printf ("#define N_SHARED_LIB(x) 0 /* Avoids warning */\n");
}
else
{
printf ("/*#define ENTRY_CAN_BE_ZERO*/\n");
printf ("/*#define N_SHARED_LIB(x) 0*/\n");
}
1999-05-03 07:29:11 +00:00
printf ("#define TEXT_START_ADDR %d\n", my_exec.a_entry);
1999-05-03 07:29:11 +00:00
#ifdef PAGSIZ
if (page_size == 0)
page_size = PAGSIZ;
#endif
1999-05-03 07:29:11 +00:00
if (page_size != 0)
printf ("#define TARGET_PAGE_SIZE %d\n", page_size);
1999-05-03 07:29:11 +00:00
else
printf ("/* #define TARGET_PAGE_SIZE ??? */\n");
printf ("#define SEGMENT_SIZE TARGET_PAGE_SIZE\n");
1999-05-03 07:29:11 +00:00
#ifdef vax
arch = "vax";
#endif
#ifdef m68k
arch = "m68k";
#endif
if (arch[0] == '1')
{
fprintf (stderr, _("warning: preprocessor substituted architecture name inside string;"));
fprintf (stderr, _(" fix DEFAULT_ARCH in the output file yourself\n"));
arch = "unknown";
}
printf ("#define DEFAULT_ARCH bfd_arch_%s\n\n", arch);
printf ("/* Do not \"beautify\" the CONCAT* macro args. Traditional C will not");
printf (" remove whitespace added here, and thus will fail to concatenate");
printf (" the tokens. */");
printf ("\n#define MY(OP) CONCAT2 (%s_,OP)\n\n", target);
printf ("#define TARGETNAME \"a.out-%s\"\n\n", target);
printf ("#include \"sysdep.h\"\n");
printf ("#include \"bfd.h\"\n");
printf ("#include \"libbfd.h\"\n");
printf ("#include \"libaout.h\"\n");
printf ("\n#include \"aout-target.h\"\n");
1999-05-03 07:29:11 +00:00
return 0;
}