i386aout.c revision 89857
133965Sjdp/* BFD back-end for i386 a.out binaries. 289857Sobrien Copyright 1990, 1991, 1992, 1994, 1996, 1997, 2001 378828Sobrien Free Software Foundation, Inc. 433965Sjdp 533965SjdpThis file is part of BFD, the Binary File Descriptor library. 633965Sjdp 733965SjdpThis program is free software; you can redistribute it and/or modify 833965Sjdpit under the terms of the GNU General Public License as published by 933965Sjdpthe Free Software Foundation; either version 2 of the License, or 1033965Sjdp(at your option) any later version. 1133965Sjdp 1233965SjdpThis program is distributed in the hope that it will be useful, 1333965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1433965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1533965SjdpGNU General Public License for more details. 1633965Sjdp 1733965SjdpYou should have received a copy of the GNU General Public License 1833965Sjdpalong with this program; if not, write to the Free Software 1933965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2033965Sjdp 2133965Sjdp 2289857Sobrien/* The only 386 aout system we have here is GO32 from DJ. 2333965Sjdp These numbers make BFD work with that. If your aout 386 system 2433965Sjdp doesn't work with these, we'll have to split them into different 2533965Sjdp files. Send me (sac@cygnus.com) the runes to make it work on your 2633965Sjdp system, and I'll stick it in for the next release. */ 2733965Sjdp 2833965Sjdp#define N_HEADER_IN_TEXT(x) 0 2933965Sjdp#define BYTES_IN_WORD 4 3033965Sjdp 3133965Sjdp#define N_TXTOFF(x) 0x20 3233965Sjdp#define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0) 3333965Sjdp 3433965Sjdp#define N_TXTSIZE(x) ((x).a_text) 3533965Sjdp#if 0 3633965Sjdp#define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1)))) 3733965Sjdp#define NOSUBEXECB 3833965Sjdp 3933965Sjdp#endif 4033965Sjdp#define TARGET_PAGE_SIZE 4096 4133965Sjdp#define SEGMENT_SIZE 0x400000 4233965Sjdp#define DEFAULT_ARCH bfd_arch_i386 4333965Sjdp 4489857Sobrien/* Do not "beautify" the CONCAT* macro args. Traditional C will not 4589857Sobrien remove whitespace added here, and thus will fail to concatenate 4689857Sobrien the tokens. */ 4789857Sobrien#define MY(OP) CONCAT2 (i386aout_,OP) 4833965Sjdp#define TARGETNAME "a.out-i386" 4933965Sjdp#define NO_WRITE_HEADER_KLUDGE 1 5033965Sjdp 5133965Sjdp#include "bfd.h" 5233965Sjdp#include "sysdep.h" 5333965Sjdp#include "libbfd.h" 5433965Sjdp#include "aout/aout64.h" 5533965Sjdp#include "libaout.h" 5633965Sjdp 5789857Sobrienstatic boolean i386aout_write_object_contents PARAMS ((bfd *)); 5889857Sobrienstatic boolean MY (set_sizes) PARAMS ((bfd *)); 5989857Sobrien 6033965Sjdp/* Set the machine type correctly. */ 6133965Sjdp 6233965Sjdpstatic boolean 6333965Sjdpi386aout_write_object_contents (abfd) 6433965Sjdp bfd *abfd; 6533965Sjdp{ 6633965Sjdp struct external_exec exec_bytes; 6733965Sjdp struct internal_exec *execp = exec_hdr (abfd); 6833965Sjdp 6933965Sjdp N_SET_MACHTYPE (*execp, M_386); 7033965Sjdp 7133965Sjdp obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; 7233965Sjdp 7333965Sjdp WRITE_HEADERS (abfd, execp); 7433965Sjdp 7533965Sjdp return true; 7633965Sjdp} 7733965Sjdp 7833965Sjdp#define MY_write_object_contents i386aout_write_object_contents 7933965Sjdp 8033965Sjdp#define MY_backend_data &MY(backend_data) 8189857Sobrienstatic const struct aout_backend_data MY(backend_data) = { 8233965Sjdp 0, /* zmagic contiguous */ 8333965Sjdp 1, /* text incl header */ 8433965Sjdp 0, /* entry is text address */ 8533965Sjdp 0, /* exec_hdr_flags */ 8633965Sjdp 0, /* text vma? */ 8733965Sjdp MY(set_sizes), 8833965Sjdp 1, /* exec header not counted */ 8933965Sjdp 0, /* add_dynamic_symbols */ 9033965Sjdp 0, /* add_one_symbol */ 9133965Sjdp 0, /* link_dynamic_object */ 9233965Sjdp 0, /* write_dynamic_symbol */ 9333965Sjdp 0, /* check_dynamic_reloc */ 9433965Sjdp 0 /* finish_dynamic_link */ 9533965Sjdp}; 9633965Sjdp 9733965Sjdp#include "aout-target.h" 98