133965Sjdp/* BFD back-end for i386 a.out binaries.
2218822Sdim   Copyright 1990, 1991, 1992, 1994, 1996, 1997, 2001, 2002, 2003, 2005,
3218822Sdim   2007 Free Software Foundation, Inc.
433965Sjdp
5218822Sdim   This file is part of BFD, the Binary File Descriptor library.
633965Sjdp
7218822Sdim   This program is free software; you can redistribute it and/or modify
8218822Sdim   it under the terms of the GNU General Public License as published by
9218822Sdim   the Free Software Foundation; either version 2 of the License, or
10218822Sdim   (at your option) any later version.
1133965Sjdp
12218822Sdim   This program is distributed in the hope that it will be useful,
13218822Sdim   but WITHOUT ANY WARRANTY; without even the implied warranty of
14218822Sdim   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15218822Sdim   GNU General Public License for more details.
1633965Sjdp
17218822Sdim   You should have received a copy of the GNU General Public License
18218822Sdim   along with this program; if not, write to the Free Software
19218822Sdim   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2033965Sjdp
2189857Sobrien/* The only 386 aout system we have here is GO32 from DJ.
2233965Sjdp   These numbers make BFD work with that. If your aout 386 system
2333965Sjdp   doesn't work with these, we'll have to split them into different
2433965Sjdp   files.  Send me (sac@cygnus.com) the runes to make it work on your
2533965Sjdp   system, and I'll stick it in for the next release.  */
2633965Sjdp
27218822Sdim#define N_HEADER_IN_TEXT(x)	0
28218822Sdim#define N_TXTOFF(x)   		0x20
29218822Sdim#define N_TXTADDR(x) 		(N_MAGIC (x) == ZMAGIC ? 0x1020 : 0)
30218822Sdim#define N_TXTSIZE(x) 		((x).a_text)
31218822Sdim#define TARGET_PAGE_SIZE 	4096
32218822Sdim#define SEGMENT_SIZE 		0x400000
33218822Sdim#define DEFAULT_ARCH 		bfd_arch_i386
3433965Sjdp
3589857Sobrien/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
3689857Sobrien   remove whitespace added here, and thus will fail to concatenate
3789857Sobrien   the tokens.  */
3889857Sobrien#define MY(OP) CONCAT2 (i386aout_,OP)
3933965Sjdp#define TARGETNAME "a.out-i386"
4033965Sjdp#define NO_WRITE_HEADER_KLUDGE 1
4133965Sjdp
42218822Sdim#include "sysdep.h"
4333965Sjdp#include "bfd.h"
4433965Sjdp#include "libbfd.h"
4533965Sjdp#include "aout/aout64.h"
4633965Sjdp#include "libaout.h"
4733965Sjdp
4833965Sjdp/* Set the machine type correctly.  */
4933965Sjdp
50130561Sobrienstatic bfd_boolean
51218822Sdimi386aout_write_object_contents (bfd *abfd)
5233965Sjdp{
5333965Sjdp  struct external_exec exec_bytes;
5433965Sjdp  struct internal_exec *execp = exec_hdr (abfd);
5533965Sjdp
5633965Sjdp  N_SET_MACHTYPE (*execp, M_386);
5733965Sjdp
5833965Sjdp  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
5933965Sjdp
6033965Sjdp  WRITE_HEADERS (abfd, execp);
6133965Sjdp
62130561Sobrien  return TRUE;
6333965Sjdp}
6433965Sjdp
65218822Sdim#define MY_write_object_contents  i386aout_write_object_contents
66218822Sdim#define MY_backend_data           & MY (backend_data)
6733965Sjdp
68218822Sdimstatic const struct aout_backend_data MY (backend_data);
6933965Sjdp
7033965Sjdp#include "aout-target.h"
71218822Sdim
72218822Sdimstatic const struct aout_backend_data MY (backend_data) =
73218822Sdim{
74218822Sdim  0,				/* Zmagic contiguous.  */
75218822Sdim  1,				/* Text incl header.  */
76218822Sdim  0,				/* Entry is text address.  */
77218822Sdim  0,				/* Exec_hdr_flags.  */
78218822Sdim  0,				/* Text vma?  */
79218822Sdim  MY (set_sizes),
80218822Sdim  1,				/* Exec header not counted.  */
81218822Sdim  0,				/* Add_dynamic_symbols.  */
82218822Sdim  0,				/* Add_one_symbol.  */
83218822Sdim  0,				/* Link_dynamic_object.  */
84218822Sdim  0,				/* Write_dynamic_symbol.  */
85218822Sdim  0,				/* Check_dynamic_reloc.  */
86218822Sdim  0				/* Finish_dynamic_link.  */
87218822Sdim};
88