1*3d8817e4Smiod /* BFD back-end for i386 a.out binaries under dynix.
2*3d8817e4Smiod Copyright 1994, 1995, 2001, 2003 Free Software Foundation, Inc.
3*3d8817e4Smiod
4*3d8817e4Smiod This file is part of BFD, the Binary File Descriptor library.
5*3d8817e4Smiod
6*3d8817e4Smiod This program is free software; you can redistribute it and/or modify
7*3d8817e4Smiod it under the terms of the GNU General Public License as published by
8*3d8817e4Smiod the Free Software Foundation; either version 2 of the License, or
9*3d8817e4Smiod (at your option) any later version.
10*3d8817e4Smiod
11*3d8817e4Smiod This program is distributed in the hope that it will be useful,
12*3d8817e4Smiod but WITHOUT ANY WARRANTY; without even the implied warranty of
13*3d8817e4Smiod MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*3d8817e4Smiod GNU General Public License for more details.
15*3d8817e4Smiod
16*3d8817e4Smiod You should have received a copy of the GNU General Public License
17*3d8817e4Smiod along with this program; if not, write to the Free Software
18*3d8817e4Smiod Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
19*3d8817e4Smiod
20*3d8817e4Smiod /* This BFD is currently only tested with gdb, writing object files
21*3d8817e4Smiod may not work. */
22*3d8817e4Smiod
23*3d8817e4Smiod #define TEXT_START_ADDR 4096
24*3d8817e4Smiod #define TARGET_PAGE_SIZE 4096
25*3d8817e4Smiod #define SEGMENT_SIZE TARGET_PAGE_SIZE
26*3d8817e4Smiod
27*3d8817e4Smiod #include "aout/dynix3.h"
28*3d8817e4Smiod
29*3d8817e4Smiod #define DEFAULT_ARCH bfd_arch_i386
30*3d8817e4Smiod #define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_UNKNOWN)
31*3d8817e4Smiod
32*3d8817e4Smiod /* Do not "beautify" the CONCAT* macro args. Traditional C will not
33*3d8817e4Smiod remove whitespace added here, and thus will fail to concatenate
34*3d8817e4Smiod the tokens. */
35*3d8817e4Smiod #define MY(OP) CONCAT2 (i386dynix_,OP)
36*3d8817e4Smiod #define TARGETNAME "a.out-i386-dynix"
37*3d8817e4Smiod #define NAME(x,y) CONCAT3 (i386dynix,_32_,y)
38*3d8817e4Smiod #define ARCH_SIZE 32
39*3d8817e4Smiod #define NAME_swap_exec_header_in NAME(i386dynix_32_,swap_exec_header_in)
40*3d8817e4Smiod #define MY_get_section_contents aout_32_get_section_contents
41*3d8817e4Smiod
42*3d8817e4Smiod /* aoutx.h requires definitions for NMAGIC, BMAGIC and QMAGIC. */
43*3d8817e4Smiod #define NMAGIC 0
44*3d8817e4Smiod #define BMAGIC OMAGIC
45*3d8817e4Smiod #define QMAGIC XMAGIC
46*3d8817e4Smiod
47*3d8817e4Smiod #include "aoutx.h"
48*3d8817e4Smiod
49*3d8817e4Smiod /* (Ab)use some fields in the internal exec header to be able to read
50*3d8817e4Smiod executables that contain shared data. */
51*3d8817e4Smiod
52*3d8817e4Smiod #define a_shdata a_tload
53*3d8817e4Smiod #define a_shdrsize a_dload
54*3d8817e4Smiod
55*3d8817e4Smiod void
i386dynix_32_swap_exec_header_in(abfd,raw_bytes,execp)56*3d8817e4Smiod i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
57*3d8817e4Smiod bfd *abfd;
58*3d8817e4Smiod struct external_exec *raw_bytes;
59*3d8817e4Smiod struct internal_exec *execp;
60*3d8817e4Smiod {
61*3d8817e4Smiod struct external_exec *bytes = (struct external_exec *)raw_bytes;
62*3d8817e4Smiod
63*3d8817e4Smiod /* The internal_exec structure has some fields that are unused in this
64*3d8817e4Smiod configuration (IE for i960), so ensure that all such uninitialized
65*3d8817e4Smiod fields are zero'd out. There are places where two of these structs
66*3d8817e4Smiod are memcmp'd, and thus the contents do matter. */
67*3d8817e4Smiod memset ((PTR) execp, 0, sizeof (struct internal_exec));
68*3d8817e4Smiod /* Now fill in fields in the execp, from the bytes in the raw data. */
69*3d8817e4Smiod execp->a_info = H_GET_32 (abfd, bytes->e_info);
70*3d8817e4Smiod execp->a_text = GET_WORD (abfd, bytes->e_text);
71*3d8817e4Smiod execp->a_data = GET_WORD (abfd, bytes->e_data);
72*3d8817e4Smiod execp->a_bss = GET_WORD (abfd, bytes->e_bss);
73*3d8817e4Smiod execp->a_syms = GET_WORD (abfd, bytes->e_syms);
74*3d8817e4Smiod execp->a_entry = GET_WORD (abfd, bytes->e_entry);
75*3d8817e4Smiod execp->a_trsize = GET_WORD (abfd, bytes->e_trsize);
76*3d8817e4Smiod execp->a_drsize = GET_WORD (abfd, bytes->e_drsize);
77*3d8817e4Smiod execp->a_shdata = GET_WORD (abfd, bytes->e_shdata);
78*3d8817e4Smiod execp->a_shdrsize = GET_WORD (abfd, bytes->e_shdrsize);
79*3d8817e4Smiod }
80*3d8817e4Smiod
81*3d8817e4Smiod #include "aout-target.h"
82