2012-01-04 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_fat_member_init): New function. (bfd_mach_o_openr_next_archived_file): Reindent. Adjust to call bfd_mach_o_fat_member_init. (bfd_mach_o_fat_extract): Adjust to call bfd_mach_o_fat_member_init.
This commit is contained in:
parent
1a2da5eef0
commit
a4e241ca1b
|
@ -1,3 +1,10 @@
|
||||||
|
2012-01-04 Tristan Gingold <gingold@adacore.com>
|
||||||
|
|
||||||
|
* mach-o.c (bfd_mach_o_fat_member_init): New function.
|
||||||
|
(bfd_mach_o_openr_next_archived_file): Reindent.
|
||||||
|
Adjust to call bfd_mach_o_fat_member_init.
|
||||||
|
(bfd_mach_o_fat_extract): Adjust to call bfd_mach_o_fat_member_init.
|
||||||
|
|
||||||
2012-01-04 Tristan Gingold <gingold@adacore.com>
|
2012-01-04 Tristan Gingold <gingold@adacore.com>
|
||||||
|
|
||||||
* mach-o-x86-64.c (bfd_mach_o_x86_64_swap_reloc_out): Handle
|
* mach-o-x86-64.c (bfd_mach_o_x86_64_swap_reloc_out): Handle
|
||||||
|
|
61
bfd/mach-o.c
61
bfd/mach-o.c
|
@ -4107,6 +4107,42 @@ bfd_mach_o_archive_p (bfd *abfd)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the filename for a fat binary member ABFD, whose bfd architecture is
|
||||||
|
ARCH_TYPE/ARCH_SUBTYPE and corresponding entry in header is ENTRY.
|
||||||
|
Set arelt_data and origin fields too. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
bfd_mach_o_fat_member_init (bfd *abfd,
|
||||||
|
enum bfd_architecture arch_type,
|
||||||
|
unsigned long arch_subtype,
|
||||||
|
mach_o_fat_archentry *entry)
|
||||||
|
{
|
||||||
|
struct areltdata *areltdata;
|
||||||
|
/* Create the member filename. Use ARCH_NAME. */
|
||||||
|
const bfd_arch_info_type *ap = bfd_lookup_arch (arch_type, arch_subtype);
|
||||||
|
|
||||||
|
if (ap)
|
||||||
|
{
|
||||||
|
/* Use the architecture name if known. */
|
||||||
|
abfd->filename = ap->printable_name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Forge a uniq id. */
|
||||||
|
const size_t namelen = 2 + 8 + 1 + 2 + 8 + 1;
|
||||||
|
char *name = bfd_alloc (abfd, namelen);
|
||||||
|
snprintf (name, namelen, "0x%lx-0x%lx",
|
||||||
|
entry->cputype, entry->cpusubtype);
|
||||||
|
abfd->filename = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
areltdata = bfd_zalloc (abfd, sizeof (struct areltdata));
|
||||||
|
areltdata->parsed_size = entry->size;
|
||||||
|
abfd->arelt_data = areltdata;
|
||||||
|
abfd->iostream = NULL;
|
||||||
|
abfd->origin = entry->offset;
|
||||||
|
}
|
||||||
|
|
||||||
bfd *
|
bfd *
|
||||||
bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
||||||
{
|
{
|
||||||
|
@ -4122,9 +4158,13 @@ bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
||||||
|
|
||||||
/* Find index of previous entry. */
|
/* Find index of previous entry. */
|
||||||
if (prev == NULL)
|
if (prev == NULL)
|
||||||
i = 0; /* Start at first one. */
|
{
|
||||||
|
/* Start at first one. */
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Find index of PREV. */
|
||||||
for (i = 0; i < adata->nfat_arch; i++)
|
for (i = 0; i < adata->nfat_arch; i++)
|
||||||
{
|
{
|
||||||
if (adata->archentries[i].offset == prev->origin)
|
if (adata->archentries[i].offset == prev->origin)
|
||||||
|
@ -4137,8 +4177,10 @@ bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
||||||
bfd_set_error (bfd_error_bad_value);
|
bfd_set_error (bfd_error_bad_value);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
i++; /* Get next entry. */
|
|
||||||
}
|
/* Get next entry. */
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
if (i >= adata->nfat_arch)
|
if (i >= adata->nfat_arch)
|
||||||
{
|
{
|
||||||
|
@ -4151,14 +4193,11 @@ bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
||||||
if (nbfd == NULL)
|
if (nbfd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
nbfd->origin = entry->offset;
|
|
||||||
|
|
||||||
bfd_mach_o_convert_architecture (entry->cputype, entry->cpusubtype,
|
bfd_mach_o_convert_architecture (entry->cputype, entry->cpusubtype,
|
||||||
&arch_type, &arch_subtype);
|
&arch_type, &arch_subtype);
|
||||||
|
|
||||||
/* Create the member filename. Use ARCH_NAME. */
|
bfd_mach_o_fat_member_init (nbfd, arch_type, arch_subtype, entry);
|
||||||
nbfd->filename = bfd_printable_arch_mach (arch_type, arch_subtype);
|
|
||||||
nbfd->iostream = NULL;
|
|
||||||
bfd_set_arch_mach (nbfd, arch_type, arch_subtype);
|
bfd_set_arch_mach (nbfd, arch_type, arch_subtype);
|
||||||
|
|
||||||
return nbfd;
|
return nbfd;
|
||||||
|
@ -4169,6 +4208,7 @@ bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
|
||||||
and ARCH, returns it.
|
and ARCH, returns it.
|
||||||
In other case, returns NULL.
|
In other case, returns NULL.
|
||||||
This function allows transparent uses of fat images. */
|
This function allows transparent uses of fat images. */
|
||||||
|
|
||||||
bfd *
|
bfd *
|
||||||
bfd_mach_o_fat_extract (bfd *abfd,
|
bfd_mach_o_fat_extract (bfd *abfd,
|
||||||
bfd_format format,
|
bfd_format format,
|
||||||
|
@ -4208,10 +4248,7 @@ bfd_mach_o_fat_extract (bfd *abfd,
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
res->origin = e->offset;
|
bfd_mach_o_fat_member_init (res, cpu_type, cpu_subtype, e);
|
||||||
|
|
||||||
res->filename = bfd_printable_arch_mach (cpu_type, cpu_subtype);
|
|
||||||
res->iostream = NULL;
|
|
||||||
|
|
||||||
if (bfd_check_format (res, format))
|
if (bfd_check_format (res, format))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue