/* Mach-O support for BFD.
- Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2019 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "aout/stab_gnu.h"
#include "mach-o/reloc.h"
#include "mach-o/external.h"
}
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_mach_o_version_min_command *cmd = &command->command.version_min;
struct mach_o_version_min_command_external raw;
- unsigned int ver;
if (bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
return FALSE;
- ver = bfd_get_32 (abfd, raw.version);
- cmd->rel = ver >> 16;
- cmd->maj = ver >> 8;
- cmd->min = ver;
- cmd->reserved = bfd_get_32 (abfd, raw.reserved);
+ cmd->version = bfd_get_32 (abfd, raw.version);
+ cmd->sdk = bfd_get_32 (abfd, raw.sdk);
return TRUE;
}
return TRUE;
}
+static bfd_boolean
+bfd_mach_o_read_note (bfd *abfd, bfd_mach_o_load_command *command)
+{
+ bfd_mach_o_note_command *cmd = &command->command.note;
+ struct mach_o_note_command_external raw;
+
+ if (bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+ return FALSE;
+
+ memcpy (cmd->data_owner, raw.data_owner, 16);
+ cmd->offset = bfd_get_64 (abfd, raw.offset);
+ cmd->size = bfd_get_64 (abfd, raw.size);
+ return TRUE;
+}
+
+static bfd_boolean
+bfd_mach_o_read_build_version (bfd *abfd, bfd_mach_o_load_command *command)
+{
+ bfd_mach_o_build_version_command *cmd = &command->command.build_version;
+ struct mach_o_build_version_command_external raw;
+
+ if (bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+ return FALSE;
+
+ cmd->platform = bfd_get_32 (abfd, raw.platform);
+ cmd->minos = bfd_get_32 (abfd, raw.minos);
+ cmd->sdk = bfd_get_32 (abfd, raw.sdk);
+ cmd->ntools = bfd_get_32 (abfd, raw.ntools);
+ return TRUE;
+}
+
static bfd_boolean
bfd_mach_o_read_segment (bfd *abfd,
bfd_mach_o_load_command *command,
case BFD_MACH_O_LC_VERSION_MIN_MACOSX:
case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS:
case BFD_MACH_O_LC_VERSION_MIN_WATCHOS:
+ case BFD_MACH_O_LC_VERSION_MIN_TVOS:
if (!bfd_mach_o_read_version_min (abfd, command))
return FALSE;
break;
if (!bfd_mach_o_read_source_version (abfd, command))
return FALSE;
break;
+ case BFD_MACH_O_LC_LINKER_OPTIONS:
+ break;
+ case BFD_MACH_O_LC_NOTE:
+ if (!bfd_mach_o_read_note (abfd, command))
+ return FALSE;
+ break;
+ case BFD_MACH_O_LC_BUILD_VERSION:
+ if (!bfd_mach_o_read_build_version (abfd, command))
+ return FALSE;
+ break;
default:
command->len = 0;
_bfd_error_handler (_("%pB: unknown load command %#x"),
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,
/* 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