* bfd.c (struct bfd_preserve): New.
(bfd_preserve_save): New function. (bfd_preserve_restore): Ditto. (bfd_preserve_finish): Ditto. * bfd-in2.h: Regenerate. * mach-o.c: Formatting. (bfd_mach_o_scan_read_symtab_symbol): Make "value" unsigned. (bfd_mach_o_object_p): Use bfd_preserve_save/restore/finish. (bfd_mach_o_core_p): Ditto. (bfd_mach_o_scan): Pass in mdata. * mach-o.h (bfd_mach_o_scan): Update prototype. * pef.c: Formatting. (bfd_pef_object_p): Use bfd_preserve_save/restore/finish. (bfd_pef_xlib_object_p): Ditto. (bfd_pef_scan): Pass in mdata. Move version check to bfd_pef_object_p. * pef.h (bfd_pef_scan): Update prototype. * xsym.c: Formatting, K&R fixes. (bfd_sym_object_p): Use bfd_preserve_save/restore/finish. (bfd_sym_scan): New function split out from bfd_sym_object_p. * xsym.h (bfd_sym_scan): Declare. * elfcode.h (elf_object_p): Use bfd_preserve_save/restore/finish. (elf_core_file_p): Likewise. * targets.c (_bfd_target_vector): Revert 2002-11-08 change.
This commit is contained in:
parent
c4c4121963
commit
e84d6fca26
11 changed files with 1068 additions and 753 deletions
|
@ -1,3 +1,30 @@
|
|||
2002-11-13 Klee Dienes <kdienes@apple.com>
|
||||
Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* bfd.c (struct bfd_preserve): New.
|
||||
(bfd_preserve_save): New function.
|
||||
(bfd_preserve_restore): Ditto.
|
||||
(bfd_preserve_finish): Ditto.
|
||||
* bfd-in2.h: Regenerate.
|
||||
* mach-o.c: Formatting.
|
||||
(bfd_mach_o_scan_read_symtab_symbol): Make "value" unsigned.
|
||||
(bfd_mach_o_object_p): Use bfd_preserve_save/restore/finish.
|
||||
(bfd_mach_o_core_p): Ditto.
|
||||
(bfd_mach_o_scan): Pass in mdata.
|
||||
* mach-o.h (bfd_mach_o_scan): Update prototype.
|
||||
* pef.c: Formatting.
|
||||
(bfd_pef_object_p): Use bfd_preserve_save/restore/finish.
|
||||
(bfd_pef_xlib_object_p): Ditto.
|
||||
(bfd_pef_scan): Pass in mdata. Move version check to bfd_pef_object_p.
|
||||
* pef.h (bfd_pef_scan): Update prototype.
|
||||
* xsym.c: Formatting, K&R fixes.
|
||||
(bfd_sym_object_p): Use bfd_preserve_save/restore/finish.
|
||||
(bfd_sym_scan): New function split out from bfd_sym_object_p.
|
||||
* xsym.h (bfd_sym_scan): Declare.
|
||||
* elfcode.h (elf_object_p): Use bfd_preserve_save/restore/finish.
|
||||
(elf_core_file_p): Likewise.
|
||||
* targets.c (_bfd_target_vector): Revert 2002-11-08 change.
|
||||
|
||||
2002-11-12 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* po/da.po: Updated Danish translation.
|
||||
|
|
|
@ -3739,6 +3739,27 @@ extern bfd_byte *bfd_get_relocated_section_contents
|
|||
boolean
|
||||
bfd_alt_mach_code PARAMS ((bfd *abfd, int alternative));
|
||||
|
||||
struct bfd_preserve
|
||||
{
|
||||
PTR marker;
|
||||
PTR tdata;
|
||||
flagword flags;
|
||||
const struct bfd_arch_info *arch_info;
|
||||
struct sec *sections;
|
||||
struct sec **section_tail;
|
||||
unsigned int section_count;
|
||||
struct bfd_hash_table section_htab;
|
||||
};
|
||||
|
||||
boolean
|
||||
bfd_preserve_save PARAMS ((bfd *, struct bfd_preserve *));
|
||||
|
||||
void
|
||||
bfd_preserve_restore PARAMS ((bfd *, struct bfd_preserve *));
|
||||
|
||||
void
|
||||
bfd_preserve_finish PARAMS ((bfd *, struct bfd_preserve *));
|
||||
|
||||
/* Extracted from archive.c. */
|
||||
symindex
|
||||
bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
|
||||
|
|
130
bfd/bfd.c
130
bfd/bfd.c
|
@ -1392,3 +1392,133 @@ bfd_alt_mach_code (abfd, alternative)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
CODE_FRAGMENT
|
||||
|
||||
.struct bfd_preserve
|
||||
.{
|
||||
. PTR marker;
|
||||
. PTR tdata;
|
||||
. flagword flags;
|
||||
. const struct bfd_arch_info *arch_info;
|
||||
. struct sec *sections;
|
||||
. struct sec **section_tail;
|
||||
. unsigned int section_count;
|
||||
. struct bfd_hash_table section_htab;
|
||||
.};
|
||||
.
|
||||
*/
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_preserve_save
|
||||
|
||||
SYNOPSIS
|
||||
boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
|
||||
|
||||
DESCRIPTION
|
||||
When testing an object for compatibility with a particular
|
||||
target back-end, the back-end object_p function needs to set
|
||||
up certain fields in the bfd on successfully recognizing the
|
||||
object. This typically happens in a piecemeal fashion, with
|
||||
failures possible at many points. On failure, the bfd is
|
||||
supposed to be restored to its initial state, which is
|
||||
virtually impossible. However, restoring a subset of the bfd
|
||||
state works in practice. This function stores the subset and
|
||||
reinitializes the bfd.
|
||||
|
||||
*/
|
||||
|
||||
boolean
|
||||
bfd_preserve_save (abfd, preserve)
|
||||
bfd *abfd;
|
||||
struct bfd_preserve *preserve;
|
||||
{
|
||||
preserve->tdata = abfd->tdata.any;
|
||||
preserve->arch_info = abfd->arch_info;
|
||||
preserve->flags = abfd->flags;
|
||||
|
||||
preserve->sections = abfd->sections;
|
||||
preserve->section_tail = abfd->section_tail;
|
||||
preserve->section_count = abfd->section_count;
|
||||
preserve->section_htab = abfd->section_htab;
|
||||
|
||||
if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
|
||||
return false;
|
||||
|
||||
abfd->tdata.any = NULL;
|
||||
abfd->arch_info = &bfd_default_arch_struct;
|
||||
abfd->flags = 0;
|
||||
|
||||
abfd->sections = NULL;
|
||||
abfd->section_tail = &abfd->sections;
|
||||
abfd->section_count = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_preserve_restore
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_preserve_restore (bfd *, struct bfd_preserve *);
|
||||
|
||||
DESCRIPTION
|
||||
This function restores bfd state saved by bfd_preserve_save.
|
||||
If MARKER is non-NULL in struct bfd_preserve then that block
|
||||
and all subsequently bfd_alloc'd memory is freed.
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_preserve_restore (abfd, preserve)
|
||||
bfd *abfd;
|
||||
struct bfd_preserve *preserve;
|
||||
{
|
||||
bfd_hash_table_free (&abfd->section_htab);
|
||||
|
||||
abfd->tdata.any = preserve->tdata;
|
||||
abfd->arch_info = preserve->arch_info;
|
||||
abfd->flags = preserve->flags;
|
||||
|
||||
abfd->section_htab = preserve->section_htab;
|
||||
abfd->sections = preserve->sections;
|
||||
abfd->section_tail = preserve->section_tail;
|
||||
abfd->section_count = preserve->section_count;
|
||||
|
||||
/* bfd_release frees all memory more recently bfd_alloc'd than
|
||||
its arg, as well as its arg. */
|
||||
if (preserve->marker != NULL)
|
||||
{
|
||||
bfd_release (abfd, preserve->marker);
|
||||
preserve->marker = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
bfd_preserve_finish
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_preserve_finish (bfd *, struct bfd_preserve *);
|
||||
|
||||
DESCRIPTION
|
||||
This function should be called when the bfd state saved by
|
||||
bfd_preserve_save is no longer needed. ie. when the back-end
|
||||
object_p function returns with success.
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
bfd_preserve_finish (abfd, preserve)
|
||||
bfd *abfd ATTRIBUTE_UNUSED;
|
||||
struct bfd_preserve *preserve;
|
||||
{
|
||||
/* It would be nice to be able to free more memory here, eg. old
|
||||
tdata, but that's not possible since these blocks are sitting
|
||||
inside bfd_alloc'd memory. The section hash is on a separate
|
||||
objalloc. */
|
||||
bfd_hash_table_free (&preserve->section_htab);
|
||||
}
|
||||
|
|
|
@ -505,16 +505,6 @@ elf_file_p (x_ehdrp)
|
|||
&& (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
|
||||
}
|
||||
|
||||
struct bfd_preserve
|
||||
{
|
||||
const struct bfd_arch_info *arch_info;
|
||||
struct elf_obj_tdata *tdata;
|
||||
struct bfd_hash_table section_htab;
|
||||
struct sec *sections;
|
||||
struct sec **section_tail;
|
||||
unsigned int section_count;
|
||||
};
|
||||
|
||||
/* Check to see if the file associated with ABFD matches the target vector
|
||||
that ABFD points to.
|
||||
|
||||
|
@ -536,11 +526,10 @@ elf_object_p (abfd)
|
|||
char *shstrtab; /* Internal copy of section header stringtab */
|
||||
struct elf_backend_data *ebd;
|
||||
struct bfd_preserve preserve;
|
||||
struct elf_obj_tdata *new_tdata = NULL;
|
||||
asection *s;
|
||||
bfd_size_type amt;
|
||||
|
||||
preserve.arch_info = abfd->arch_info;
|
||||
preserve.marker = NULL;
|
||||
|
||||
/* Read in the ELF header in external format. */
|
||||
|
||||
|
@ -584,23 +573,13 @@ elf_object_p (abfd)
|
|||
the tdata pointer in the bfd. */
|
||||
|
||||
amt = sizeof (struct elf_obj_tdata);
|
||||
new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
|
||||
if (new_tdata == NULL)
|
||||
preserve.marker = bfd_zalloc (abfd, amt);
|
||||
if (preserve.marker == NULL)
|
||||
goto got_no_match;
|
||||
if (!bfd_preserve_save (abfd, &preserve))
|
||||
goto got_no_match;
|
||||
preserve.tdata = elf_tdata (abfd);
|
||||
elf_tdata (abfd) = new_tdata;
|
||||
|
||||
/* Clear section information, since there might be a recognized bfd that
|
||||
we now check if we can replace, and we don't want to append to it. */
|
||||
preserve.sections = abfd->sections;
|
||||
preserve.section_tail = abfd->section_tail;
|
||||
preserve.section_count = abfd->section_count;
|
||||
preserve.section_htab = abfd->section_htab;
|
||||
abfd->sections = NULL;
|
||||
abfd->section_tail = &abfd->sections;
|
||||
abfd->section_count = 0;
|
||||
if (!bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
|
||||
goto got_no_match;
|
||||
elf_tdata (abfd) = preserve.marker;
|
||||
|
||||
/* Now that we know the byte order, swap in the rest of the header */
|
||||
i_ehdrp = elf_elfheader (abfd);
|
||||
|
@ -633,8 +612,10 @@ elf_object_p (abfd)
|
|||
/* Check that the ELF e_machine field matches what this particular
|
||||
BFD format expects. */
|
||||
if (ebd->elf_machine_code != i_ehdrp->e_machine
|
||||
&& (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
||||
&& (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
|
||||
&& (ebd->elf_machine_alt1 == 0
|
||||
|| i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
||||
&& (ebd->elf_machine_alt2 == 0
|
||||
|| i_ehdrp->e_machine != ebd->elf_machine_alt2))
|
||||
{
|
||||
const bfd_target * const *target_ptr;
|
||||
|
||||
|
@ -844,11 +825,8 @@ elf_object_p (abfd)
|
|||
}
|
||||
}
|
||||
|
||||
/* It would be nice to be able to free more memory here, eg. old
|
||||
elf_elfsections, old tdata, but that's not possible since these
|
||||
blocks are sitting inside obj_alloc'd memory. */
|
||||
bfd_hash_table_free (&preserve.section_htab);
|
||||
return (abfd->xvec);
|
||||
bfd_preserve_finish (abfd, &preserve);
|
||||
return abfd->xvec;
|
||||
|
||||
got_wrong_format_error:
|
||||
/* There is way too much undoing of half-known state here. The caller,
|
||||
|
@ -864,17 +842,8 @@ elf_object_p (abfd)
|
|||
|
||||
got_no_match:
|
||||
abfd->arch_info = preserve.arch_info;
|
||||
if (new_tdata != NULL)
|
||||
{
|
||||
/* bfd_release frees all memory more recently bfd_alloc'd than
|
||||
its arg, as well as its arg. */
|
||||
bfd_release (abfd, new_tdata);
|
||||
elf_tdata (abfd) = preserve.tdata;
|
||||
abfd->section_htab = preserve.section_htab;
|
||||
abfd->sections = preserve.sections;
|
||||
abfd->section_tail = preserve.section_tail;
|
||||
abfd->section_count = preserve.section_count;
|
||||
}
|
||||
if (preserve.marker != NULL)
|
||||
bfd_preserve_restore (abfd, &preserve);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
198
bfd/mach-o.c
198
bfd/mach-o.c
|
@ -691,7 +691,7 @@ bfd_mach_o_scan_read_symtab_symbol (abfd, sym, s, i)
|
|||
unsigned char type = -1;
|
||||
unsigned char section = -1;
|
||||
short desc = -1;
|
||||
long value = -1;
|
||||
unsigned long value = -1;
|
||||
unsigned long stroff = -1;
|
||||
unsigned int symtype = -1;
|
||||
|
||||
|
@ -1374,7 +1374,8 @@ bfd_mach_o_scan_read_segment (abfd, command)
|
|||
{
|
||||
bfd_vma segoff = command->offset + 48 + 8 + (i * 68);
|
||||
|
||||
if (bfd_mach_o_scan_read_section (abfd, &seg->sections[i], segoff) != 0)
|
||||
if (bfd_mach_o_scan_read_section (abfd, &seg->sections[i],
|
||||
segoff) != 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -1455,7 +1456,8 @@ bfd_mach_o_scan_read_command (abfd, command)
|
|||
return -1;
|
||||
|
||||
command->type = (bfd_h_get_32 (abfd, buf) & ~BFD_MACH_O_LC_REQ_DYLD);
|
||||
command->type_required = (bfd_h_get_32 (abfd, buf) & BFD_MACH_O_LC_REQ_DYLD) ? 1 : 0;
|
||||
command->type_required = (bfd_h_get_32 (abfd, buf) & BFD_MACH_O_LC_REQ_DYLD
|
||||
? 1 : 0);
|
||||
command->len = bfd_h_get_32 (abfd, buf + 4);
|
||||
|
||||
switch (command->type)
|
||||
|
@ -1531,20 +1533,24 @@ bfd_mach_o_flatten_sections (abfd)
|
|||
{
|
||||
if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
|
||||
{
|
||||
bfd_mach_o_segment_command *seg = &mdata->commands[i].command.segment;
|
||||
bfd_mach_o_segment_command *seg;
|
||||
|
||||
seg = &mdata->commands[i].command.segment;
|
||||
mdata->nsects += seg->nsects;
|
||||
}
|
||||
}
|
||||
|
||||
mdata->sections = bfd_alloc (abfd, mdata->nsects * sizeof (bfd_mach_o_section *));
|
||||
mdata->sections = bfd_alloc (abfd,
|
||||
mdata->nsects * sizeof (bfd_mach_o_section *));
|
||||
csect = 0;
|
||||
|
||||
for (i = 0; i < mdata->header.ncmds; i++)
|
||||
{
|
||||
if (mdata->commands[i].type == BFD_MACH_O_LC_SEGMENT)
|
||||
{
|
||||
bfd_mach_o_segment_command *seg = &mdata->commands[i].command.segment;
|
||||
bfd_mach_o_segment_command *seg;
|
||||
|
||||
seg = &mdata->commands[i].command.segment;
|
||||
BFD_ASSERT (csect + seg->nsects <= mdata->nsects);
|
||||
|
||||
for (j = 0; j < seg->nsects; j++)
|
||||
|
@ -1579,7 +1585,8 @@ bfd_mach_o_scan_start_address (abfd)
|
|||
for (i = 0; i < cmd->nflavours; i++)
|
||||
{
|
||||
if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_I386)
|
||||
&& (cmd->flavours[i].flavour == (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
|
||||
&& (cmd->flavours[i].flavour
|
||||
== (unsigned long) BFD_MACH_O_i386_THREAD_STATE))
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
|
@ -1608,27 +1615,24 @@ bfd_mach_o_scan_start_address (abfd)
|
|||
}
|
||||
|
||||
int
|
||||
bfd_mach_o_scan (abfd, header)
|
||||
bfd_mach_o_scan (abfd, header, mdata)
|
||||
bfd *abfd;
|
||||
bfd_mach_o_header *header;
|
||||
bfd_mach_o_data_struct *mdata;
|
||||
{
|
||||
unsigned int i;
|
||||
bfd_mach_o_data_struct *mdata = NULL;
|
||||
enum bfd_architecture cputype;
|
||||
unsigned long cpusubtype;
|
||||
|
||||
mdata = ((bfd_mach_o_data_struct *)
|
||||
bfd_alloc (abfd, sizeof (bfd_mach_o_data_struct)));
|
||||
if (mdata == NULL)
|
||||
return -1;
|
||||
|
||||
mdata->header = *header;
|
||||
mdata->symbols = NULL;
|
||||
|
||||
abfd->flags = abfd->xvec->object_flags | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS));
|
||||
abfd->flags = (abfd->xvec->object_flags
|
||||
| (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));
|
||||
abfd->tdata.mach_o_data = mdata;
|
||||
|
||||
bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype, &cputype, &cpusubtype);
|
||||
bfd_mach_o_convert_architecture (header->cputype, header->cpusubtype,
|
||||
&cputype, &cpusubtype);
|
||||
if (cputype == bfd_arch_unknown)
|
||||
{
|
||||
fprintf (stderr, "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx\n",
|
||||
|
@ -1712,84 +1716,99 @@ const bfd_target *
|
|||
bfd_mach_o_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bfd_preserve preserve;
|
||||
bfd_mach_o_header header;
|
||||
|
||||
preserve.marker = NULL;
|
||||
if (bfd_mach_o_read_header (abfd, &header) != 0)
|
||||
goto wrong;
|
||||
|
||||
if (! (header.byteorder == BFD_ENDIAN_BIG
|
||||
|| header.byteorder == BFD_ENDIAN_LITTLE))
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
fprintf (stderr, "unknown header byte-order value 0x%lx\n",
|
||||
(long) header.byteorder);
|
||||
goto wrong;
|
||||
}
|
||||
|
||||
if (! ((header.byteorder == BFD_ENDIAN_BIG)
|
||||
|| (header.byteorder == BFD_ENDIAN_LITTLE)))
|
||||
{
|
||||
fprintf (stderr, "unknown header byte-order value 0x%lx\n", (long) header.byteorder);
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
if (! ((header.byteorder == BFD_ENDIAN_BIG
|
||||
&& abfd->xvec->byteorder == BFD_ENDIAN_BIG
|
||||
&& abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
|
||||
|| (header.byteorder == BFD_ENDIAN_LITTLE
|
||||
&& abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
|
||||
&& abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
|
||||
goto wrong;
|
||||
|
||||
if (! (((header.byteorder == BFD_ENDIAN_BIG)
|
||||
&& (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
|
||||
&& (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG))
|
||||
||
|
||||
((header.byteorder == BFD_ENDIAN_LITTLE)
|
||||
&& (abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
|
||||
&& (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE))))
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
|
||||
if (preserve.marker == NULL
|
||||
|| !bfd_preserve_save (abfd, &preserve))
|
||||
goto fail;
|
||||
|
||||
abfd->tdata.mach_o_data = NULL;
|
||||
|
||||
if (bfd_mach_o_scan (abfd, &header) != 0)
|
||||
{
|
||||
abfd->tdata.mach_o_data = NULL;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
if (bfd_mach_o_scan (abfd, &header,
|
||||
(bfd_mach_o_data_struct *) preserve.marker) != 0)
|
||||
goto wrong;
|
||||
|
||||
bfd_preserve_finish (abfd, &preserve);
|
||||
return abfd->xvec;
|
||||
|
||||
wrong:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
fail:
|
||||
if (preserve.marker != NULL)
|
||||
bfd_preserve_restore (abfd, &preserve);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const bfd_target *
|
||||
bfd_mach_o_core_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bfd_preserve preserve;
|
||||
bfd_mach_o_header header;
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
preserve.marker = NULL;
|
||||
if (bfd_mach_o_read_header (abfd, &header) != 0)
|
||||
return NULL;
|
||||
goto wrong;
|
||||
|
||||
if (! ((header.byteorder == BFD_ENDIAN_BIG)
|
||||
|| (header.byteorder == BFD_ENDIAN_LITTLE)))
|
||||
if (! (header.byteorder == BFD_ENDIAN_BIG
|
||||
|| header.byteorder == BFD_ENDIAN_LITTLE))
|
||||
{
|
||||
fprintf (stderr, "unknown header byte-order value 0x%lx\n", (long) header.byteorder);
|
||||
fprintf (stderr, "unknown header byte-order value 0x%lx\n",
|
||||
(long) header.byteorder);
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (! (((header.byteorder == BFD_ENDIAN_BIG)
|
||||
&& (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
|
||||
&& (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG))
|
||||
||
|
||||
((header.byteorder == BFD_ENDIAN_LITTLE)
|
||||
&& (abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
|
||||
&& (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE))))
|
||||
return NULL;
|
||||
if (! ((header.byteorder == BFD_ENDIAN_BIG
|
||||
&& abfd->xvec->byteorder == BFD_ENDIAN_BIG
|
||||
&& abfd->xvec->header_byteorder == BFD_ENDIAN_BIG)
|
||||
|| (header.byteorder == BFD_ENDIAN_LITTLE
|
||||
&& abfd->xvec->byteorder == BFD_ENDIAN_LITTLE
|
||||
&& abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
|
||||
goto wrong;
|
||||
|
||||
if (header.filetype != BFD_MACH_O_MH_CORE)
|
||||
return NULL;
|
||||
goto wrong;
|
||||
|
||||
abfd->tdata.mach_o_data = NULL;
|
||||
if (bfd_mach_o_scan (abfd, &header) != 0)
|
||||
{
|
||||
abfd->tdata.mach_o_data = NULL;
|
||||
return NULL;
|
||||
}
|
||||
preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
|
||||
if (preserve.marker == NULL
|
||||
|| !bfd_preserve_save (abfd, &preserve))
|
||||
goto fail;
|
||||
|
||||
if (bfd_mach_o_scan (abfd, &header,
|
||||
(bfd_mach_o_data_struct *) preserve.marker) != 0)
|
||||
goto wrong;
|
||||
|
||||
bfd_preserve_finish (abfd, &preserve);
|
||||
return abfd->xvec;
|
||||
|
||||
wrong:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
fail:
|
||||
if (preserve.marker != NULL)
|
||||
bfd_preserve_restore (abfd, &preserve);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typedef struct mach_o_fat_archentry
|
||||
|
@ -1813,35 +1832,35 @@ const bfd_target *
|
|||
bfd_mach_o_archive_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
mach_o_fat_data_struct *adata;
|
||||
mach_o_fat_data_struct *adata = NULL;
|
||||
unsigned char buf[20];
|
||||
unsigned long i;
|
||||
|
||||
bfd_seek (abfd, 0, SEEK_SET);
|
||||
if (bfd_bread ((PTR) buf, 8, abfd) != 8)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
adata = (mach_o_fat_data_struct *)
|
||||
bfd_alloc (abfd, sizeof (mach_o_fat_data_struct));
|
||||
if (adata == NULL)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
adata->magic = bfd_getb32 (buf);
|
||||
adata->nfat_arch = bfd_getb32 (buf + 4);
|
||||
if (adata->magic != 0xcafebabe)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
adata->archentries = (mach_o_fat_archentry *)
|
||||
bfd_alloc (abfd, adata->nfat_arch * sizeof (mach_o_fat_archentry));
|
||||
if (adata->archentries == NULL)
|
||||
return NULL;
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < adata->nfat_arch; i++)
|
||||
{
|
||||
bfd_seek (abfd, 8 + 20 * i, SEEK_SET);
|
||||
|
||||
if (bfd_bread ((PTR) buf, 20, abfd) != 20)
|
||||
return NULL;
|
||||
goto error;
|
||||
adata->archentries[i].cputype = bfd_getb32 (buf);
|
||||
adata->archentries[i].cpusubtype = bfd_getb32 (buf + 4);
|
||||
adata->archentries[i].offset = bfd_getb32 (buf + 8);
|
||||
|
@ -1852,6 +1871,12 @@ bfd_mach_o_archive_p (abfd)
|
|||
|
||||
abfd->tdata.mach_o_fat_data = adata;
|
||||
return abfd->xvec;
|
||||
|
||||
error:
|
||||
if (adata != NULL)
|
||||
bfd_release (abfd, adata);
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bfd *
|
||||
|
@ -1859,10 +1884,11 @@ bfd_mach_o_openr_next_archived_file (archive, prev)
|
|||
bfd *archive;
|
||||
bfd *prev;
|
||||
{
|
||||
mach_o_fat_data_struct *adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
|
||||
mach_o_fat_data_struct *adata;
|
||||
mach_o_fat_archentry *entry = NULL;
|
||||
unsigned long i;
|
||||
|
||||
adata = (mach_o_fat_data_struct *) archive->tdata.mach_o_fat_data;
|
||||
BFD_ASSERT (adata != NULL);
|
||||
|
||||
/* Find index of previous entry. */
|
||||
|
@ -1913,9 +1939,12 @@ bfd_mach_o_openr_next_archived_file (archive, prev)
|
|||
return entry->abfd;
|
||||
}
|
||||
|
||||
int bfd_mach_o_lookup_section
|
||||
(bfd *abfd, asection *section,
|
||||
bfd_mach_o_load_command **mcommand, bfd_mach_o_section **msection)
|
||||
int
|
||||
bfd_mach_o_lookup_section (abfd, section, mcommand, msection)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
bfd_mach_o_load_command **mcommand;
|
||||
bfd_mach_o_section **msection;
|
||||
{
|
||||
struct mach_o_data_struct *md = abfd->tdata.mach_o_data;
|
||||
unsigned int i, j, num;
|
||||
|
@ -1962,9 +1991,10 @@ int bfd_mach_o_lookup_section
|
|||
}
|
||||
|
||||
int
|
||||
bfd_mach_o_lookup_command
|
||||
(bfd *abfd, bfd_mach_o_load_command_type type,
|
||||
bfd_mach_o_load_command **mcommand)
|
||||
bfd_mach_o_lookup_command (abfd, type, mcommand)
|
||||
bfd *abfd;
|
||||
bfd_mach_o_load_command_type type;
|
||||
bfd_mach_o_load_command **mcommand;
|
||||
{
|
||||
struct mach_o_data_struct *md = NULL;
|
||||
bfd_mach_o_load_command *ncmd = NULL;
|
||||
|
@ -2011,7 +2041,7 @@ bfd_mach_o_stack_addr (type)
|
|||
case BFD_MACH_O_CPU_TYPE_I860:
|
||||
return 0;
|
||||
case BFD_MACH_O_CPU_TYPE_HPPA:
|
||||
return (0xc0000000-0x04000000);
|
||||
return 0xc0000000 - 0x04000000;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -2063,8 +2093,9 @@ bfd_mach_o_core_fetch_environment (abfd, rbuf, rlen)
|
|||
|
||||
for (offset = 4; offset <= size; offset += 4)
|
||||
{
|
||||
unsigned long val = *((unsigned long *) (buf + size - offset));
|
||||
unsigned long val;
|
||||
|
||||
val = *((unsigned long *) (buf + size - offset));
|
||||
if (! found_nonnull)
|
||||
{
|
||||
if (val != 0)
|
||||
|
@ -2072,9 +2103,11 @@ bfd_mach_o_core_fetch_environment (abfd, rbuf, rlen)
|
|||
}
|
||||
else if (val == 0x0)
|
||||
{
|
||||
unsigned long bottom = seg->fileoff + seg->filesize - offset;
|
||||
unsigned long top = seg->fileoff + seg->filesize - 4;
|
||||
unsigned long bottom;
|
||||
unsigned long top;
|
||||
|
||||
bottom = seg->fileoff + seg->filesize - offset;
|
||||
top = seg->fileoff + seg->filesize - 4;
|
||||
*rbuf = bfd_malloc (top - bottom);
|
||||
*rlen = top - bottom;
|
||||
|
||||
|
@ -2159,4 +2192,3 @@ bfd_mach_o_core_file_matches_executable_p (core_bfd, exec_bfd)
|
|||
#undef TARGET_STRING
|
||||
#undef TARGET_BIG_ENDIAN
|
||||
#undef TARGET_ARCHIVE
|
||||
|
||||
|
|
|
@ -469,7 +469,7 @@ int bfd_mach_o_scan_read_symtab_strtab PARAMS ((bfd *, bfd_mach
|
|||
int bfd_mach_o_scan_read_symtab_symbols PARAMS ((bfd *, bfd_mach_o_symtab_command *));
|
||||
int bfd_mach_o_scan_read_dysymtab_symbol PARAMS ((bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, asymbol *, unsigned long));
|
||||
int bfd_mach_o_scan_start_address PARAMS ((bfd *));
|
||||
int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *));
|
||||
int bfd_mach_o_scan PARAMS ((bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *));
|
||||
boolean bfd_mach_o_mkobject PARAMS ((bfd *));
|
||||
const bfd_target * bfd_mach_o_object_p PARAMS ((bfd *));
|
||||
const bfd_target * bfd_mach_o_core_p PARAMS ((bfd *));
|
||||
|
|
|
@ -183,4 +183,4 @@ int bfd_pef_parse_imported_library PARAMS ((bfd *, unsigned char *, size_t, bfd
|
|||
int bfd_pef_parse_imported_symbol PARAMS ((bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *));
|
||||
int bfd_pef_scan_section PARAMS ((bfd *, bfd_pef_section *));
|
||||
int bfd_pef_scan_start_address PARAMS ((bfd *));
|
||||
int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *));
|
||||
int bfd_pef_scan PARAMS ((bfd *, bfd_pef_header *, bfd_pef_data_struct *));
|
||||
|
|
|
@ -997,11 +997,8 @@ static const bfd_target * const _bfd_target_vector[] = {
|
|||
&pc532machaout_vec,
|
||||
&pc532netbsd_vec,
|
||||
&pdp11_aout_vec,
|
||||
#if 0
|
||||
/* bfd_pef_object_p and bfd_pef_xlib_object_p are broken. */
|
||||
&pef_vec,
|
||||
&pef_xlib_vec,
|
||||
#endif
|
||||
#if 0
|
||||
/* This has the same magic number as RS/6000. */
|
||||
&pmac_xcoff_vec,
|
||||
|
@ -1031,10 +1028,7 @@ static const bfd_target * const _bfd_target_vector[] = {
|
|||
&sparclynx_coff_vec,
|
||||
&sparcnetbsd_vec,
|
||||
&sunos_big_vec,
|
||||
#if 0
|
||||
/* bfd_sym_object_p is broken. */
|
||||
&sym_vec,
|
||||
#endif
|
||||
&tic30_aout_vec,
|
||||
&tic30_coff_vec,
|
||||
&tic54x_coff0_beh_vec,
|
||||
|
|
139
bfd/xsym.c
139
bfd/xsym.c
|
@ -116,7 +116,7 @@ bfd_sym_valid (abfd)
|
|||
if (abfd == NULL || abfd->xvec == NULL)
|
||||
return 0;
|
||||
|
||||
return (abfd->xvec == &sym_vec);
|
||||
return abfd->xvec == &sym_vec;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
|
@ -135,7 +135,7 @@ bfd_sym_read_name_table (abfd, dshb)
|
|||
|
||||
bfd_seek (abfd, table_offset, SEEK_SET);
|
||||
ret = bfd_bread (rstr, table_size, abfd);
|
||||
if ((ret < 0) || ((unsigned long) ret != table_size))
|
||||
if (ret < 0 || (unsigned long) ret != table_size)
|
||||
{
|
||||
bfd_release (abfd, rstr);
|
||||
return NULL;
|
||||
|
@ -554,12 +554,14 @@ bfd_sym_fetch_resources_table_entry (abfd, entry, index)
|
|||
bfd_sym_resources_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_resources_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size;
|
||||
unsigned char buf[18];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -605,12 +607,14 @@ bfd_sym_fetch_modules_table_entry (abfd, entry, index)
|
|||
bfd_sym_modules_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_modules_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size;
|
||||
unsigned char buf[46];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -656,12 +660,14 @@ bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
|
|||
bfd_sym_file_references_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_file_references_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[8];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -706,12 +712,14 @@ bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
|
|||
bfd_sym_contained_modules_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_contained_modules_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[6];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -756,12 +764,14 @@ bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
|
|||
bfd_sym_contained_variables_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_contained_variables_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[26];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -806,12 +816,14 @@ bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
|
|||
bfd_sym_contained_statements_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_contained_statements_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[8];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -856,12 +868,14 @@ bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
|
|||
bfd_sym_contained_labels_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_contained_labels_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[12];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -906,12 +920,14 @@ bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
|
|||
bfd_sym_contained_types_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_contained_types_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[0];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -956,12 +972,14 @@ bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
|
|||
bfd_sym_file_references_index_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_file_references_index_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[0];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -1006,12 +1024,14 @@ bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
|
|||
bfd_sym_constant_pool_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_constant_pool_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[0];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -1056,12 +1076,14 @@ bfd_sym_fetch_type_table_entry (abfd, entry, index)
|
|||
bfd_sym_type_table_entry *entry;
|
||||
unsigned long index;
|
||||
{
|
||||
void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *) = NULL;
|
||||
void (*parser) PARAMS ((unsigned char *, size_t,
|
||||
bfd_sym_type_table_entry *));
|
||||
unsigned long offset;
|
||||
unsigned long entry_size = 0;
|
||||
unsigned char buf[4];
|
||||
bfd_sym_data_struct *sdata = NULL;
|
||||
|
||||
parser = NULL;
|
||||
BFD_ASSERT (bfd_sym_valid (abfd));
|
||||
sdata = abfd->tdata.sym_data;
|
||||
|
||||
|
@ -1182,10 +1204,11 @@ bfd_sym_symbol_name (abfd, index)
|
|||
return "";
|
||||
|
||||
index *= 2;
|
||||
if ((index / sdata->header.dshb_page_size) > sdata->header.dshb_nte.dti_page_count)
|
||||
if ((index / sdata->header.dshb_page_size)
|
||||
> sdata->header.dshb_nte.dti_page_count)
|
||||
return "\009[INVALID]";
|
||||
|
||||
return ((const unsigned char *) sdata->name_table + index);
|
||||
return (const unsigned char *) sdata->name_table + index;
|
||||
}
|
||||
|
||||
const unsigned char *
|
||||
|
@ -1272,7 +1295,8 @@ bfd_sym_print_file_reference (abfd, f, entry)
|
|||
bfd_sym_file_references_table_entry frtentry;
|
||||
int ret;
|
||||
|
||||
ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry, entry->fref_frte_index);
|
||||
ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
|
||||
entry->fref_frte_index);
|
||||
fprintf (f, "FILE ");
|
||||
|
||||
if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
|
||||
|
@ -1312,7 +1336,8 @@ bfd_sym_print_modules_table_entry (abfd, f, entry)
|
|||
fprintf (f, "\n ");
|
||||
|
||||
bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
|
||||
fprintf (f, " range %lu -- %lu", entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
|
||||
fprintf (f, " range %lu -- %lu",
|
||||
entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
|
||||
|
||||
fprintf (f, "\n ");
|
||||
|
||||
|
@ -1924,7 +1949,7 @@ bfd_sym_display_name_table_entry (abfd, f, entry)
|
|||
sdata = abfd->tdata.sym_data;
|
||||
index = (entry - sdata->name_table) / 2;
|
||||
|
||||
if ((sdata->version >= BFD_SYM_VERSION_3_4) && (entry[0] == 255) && (entry[1] == 0))
|
||||
if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
|
||||
{
|
||||
unsigned short length = bfd_getb16 (entry + 2);
|
||||
fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
|
||||
|
@ -1932,7 +1957,7 @@ bfd_sym_display_name_table_entry (abfd, f, entry)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (! ((entry[0] == 0) || ((entry[0] == 1) && (entry[1] == '\0'))))
|
||||
if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
|
||||
fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
|
||||
|
||||
if (sdata->version >= BFD_SYM_VERSION_3_4)
|
||||
|
@ -2293,55 +2318,30 @@ bfd_sym_display_type_information_table (abfd, f)
|
|||
}
|
||||
}
|
||||
|
||||
const bfd_target *
|
||||
bfd_sym_object_p (abfd)
|
||||
int
|
||||
bfd_sym_scan (abfd, version, mdata)
|
||||
bfd *abfd;
|
||||
bfd_sym_version version;
|
||||
bfd_sym_data_struct *mdata;
|
||||
{
|
||||
bfd_sym_data_struct *mdata = NULL;
|
||||
asection *bfdsec;
|
||||
const char *name = "symbols";
|
||||
|
||||
mdata = ((bfd_sym_data_struct *)
|
||||
bfd_alloc (abfd, sizeof (bfd_sym_data_struct)));
|
||||
if (mdata == NULL)
|
||||
return NULL;
|
||||
|
||||
abfd->tdata.sym_data = mdata;
|
||||
|
||||
mdata->name_table = 0;
|
||||
mdata->sbfd = abfd;
|
||||
|
||||
bfd_seek (abfd, 0, SEEK_SET);
|
||||
if (bfd_sym_read_version (abfd, &mdata->version) != 0)
|
||||
{
|
||||
abfd->tdata.sym_data = NULL;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
mdata->version = version;
|
||||
|
||||
bfd_seek (abfd, 0, SEEK_SET);
|
||||
if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
|
||||
{
|
||||
abfd->tdata.sym_data = NULL;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
return -1;
|
||||
|
||||
mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
|
||||
if (mdata->name_table == NULL)
|
||||
{
|
||||
abfd->tdata.sym_data = NULL;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
return -1;
|
||||
|
||||
bfdsec = bfd_make_section_anyway (abfd, name);
|
||||
if (bfdsec == NULL)
|
||||
{
|
||||
abfd->tdata.sym_data = NULL;
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
return -1;
|
||||
|
||||
bfdsec->vma = 0;
|
||||
bfdsec->lma = 0;
|
||||
|
@ -2351,7 +2351,42 @@ bfd_sym_object_p (abfd)
|
|||
|
||||
bfdsec->flags = SEC_HAS_CONTENTS;
|
||||
|
||||
abfd->tdata.sym_data = mdata;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const bfd_target *
|
||||
bfd_sym_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct bfd_preserve preserve;
|
||||
bfd_sym_version version = -1;
|
||||
|
||||
preserve.marker = NULL;
|
||||
bfd_seek (abfd, 0, SEEK_SET);
|
||||
if (bfd_sym_read_version (abfd, &version) != 0)
|
||||
goto wrong;
|
||||
|
||||
preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
|
||||
if (preserve.marker == NULL
|
||||
|| ! bfd_preserve_save (abfd, &preserve))
|
||||
goto fail;
|
||||
|
||||
if (bfd_sym_scan (abfd, version,
|
||||
(bfd_sym_data_struct *) preserve.marker) != 0)
|
||||
goto wrong;
|
||||
|
||||
bfd_preserve_finish (abfd, &preserve);
|
||||
return abfd->xvec;
|
||||
|
||||
wrong:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
|
||||
fail:
|
||||
if (preserve.marker != NULL)
|
||||
bfd_preserve_restore (abfd, &preserve);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
asymbol *
|
||||
|
|
|
@ -683,6 +683,8 @@ extern void bfd_sym_display_constant_pool
|
|||
PARAMS ((bfd *, FILE *));
|
||||
extern void bfd_sym_display_type_information_table
|
||||
PARAMS ((bfd *, FILE *));
|
||||
extern int bfd_sym_scan
|
||||
PARAMS ((bfd *, bfd_sym_version, bfd_sym_data_struct *));
|
||||
extern const bfd_target * bfd_sym_object_p
|
||||
PARAMS ((bfd *));
|
||||
extern asymbol * bfd_sym_make_empty_symbol
|
||||
|
|
Loading…
Add table
Reference in a new issue