1 |
330 |
jeremybenn |
/* BFD back-end for Mach3/532 a.out-ish binaries.
|
2 |
|
|
Copyright 1990, 1991, 1992, 1994, 1995, 2000, 2001, 2002, 2005, 2007, 2009
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify
|
8 |
|
|
it under the terms of the GNU General Public License as published by
|
9 |
|
|
the Free Software Foundation; either version 3 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful,
|
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
GNU General Public License for more details.
|
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License
|
18 |
|
|
along with this program; if not, write to the Free Software
|
19 |
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
20 |
|
|
MA 02110-1301, USA. */
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
/* Written by Ian Dall
|
24 |
|
|
19-Apr-94
|
25 |
|
|
|
26 |
|
|
Formerly part of aout-pc532-mach.c. Split out to allow more
|
27 |
|
|
flexibility with multiple formats. */
|
28 |
|
|
|
29 |
|
|
/* This architecture has N_TXTOFF and N_TXTADDR defined as if
|
30 |
|
|
N_HEADER_IN_TEXT, but the a_text entry (text size) does not include the
|
31 |
|
|
space for the header. So we have N_HEADER_IN_TEXT defined to
|
32 |
|
|
1 and specially define our own N_TXTSIZE. */
|
33 |
|
|
|
34 |
|
|
#define N_HEADER_IN_TEXT(x) 1
|
35 |
|
|
#define N_TXTSIZE(x) ((x).a_text)
|
36 |
|
|
|
37 |
|
|
#define TEXT_START_ADDR 0x10000 /* from old ld */
|
38 |
|
|
#define TARGET_PAGE_SIZE 0x1000 /* from old ld, 032 & 532 are really 512/4k */
|
39 |
|
|
|
40 |
|
|
/* Use a_entry of 0 to distinguish object files from OMAGIC executables */
|
41 |
|
|
#define N_TXTADDR(x) \
|
42 |
|
|
(N_MAGIC(x) == OMAGIC ? \
|
43 |
|
|
((x).a_entry < TEXT_START_ADDR? 0: TEXT_START_ADDR): \
|
44 |
|
|
(N_MAGIC(x) == NMAGIC? TEXT_START_ADDR: \
|
45 |
|
|
TEXT_START_ADDR + EXEC_BYTES_SIZE))
|
46 |
|
|
|
47 |
|
|
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
48 |
|
|
|
49 |
|
|
#define SEGMENT_SIZE TARGET_PAGE_SIZE
|
50 |
|
|
#define DEFAULT_ARCH bfd_arch_ns32k
|
51 |
|
|
|
52 |
|
|
/* Do not "beautify" the CONCAT* macro args. Traditional C will not
|
53 |
|
|
remove whitespace added here, and thus will fail to concatenate
|
54 |
|
|
the tokens. */
|
55 |
|
|
#define MY(OP) CONCAT2 (pc532machaout_,OP)
|
56 |
|
|
|
57 |
|
|
/* Must be the same as aout-ns32k.c */
|
58 |
|
|
#define NAME(x,y) CONCAT3 (ns32kaout,_32_,y)
|
59 |
|
|
|
60 |
|
|
#define TARGETNAME "a.out-pc532-mach"
|
61 |
|
|
|
62 |
|
|
#include "sysdep.h"
|
63 |
|
|
#include "bfd.h"
|
64 |
|
|
#include "libaout.h"
|
65 |
|
|
#include "libbfd.h"
|
66 |
|
|
#include "aout/aout64.h"
|
67 |
|
|
|
68 |
|
|
#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
|
69 |
|
|
|
70 |
|
|
/* libaout doesn't use NAME for these ... */
|
71 |
|
|
|
72 |
|
|
#define MY_get_section_contents aout_32_get_section_contents
|
73 |
|
|
|
74 |
|
|
#define MY_text_includes_header 1
|
75 |
|
|
|
76 |
|
|
#define MY_exec_header_not_counted 1
|
77 |
|
|
|
78 |
|
|
reloc_howto_type *ns32kaout_bfd_reloc_type_lookup
|
79 |
|
|
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
|
80 |
|
|
|
81 |
|
|
static bfd_boolean MY(write_object_contents)
|
82 |
|
|
PARAMS ((bfd *abfd));
|
83 |
|
|
|
84 |
|
|
static bfd_boolean
|
85 |
|
|
MY(write_object_contents) (abfd)
|
86 |
|
|
bfd *abfd;
|
87 |
|
|
{
|
88 |
|
|
struct external_exec exec_bytes;
|
89 |
|
|
struct internal_exec *execp = exec_hdr (abfd);
|
90 |
|
|
|
91 |
|
|
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
|
92 |
|
|
|
93 |
|
|
BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_ns32k);
|
94 |
|
|
switch (bfd_get_mach (abfd))
|
95 |
|
|
{
|
96 |
|
|
case 32032:
|
97 |
|
|
N_SET_MACHTYPE (*execp, M_NS32032);
|
98 |
|
|
break;
|
99 |
|
|
case 32532:
|
100 |
|
|
default:
|
101 |
|
|
N_SET_MACHTYPE (*execp, M_NS32532);
|
102 |
|
|
break;
|
103 |
|
|
}
|
104 |
|
|
N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
|
105 |
|
|
|
106 |
|
|
WRITE_HEADERS(abfd, execp);
|
107 |
|
|
|
108 |
|
|
return TRUE;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
#define MY_write_object_contents MY(write_object_contents)
|
112 |
|
|
|
113 |
|
|
#include "aout-target.h"
|