SEC_CODE | SEC_LOAD, BFD_MACH_O_S_REGULAR,
BFD_MACH_O_S_ATTR_NONE, 0},
{ ".eh_frame", "__eh_frame",
- SEC_READONLY | SEC_LOAD, BFD_MACH_O_S_COALESCED,
+ SEC_READONLY | SEC_DATA | SEC_LOAD, BFD_MACH_O_S_COALESCED,
BFD_MACH_O_S_ATTR_LIVE_SUPPORT
| BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS
- | BFD_MACH_O_S_ATTR_NO_TOC, 3},
+ | BFD_MACH_O_S_ATTR_NO_TOC, 2},
{ NULL, NULL, 0, 0, 0, 0}
};
return (asect->reloc_count + 1) * sizeof (arelent *);
}
+/* In addition to the need to byte-swap the symbol number, the bit positions
+ of the fields in the relocation information vary per target endian-ness. */
+
+static void
+bfd_mach_o_swap_in_non_scattered_reloc (bfd *abfd, bfd_mach_o_reloc_info *rel,
+ unsigned char *fields)
+{
+ unsigned char info = fields[3];
+
+ if (bfd_big_endian (abfd))
+ {
+ rel->r_value = (fields[0] << 16) | (fields[1] << 8) | fields[2];
+ rel->r_type = (info >> BFD_MACH_O_BE_TYPE_SHIFT) & BFD_MACH_O_TYPE_MASK;
+ rel->r_pcrel = (info & BFD_MACH_O_BE_PCREL) ? 1 : 0;
+ rel->r_length = (info >> BFD_MACH_O_BE_LENGTH_SHIFT)
+ & BFD_MACH_O_LENGTH_MASK;
+ rel->r_extern = (info & BFD_MACH_O_BE_EXTERN) ? 1 : 0;
+ }
+ else
+ {
+ rel->r_value = (fields[2] << 16) | (fields[1] << 8) | fields[0];
+ rel->r_type = (info >> BFD_MACH_O_LE_TYPE_SHIFT) & BFD_MACH_O_TYPE_MASK;
+ rel->r_pcrel = (info & BFD_MACH_O_LE_PCREL) ? 1 : 0;
+ rel->r_length = (info >> BFD_MACH_O_LE_LENGTH_SHIFT)
+ & BFD_MACH_O_LENGTH_MASK;
+ rel->r_extern = (info & BFD_MACH_O_LE_EXTERN) ? 1 : 0;
+ }
+}
+
static int
bfd_mach_o_canonicalize_one_reloc (bfd *abfd,
struct mach_o_reloc_info_external *raw,
bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
bfd_mach_o_reloc_info reloc;
bfd_vma addr;
- bfd_vma symnum;
asymbol **sym;
addr = bfd_get_32 (abfd, raw->r_address);
- symnum = bfd_get_32 (abfd, raw->r_symbolnum);
+ res->sym_ptr_ptr = NULL;
+ res->addend = 0;
if (addr & BFD_MACH_O_SR_SCATTERED)
{
unsigned int j;
+ bfd_vma symnum = bfd_get_32 (abfd, raw->r_symbolnum);
- /* Scattered relocation.
- Extract section and offset from r_value. */
- res->sym_ptr_ptr = NULL;
- res->addend = 0;
+ /* Scattered relocation, can't be extern. */
+ reloc.r_scattered = 1;
+ reloc.r_extern = 0;
+
+ /* Extract section and offset from r_value (symnum). */
+ reloc.r_value = symnum;
+ /* FIXME: This breaks when a symbol in a reloc exactly follows the
+ end of the data for the section (e.g. in a calculation of section
+ data length). At present, the symbol will end up associated with
+ the following section or, if it falls within alignment padding, as
+ null - which will assert later. */
for (j = 0; j < mdata->nsects; j++)
{
bfd_mach_o_section *sect = mdata->sections[j];
break;
}
}
- res->address = BFD_MACH_O_GET_SR_ADDRESS (addr);
+
+ /* Extract the info and address fields from r_address. */
reloc.r_type = BFD_MACH_O_GET_SR_TYPE (addr);
reloc.r_length = BFD_MACH_O_GET_SR_LENGTH (addr);
reloc.r_pcrel = addr & BFD_MACH_O_SR_PCREL;
- reloc.r_scattered = 1;
+ reloc.r_address = BFD_MACH_O_GET_SR_TYPE (addr);
+ res->address = BFD_MACH_O_GET_SR_ADDRESS (addr);
}
else
{
- unsigned int num = BFD_MACH_O_GET_R_SYMBOLNUM (symnum);
- res->addend = 0;
- res->address = addr;
- if (symnum & BFD_MACH_O_R_EXTERN)
- {
+ unsigned int num;
+
+ /* Non-scattered relocation. */
+ reloc.r_scattered = 0;
+
+ /* The value and info fields have to be extracted dependent on target
+ endian-ness. */
+ bfd_mach_o_swap_in_non_scattered_reloc (abfd, &reloc, raw->r_symbolnum);
+ num = reloc.r_value;
+
+ if (reloc.r_extern)
sym = syms + num;
- reloc.r_extern = 1;
- }
- else
+ else if (reloc.r_scattered
+ || (reloc.r_type != BFD_MACH_O_GENERIC_RELOC_PAIR))
{
BFD_ASSERT (num != 0);
BFD_ASSERT (num <= mdata->nsects);
sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr;
/* For a symbol defined in section S, the addend (stored in the
binary) contains the address of the section. To comply with
- bfd conventio, substract the section address.
+ bfd convention, subtract the section address.
Use the address from the header, so that the user can modify
the vma of the section. */
res->addend = -mdata->sections[num - 1]->addr;
- reloc.r_extern = 0;
+ }
+ else /* ... The 'symnum' in a non-scattered PAIR will be 0x00ffffff. */
+ {
+ /* Pairs for PPC LO/HI/HA are not scattered, but contain the offset
+ in the lower 16bits of the address value. So we have to find the
+ 'symbol' from the preceding reloc. We do this even thoough the
+ section symbol is probably not needed here, because NULL symbol
+ values cause an assert in generic BFD code. */
+ sym = (res - 1)->sym_ptr_ptr;
}
res->sym_ptr_ptr = sym;
- reloc.r_type = BFD_MACH_O_GET_R_TYPE (symnum);
- reloc.r_length = BFD_MACH_O_GET_R_LENGTH (symnum);
- reloc.r_pcrel = (symnum & BFD_MACH_O_R_PCREL) ? 1 : 0;
- reloc.r_scattered = 0;
+
+ /* The 'address' is just r_address.
+ ??? maybe this should be masked with 0xffffff for safety. */
+ res->address = addr;
+ reloc.r_address = addr;
}
+ /* We have set up a reloc with all the information present, so the swapper can
+ modify address, value and addend fields, if necessary, to convey information
+ in the generic BFD reloc that is mach-o specific. */
+
if (!(*bed->_bfd_mach_o_swap_reloc_in)(res, &reloc))
return -1;
return 0;
return i;
}
+/* In addition to the need to byte-swap the symbol number, the bit positions
+ of the fields in the relocation information vary per target endian-ness. */
+
+static void
+bfd_mach_o_swap_out_non_scattered_reloc (bfd *abfd, unsigned char *fields,
+ bfd_mach_o_reloc_info *rel)
+{
+ unsigned char info = 0;
+
+ BFD_ASSERT (rel->r_type <= 15);
+ BFD_ASSERT (rel->r_length <= 3);
+
+ if (bfd_big_endian (abfd))
+ {
+ fields[0] = (rel->r_value >> 16) & 0xff;
+ fields[1] = (rel->r_value >> 8) & 0xff;
+ fields[2] = rel->r_value & 0xff;
+ info |= rel->r_type << BFD_MACH_O_BE_TYPE_SHIFT;
+ info |= rel->r_pcrel ? BFD_MACH_O_BE_PCREL : 0;
+ info |= rel->r_length << BFD_MACH_O_BE_LENGTH_SHIFT;
+ info |= rel->r_extern ? BFD_MACH_O_BE_EXTERN : 0;
+ }
+ else
+ {
+ fields[2] = (rel->r_value >> 16) & 0xff;
+ fields[1] = (rel->r_value >> 8) & 0xff;
+ fields[0] = rel->r_value & 0xff;
+ info |= rel->r_type << BFD_MACH_O_LE_TYPE_SHIFT;
+ info |= rel->r_pcrel ? BFD_MACH_O_LE_PCREL : 0;
+ info |= rel->r_length << BFD_MACH_O_LE_LENGTH_SHIFT;
+ info |= rel->r_extern ? BFD_MACH_O_LE_EXTERN : 0;
+ }
+ fields[3] = info;
+}
+
static bfd_boolean
bfd_mach_o_write_relocs (bfd *abfd, bfd_mach_o_section *section)
{
- bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
unsigned int i;
arelent **entries;
asection *sec;
if (bed->_bfd_mach_o_swap_reloc_out == NULL)
return TRUE;
- /* Allocate relocation room. */
- mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
- section->nreloc = sec->reloc_count;
- sec->rel_filepos = mdata->filelen;
- section->reloff = sec->rel_filepos;
- mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
-
if (bfd_seek (abfd, section->reloff, SEEK_SET) != 0)
return FALSE;
}
else
{
- unsigned long v;
-
bfd_put_32 (abfd, pinfo->r_address, raw.r_address);
- v = BFD_MACH_O_SET_R_SYMBOLNUM (pinfo->r_value)
- | (pinfo->r_pcrel ? BFD_MACH_O_R_PCREL : 0)
- | BFD_MACH_O_SET_R_LENGTH (pinfo->r_length)
- | (pinfo->r_extern ? BFD_MACH_O_R_EXTERN : 0)
- | BFD_MACH_O_SET_R_TYPE (pinfo->r_type);
- bfd_put_32 (abfd, v, raw.r_symbolnum);
+ bfd_mach_o_swap_out_non_scattered_reloc (abfd, raw.r_symbolnum,
+ pinfo);
}
if (bfd_bwrite (&raw, BFD_MACH_O_RELENT_SIZE, abfd)
/* TODO: fix this up for non-MH_OBJECT cases. */
seg->vmaddr = 0;
+ seg->vmsize = 0;
seg->fileoff = mdata->filelen;
seg->filesize = 0;
seg->sect_head = NULL;
seg->sect_tail = NULL;
- /* Append sections to the segment. */
+ /* Append sections to the segment.
+
+ This is a little tedious, we have to honor the need to account zerofill
+ sections after all the rest. This forces us to do the calculation of
+ total vmsize in three passes so that any alignment increments are
+ properly accounted. */
for (i = 0; i < mdata->nsects; ++i)
{
&& strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
continue;
+ /* Although we account for zerofill section sizes in vm order, they are
+ placed in the file in source sequence. */
bfd_mach_o_append_section_to_segment (seg, sec);
-
- if (s->size == 0)
- s->offset = 0;
- else
+ s->offset = 0;
+
+ /* Zerofill sections have zero file size & offset,
+ and are not written. */
+ if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) == BFD_MACH_O_S_ZEROFILL
+ || (s->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+ == BFD_MACH_O_S_GB_ZEROFILL)
+ continue;
+
+ if (s->size > 0)
{
+ seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+ seg->vmsize += s->size;
+
+ seg->filesize = FILE_ALIGN (seg->filesize, s->align);
+ seg->filesize += s->size;
+
mdata->filelen = FILE_ALIGN (mdata->filelen, s->align);
s->offset = mdata->filelen;
}
sec->filepos = s->offset;
-
mdata->filelen += s->size;
}
- seg->filesize = mdata->filelen - seg->fileoff;
- seg->vmsize = seg->filesize;
+ /* Now pass through again, for zerofill, only now we just update the vmsize. */
+ for (i = 0; i < mdata->nsects; ++i)
+ {
+ bfd_mach_o_section *s = mdata->sections[i];
+
+ if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) != BFD_MACH_O_S_ZEROFILL)
+ continue;
+
+ if (! is_mho
+ && strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
+ continue;
+
+ if (s->size > 0)
+ {
+ seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+ seg->vmsize += s->size;
+ }
+ }
+
+ /* Now pass through again, for zerofill_GB. */
+ for (i = 0; i < mdata->nsects; ++i)
+ {
+ bfd_mach_o_section *s = mdata->sections[i];
+
+ if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) != BFD_MACH_O_S_GB_ZEROFILL)
+ continue;
+
+ if (! is_mho
+ && strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
+ continue;
+
+ if (s->size > 0)
+ {
+ seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+ seg->vmsize += s->size;
+ }
+ }
+
+ /* Allocate space for the relocations. */
+ mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
+
+ for (i = 0; i < mdata->nsects; ++i)
+ {
+ bfd_mach_o_section *ms = mdata->sections[i];
+ asection *sec = ms->bfdsection;
+
+ if ((ms->nreloc = sec->reloc_count) == 0)
+ {
+ ms->reloff = 0;
+ continue;
+ }
+ sec->rel_filepos = mdata->filelen;
+ ms->reloff = sec->rel_filepos;
+ mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
+ }
return TRUE;
}
+/* Count the number of indirect symbols in the image.
+ Requires that the sections are in their final order. */
+
+static unsigned int
+bfd_mach_o_count_indirect_symbols (bfd *abfd, bfd_mach_o_data_struct *mdata)
+{
+ unsigned int i;
+ unsigned int nisyms = 0;
+
+ for (i = 0; i < mdata->nsects; ++i)
+ {
+ bfd_mach_o_section *sec = mdata->sections[i];
+
+ switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+ {
+ case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
+ case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
+ case BFD_MACH_O_S_SYMBOL_STUBS:
+ nisyms += bfd_mach_o_section_get_nbr_indirect (abfd, sec);
+ break;
+ default:
+ break;
+ }
+ }
+ return nisyms;
+}
+
static bfd_boolean
bfd_mach_o_build_dysymtab_command (bfd *abfd,
bfd_mach_o_data_struct *mdata,
dsym->nundefsym = 0;
}
+ dsym->nindirectsyms = bfd_mach_o_count_indirect_symbols (abfd, mdata);
if (dsym->nindirectsyms > 0)
{
unsigned i;
+ unsigned n;
mdata->filelen = FILE_ALIGN (mdata->filelen, 2);
dsym->indirectsymoff = mdata->filelen;
dsym->indirect_syms = bfd_zalloc (abfd, dsym->nindirectsyms * 4);
if (dsym->indirect_syms == NULL)
return FALSE;
-
- /* So fill in the indices. */
- for (i = 0; i < dsym->nindirectsyms; ++i)
+
+ n = 0;
+ for (i = 0; i < mdata->nsects; ++i)
{
- /* TODO: fill in the table. */
+ bfd_mach_o_section *sec = mdata->sections[i];
+
+ switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+ {
+ case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
+ case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
+ case BFD_MACH_O_S_SYMBOL_STUBS:
+ {
+ unsigned j, num;
+ bfd_mach_o_asymbol **isyms = sec->indirect_syms;
+
+ num = bfd_mach_o_section_get_nbr_indirect (abfd, sec);
+ if (isyms == NULL || num == 0)
+ break;
+ /* Record the starting index in the reserved1 field. */
+ sec->reserved1 = n;
+ for (j = 0; j < num; j++, n++)
+ {
+ if (isyms[j] == NULL)
+ dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL;
+ else if (isyms[j]->symbol.section == bfd_abs_section_ptr
+ && ! (isyms[j]->n_type & BFD_MACH_O_N_EXT))
+ dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL
+ | BFD_MACH_O_INDIRECT_SYM_ABS;
+ else
+ dsym->indirect_syms[n] = isyms[j]->symbol.udata.i;
+ }
+ }
+ break;
+ default:
+ break;
+ }
}
}
bfd_mach_o_build_commands (bfd *abfd)
{
bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
- unsigned int wide = mach_o_wide_p (&mdata->header);
- bfd_mach_o_segment_command *seg = NULL;
- bfd_mach_o_load_command *cmd;
- bfd_mach_o_load_command *symtab_cmd;
- unsigned symcind;
+ unsigned wide = mach_o_wide_p (&mdata->header);
+ int segcmd_idx = -1;
+ int symtab_idx = -1;
+ int dysymtab_idx = -1;
+ unsigned long base_offset = 0;
/* Return now if commands are already present. */
if (mdata->header.ncmds)
if (!bfd_mach_o_mangle_symbols (abfd))
return FALSE;
- /* It's valid to have a file with only absolute symbols... */
+ /* Very simple command set (only really applicable to MH_OBJECTs):
+ All the commands are optional - present only when there is suitable data.
+ (i.e. it is valid to have an empty file)
+
+ a command (segment) to contain all the sections,
+ command for the symbol table,
+ a command for the dysymtab.
+
+ ??? maybe we should assert that this is an MH_OBJECT? */
+
if (mdata->nsects > 0)
{
+ segcmd_idx = 0;
mdata->header.ncmds = 1;
- symcind = 1;
}
- else
- symcind = 0;
- /* It's OK to have a file with only section statements. */
if (bfd_get_symcount (abfd) > 0)
- mdata->header.ncmds += 1;
+ {
+ mdata->header.ncmds++;
+ symtab_idx = segcmd_idx + 1; /* 0 if the seg command is absent. */
+ }
- /* Very simple version (only really applicable to MH_OBJECTs):
- a command (segment) to contain all the sections,
- a command for the symbol table
- a n (optional) command for the dysymtab.
+ /* FIXME:
+ This is a rather crude test for whether we should build a dysymtab. */
+ if (bfd_mach_o_should_emit_dysymtab ()
+ && bfd_get_symcount (abfd))
+ {
+ mdata->header.ncmds++;
+ /* If there should be a case where a dysymtab could be emitted without
+ a symtab (seems improbable), this would need amending. */
+ dysymtab_idx = symtab_idx + 1;
+ }
- ??? maybe we should assert that this is an MH_OBJECT? */
+ if (wide)
+ base_offset = BFD_MACH_O_HEADER_64_SIZE;
+ else
+ base_offset = BFD_MACH_O_HEADER_SIZE;
- if (bfd_mach_o_should_emit_dysymtab ()
- && bfd_get_symcount (abfd) > 0)
- mdata->header.ncmds += 1;
+ /* Well, we must have a header, at least. */
+ mdata->filelen = base_offset;
- /* A bit weird, but looks like no content;
+ /* A bit unusual, but no content is valid;
as -n empty.s -o empty.o */
if (mdata->header.ncmds == 0)
return TRUE;
if (mdata->commands == NULL)
return FALSE;
- if (mdata->nsects > 0)
+ if (segcmd_idx >= 0)
{
- cmd = &mdata->commands[0];
- seg = &cmd->command.segment;
+ bfd_mach_o_load_command *cmd = &mdata->commands[segcmd_idx];
+ bfd_mach_o_segment_command *seg = &cmd->command.segment;
/* Count the segctions in the special blank segment used for MH_OBJECT. */
seg->nsects = bfd_mach_o_count_sections_for_seg (NULL, mdata);
return FALSE;
/* Init segment command. */
+ cmd->offset = base_offset;
if (wide)
{
cmd->type = BFD_MACH_O_LC_SEGMENT_64;
- cmd->offset = BFD_MACH_O_HEADER_64_SIZE;
cmd->len = BFD_MACH_O_LC_SEGMENT_64_SIZE
+ BFD_MACH_O_SECTION_64_SIZE * seg->nsects;
}
else
{
cmd->type = BFD_MACH_O_LC_SEGMENT;
- cmd->offset = BFD_MACH_O_HEADER_SIZE;
cmd->len = BFD_MACH_O_LC_SEGMENT_SIZE
+ BFD_MACH_O_SECTION_SIZE * seg->nsects;
}
+
cmd->type_required = FALSE;
mdata->header.sizeofcmds = cmd->len;
- mdata->filelen = cmd->offset + cmd->len;
+ mdata->filelen += cmd->len;
}
- if (bfd_get_symcount (abfd) > 0)
+ if (symtab_idx >= 0)
{
/* Init symtab command. */
- symtab_cmd = &mdata->commands[symcind];
+ bfd_mach_o_load_command *cmd = &mdata->commands[symtab_idx];
- symtab_cmd->type = BFD_MACH_O_LC_SYMTAB;
- if (symcind > 0)
- symtab_cmd->offset = mdata->commands[0].offset
- + mdata->commands[0].len;
- else
- symtab_cmd->offset = 0;
- symtab_cmd->len = 6 * 4;
- symtab_cmd->type_required = FALSE;
-
- mdata->header.sizeofcmds += symtab_cmd->len;
- mdata->filelen += symtab_cmd->len;
+ cmd->type = BFD_MACH_O_LC_SYMTAB;
+ cmd->offset = base_offset;
+ if (segcmd_idx >= 0)
+ cmd->offset += mdata->commands[segcmd_idx].len;
+
+ cmd->len = sizeof (struct mach_o_symtab_command_external)
+ + BFD_MACH_O_LC_SIZE;
+ cmd->type_required = FALSE;
+ mdata->header.sizeofcmds += cmd->len;
+ mdata->filelen += cmd->len;
}
- /* If required, setup symtab command. */
- if (bfd_mach_o_should_emit_dysymtab ()
- && bfd_get_symcount (abfd) > 0)
+ /* If required, setup symtab command, see comment above about the quality
+ of this test. */
+ if (dysymtab_idx >= 0)
{
- cmd = &mdata->commands[symcind+1];
+ bfd_mach_o_load_command *cmd = &mdata->commands[dysymtab_idx];
+
cmd->type = BFD_MACH_O_LC_DYSYMTAB;
- cmd->offset = symtab_cmd->offset + symtab_cmd->len;
+ if (symtab_idx >= 0)
+ cmd->offset = mdata->commands[symtab_idx].offset
+ + mdata->commands[symtab_idx].len;
+ else if (segcmd_idx >= 0)
+ cmd->offset = mdata->commands[segcmd_idx].offset
+ + mdata->commands[segcmd_idx].len;
+ else
+ cmd->offset = base_offset;
+
cmd->type_required = FALSE;
- cmd->len = 18 * 4 + BFD_MACH_O_LC_SIZE;
+ cmd->len = sizeof (struct mach_o_dysymtab_command_external)
+ + BFD_MACH_O_LC_SIZE;
mdata->header.sizeofcmds += cmd->len;
mdata->filelen += cmd->len;
/* So, now we have sized the commands and the filelen set to that.
Now we can build the segment command and set the section file offsets. */
- if (mdata->nsects > 0
- && ! bfd_mach_o_build_seg_command (NULL, mdata, seg))
+ if (segcmd_idx >= 0
+ && ! bfd_mach_o_build_seg_command
+ (NULL, mdata, &mdata->commands[segcmd_idx].command.segment))
return FALSE;
/* If we're doing a dysymtab, cmd points to its load command. */
- if (bfd_mach_o_should_emit_dysymtab ()
- && bfd_get_symcount (abfd) > 0
+ if (dysymtab_idx >= 0
&& ! bfd_mach_o_build_dysymtab_command (abfd, mdata,
- &mdata->commands[symcind+1]))
+ &mdata->commands[dysymtab_idx]))
return FALSE;
/* The symtab command is filled in when the symtab is written. */
if (mach_o_wide_p (header))
header->reserved = (*get32) (raw.reserved);
+ else
+ header->reserved = 0;
return TRUE;
}
abfd->filename = name;
}
- areltdata = bfd_zalloc (abfd, sizeof (struct areltdata));
+ areltdata = bfd_zmalloc (sizeof (struct areltdata));
areltdata->parsed_size = entry->size;
abfd->arelt_data = areltdata;
abfd->iostream = NULL;
if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
section, symbols, offset,
filename_ptr, functionname_ptr,
- line_ptr, 0,
+ line_ptr, NULL, 0,
&mdata->dwarf2_find_line_info))
return TRUE;
return FALSE;
}
}
+ if (bfd_get_format (abfd) == bfd_archive
+ && abfd->xvec == &mach_o_fat_vec)
+ return TRUE;
return _bfd_generic_close_and_cleanup (abfd);
}