}
}
+/* Convert Mach-O section name to BFD. Try to use standard names, otherwise
+ forge a new name. SEGNAME and SECTNAME are 16 bytes strings. */
+
static void
bfd_mach_o_convert_section_name_to_bfd
(bfd *abfd, const char *segname, const char *sectname,
if (*name)
return;
- len = strlen (segname) + 1 + strlen (sectname) + 1;
+ len = 16 + 1 + 16 + 1;
/* Put "LC_SEGMENT." prefix if the segment name is weird (ie doesn't start
with an underscore. */
res = bfd_alloc (abfd, len);
if (res == NULL)
return;
- snprintf (res, len, "%s%s.%s", pfx, segname, sectname);
+ snprintf (res, len, "%s%.16s.%.16s", pfx, segname, sectname);
*name = res;
*flags = SEC_NO_FLAGS;
}
switch (asym->n_type & BFD_MACH_O_N_TYPE)
{
case BFD_MACH_O_N_UNDF:
- name = "UND";
+ if (symbol->value == 0)
+ name = "UND";
+ else
+ name = "COM";
break;
case BFD_MACH_O_N_ABS:
name = "ABS";
asym->n_type, name, asym->n_sect, asym->n_desc);
if ((asym->n_type & BFD_MACH_O_N_STAB) == 0
&& (asym->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_SECT)
- fprintf (file, " %-5s", symbol->section->name);
+ fprintf (file, " [%s]", symbol->section->name);
fprintf (file, " %s", symbol->name);
}
}
struct mach_o_section_32_external raw;
memcpy (raw.sectname, section->sectname, 16);
- memcpy (raw.segname + 16, section->segname, 16);
+ memcpy (raw.segname, section->segname, 16);
bfd_h_put_32 (abfd, section->addr, raw.addr);
bfd_h_put_32 (abfd, section->size, raw.size);
bfd_h_put_32 (abfd, section->offset, raw.offset);
case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
case BFD_MACH_O_LC_ID_DYLIB:
case BFD_MACH_O_LC_REEXPORT_DYLIB:
+ case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
case BFD_MACH_O_LC_LOAD_DYLINKER:
case BFD_MACH_O_LC_ID_DYLINKER:
case BFD_MACH_O_LC_PREBOUND_DYLIB:
| BFD_MACH_O_PROT_EXECUTE;
seg->initprot = seg->maxprot;
seg->flags = 0;
+ seg->sect_head = NULL;
+ seg->sect_tail = NULL;
/* Create Mach-O sections. */
target_index = 0;
}
break;
case BFD_MACH_O_N_INDR:
- (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
- "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined"),
- s->symbol.name);
- s->symbol.section = bfd_und_section_ptr;
+ /* FIXME: we don't follow the BFD convention as this indirect symbol
+ won't be followed by the referenced one. This looks harmless
+ unless we start using the linker. */
+ s->symbol.flags |= BSF_INDIRECT;
+ s->symbol.section = bfd_ind_section_ptr;
+ s->symbol.value = 0;
break;
default:
(*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
case BFD_MACH_O_LC_ID_DYLIB:
case BFD_MACH_O_LC_REEXPORT_DYLIB:
+ case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
break;
default:
BFD_FAIL ();
seg->nsects = bfd_h_get_32 (abfd, raw.nsects);
seg->flags = bfd_h_get_32 (abfd, raw.flags);
}
+ seg->sect_head = NULL;
+ seg->sect_tail = NULL;
for (i = 0; i < seg->nsects; i++)
{
case BFD_MACH_O_LC_ID_DYLIB:
case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
case BFD_MACH_O_LC_REEXPORT_DYLIB:
+ case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
if (bfd_mach_o_read_dylib (abfd, command) != 0)
return -1;
break;
return -1;
break;
default:
- (*_bfd_error_handler) (_("unable to read unknown load command 0x%lx"),
- (unsigned long) command->type);
+ (*_bfd_error_handler)(_("%B: unable to read unknown load command 0x%lx"),
+ abfd, (unsigned long) command->type);
break;
}
bfd_mach_o_convert_architecture (entry->cputype, entry->cpusubtype,
&arch_type, &arch_subtype);
- /* Create the member filename.
- Use FILENAME:ARCH_NAME. */
- {
- char *s = NULL;
- const char *arch_name;
- size_t arch_file_len = strlen (bfd_get_filename (archive));
- arch_name = bfd_printable_arch_mach (arch_type, arch_subtype);
- s = bfd_malloc (arch_file_len + 1 + strlen (arch_name) + 1);
- if (s == NULL)
- return NULL;
- memcpy (s, bfd_get_filename (archive), arch_file_len);
- s[arch_file_len] = ':';
- strcpy (s + arch_file_len + 1, arch_name);
- nbfd->filename = s;
- }
+ /* Create the member filename. Use ARCH_NAME. */
+ nbfd->filename = bfd_printable_arch_mach (arch_type, arch_subtype);
nbfd->iostream = NULL;
bfd_set_arch_mach (nbfd, arch_type, arch_subtype);
res->origin = e->offset;
- res->filename = strdup (abfd->filename);
+ res->filename = bfd_printable_arch_mach (cpu_type, cpu_subtype);
res->iostream = NULL;
if (bfd_check_format (res, format))
case BFD_MACH_O_LC_LOAD_DYLIB:
case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
case BFD_MACH_O_LC_REEXPORT_DYLIB:
+ case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
case BFD_MACH_O_LC_ID_DYLIB:
{
bfd_mach_o_dylib_command *dylib = &cmd->command.dylib;