return TRUE;
}
+static const char *
+cputype (unsigned long value)
+{
+ switch (value)
+ {
+ case BFD_MACH_O_CPU_TYPE_VAX: return "VAX";
+ case BFD_MACH_O_CPU_TYPE_MC680x0: return "MC68k";
+ case BFD_MACH_O_CPU_TYPE_I386: return "I386";
+ case BFD_MACH_O_CPU_TYPE_MIPS: return "MIPS";
+ case BFD_MACH_O_CPU_TYPE_MC98000: return "MC98k";
+ case BFD_MACH_O_CPU_TYPE_HPPA: return "HPPA";
+ case BFD_MACH_O_CPU_TYPE_ARM: return "ARM";
+ case BFD_MACH_O_CPU_TYPE_MC88000: return "MC88K";
+ case BFD_MACH_O_CPU_TYPE_SPARC: return "SPARC";
+ case BFD_MACH_O_CPU_TYPE_I860: return "I860";
+ case BFD_MACH_O_CPU_TYPE_ALPHA: return "ALPHA";
+ case BFD_MACH_O_CPU_TYPE_POWERPC: return "PPC";
+ case BFD_MACH_O_CPU_TYPE_POWERPC_64: return "PPC64";
+ case BFD_MACH_O_CPU_TYPE_X86_64: return "X86_64";
+ case BFD_MACH_O_CPU_TYPE_ARM64: return "ARM64";
+ default: return _("<unknown>");
+ }
+}
+
+static const char *
+cpusubtype (unsigned long cputype, unsigned long cpusubtype)
+{
+ static char buffer[128];
+
+ buffer[0] = 0;
+ switch (cpusubtype & BFD_MACH_O_CPU_SUBTYPE_MASK)
+ {
+ case 0:
+ break;
+ case BFD_MACH_O_CPU_SUBTYPE_LIB64:
+ sprintf (buffer, " (LIB64)"); break;
+ default:
+ sprintf (buffer, _("<unknown mask flags>")); break;
+ }
+
+ cpusubtype &= ~ BFD_MACH_O_CPU_SUBTYPE_MASK;
+
+ switch (cputype)
+ {
+ case BFD_MACH_O_CPU_TYPE_X86_64:
+ case BFD_MACH_O_CPU_TYPE_I386:
+ switch (cpusubtype)
+ {
+ case BFD_MACH_O_CPU_SUBTYPE_X86_ALL:
+ return strcat (buffer, " (X86_ALL)");
+ default:
+ break;
+ }
+ break;
+
+ case BFD_MACH_O_CPU_TYPE_ARM:
+ switch (cpusubtype)
+ {
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_ALL:
+ return strcat (buffer, " (ARM_ALL)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_V4T:
+ return strcat (buffer, " (ARM_V4T)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_V6:
+ return strcat (buffer, " (ARM_V6)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_V5TEJ:
+ return strcat (buffer, " (ARM_V5TEJ)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_XSCALE:
+ return strcat (buffer, " (ARM_XSCALE)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM_V7:
+ return strcat (buffer, " (ARM_V7)");
+ default:
+ break;
+ }
+ break;
+
+ case BFD_MACH_O_CPU_TYPE_ARM64:
+ switch (cpusubtype)
+ {
+ case BFD_MACH_O_CPU_SUBTYPE_ARM64_ALL:
+ return strcat (buffer, " (ARM64_ALL)");
+ case BFD_MACH_O_CPU_SUBTYPE_ARM64_V8:
+ return strcat (buffer, " (ARM64_V8)");
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (cpusubtype != 0)
+ return strcat (buffer, _(" (<unknown>)"));
+
+ return buffer;
+}
+
+bfd_boolean
+bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void *ptr)
+{
+ FILE * file = (FILE *) ptr;
+ bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+
+ fprintf (file, _(" MACH-O header:\n"));
+ fprintf (file, _(" magic: %#lx\n"), (long) mdata->header.magic);
+ fprintf (file, _(" cputype: %#lx (%s)\n"), (long) mdata->header.cputype,
+ cputype (mdata->header.cputype));
+ fprintf (file, _(" cpusubtype: %#lx%s\n"), (long) mdata->header.cpusubtype,
+ cpusubtype (mdata->header.cputype, mdata->header.cpusubtype));
+ fprintf (file, _(" filetype: %#lx\n"), (long) mdata->header.filetype);
+ fprintf (file, _(" ncmds: %#lx\n"), (long) mdata->header.ncmds);
+ fprintf (file, _(" sizeocmds: %#lx\n"), (long) mdata->header.sizeofcmds);
+ fprintf (file, _(" flags: %#lx\n"), (long) mdata->header.flags);
+ fprintf (file, _(" version: %x\n"), mdata->header.version);
+
+ return TRUE;
+}
+
/* Copy any private info we understand from the input bfd
to the output bfd. */
/* Copy header flags. */
omdata->header.flags = imdata->header.flags;
+ /* PR 23299. Copy the cputype. */
+ if (imdata->header.cputype != omdata->header.cputype)
+ {
+ if (omdata->header.cputype == 0)
+ omdata->header.cputype = imdata->header.cputype;
+ else if (imdata->header.cputype != 0)
+ /* Urg - what has happened ? */
+ _bfd_error_handler (_("incompatible cputypes in mach-o files: %ld vs %ld"),
+ (long) imdata->header.cputype,
+ (long) omdata->header.cputype);
+ }
+
+ /* Copy the cpusubtype. */
+ omdata->header.cpusubtype = imdata->header.cpusubtype;
+
/* Copy commands. */
for (icmd = imdata->first_command; icmd != NULL; icmd = icmd->next)
{
break;
}
break;
- case BFD_MACH_O_CPU_TYPE_MC88000:
- *type = bfd_arch_m88k;
- break;
case BFD_MACH_O_CPU_TYPE_SPARC:
*type = bfd_arch_sparc;
*subtype = bfd_mach_sparc;
break;
- case BFD_MACH_O_CPU_TYPE_I860:
- *type = bfd_arch_i860;
- break;
case BFD_MACH_O_CPU_TYPE_ALPHA:
*type = bfd_arch_alpha;
break;
void
bfd_mach_o_swap_in_non_scattered_reloc (bfd *abfd, bfd_mach_o_reloc_info *rel,
- unsigned char *fields)
+ unsigned char *fields)
{
unsigned char info = fields[3];
static void
bfd_mach_o_swap_out_non_scattered_reloc (bfd *abfd, unsigned char *fields,
- bfd_mach_o_reloc_info *rel)
+ bfd_mach_o_reloc_info *rel)
{
unsigned char info = 0;
}
else
s->n_type = BFD_MACH_O_N_SECT;
-
- if (s->symbol.flags & BSF_GLOBAL)
- s->n_type |= BFD_MACH_O_N_EXT;
}
+ /* Update external symbol bit in case objcopy changed it. */
+ if (s->symbol.flags & BSF_GLOBAL)
+ s->n_type |= BFD_MACH_O_N_EXT;
+ else
+ s->n_type &= ~BFD_MACH_O_N_EXT;
+
/* Put the section index in, where required. */
if ((s->symbol.section != bfd_abs_section_ptr
&& s->symbol.section != bfd_und_section_ptr
{
_bfd_error_handler
/* xgettext:c-format */
- (_("section address (%#Lx) below start of segment (%#Lx)"),
- s->addr, vma);
+ (_("section address (%#" PRIx64 ") "
+ "below start of segment (%#" PRIx64 ")"),
+ (uint64_t) s->addr, (uint64_t) vma);
return FALSE;
}
return NULL;
}
+static bfd_boolean
+bfd_mach_o_fat_close_and_cleanup (bfd *abfd)
+{
+ _bfd_unlink_from_archive_parent (abfd);
+ return TRUE;
+}
+
int
bfd_mach_o_lookup_command (bfd *abfd,
bfd_mach_o_load_command_type type,
{
case BFD_MACH_O_CPU_TYPE_MC680x0:
return 0x04000000;
- case BFD_MACH_O_CPU_TYPE_MC88000:
- return 0xffffe000;
case BFD_MACH_O_CPU_TYPE_POWERPC:
return 0xc0000000;
case BFD_MACH_O_CPU_TYPE_I386:
return 0xc0000000;
case BFD_MACH_O_CPU_TYPE_SPARC:
return 0xf0000000;
- case BFD_MACH_O_CPU_TYPE_I860:
- return 0;
case BFD_MACH_O_CPU_TYPE_HPPA:
return 0xc0000000 - 0x04000000;
default:
return _bfd_generic_close_and_cleanup (abfd);
}
-bfd_boolean bfd_mach_o_free_cached_info (bfd *abfd)
+bfd_boolean
+bfd_mach_o_free_cached_info (bfd *abfd)
{
bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
asection *asect;
/* Not yet handled: creating an archive. */
#define bfd_mach_o_mkarchive _bfd_noarchive_mkarchive
-#define bfd_mach_o_close_and_cleanup _bfd_bool_bfd_true
+#define bfd_mach_o_close_and_cleanup bfd_mach_o_fat_close_and_cleanup
/* Not used. */
#define bfd_mach_o_generic_stat_arch_elt bfd_mach_o_fat_stat_arch_elt