1 |
/* BFD back-end data structures for a.out (and similar) files. |
/* BFD back-end data structures for a.out (and similar) files. |
2 |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 |
2000, 2001 |
2000, 2001, 2002, 2003, 2004 |
4 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
5 |
Written by Cygnus Support. |
Written by Cygnus Support. |
6 |
|
|
7 |
This file is part of BFD, the Binary File Descriptor library. |
This file is part of BFD, the Binary File Descriptor library. |
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
10 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
11 |
the Free Software Foundation; either version 2 of the License, or |
the Free Software Foundation; either version 2 of the License, or |
12 |
(at your option) any later version. |
(at your option) any later version. |
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
GNU General Public License for more details. |
GNU General Public License for more details. |
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
20 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
21 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
22 |
|
|
23 |
#ifndef LIBAOUT_H |
#ifndef LIBAOUT_H |
24 |
#define LIBAOUT_H |
#define LIBAOUT_H |
29 |
|
|
30 |
#include "bfdlink.h" |
#include "bfdlink.h" |
31 |
|
|
32 |
/* Macros for accessing components in an aout header. Saves cluttering |
/* Macros for accessing components in an aout header. */ |
|
the source with (bfd_vma) and (bfd_byte *) casts. */ |
|
|
|
|
|
#define H_PUT_64(abfd, val, where) \ |
|
|
bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
|
|
|
|
|
#define H_PUT_32(abfd, val, where) \ |
|
|
bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
|
|
|
|
|
#define H_PUT_16(abfd, val, where) \ |
|
|
bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
|
33 |
|
|
34 |
|
#define H_PUT_64 bfd_h_put_64 |
35 |
|
#define H_PUT_32 bfd_h_put_32 |
36 |
|
#define H_PUT_16 bfd_h_put_16 |
37 |
#define H_PUT_8 bfd_h_put_8 |
#define H_PUT_8 bfd_h_put_8 |
38 |
|
#define H_PUT_S64 bfd_h_put_signed_64 |
39 |
#define H_PUT_S64(abfd, val, where) \ |
#define H_PUT_S32 bfd_h_put_signed_32 |
40 |
bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
#define H_PUT_S16 bfd_h_put_signed_16 |
|
|
|
|
#define H_PUT_S32(abfd, val, where) \ |
|
|
bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
|
|
|
|
|
#define H_PUT_S16(abfd, val, where) \ |
|
|
bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where)) |
|
|
|
|
41 |
#define H_PUT_S8 bfd_h_put_signed_8 |
#define H_PUT_S8 bfd_h_put_signed_8 |
42 |
|
#define H_GET_64 bfd_h_get_64 |
43 |
#define H_GET_64(abfd, where) \ |
#define H_GET_32 bfd_h_get_32 |
44 |
bfd_h_get_64 ((abfd), (bfd_byte *) (where)) |
#define H_GET_16 bfd_h_get_16 |
|
|
|
|
#define H_GET_32(abfd, where) \ |
|
|
bfd_h_get_32 ((abfd), (bfd_byte *) (where)) |
|
|
|
|
|
#define H_GET_16(abfd, where) \ |
|
|
bfd_h_get_16 ((abfd), (bfd_byte *) (where)) |
|
|
|
|
45 |
#define H_GET_8 bfd_h_get_8 |
#define H_GET_8 bfd_h_get_8 |
46 |
|
#define H_GET_S64 bfd_h_get_signed_64 |
47 |
#define H_GET_S64(abfd, where) \ |
#define H_GET_S32 bfd_h_get_signed_32 |
48 |
bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where)) |
#define H_GET_S16 bfd_h_get_signed_16 |
|
|
|
|
#define H_GET_S32(abfd, where) \ |
|
|
bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where)) |
|
|
|
|
|
#define H_GET_S16(abfd, where) \ |
|
|
bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where)) |
|
|
|
|
49 |
#define H_GET_S8 bfd_h_get_signed_8 |
#define H_GET_S8 bfd_h_get_signed_8 |
50 |
|
|
51 |
/* Parameterize the a.out code based on whether it is being built |
/* Parameterize the a.out code based on whether it is being built |
103 |
{ |
{ |
104 |
struct bfd_link_hash_entry root; |
struct bfd_link_hash_entry root; |
105 |
/* Whether this symbol has been written out. */ |
/* Whether this symbol has been written out. */ |
106 |
boolean written; |
bfd_boolean written; |
107 |
/* Symbol index in output file. */ |
/* Symbol index in output file. */ |
108 |
int indx; |
int indx; |
109 |
}; |
}; |
126 |
#define aout_link_hash_traverse(table, func, info) \ |
#define aout_link_hash_traverse(table, func, info) \ |
127 |
(bfd_link_hash_traverse \ |
(bfd_link_hash_traverse \ |
128 |
(&(table)->root, \ |
(&(table)->root, \ |
129 |
(boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ |
(bfd_boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ |
130 |
(info))) |
(info))) |
131 |
|
|
132 |
/* Get the a.out link hash table from the info structure. This is |
/* Get the a.out link hash table from the info structure. This is |
165 |
|
|
166 |
/* Callback for setting the page and segment sizes, if they can't be |
/* Callback for setting the page and segment sizes, if they can't be |
167 |
trivially determined from the architecture. */ |
trivially determined from the architecture. */ |
168 |
boolean (*set_sizes) |
bfd_boolean (*set_sizes) |
169 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
170 |
|
|
171 |
/* zmagic files only. For go32, the length of the exec header contributes |
/* zmagic files only. For go32, the length of the exec header contributes |
175 |
|
|
176 |
/* Callback from the add symbols phase of the linker code to handle |
/* Callback from the add symbols phase of the linker code to handle |
177 |
a dynamic object. */ |
a dynamic object. */ |
178 |
boolean (*add_dynamic_symbols) |
bfd_boolean (*add_dynamic_symbols) |
179 |
PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **, |
PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **, |
180 |
bfd_size_type *, char **)); |
bfd_size_type *, char **)); |
181 |
|
|
182 |
/* Callback from the add symbols phase of the linker code to handle |
/* Callback from the add symbols phase of the linker code to handle |
183 |
adding a single symbol to the global linker hash table. */ |
adding a single symbol to the global linker hash table. */ |
184 |
boolean (*add_one_symbol) |
bfd_boolean (*add_one_symbol) |
185 |
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, |
PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, |
186 |
asection *, bfd_vma, const char *, boolean, boolean, |
asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean, |
187 |
struct bfd_link_hash_entry **)); |
struct bfd_link_hash_entry **)); |
188 |
|
|
189 |
/* Called to handle linking a dynamic object. */ |
/* Called to handle linking a dynamic object. */ |
190 |
boolean (*link_dynamic_object) |
bfd_boolean (*link_dynamic_object) |
191 |
PARAMS ((struct bfd_link_info *, bfd *)); |
PARAMS ((struct bfd_link_info *, bfd *)); |
192 |
|
|
193 |
/* Called for each global symbol being written out by the linker. |
/* Called for each global symbol being written out by the linker. |
194 |
This should write out the dynamic symbol information. */ |
This should write out the dynamic symbol information. */ |
195 |
boolean (*write_dynamic_symbol) |
bfd_boolean (*write_dynamic_symbol) |
196 |
PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *)); |
PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *)); |
197 |
|
|
198 |
/* If this callback is not NULL, the linker calls it for each reloc. |
/* If this callback is not NULL, the linker calls it for each reloc. |
199 |
RELOC is a pointer to the unswapped reloc. If *SKIP is set to |
RELOC is a pointer to the unswapped reloc. If *SKIP is set to |
200 |
true, the reloc will be skipped. *RELOCATION may be changed to |
TRUE, the reloc will be skipped. *RELOCATION may be changed to |
201 |
change the effects of the relocation. */ |
change the effects of the relocation. */ |
202 |
boolean (*check_dynamic_reloc) |
bfd_boolean (*check_dynamic_reloc) |
203 |
PARAMS ((struct bfd_link_info *info, bfd *input_bfd, |
PARAMS ((struct bfd_link_info *info, bfd *input_bfd, |
204 |
asection *input_section, struct aout_link_hash_entry *h, |
asection *input_section, struct aout_link_hash_entry *h, |
205 |
PTR reloc, bfd_byte *contents, boolean *skip, |
PTR reloc, bfd_byte *contents, bfd_boolean *skip, |
206 |
bfd_vma *relocation)); |
bfd_vma *relocation)); |
207 |
|
|
208 |
/* Called at the end of a link to finish up any dynamic linking |
/* Called at the end of a link to finish up any dynamic linking |
209 |
information. */ |
information. */ |
210 |
boolean (*finish_dynamic_link) |
bfd_boolean (*finish_dynamic_link) |
211 |
PARAMS ((bfd *, struct bfd_link_info *)); |
PARAMS ((bfd *, struct bfd_link_info *)); |
212 |
}; |
}; |
213 |
#define aout_backend_info(abfd) \ |
#define aout_backend_info(abfd) \ |
221 |
|
|
222 |
struct internal_exec |
struct internal_exec |
223 |
{ |
{ |
224 |
long a_info; /* Magic number and flags, packed */ |
long a_info; /* Magic number and flags, packed. */ |
225 |
bfd_vma a_text; /* length of text, in bytes */ |
bfd_vma a_text; /* Length of text, in bytes. */ |
226 |
bfd_vma a_data; /* length of data, in bytes */ |
bfd_vma a_data; /* Length of data, in bytes. */ |
227 |
bfd_vma a_bss; /* length of uninitialized data area in mem */ |
bfd_vma a_bss; /* Length of uninitialized data area in mem. */ |
228 |
bfd_vma a_syms; /* length of symbol table data in file */ |
bfd_vma a_syms; /* Length of symbol table data in file. */ |
229 |
bfd_vma a_entry; /* start address */ |
bfd_vma a_entry; /* Start address. */ |
230 |
bfd_vma a_trsize; /* length of text's relocation info, in bytes */ |
bfd_vma a_trsize; /* Length of text's relocation info, in bytes. */ |
231 |
bfd_vma a_drsize; /* length of data's relocation info, in bytes */ |
bfd_vma a_drsize; /* Length of data's relocation info, in bytes. */ |
232 |
/* Added for i960 */ |
/* Added for i960 */ |
233 |
bfd_vma a_tload; /* Text runtime load address */ |
bfd_vma a_tload; /* Text runtime load address. */ |
234 |
bfd_vma a_dload; /* Data runtime load address */ |
bfd_vma a_dload; /* Data runtime load address. */ |
235 |
unsigned char a_talign; /* Alignment of text segment */ |
unsigned char a_talign; /* Alignment of text segment. */ |
236 |
unsigned char a_dalign; /* Alignment of data segment */ |
unsigned char a_dalign; /* Alignment of data segment. */ |
237 |
unsigned char a_balign; /* Alignment of bss segment */ |
unsigned char a_balign; /* Alignment of bss segment. */ |
238 |
char a_relaxable; /* Enough info for linker relax */ |
char a_relaxable; /* Enough info for linker relax. */ |
239 |
}; |
}; |
240 |
|
|
241 |
/* Magic number is written |
/* Magic number is written |
242 |
< MSB > |
< MSB > |
243 |
3130292827262524232221201918171615141312111009080706050403020100 |
3130292827262524232221201918171615141312111009080706050403020100 |
244 |
< FLAGS >< MACHINE TYPE >< MAGIC NUMBER > |
< FLAGS >< MACHINE TYPE >< MAGIC NUMBER > */ |
245 |
*/ |
|
246 |
/* Magic number for NetBSD is |
/* Magic number for NetBSD is |
247 |
<MSB > |
<MSB > |
248 |
3130292827262524232221201918171615141312111009080706050403020100 |
3130292827262524232221201918171615141312111009080706050403020100 |
249 |
< FLAGS >< MACHINE TYPE >< MAGIC NUMBER > |
< FLAGS >< MACHINE TYPE >< MAGIC NUMBER > */ |
|
*/ |
|
250 |
|
|
251 |
enum machine_type { |
enum machine_type |
252 |
|
{ |
253 |
M_UNKNOWN = 0, |
M_UNKNOWN = 0, |
254 |
M_68010 = 1, |
M_68010 = 1, |
255 |
M_68020 = 2, |
M_68020 = 2, |
256 |
M_SPARC = 3, |
M_SPARC = 3, |
257 |
/* skip a bunch so we don't run into any of suns numbers */ |
/* Skip a bunch so we don't run into any of SUN's numbers. */ |
258 |
/* make these up for the ns32k*/ |
/* Make these up for the ns32k. */ |
259 |
M_NS32032 = (64), /* ns32032 running ? */ |
M_NS32032 = (64), /* NS32032 running ? */ |
260 |
M_NS32532 = (64 + 5), /* ns32532 running mach */ |
M_NS32532 = (64 + 5), /* NS32532 running mach. */ |
|
|
|
261 |
M_386 = 100, |
M_386 = 100, |
262 |
M_29K = 101, /* AMD 29000 */ |
M_29K = 101, /* AMD 29000. */ |
263 |
M_386_DYNIX = 102, /* Sequent running dynix */ |
M_386_DYNIX = 102, /* Sequent running dynix. */ |
264 |
M_ARM = 103, /* Advanced Risc Machines ARM */ |
M_ARM = 103, /* Advanced Risc Machines ARM. */ |
265 |
M_SPARCLET = 131, /* SPARClet = M_SPARC + 128 */ |
M_SPARCLET = 131, /* SPARClet = M_SPARC + 128. */ |
266 |
M_386_NETBSD = 134, /* NetBSD/i386 binary */ |
M_386_NETBSD = 134, /* NetBSD/i386 binary. */ |
267 |
M_68K_NETBSD = 135, /* NetBSD/m68k binary */ |
M_68K_NETBSD = 135, /* NetBSD/m68k binary. */ |
268 |
M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary */ |
M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary. */ |
269 |
M_532_NETBSD = 137, /* NetBSD/ns32k binary */ |
M_532_NETBSD = 137, /* NetBSD/ns32k binary. */ |
270 |
M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */ |
M_SPARC_NETBSD = 138, /* NetBSD/sparc binary. */ |
271 |
M_PMAX_NETBSD = 139, /* NetBSD/pmax (MIPS little-endian) binary */ |
M_PMAX_NETBSD = 139, /* NetBSD/pmax (MIPS little-endian) binary. */ |
272 |
M_VAX_NETBSD = 140, /* NetBSD/vax binary */ |
M_VAX_NETBSD = 140, /* NetBSD/vax binary. */ |
273 |
M_ALPHA_NETBSD = 141, /* NetBSD/alpha binary */ |
M_ALPHA_NETBSD = 141, /* NetBSD/alpha binary. */ |
274 |
M_ARM6_NETBSD = 143, /* NetBSD/arm32 binary */ |
M_ARM6_NETBSD = 143, /* NetBSD/arm32 binary. */ |
275 |
M_SPARCLET_1 = 147, /* 0x93, reserved */ |
M_SPARCLET_1 = 147, /* 0x93, reserved. */ |
276 |
M_VAX4K_NETBSD = 150, /* NetBSD/vax 4K pages binary */ |
M_POWERPC_NETBSD = 149, /* NetBSD/powerpc (big-endian) binary. */ |
277 |
M_MIPS1 = 151, /* MIPS R2000/R3000 binary */ |
M_VAX4K_NETBSD = 150, /* NetBSD/vax 4K pages binary. */ |
278 |
M_MIPS2 = 152, /* MIPS R4000/R6000 binary */ |
M_MIPS1 = 151, /* MIPS R2000/R3000 binary. */ |
279 |
M_SPARCLET_2 = 163, /* 0xa3, reserved */ |
M_MIPS2 = 152, /* MIPS R4000/R6000 binary. */ |
280 |
M_SPARCLET_3 = 179, /* 0xb3, reserved */ |
M_88K_OPENBSD = 153, /* OpenBSD/m88k binary. */ |
281 |
M_SPARCLET_4 = 195, /* 0xc3, reserved */ |
M_HPPA_OPENBSD = 154, /* OpenBSD/hppa binary. */ |
282 |
M_HP200 = 200, /* HP 200 (68010) BSD binary */ |
M_SPARC64_NETBSD = 156, /* NetBSD/sparc64 binary. */ |
283 |
M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */ |
M_X86_64_NETBSD = 157, /* NetBSD/amd64 binary. */ |
284 |
M_HPUX = (0x20c % 256), /* HP 200/300 HPUX binary */ |
M_SPARCLET_2 = 163, /* 0xa3, reserved. */ |
285 |
M_SPARCLET_5 = 211, /* 0xd3, reserved */ |
M_SPARCLET_3 = 179, /* 0xb3, reserved. */ |
286 |
M_SPARCLET_6 = 227, /* 0xe3, reserved */ |
M_SPARCLET_4 = 195, /* 0xc3, reserved. */ |
287 |
/* M_SPARCLET_7 = 243 / * 0xf3, reserved */ |
M_HP200 = 200, /* HP 200 (68010) BSD binary. */ |
288 |
|
M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary. */ |
289 |
|
M_HPUX = (0x20c % 256), /* HP 200/300 HPUX binary. */ |
290 |
|
M_SPARCLET_5 = 211, /* 0xd3, reserved. */ |
291 |
|
M_SPARCLET_6 = 227, /* 0xe3, reserved. */ |
292 |
|
/*M_SPARCLET_7 = 243 / * 0xf3, reserved. */ |
293 |
M_SPARCLITE_LE = 243, |
M_SPARCLITE_LE = 243, |
294 |
M_CRIS = 255 /* Axis CRIS binary. */ |
M_CRIS = 255 /* Axis CRIS binary. */ |
295 |
}; |
}; |
296 |
|
|
297 |
#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000) |
#define N_DYNAMIC(exec) ((exec).a_info & 0x80000000) |
338 |
((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) |
((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) |
339 |
#endif |
#endif |
340 |
|
|
341 |
typedef struct aout_symbol { |
typedef struct aout_symbol |
342 |
|
{ |
343 |
asymbol symbol; |
asymbol symbol; |
344 |
short desc; |
short desc; |
345 |
char other; |
char other; |
350 |
Various things depend on this struct being around any time an a.out |
Various things depend on this struct being around any time an a.out |
351 |
file is being handled. An example is dbxread.c in GDB. */ |
file is being handled. An example is dbxread.c in GDB. */ |
352 |
|
|
353 |
struct aoutdata { |
struct aoutdata |
354 |
struct internal_exec *hdr; /* exec file header */ |
{ |
355 |
aout_symbol_type *symbols; /* symtab for input bfd */ |
struct internal_exec *hdr; /* Exec file header. */ |
356 |
|
aout_symbol_type *symbols; /* Symtab for input bfd. */ |
357 |
|
|
358 |
/* For ease, we do this */ |
/* For ease, we do this. */ |
359 |
asection *textsec; |
asection *textsec; |
360 |
asection *datasec; |
asection *datasec; |
361 |
asection *bsssec; |
asection *bsssec; |
365 |
file_ptr sym_filepos; |
file_ptr sym_filepos; |
366 |
file_ptr str_filepos; |
file_ptr str_filepos; |
367 |
|
|
368 |
/* Size of a relocation entry in external form */ |
/* Size of a relocation entry in external form. */ |
369 |
unsigned reloc_entry_size; |
unsigned reloc_entry_size; |
370 |
|
|
371 |
/* Size of a symbol table entry in external form */ |
/* Size of a symbol table entry in external form. */ |
372 |
unsigned symbol_entry_size; |
unsigned symbol_entry_size; |
373 |
|
|
374 |
/* Page size - needed for alignment of demand paged files. */ |
/* Page size - needed for alignment of demand paged files. */ |
375 |
unsigned long page_size; |
unsigned long page_size; |
376 |
|
|
377 |
/* Segment size - needed for alignment of demand paged files. */ |
/* Segment size - needed for alignment of demand paged files. */ |
378 |
unsigned long segment_size; |
unsigned long segment_size; |
379 |
|
|
380 |
/* Zmagic disk block size - need to align the start of the text |
/* Zmagic disk block size - need to align the start of the text |
384 |
unsigned exec_bytes_size; |
unsigned exec_bytes_size; |
385 |
unsigned vma_adjusted : 1; |
unsigned vma_adjusted : 1; |
386 |
|
|
387 |
/* used when a bfd supports several highly similar formats */ |
/* Used when a bfd supports several highly similar formats. */ |
388 |
enum |
enum |
389 |
{ |
{ |
390 |
default_format = 0, |
default_format = 0, |
423 |
bfd_vma *local_got_offsets; |
bfd_vma *local_got_offsets; |
424 |
}; |
}; |
425 |
|
|
426 |
struct aout_data_struct { |
struct aout_data_struct |
427 |
struct aoutdata a; |
{ |
428 |
struct internal_exec e; |
struct aoutdata a; |
429 |
|
struct internal_exec e; |
430 |
}; |
}; |
431 |
|
|
432 |
#define adata(bfd) ((bfd)->tdata.aout_data->a) |
#define adata(bfd) ((bfd)->tdata.aout_data->a) |
433 |
#define exec_hdr(bfd) (adata(bfd).hdr) |
#define exec_hdr(bfd) (adata (bfd).hdr) |
434 |
#define obj_aout_symbols(bfd) (adata(bfd).symbols) |
#define obj_aout_symbols(bfd) (adata (bfd).symbols) |
435 |
#define obj_textsec(bfd) (adata(bfd).textsec) |
#define obj_textsec(bfd) (adata (bfd).textsec) |
436 |
#define obj_datasec(bfd) (adata(bfd).datasec) |
#define obj_datasec(bfd) (adata (bfd).datasec) |
437 |
#define obj_bsssec(bfd) (adata(bfd).bsssec) |
#define obj_bsssec(bfd) (adata (bfd).bsssec) |
438 |
#define obj_sym_filepos(bfd) (adata(bfd).sym_filepos) |
#define obj_sym_filepos(bfd) (adata (bfd).sym_filepos) |
439 |
#define obj_str_filepos(bfd) (adata(bfd).str_filepos) |
#define obj_str_filepos(bfd) (adata (bfd).str_filepos) |
440 |
#define obj_reloc_entry_size(bfd) (adata(bfd).reloc_entry_size) |
#define obj_reloc_entry_size(bfd) (adata (bfd).reloc_entry_size) |
441 |
#define obj_symbol_entry_size(bfd) (adata(bfd).symbol_entry_size) |
#define obj_symbol_entry_size(bfd) (adata (bfd).symbol_entry_size) |
442 |
#define obj_aout_subformat(bfd) (adata(bfd).subformat) |
#define obj_aout_subformat(bfd) (adata (bfd).subformat) |
443 |
#define obj_aout_external_syms(bfd) (adata(bfd).external_syms) |
#define obj_aout_external_syms(bfd) (adata (bfd).external_syms) |
444 |
#define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count) |
#define obj_aout_external_sym_count(bfd) (adata (bfd).external_sym_count) |
445 |
#define obj_aout_sym_window(bfd) (adata(bfd).sym_window) |
#define obj_aout_sym_window(bfd) (adata (bfd).sym_window) |
446 |
#define obj_aout_external_strings(bfd) (adata(bfd).external_strings) |
#define obj_aout_external_strings(bfd) (adata (bfd).external_strings) |
447 |
#define obj_aout_external_string_size(bfd) (adata(bfd).external_string_size) |
#define obj_aout_external_string_size(bfd) (adata (bfd).external_string_size) |
448 |
#define obj_aout_string_window(bfd) (adata(bfd).string_window) |
#define obj_aout_string_window(bfd) (adata (bfd).string_window) |
449 |
#define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes) |
#define obj_aout_sym_hashes(bfd) (adata (bfd).sym_hashes) |
450 |
#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info) |
#define obj_aout_dynamic_info(bfd) (adata (bfd).dynamic_info) |
451 |
|
|
452 |
/* We take the address of the first element of an asymbol to ensure that the |
/* We take the address of the first element of an asymbol to ensure that the |
453 |
macro is only ever applied to an asymbol */ |
macro is only ever applied to an asymbol. */ |
454 |
#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd)) |
#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd)) |
455 |
|
|
456 |
/* Information we keep for each a.out section. This is currently only |
/* Information we keep for each a.out section. This is currently only |
468 |
#define set_aout_section_data(s,v) \ |
#define set_aout_section_data(s,v) \ |
469 |
((s)->used_by_bfd = (PTR)&(v)->relocs) |
((s)->used_by_bfd = (PTR)&(v)->relocs) |
470 |
|
|
471 |
/* Prototype declarations for functions defined in aoutx.h */ |
/* Prototype declarations for functions defined in aoutx.h. */ |
472 |
|
|
473 |
extern boolean NAME(aout,squirt_out_relocs) |
extern bfd_boolean NAME(aout,squirt_out_relocs) |
474 |
PARAMS ((bfd *, asection *)); |
PARAMS ((bfd *, asection *)); |
475 |
|
|
476 |
extern boolean NAME(aout,make_sections) |
extern bfd_boolean NAME(aout,make_sections) |
477 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
478 |
|
|
479 |
extern const bfd_target * NAME(aout,some_aout_object_p) |
extern const bfd_target * NAME(aout,some_aout_object_p) |
480 |
PARAMS ((bfd *, struct internal_exec *, const bfd_target *(*) (bfd *))); |
PARAMS ((bfd *, struct internal_exec *, const bfd_target *(*) (bfd *))); |
481 |
|
|
482 |
extern boolean NAME(aout,mkobject) |
extern bfd_boolean NAME(aout,mkobject) |
483 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
484 |
|
|
485 |
extern enum machine_type NAME(aout,machine_type) |
extern enum machine_type NAME(aout,machine_type) |
486 |
PARAMS ((enum bfd_architecture, unsigned long, boolean *)); |
PARAMS ((enum bfd_architecture, unsigned long, bfd_boolean *)); |
487 |
|
|
488 |
extern boolean NAME(aout,set_arch_mach) |
extern bfd_boolean NAME(aout,set_arch_mach) |
489 |
PARAMS ((bfd *, enum bfd_architecture, unsigned long)); |
PARAMS ((bfd *, enum bfd_architecture, unsigned long)); |
490 |
|
|
491 |
extern boolean NAME(aout,new_section_hook) |
extern bfd_boolean NAME(aout,new_section_hook) |
492 |
PARAMS ((bfd *, asection *)); |
PARAMS ((bfd *, asection *)); |
493 |
|
|
494 |
extern boolean NAME(aout,set_section_contents) |
extern bfd_boolean NAME(aout,set_section_contents) |
495 |
PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); |
PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type)); |
496 |
|
|
497 |
extern asymbol * NAME(aout,make_empty_symbol) |
extern asymbol * NAME(aout,make_empty_symbol) |
498 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
499 |
|
|
500 |
extern boolean NAME(aout,translate_symbol_table) |
extern bfd_boolean NAME(aout,translate_symbol_table) |
501 |
PARAMS ((bfd *, aout_symbol_type *, struct external_nlist *, bfd_size_type, |
PARAMS ((bfd *, aout_symbol_type *, struct external_nlist *, bfd_size_type, |
502 |
char *, bfd_size_type, boolean)); |
char *, bfd_size_type, bfd_boolean)); |
503 |
|
|
504 |
extern boolean NAME(aout,slurp_symbol_table) |
extern bfd_boolean NAME(aout,slurp_symbol_table) |
505 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
506 |
|
|
507 |
extern boolean NAME(aout,write_syms) |
extern bfd_boolean NAME(aout,write_syms) |
508 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
509 |
|
|
510 |
extern void NAME(aout,reclaim_symbol_table) |
extern void NAME(aout,reclaim_symbol_table) |
513 |
extern long NAME(aout,get_symtab_upper_bound) |
extern long NAME(aout,get_symtab_upper_bound) |
514 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
515 |
|
|
516 |
extern long NAME(aout,get_symtab) |
extern long NAME(aout,canonicalize_symtab) |
517 |
PARAMS ((bfd *, asymbol **)); |
PARAMS ((bfd *, asymbol **)); |
518 |
|
|
519 |
extern void NAME(aout,swap_ext_reloc_in) |
extern void NAME(aout,swap_ext_reloc_in) |
526 |
extern reloc_howto_type * NAME(aout,reloc_type_lookup) |
extern reloc_howto_type * NAME(aout,reloc_type_lookup) |
527 |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
PARAMS ((bfd *, bfd_reloc_code_real_type)); |
528 |
|
|
529 |
extern boolean NAME(aout,slurp_reloc_table) |
extern bfd_boolean NAME(aout,slurp_reloc_table) |
530 |
PARAMS ((bfd *, sec_ptr, asymbol **)); |
PARAMS ((bfd *, sec_ptr, asymbol **)); |
531 |
|
|
532 |
extern long NAME(aout,canonicalize_reloc) |
extern long NAME(aout,canonicalize_reloc) |
547 |
extern void NAME(aout,get_symbol_info) |
extern void NAME(aout,get_symbol_info) |
548 |
PARAMS ((bfd *, asymbol *, symbol_info *)); |
PARAMS ((bfd *, asymbol *, symbol_info *)); |
549 |
|
|
550 |
extern boolean NAME(aout,find_nearest_line) |
extern bfd_boolean NAME(aout,find_nearest_line) |
551 |
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, |
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, |
552 |
const char **, unsigned int *)); |
const char **, unsigned int *)); |
553 |
|
|
554 |
extern long NAME(aout,read_minisymbols) |
extern long NAME(aout,read_minisymbols) |
555 |
PARAMS ((bfd *, boolean, PTR *, unsigned int *)); |
PARAMS ((bfd *, bfd_boolean, PTR *, unsigned int *)); |
556 |
|
|
557 |
extern asymbol * NAME(aout,minisymbol_to_symbol) |
extern asymbol * NAME(aout,minisymbol_to_symbol) |
558 |
PARAMS ((bfd *, boolean, const PTR, asymbol *)); |
PARAMS ((bfd *, bfd_boolean, const PTR, asymbol *)); |
559 |
|
|
560 |
extern int NAME(aout,sizeof_headers) |
extern int NAME(aout,sizeof_headers) |
561 |
PARAMS ((bfd *, boolean)); |
PARAMS ((bfd *, bfd_boolean)); |
562 |
|
|
563 |
extern boolean NAME(aout,adjust_sizes_and_vmas) |
extern bfd_boolean NAME(aout,adjust_sizes_and_vmas) |
564 |
PARAMS ((bfd *, bfd_size_type *, file_ptr *)); |
PARAMS ((bfd *, bfd_size_type *, file_ptr *)); |
565 |
|
|
566 |
extern void NAME(aout,swap_exec_header_in) |
extern void NAME(aout,swap_exec_header_in) |
572 |
extern struct bfd_hash_entry * NAME(aout,link_hash_newfunc) |
extern struct bfd_hash_entry * NAME(aout,link_hash_newfunc) |
573 |
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); |
574 |
|
|
575 |
extern boolean NAME(aout,link_hash_table_init) |
extern bfd_boolean NAME(aout,link_hash_table_init) |
576 |
PARAMS ((struct aout_link_hash_table *, bfd *, |
PARAMS ((struct aout_link_hash_table *, bfd *, |
577 |
struct bfd_hash_entry *(*) (struct bfd_hash_entry *, |
struct bfd_hash_entry *(*) (struct bfd_hash_entry *, |
578 |
struct bfd_hash_table *, |
struct bfd_hash_table *, |
581 |
extern struct bfd_link_hash_table * NAME(aout,link_hash_table_create) |
extern struct bfd_link_hash_table * NAME(aout,link_hash_table_create) |
582 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
583 |
|
|
584 |
extern boolean NAME(aout,link_add_symbols) |
extern bfd_boolean NAME(aout,link_add_symbols) |
585 |
PARAMS ((bfd *, struct bfd_link_info *)); |
PARAMS ((bfd *, struct bfd_link_info *)); |
586 |
|
|
587 |
extern boolean NAME(aout,final_link) |
extern bfd_boolean NAME(aout,final_link) |
588 |
PARAMS ((bfd *, struct bfd_link_info *, |
PARAMS ((bfd *, struct bfd_link_info *, |
589 |
void (*) (bfd *, file_ptr *, file_ptr *, file_ptr *))); |
void (*) (bfd *, file_ptr *, file_ptr *, file_ptr *))); |
590 |
|
|
591 |
extern boolean NAME(aout,bfd_free_cached_info) |
extern bfd_boolean NAME(aout,bfd_free_cached_info) |
592 |
PARAMS ((bfd *)); |
PARAMS ((bfd *)); |
593 |
|
|
594 |
/* A.out uses the generic versions of these routines... */ |
/* A.out uses the generic versions of these routines... */ |
595 |
|
|
596 |
#define aout_16_get_section_contents _bfd_generic_get_section_contents |
#define aout_16_get_section_contents _bfd_generic_get_section_contents |
597 |
|
|
606 |
#define aout_32_bfd_is_local_label_name bfd_generic_is_local_label_name |
#define aout_32_bfd_is_local_label_name bfd_generic_is_local_label_name |
607 |
#endif |
#endif |
608 |
|
|
609 |
|
#ifndef aout_32_bfd_is_target_special_symbol |
610 |
|
#define aout_32_bfd_is_target_special_symbol \ |
611 |
|
((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) |
612 |
|
#endif |
613 |
|
|
614 |
#ifndef WRITE_HEADERS |
#ifndef WRITE_HEADERS |
615 |
#define WRITE_HEADERS(abfd, execp) \ |
#define WRITE_HEADERS(abfd, execp) \ |
616 |
{ \ |
{ \ |
617 |
bfd_size_type text_size; /* dummy vars */ \ |
bfd_size_type text_size; /* Dummy vars. */ \ |
618 |
file_ptr text_end; \ |
file_ptr text_end; \ |
619 |
if (adata(abfd).magic == undecided_magic) \ |
if (adata(abfd).magic == undecided_magic) \ |
620 |
NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \ |
NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \ |
629 |
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ |
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ |
630 |
\ |
\ |
631 |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \ |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \ |
632 |
|| bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \ |
|| bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE,\ |
633 |
abfd) != EXEC_BYTES_SIZE) \ |
abfd) != EXEC_BYTES_SIZE) \ |
634 |
return false; \ |
return FALSE; \ |
635 |
/* Now write out reloc info, followed by syms and strings */ \ |
/* Now write out reloc info, followed by syms and strings. */ \ |
636 |
\ |
\ |
637 |
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \ |
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \ |
638 |
&& bfd_get_symcount (abfd) != 0) \ |
&& bfd_get_symcount (abfd) != 0) \ |
639 |
{ \ |
{ \ |
640 |
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)\ |
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)\ |
641 |
return false; \ |
return FALSE; \ |
642 |
\ |
\ |
643 |
if (! NAME(aout,write_syms) (abfd)) \ |
if (! NAME(aout,write_syms) (abfd)) \ |
644 |
return false; \ |
return FALSE; \ |
645 |
} \ |
} \ |
646 |
\ |
\ |
647 |
if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0) \ |
if (bfd_seek (abfd, (file_ptr) (N_TRELOFF (*execp)), SEEK_SET) != 0) \ |
648 |
return false; \ |
return FALSE; \ |
649 |
if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \ |
if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \ |
650 |
return false; \ |
return FALSE; \ |
651 |
\ |
\ |
652 |
if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0) \ |
if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp)), SEEK_SET) != 0) \ |
653 |
return false; \ |
return FALSE; \ |
654 |
if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \ |
if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \ |
655 |
return false; \ |
return FALSE; \ |
656 |
} |
} |
657 |
#endif |
#endif |
658 |
|
|
659 |
|
/* Test if a read-only section can be merged with .text. This is |
660 |
|
possible if: |
661 |
|
|
662 |
|
1. Section has file contents and is read-only. |
663 |
|
2. The VMA of the section is after the end of .text and before |
664 |
|
the start of .data. |
665 |
|
3. The image is demand-pageable (otherwise, a_text in the header |
666 |
|
will not reflect the gap between .text and .data). */ |
667 |
|
|
668 |
|
#define aout_section_merge_with_text_p(abfd, sec) \ |
669 |
|
(((sec)->flags & (SEC_HAS_CONTENTS | SEC_READONLY)) == \ |
670 |
|
(SEC_HAS_CONTENTS | SEC_READONLY) \ |
671 |
|
&& obj_textsec (abfd) != NULL \ |
672 |
|
&& obj_datasec (abfd) != NULL \ |
673 |
|
&& (sec)->vma >= (obj_textsec (abfd)->vma + \ |
674 |
|
obj_textsec (abfd)->size) \ |
675 |
|
&& ((sec)->vma + (sec)->size) <= obj_datasec (abfd)->vma \ |
676 |
|
&& ((abfd)->flags & D_PAGED) != 0) |
677 |
|
|
678 |
#endif /* ! defined (LIBAOUT_H) */ |
#endif /* ! defined (LIBAOUT_H) */ |