12159047fSniklas /* BFD back-end for i386 a.out binaries under dynix.
2*c074d1c9Sdrahn Copyright 1994, 1995, 2001, 2003 Free Software Foundation, Inc.
32159047fSniklas
42159047fSniklas This file is part of BFD, the Binary File Descriptor library.
52159047fSniklas
62159047fSniklas This program is free software; you can redistribute it and/or modify
72159047fSniklas it under the terms of the GNU General Public License as published by
82159047fSniklas the Free Software Foundation; either version 2 of the License, or
92159047fSniklas (at your option) any later version.
102159047fSniklas
112159047fSniklas This program is distributed in the hope that it will be useful,
122159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
132159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142159047fSniklas GNU General Public License for more details.
152159047fSniklas
162159047fSniklas You should have received a copy of the GNU General Public License
172159047fSniklas along with this program; if not, write to the Free Software
182159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
192159047fSniklas
202159047fSniklas /* This BFD is currently only tested with gdb, writing object files
212159047fSniklas may not work. */
222159047fSniklas
232159047fSniklas #define TEXT_START_ADDR 4096
242159047fSniklas #define TARGET_PAGE_SIZE 4096
252159047fSniklas #define SEGMENT_SIZE TARGET_PAGE_SIZE
262159047fSniklas
272159047fSniklas #include "aout/dynix3.h"
282159047fSniklas
292159047fSniklas #define DEFAULT_ARCH bfd_arch_i386
302159047fSniklas #define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
312159047fSniklas
32*c074d1c9Sdrahn /* Do not "beautify" the CONCAT* macro args. Traditional C will not
33*c074d1c9Sdrahn remove whitespace added here, and thus will fail to concatenate
34*c074d1c9Sdrahn the tokens. */
35*c074d1c9Sdrahn #define MY(OP) CONCAT2 (i386dynix_,OP)
362159047fSniklas #define TARGETNAME "a.out-i386-dynix"
37*c074d1c9Sdrahn #define NAME(x,y) CONCAT3 (i386dynix,_32_,y)
382159047fSniklas #define ARCH_SIZE 32
392159047fSniklas #define NAME_swap_exec_header_in NAME(i386dynix_32_,swap_exec_header_in)
402159047fSniklas #define MY_get_section_contents aout_32_get_section_contents
412159047fSniklas
422159047fSniklas /* aoutx.h requires definitions for NMAGIC, BMAGIC and QMAGIC. */
432159047fSniklas #define NMAGIC 0
442159047fSniklas #define BMAGIC OMAGIC
452159047fSniklas #define QMAGIC XMAGIC
462159047fSniklas
472159047fSniklas #include "aoutx.h"
482159047fSniklas
492159047fSniklas /* (Ab)use some fields in the internal exec header to be able to read
502159047fSniklas executables that contain shared data. */
512159047fSniklas
522159047fSniklas #define a_shdata a_tload
532159047fSniklas #define a_shdrsize a_dload
542159047fSniklas
552159047fSniklas void
i386dynix_32_swap_exec_header_in(abfd,raw_bytes,execp)562159047fSniklas i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
572159047fSniklas bfd *abfd;
582159047fSniklas struct external_exec *raw_bytes;
592159047fSniklas struct internal_exec *execp;
602159047fSniklas {
612159047fSniklas struct external_exec *bytes = (struct external_exec *)raw_bytes;
622159047fSniklas
632159047fSniklas /* The internal_exec structure has some fields that are unused in this
642159047fSniklas configuration (IE for i960), so ensure that all such uninitialized
652159047fSniklas fields are zero'd out. There are places where two of these structs
662159047fSniklas are memcmp'd, and thus the contents do matter. */
672159047fSniklas memset ((PTR) execp, 0, sizeof (struct internal_exec));
682159047fSniklas /* Now fill in fields in the execp, from the bytes in the raw data. */
69*c074d1c9Sdrahn execp->a_info = H_GET_32 (abfd, bytes->e_info);
702159047fSniklas execp->a_text = GET_WORD (abfd, bytes->e_text);
712159047fSniklas execp->a_data = GET_WORD (abfd, bytes->e_data);
722159047fSniklas execp->a_bss = GET_WORD (abfd, bytes->e_bss);
732159047fSniklas execp->a_syms = GET_WORD (abfd, bytes->e_syms);
742159047fSniklas execp->a_entry = GET_WORD (abfd, bytes->e_entry);
752159047fSniklas execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
762159047fSniklas execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
772159047fSniklas execp->a_shdata = GET_WORD (abfd, bytes->e_shdata);
782159047fSniklas execp->a_shdrsize = GET_WORD (abfd, bytes->e_shdrsize);
792159047fSniklas }
802159047fSniklas
812159047fSniklas #include "aout-target.h"
82