/src/binutils-gdb/bfd/pc532-mach.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* BFD back-end for Mach3/532 a.out-ish binaries. |
2 | | Copyright (C) 1990-2023 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 3 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., 51 Franklin Street - Fifth Floor, Boston, |
19 | | MA 02110-1301, USA. */ |
20 | | |
21 | | |
22 | | /* Written by Ian Dall |
23 | | 19-Apr-94 |
24 | | |
25 | | Formerly part of aout-pc532-mach.c. Split out to allow more |
26 | | flexibility with multiple formats. */ |
27 | | |
28 | | /* This architecture has N_TXTOFF and N_TXTADDR defined as if |
29 | | N_HEADER_IN_TEXT, but the a_text entry (text size) does not include the |
30 | | space for the header. So we have N_HEADER_IN_TEXT defined to |
31 | | 1 and specially define our own N_TXTSIZE. */ |
32 | | |
33 | 15.6k | #define N_HEADER_IN_TEXT(x) 1 |
34 | 70.9k | #define N_TXTSIZE(x) ((x)->a_text) |
35 | | |
36 | 29.3k | #define TEXT_START_ADDR 0x10000 /* from old ld */ |
37 | 18.4E | #define TARGET_PAGE_SIZE 0x1000 /* from old ld, 032 & 532 are really 512/4k */ |
38 | | |
39 | | /* Use a_entry of 0 to distinguish object files from OMAGIC executables */ |
40 | | #define N_TXTADDR(x) \ |
41 | 26.5k | (N_MAGIC(x) == OMAGIC ? \ |
42 | 26.5k | ((x)->a_entry < TEXT_START_ADDR? 0: TEXT_START_ADDR): \ |
43 | 26.5k | (N_MAGIC(x) == NMAGIC? TEXT_START_ADDR: \ |
44 | 21.2k | TEXT_START_ADDR + EXEC_BYTES_SIZE)) |
45 | | |
46 | | #define SEGMENT_SIZE TARGET_PAGE_SIZE |
47 | | |
48 | 28.3k | #define SEGMENT_SIZE TARGET_PAGE_SIZE |
49 | 8.86k | #define DEFAULT_ARCH bfd_arch_ns32k |
50 | | |
51 | | /* Do not "beautify" the CONCAT* macro args. Traditional C will not |
52 | | remove whitespace added here, and thus will fail to concatenate |
53 | | the tokens. */ |
54 | 8.86k | #define MY(OP) CONCAT2 (ns32k_aout_pc532mach_,OP) |
55 | | |
56 | | /* Must be the same as aout-ns32k.c */ |
57 | 17.7k | #define NAME(x,y) CONCAT3 (ns32kaout,_32_,y) |
58 | | |
59 | | #define TARGETNAME "a.out-pc532-mach" |
60 | | |
61 | | #include "sysdep.h" |
62 | | #include "bfd.h" |
63 | | #include "libaout.h" |
64 | | #include "libbfd.h" |
65 | | #include "aout/aout64.h" |
66 | | |
67 | | #define MY_bfd_reloc_type_lookup ns32k_aout_bfd_reloc_type_lookup |
68 | | |
69 | | /* libaout doesn't use NAME for these ... */ |
70 | | |
71 | | #define MY_get_section_contents aout_32_get_section_contents |
72 | | |
73 | | #define MY_text_includes_header 1 |
74 | | |
75 | | #define MY_exec_header_not_counted 1 |
76 | | |
77 | | reloc_howto_type *MY_bfd_reloc_type_lookup |
78 | | (bfd *abfd, bfd_reloc_code_real_type code); |
79 | | |
80 | | static bool |
81 | | MY(write_object_contents) (bfd *abfd) |
82 | 0 | { |
83 | 0 | struct external_exec exec_bytes; |
84 | 0 | struct internal_exec *execp = exec_hdr (abfd); |
85 | |
|
86 | 0 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; |
87 | |
|
88 | 0 | BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k); |
89 | 0 | switch (bfd_get_mach (abfd)) |
90 | 0 | { |
91 | 0 | case 32032: |
92 | 0 | N_SET_MACHTYPE (execp, M_NS32032); |
93 | 0 | break; |
94 | 0 | case 32532: |
95 | 0 | default: |
96 | 0 | N_SET_MACHTYPE (execp, M_NS32532); |
97 | 0 | break; |
98 | 0 | } |
99 | 0 | N_SET_FLAGS (execp, aout_backend_info (abfd)->exec_hdr_flags); |
100 | |
|
101 | 0 | WRITE_HEADERS (abfd, execp); |
102 | |
|
103 | 0 | return true; |
104 | 0 | } |
105 | | |
106 | | #define MY_write_object_contents MY(write_object_contents) |
107 | | |
108 | | #include "aout-target.h" |