xref: /openbsd-src/gnu/usr.bin/binutils/bfd/i386aout.c (revision c074d1c999f3e07019cd5e9a2f190b057ef3b935)
12159047fSniklas /* BFD back-end for i386 a.out binaries.
2*c074d1c9Sdrahn    Copyright 1990, 1991, 1992, 1994, 1996, 1997, 2001, 2002, 2003
3b55d4692Sfgsch    Free Software Foundation, Inc.
42159047fSniklas 
52159047fSniklas This file is part of BFD, the Binary File Descriptor library.
62159047fSniklas 
72159047fSniklas This program is free software; you can redistribute it and/or modify
82159047fSniklas it under the terms of the GNU General Public License as published by
92159047fSniklas the Free Software Foundation; either version 2 of the License, or
102159047fSniklas (at your option) any later version.
112159047fSniklas 
122159047fSniklas This program is distributed in the hope that it will be useful,
132159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
142159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
152159047fSniklas GNU General Public License for more details.
162159047fSniklas 
172159047fSniklas You should have received a copy of the GNU General Public License
182159047fSniklas along with this program; if not, write to the Free Software
192159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
202159047fSniklas 
212159047fSniklas 
222159047fSniklas /* The only 386 aout system we have here is GO32 from DJ.
232159047fSniklas    These numbers make BFD work with that. If your aout 386 system
242159047fSniklas    doesn't work with these, we'll have to split them into different
252159047fSniklas    files.  Send me (sac@cygnus.com) the runes to make it work on your
262159047fSniklas    system, and I'll stick it in for the next release.  */
272159047fSniklas 
282159047fSniklas #define N_HEADER_IN_TEXT(x) 0
292159047fSniklas 
302159047fSniklas #define N_TXTOFF(x) 0x20
312159047fSniklas #define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
322159047fSniklas 
332159047fSniklas #define N_TXTSIZE(x) ((x).a_text)
342159047fSniklas #if 0
352159047fSniklas #define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
362159047fSniklas #define NOSUBEXECB
372159047fSniklas 
382159047fSniklas #endif
392159047fSniklas #define TARGET_PAGE_SIZE 4096
402159047fSniklas #define SEGMENT_SIZE 0x400000
412159047fSniklas #define DEFAULT_ARCH bfd_arch_i386
422159047fSniklas 
43*c074d1c9Sdrahn /* Do not "beautify" the CONCAT* macro args.  Traditional C will not
44*c074d1c9Sdrahn    remove whitespace added here, and thus will fail to concatenate
45*c074d1c9Sdrahn    the tokens.  */
46*c074d1c9Sdrahn #define MY(OP) CONCAT2 (i386aout_,OP)
472159047fSniklas #define TARGETNAME "a.out-i386"
482159047fSniklas #define NO_WRITE_HEADER_KLUDGE 1
492159047fSniklas 
502159047fSniklas #include "bfd.h"
512159047fSniklas #include "sysdep.h"
522159047fSniklas #include "libbfd.h"
534361b62eSniklas #include "aout/aout64.h"
542159047fSniklas #include "libaout.h"
554361b62eSniklas 
56*c074d1c9Sdrahn static bfd_boolean i386aout_write_object_contents PARAMS ((bfd *));
57*c074d1c9Sdrahn static bfd_boolean MY (set_sizes) PARAMS ((bfd *));
58*c074d1c9Sdrahn 
594361b62eSniklas /* Set the machine type correctly.  */
604361b62eSniklas 
61*c074d1c9Sdrahn static bfd_boolean
i386aout_write_object_contents(abfd)624361b62eSniklas i386aout_write_object_contents (abfd)
634361b62eSniklas      bfd *abfd;
644361b62eSniklas {
654361b62eSniklas   struct external_exec exec_bytes;
664361b62eSniklas   struct internal_exec *execp = exec_hdr (abfd);
674361b62eSniklas 
684361b62eSniklas   N_SET_MACHTYPE (*execp, M_386);
694361b62eSniklas 
704361b62eSniklas   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
714361b62eSniklas 
724361b62eSniklas   WRITE_HEADERS (abfd, execp);
734361b62eSniklas 
74*c074d1c9Sdrahn   return TRUE;
754361b62eSniklas }
764361b62eSniklas 
774361b62eSniklas #define MY_write_object_contents i386aout_write_object_contents
784361b62eSniklas 
792159047fSniklas #define MY_backend_data &MY(backend_data)
80*c074d1c9Sdrahn static const struct aout_backend_data MY(backend_data) = {
812159047fSniklas   0,				/* zmagic contiguous */
822159047fSniklas   1,				/* text incl header */
836a4c786fSespie   0,				/* entry is text address */
842159047fSniklas   0,				/* exec_hdr_flags */
852159047fSniklas   0,				/* text vma? */
862159047fSniklas   MY(set_sizes),
872159047fSniklas   1,				/* exec header not counted */
882159047fSniklas   0,				/* add_dynamic_symbols */
892159047fSniklas   0,				/* add_one_symbol */
902159047fSniklas   0,				/* link_dynamic_object */
912159047fSniklas   0,				/* write_dynamic_symbol */
922159047fSniklas   0,				/* check_dynamic_reloc */
932159047fSniklas   0				/* finish_dynamic_link */
942159047fSniklas };
952159047fSniklas 
962159047fSniklas #include "aout-target.h"
97