]> Git Repo - binutils.git/blob - bfd/netbsd532.c
configure: Accept and ignore --cache*, for compat w/autoconf 2.
[binutils.git] / bfd / netbsd532.c
1 /* BFD back-end for NetBSD/532 a.out-ish binaries.
2    Copyright (C) 1990, 1991, 1992, 1994 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  * Created by Ian Dall
21  *            5-Jun-94
22  *
23  * Largely a copy of netbsd386.c plus some code from aout-pc532-mach.c
24  */
25
26 #define BYTES_IN_WORD   4
27
28 /* ZMAGIC files never include the header in the text.  */
29 #define N_HEADER_IN_TEXT(x)     1
30   
31 #define PAGE_SIZE       0x1000
32   
33   /* ZMAGIC files start at address 0.  This does not apply to QMAGIC.  */
34 #define TEXT_START_ADDR PAGE_SIZE
35 #define N_SHARED_LIB(x) 0
36   
37   /* Use a_entry of 0 to distinguish object files from OMAGIC executables */
38 #define N_TXTADDR(x) \
39   ((N_MAGIC(x) == OMAGIC) && \
40    ((x).a_entry < TEXT_START_ADDR) ? 0 :        /* object file or NMAGIC */\
41    N_SHARED_LIB(x) ? 0 :        \
42    N_HEADER_IN_TEXT(x)  ?       \
43    TEXT_START_ADDR + EXEC_BYTES_SIZE :  /* no padding */\
44    TEXT_START_ADDR                      /* a page of padding */\
45    )
46
47 #define SEGMENT_SIZE    PAGE_SIZE
48
49 #define DEFAULT_ARCH    bfd_arch_ns32k
50
51 #define MY(OP) CAT(netbsd532_,OP)
52 /* This needs to start with a.out so GDB knows it is an a.out variant.  */
53 #define TARGETNAME "a.out-netbsd-532"
54 #define MACHTYPE_OK(mtype) ((mtype) == M_532_NETBSD)
55
56 #define N_MAGIC(ex) \
57   ( (((ex).a_info)&0xffff0000) ? ((((ex).a_info))&0xffff) : ((ex).a_info))
58 #define N_MACHTYPE(ex) \
59   ( (((ex).a_info)&0xffff0000) ? (((((ex).a_info))>>16)&0x03ff) : 0 )
60 #define N_FLAGS(ex) \
61   ( (((ex).a_info)&0xffff0000) ? ((((ex).a_info)>>26)&0x3f) : 0 )
62 #define N_SET_INFO(ex, mag,mid,flag) \
63   ( (ex).a_info = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
64                         (((mag)&0xffff)) ) )
65 #define N_SET_MAGIC(exec,magic) \
66   ((exec).a_info = (((exec).a_info & ~0xffff) | ((magic) & 0xffff)))
67 #define N_SET_MACHTYPE(exec,machtype) \
68   ((exec).a_info = \
69    (((exec).a_info & ~(0x3ff<<16)) | (((machtype)&0xff) << 16)))
70 #define N_SET_FLAGS(exec, flags) \
71   ((exec).a_info = \
72    (((exec).a_info & ~(0x3f<<26)) | (((flags)&0x3f) << 26)))
73
74 #define N_MAG(MAG) ((MAG) == o_magic? OMAGIC: ((MAG) == z_magic? ZMAGIC: ((MAG) == n_magic? NMAGIC: 0)))
75
76 #define WRITE_HEADERS(abfd, execp) \
77 { \
78   bfd_size_type text_size; /* dummy vars */ \
79   int mag; \
80   file_ptr text_end; \
81   if (adata(abfd).magic == undecided_magic) \
82     NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
83   mag = adata(abfd).magic; \
84   N_SET_INFO(*execp, N_MAG(mag), M_532_NETBSD, aout_backend_info (abfd)->exec_hdr_flags); \
85    \
86   execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
87   execp->a_entry = bfd_get_start_address (abfd); \
88    \
89   execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
90                      obj_reloc_entry_size (abfd)); \
91   execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
92                      obj_reloc_entry_size (abfd)); \
93   NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
94    \
95   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
96   if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
97       != EXEC_BYTES_SIZE) \
98     return false; \
99   /* Now write out reloc info, followed by syms and strings */ \
100    \
101   if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
102       && bfd_get_symcount (abfd) != 0) \
103     { \
104       if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
105           != 0) \
106         return false; \
107        \
108       if (! NAME(aout,write_syms)(abfd)) return false; \
109        \
110       if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
111           != 0) \
112         return false; \
113        \
114       if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
115         return false; \
116       if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
117           != 0) \
118         return false; \
119        \
120       if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
121         return false; \
122     } \
123 }
124
125 #include "bfd.h"
126 #include "sysdep.h"
127 #include "libbfd.h"
128 #include "libaout.h"
129
130
131 /* On NetBSD, the magic number is always in ntohl's "network" (big-endian)
132    format.  */
133 #define SWAP_MAGIC(ext) bfd_getb32 (ext)
134
135 #include "aout/aout64.h"
136
137 /* Forward declaration. Defined in aout-target.h */
138
139 static boolean MY(set_sizes)();
140      
141 static CONST struct aout_backend_data MY(backend_data) = {
142   0,                            /* zmagic contiguous */
143   1,                            /* text incl header */
144   0,
145   0,                            /* text vma? */
146   MY(set_sizes),
147   0,                            /* exec header is counted */
148 };
149      
150 #define MY_backend_data &MY(backend_data)
151      
152 /* We can`t use the MYNS macro here for cpp reasons too subtle
153  * for me -- IWD
154  */
155 #define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
156      
157 /* libaout doesn't use NAME for these ... */
158 #define MY_get_section_contents aout_32_get_section_contents
159      
160 #define MYNSX(OP) CAT(ns32kaout_,OP)
161 CONST struct reloc_howto_struct *
162 MYNSX(bfd_reloc_type_lookup)
163   PARAMS((bfd *abfd AND
164           bfd_reloc_code_real_type code));
165
166 boolean
167 MYNSX(write_object_contents)
168   PARAMS((bfd *abfd));
169
170 static boolean
171 MY(write_object_contents) (abfd)
172      bfd *abfd;
173 {
174   struct external_exec exec_bytes;
175   struct internal_exec *execp = exec_hdr (abfd);
176   
177 #if CHOOSE_RELOC_SIZE
178   CHOOSE_RELOC_SIZE(abfd);
179 #else
180   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
181 #endif
182   
183   BFD_ASSERT(bfd_get_arch(abfd) == bfd_arch_ns32k);
184   BFD_ASSERT(bfd_get_mach(abfd) == 32532);
185   N_SET_MACHTYPE (*execp, M_532_NETBSD);
186   
187   N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
188   
189   WRITE_HEADERS(abfd, execp);
190   
191   return true;
192 }
193
194 #define MY_write_object_contents MY(write_object_contents)
195
196 #include "aout-target.h"
This page took 0.035096 seconds and 4 git commands to generate.