1 | /* BFD back-end for emx a.out binaries, derived from i386aout.c and aout-target.h
|
---|
2 | Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of BFD, the Binary File Descriptor library.
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program; if not, write to the Free Software
|
---|
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
---|
19 |
|
---|
20 | #include "sysdep.h"
|
---|
21 | #include "bfd.h"
|
---|
22 | #include "libbfd.h"
|
---|
23 | #include "libaout.h"
|
---|
24 |
|
---|
25 | static boolean MY(set_sizes) ();
|
---|
26 | #define MY_backend_data &MY(backend_data)
|
---|
27 |
|
---|
28 | static const bfd_target *MY(object_p) ();
|
---|
29 | #define MY_object_p MY(object_p)
|
---|
30 |
|
---|
31 | static CONST struct aout_backend_data MY(backend_data) = {
|
---|
32 | 0, /* zmagic contiguous */
|
---|
33 | 0, /* text incl header */
|
---|
34 | 0, /* entry is text address */
|
---|
35 | 0, /* exec_hdr_flags */
|
---|
36 | 0, /* text vma? */
|
---|
37 | MY(set_sizes),
|
---|
38 | 1, /* exec header not counted */
|
---|
39 | 0, /* add_dynamic_symbols */
|
---|
40 | 0, /* add_one_symbol */
|
---|
41 | 0, /* link_dynamic_object */
|
---|
42 | 0, /* write_dynamic_symbol */
|
---|
43 | 0, /* check_dynamic_reloc */
|
---|
44 | 0 /* finish_dynamic_link */
|
---|
45 | };
|
---|
46 |
|
---|
47 | #include "aout-target.h"
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * Finish up the reading of an a.out file header
|
---|
51 | */
|
---|
52 | static const bfd_target *
|
---|
53 | MY(object_p) (abfd)
|
---|
54 | bfd *abfd;
|
---|
55 | {
|
---|
56 | struct external_exec exec_bytes; /* Raw exec header from file */
|
---|
57 | struct internal_exec exec; /* Cleaned-up exec header */
|
---|
58 | const bfd_target *target;
|
---|
59 | size_t org_pos, add;
|
---|
60 |
|
---|
61 | org_pos = bfd_tell (abfd);
|
---|
62 | (void)_fseek_hdr(bfd_cache_lookup(abfd));
|
---|
63 | add = bfd_tell (abfd) - org_pos;
|
---|
64 | if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
---|
65 | != EXEC_BYTES_SIZE)
|
---|
66 | {
|
---|
67 | if (bfd_get_error () != bfd_error_system_call)
|
---|
68 | bfd_set_error (bfd_error_wrong_format);
|
---|
69 | return 0;
|
---|
70 | }
|
---|
71 |
|
---|
72 | exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
---|
73 |
|
---|
74 | if (N_BADMAG (exec))
|
---|
75 | return 0;
|
---|
76 |
|
---|
77 | NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
---|
78 | exec.emx_add = add;
|
---|
79 | target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
|
---|
80 | return target;
|
---|
81 | }
|
---|