11556Srgrimes/* BFD back-end for i386 a.out binaries.
21556Srgrimes   Copyright (C) 1990-2017 Free Software Foundation, Inc.
31556Srgrimes
41556Srgrimes   This file is part of BFD, the Binary File Descriptor library.
51556Srgrimes
61556Srgrimes   This program is free software; you can redistribute it and/or modify
71556Srgrimes   it under the terms of the GNU General Public License as published by
81556Srgrimes   the Free Software Foundation; either version 3 of the License, or
91556Srgrimes   (at your option) any later version.
101556Srgrimes
111556Srgrimes   This program is distributed in the hope that it will be useful,
121556Srgrimes   but WITHOUT ANY WARRANTY; without even the implied warranty of
131556Srgrimes   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141556Srgrimes   GNU General Public License for more details.
151556Srgrimes
161556Srgrimes   You should have received a copy of the GNU General Public License
171556Srgrimes   along with this program; if not, write to the Free Software
181556Srgrimes   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
191556Srgrimes   MA 02110-1301, USA.  */
201556Srgrimes
211556Srgrimes
221556Srgrimes/* The only 386 aout system we have here is GO32 from DJ.
231556Srgrimes   These numbers make BFD work with that. If your aout 386 system
241556Srgrimes   doesn't work with these, we'll have to split them into different
251556Srgrimes   files.  Send me (sac@cygnus.com) the runes to make it work on your
261556Srgrimes   system, and I'll stick it in for the next release.  */
271556Srgrimes
281556Srgrimes#define N_HEADER_IN_TEXT(x)	0
291556Srgrimes#define N_TXTOFF(x)   		0x20
301556Srgrimes#define N_TXTADDR(x) 		(N_MAGIC (x) == ZMAGIC ? 0x1020 : 0)
311556Srgrimes#define N_TXTSIZE(x) 		((x)->a_text)
321556Srgrimes#define TARGET_PAGE_SIZE 	4096
331556Srgrimes#define SEGMENT_SIZE 		0x400000
3450471Speter#define DEFAULT_ARCH 		bfd_arch_i386
351556Srgrimes
361556Srgrimes/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
371556Srgrimes   remove whitespace added here, and thus will fail to concatenate
381556Srgrimes   the tokens.  */
3951249Sgreen#define MY(OP) CONCAT2 (i386_aout_,OP)
4051249Sgreen#define TARGETNAME "a.out-i386"
4151249Sgreen#define NO_WRITE_HEADER_KLUDGE 1
4251249Sgreen
4351249Sgreen#include "sysdep.h"
4451249Sgreen#include "bfd.h"
451556Srgrimes#include "libbfd.h"
461556Srgrimes#include "aout/aout64.h"
4762311Sgreen#include "libaout.h"
4851249Sgreen
4951212Sgreen/* Set the machine type correctly.  */
5048802Sgreen
5162311Sgreenstatic bfd_boolean
5251249Sgreeni386aout_write_object_contents (bfd *abfd)
531556Srgrimes{
54126690Sbde  struct external_exec exec_bytes;
5551249Sgreen  struct internal_exec *execp = exec_hdr (abfd);
5651249Sgreen
57298258Sthomas  N_SET_MACHTYPE (execp, M_386);
581556Srgrimes
591556Srgrimes  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
601556Srgrimes
61111629Smarkm  WRITE_HEADERS (abfd, execp);
62111629Smarkm
63111629Smarkm  return TRUE;
64111629Smarkm}
65111629Smarkm
66111629Smarkm#define MY_write_object_contents  i386aout_write_object_contents
67111629Smarkm#define MY_backend_data           & MY (backend_data)
68126690Sbde
691556Srgrimesstatic const struct aout_backend_data MY (backend_data);
701556Srgrimes
711556Srgrimes#include "aout-target.h"
72264577Sdelphij
73264577Sdelphijstatic const struct aout_backend_data MY (backend_data) =
74264577Sdelphij{
75264577Sdelphij  0,				/* Zmagic contiguous.  */
76264577Sdelphij  1,				/* Text incl header.  */
77264577Sdelphij  0,				/* Entry is text address.  */
78264577Sdelphij  0,				/* Exec_hdr_flags.  */
79264577Sdelphij  0,				/* Text vma?  */
80264577Sdelphij  MY (set_sizes),
81264577Sdelphij  1,				/* Exec header not counted.  */
82264577Sdelphij  0,				/* Add_dynamic_symbols.  */
83264577Sdelphij  0,				/* Add_one_symbol.  */
84264577Sdelphij  0,				/* Link_dynamic_object.  */
85264577Sdelphij  0,				/* Write_dynamic_symbol.  */
86264577Sdelphij  0,				/* Check_dynamic_reloc.  */
87264577Sdelphij  0				/* Finish_dynamic_link.  */
88264577Sdelphij};
89264577Sdelphij