]>
Commit | Line | Data |
---|---|---|
05c81f45 SEF |
1 | /* BFD back-end for NetBSD/386 a.out-ish binaries. |
2 | Copyright (C) 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #define BYTES_IN_WORD 4 | |
21 | #define ARCH 32 | |
22 | ||
23 | /* ZMAGIC files never have the header in the text. */ | |
24 | #define N_HEADER_IN_TEXT(x) 0 | |
25 | ||
26 | /* ZMAGIC files start at address 0. This does not apply to QMAGIC. */ | |
27 | #define TEXT_START_ADDR 0 | |
14aa9a78 | 28 | #define N_SHARED_LIB(x) 0 |
05c81f45 SEF |
29 | |
30 | #define PAGE_SIZE 4096 | |
31 | #define SEGMENT_SIZE PAGE_SIZE | |
32 | ||
33 | #define DEFAULT_ARCH bfd_arch_i386 | |
f6fcc082 | 34 | #define MACHTYPE_OK(mtype) ((mtype) == M_386 || (mtype) == M_386_NETBSD || (mtype) == M_UNKNOWN) |
05c81f45 SEF |
35 | |
36 | #define MY(OP) CAT(netbsd386_,OP) | |
c28096f3 JK |
37 | /* This needs to start with a.out so GDB knows it is an a.out variant. */ |
38 | #define TARGETNAME "a.out-netbsd-386" | |
05c81f45 SEF |
39 | |
40 | #define N_MAGIC(ex) \ | |
3f99570e | 41 | ( (((ex).a_info)&0xffff0000) ? ((((ex).a_info))&0xffff) : ((ex).a_info)) |
05c81f45 | 42 | #define N_MACHTYPE(ex) \ |
3f99570e | 43 | ( (((ex).a_info)&0xffff0000) ? (((((ex).a_info))>>16)&0x03ff) : 0 ) |
05c81f45 | 44 | # define N_FLAGS(ex) \ |
3f99570e | 45 | ( (((ex).a_info)&0xffff0000) ? ((((ex).a_info)>>26)&0x3f) : 0 ) |
05c81f45 SEF |
46 | #define N_SET_INFO(ex, mag,mid,flag) \ |
47 | ( (ex).a_info = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \ | |
48 | (((mag)&0xffff)) ) ) | |
49 | #define N_SET_MAGIC(exec,magic) \ | |
50 | ((exec).a_info = (((exec).a_info & ~0xffff) | ((magic) & 0xffff))) | |
51 | #define N_SET_MACHTYPE(exec,machtype) \ | |
52 | ((exec).a_info = \ | |
53 | (((exec).a_info & ~(0x3ff<<16)) | (((machtype)&0xff) << 16))) | |
ae6710bc DM |
54 | #define N_SET_FLAGS(exec, flags) \ |
55 | ((exec).a_info = \ | |
56 | (((exec).a_info & ~(0x3f<<26)) | (((flags)&0x3f) << 26))) | |
05c81f45 SEF |
57 | |
58 | #include "bfd.h" | |
59 | #include "sysdep.h" | |
60 | #include "libbfd.h" | |
61 | #include "libaout.h" | |
62 | ||
63 | #define N_GETMAGIC2(ex) \ | |
3f99570e | 64 | ( (((ex).a_info)&0xffff0000) ? ((((ex).a_info))&0xffff) : \ |
05c81f45 SEF |
65 | (((ex).a_info) | 0x10000) ) |
66 | ||
67 | #define N_TXTADDR(ex) (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 : 4096) | |
68 | #define N_TXTOFF(ex) \ | |
69 | ( N_GETMAGIC2(ex)==ZMAGIC || N_GETMAGIC2(ex)==(QMAGIC|0x10000) ? \ | |
70 | 0 : (N_GETMAGIC2(ex)==(ZMAGIC|0x10000) ? 4096 : EXEC_BYTES_SIZE )) | |
71 | #define N_ALIGN(ex,x) \ | |
72 | (N_MAGIC(ex) == ZMAGIC || N_MAGIC(ex) == QMAGIC ? \ | |
73 | ((x) + 4096 - 1) & ~(4096 - 1) : (x)) | |
74 | #define N_DATADDR(ex) \ | |
75 | N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text) | |
76 | /* Data segment offset. */ | |
77 | #define N_DATOFF(ex) \ | |
78 | N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text) | |
79 | ||
80 | /* #define N_BADMAG(x) n_badmag(N_MAGIC(x)) */ | |
81 | ||
3f99570e JK |
82 | /* On NetBSD, the magic number is always in ntohl's "network" (big-endian) |
83 | format. */ | |
84 | #define SWAP_MAGIC(ext) bfd_getb32 (ext) | |
05c81f45 SEF |
85 | |
86 | #include "aout-target.h" | |
87 | ||
88 | #if 0 | |
89 | int | |
90 | n_badmag(x) | |
91 | unsigned long x; { | |
92 | union { | |
93 | unsigned long l; | |
94 | unsigned char c[sizeof(unsigned long)]; | |
95 | } l; | |
96 | unsigned char temp; | |
97 | ||
98 | printf ("x = %o, OMAGIC = %o, NMAGIC = %o, ZMAGIC = %o, QMAGIC = %o\n", | |
99 | x, OMAGIC, NMAGIC, ZMAGIC, QMAGIC); | |
100 | ||
101 | l.l = x; | |
102 | temp = l.c[0]; | |
103 | l.c[0] = l.c[3]; | |
104 | l.c[3] = temp; | |
105 | temp = l.c[2]; | |
106 | l.c[2] = l.c[1]; | |
107 | l.c[1] = temp; | |
108 | printf ("\tbyte-swapped(x) = %o\n", l.l); | |
109 | ||
110 | return (x != OMAGIC | |
111 | && x != NMAGIC | |
112 | && x != ZMAGIC | |
113 | && x != QMAGIC); | |
114 | } | |
115 | #endif | |
116 |